Creating open-source Android libraries benefits for both library owner and the other developers. A code written by a developer can save other developers from building the same thing, and also the other developers can contribute the same code. Thus, a library that will be useful for many people is can be created with the contribution of a few people.
However, you may not want to open some of your personal or corporate libraries to the outside world. In this case, you can create your own packages using one of GitHub, GitLab, AWS, GCP etc. services.
When you have multiple projects that use shared components, implementing a single main code for these projects instead of using the same code in all projects will benefit you in many ways. It is important to make bug fix or code change in a single library and create a new version, both in terms of spending less time and ensuring consistent build quality. …
Android Shared Preferences is best and easy way of the key-value storage. It also provides callback to listen changes in the preference values. However, can we make this use more suitable for our architecture?
Let’s imagine we have an Android application and it storages some feature status data (like open-closed) in the shared preferences. Multiple fragments of application has indicators which are showing that feature status and we want to see changes immediately. Each indicator is getting status of feature from shared preferences. Additionally, this feature status can also be updated in some service or broadcast receiver.
We can use
OnSharedPreferenceChangeListener to listen changes in the preferences but as you can see, we have to check every possible key changes in the when statement and we need to register and unregister listener in every fragment we listen in. Additionally, it doesn’t look good and clean. We can do better! …
I used to work with MVP pattern until now. However, when Google released nice-to-use components like the
ViewModel along with the Android Jetpack, I have tried to work with MVVM pattern. In this article, we will see how can we use the MVVM pattern with Retrofit, RxJava, and Dagger 2.
Model-View-ViewModel architecture consists of 3 parts.
ViewModel, or listens live data stream from the
ViewModeland provides to the users.
Viewor provides data to
ViewModeluses that on data stream. …