Tutorial by Examples

Project build.gradle allprojects { repositories { jcenter() // Add this if you use Gradle 4.0+ google() // Add this if you use Gradle < 4.0 maven { url 'https://maven.google.com' } } } ext { archVersion = '1.0.0-alpha5' } Applic...
Extend your activity from this activity public abstract class BaseCompatLifecycleActivity extends AppCompatActivity implements LifecycleRegistryOwner { // We need this class, because LifecycleActivity extends FragmentActivity not AppCompatActivity @NonNull private final LifecycleRe...
public class BaseViewModel extends ViewModel { private static final int TAG_SEGMENT_INDEX = 2; private static final int VIDEOS_LIMIT = 100; // We save input params here private final MutableLiveData<Pair<String, String>> urlWithReferrerLiveData = new MutableLiveData...
Room require four parts: Database class, DAO classes, Entity classes and Migration classes (now you may use only DDL methods): Entity classes // Set custom table name, add indexes @Entity(tableName = "videos", indices = {@Index("title")} ) public final class VideoIt...
You may write custom LiveData, if you need custom logic. Don't write custom class, if you only need to transform data (use Transformations class) public class LocationLiveData extends LiveData<Location> { private LocationManager locationManager; private LocationListener liste...
Each UI component lifecycle changed as shown at image. You may create component, that will be notified on lifecycle state change: public class MyLocationListener implements LifecycleObserver { private boolean enabled = false; private Lifecycle lifecycle; public MyLocationListener(...

Page 1 of 1