Hot to use Realm in android project. Befor you use realm we should be read documentation https://realm.io/docs/java/latest#getting-started Then we got the way how to install. Install Realm as a Gradle plugin. Setp 1: change build.gradle in project level buildscript { repositories { jcenter() } dependencies { classpath "io.realm:realm-gradle-plugin:5.14.0" } } Step 2: Apply the realm-android plugin to the top of the application level build.gradle file. Create reaml map Object There has two way for mapping Object Make Object extends ReamlObject Or make Object implement ReamlModel Declear reaml mapping objects Realm not support data class yet. So we can't use it now. And object will make it open, because Realm object will generate subclass after aapt or kapt . // 1. open class User : RealmObject() { var id: String = UUID . random UUID() . to String() var name: String = "
Today a new request for ViewPager, will set ViewPager auto play, in last code is user Handler, but I want a new way to finish it. private void autoPlay (ViewPager viewPager ) { viewPager . postDelayed ( new Runnable () { @Override public void run () { try { if ( adapter != null && viewPager.getAdapter() . getCount () > 0 ) { int position = currentCount % adapter . getCount (); currentCount ++; viewPager . setCurrentItem ( position ); autoPlay ( viewPager); } } catch ( Exception e ) { Log . e ( TAG , "auto scroll pager error." , e ); } } }, 3000 ); } So I do like that , user recursion is very simple and fast. That is.