A collection of libraries that help you design robust, testable, and maintainable apps. Start with classes for managing your UI component lifecycle and handling data persistence.
of defining a structured solution that meets all of the technical and operational requirements, while optimizing common quality attributes such as performance, security, and manageability. It involves a series of decisions based on a wide range of factors, and each of these decisions can have considerable impact on the quality, performance, maintainability, and overall success of the application
location -> { // update UI }); } @Override public void onStop() { super.onStop(); myLocationListener.stop(); } @Override public void onStart() { super.onStart(); Util.checkUserStatus(result -> { // what if this callback is invoked AFTER activity is stopped? if (result) { myLocationListener.start(); } }); }
data so that data survives the configuration changes such as screen rotations ViewModel: public class MyViewModel extends ViewModel{ } AndroidViewModel with context: public class MyViewModel extends AndroidViewModel { public MyViewModel(@NonNull Application application) { super(application); } }
Rest of the ViewModel... } // Create a LiveData with a String private MutableLiveData<String> mCurrentName; public MutableLiveData<String> getCurrentName() { if (mCurrentName == null) { mCurrentName = new MutableLiveData<String>(); } return mCurrentName; }
savedInstanceState) { super.onCreate(savedInstanceState); } // Get the ViewModel. mModel = ViewModelProviders.of(this).get(NameViewModel.class); // Create the observer which updates the UI. final Observer<String> nameObserver = new Observer<String>() { @Override public void onChanged(@Nullable final String newName) { // Update the UI, in this case, a TextView. mNameTextView.setText(newName); } }; // Observe the LiveData, passing in this activity as the // LifecycleOwner and the observer. mModel.getCurrentName().observe(this, nameObserver);
class User { private int uid; private String firstName; private String lastName; private int age; private Date dateOfJoining; } public class User { private int uid; private String firstName; private String lastName; private int age; private Date dateOfJoining; } @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "first_name") @Entity @ColumnInfo(name = "last_name")