may kill app at random time App components lifecycle is not under control Components should not depend on each other Can’t rely on data, stored in components
of concerns -Provide solid user experience -Keep UI lean and simple -Keep UI free of app logic -Drive UI from model -Use persistent model -Assign clear responsibilities for each model class
have one way of writing apps that will be the best for every scenario. That being said, this recommended architecture should be a good starting point for most use cases. If you already have a good way of writing Android apps, you don't need to change.” Quote from Guide to App Architecture
public DetailActivityViewModel() {} public MutableLiveData<WeatherEntry> getWeather() { return mWeather; } public void setWeather(WeatherEntry weatherEntry) { mWeather.postValue(weatherEntry); } } Live Data LiveData
...) { //Json constructor - ignored by Room @Ignore public WeatherEntry(int weatherIconId, Date date, // (!) Only one constructor should be exposed to Room ... @Entity constructors
{ mExecutors.diskIO().execute(() -> { mWeatherDao.bulkInsert(newForecastsFromNetwork); Log.d(LOG_TAG, "New values inserted"); }); }); Repository - fetch data from network Get and observe
2 - improved LiveDataReactiveStreams, - FullLifecycleObserver for Java 8, - Handling @Query methods with @NonNull annotations, - Still requires proguard settings to keep android.arch.lifecycle.GeneratedAdapter 1.0.0 Alpha 9-1 - Support Library 26.1.0, AppCompatActivity and Support Fragment now implement the LifecycleOwner interface - LifecycleActivity & LifecycleFragment are now deprecated - New Library: Paging
users WHERE age > :age order by name DESC, id ASC") TiledDataSource<User> usersOlderThan(int age); @Query("SELECT * from users order WHERE age > :age order by name DESC, id ASC") public abstract LivePagedListProvider<Integer, User> usersOlderThan(int age);
Helper https://github.com/Ufkoku/AndroidMVPHelper Clean Architecture https://github.com/android10/Android-CleanArchitecture Reark https://github.com/reark/reark MVP + Dagger2 + Rx https://android.jlelse.eu/mvp-dagger-2-rx-clean-modern-android-app-code-74f63c9a6f2f Architecture the Lost Years by Uncle Bob https://youtu.be/WpkDN78P884