It is an exemplary social media application where users motivate each other.
Ideally, ViewModels shouldn’t know anything about Android. This improves testability, leak safety and modularity. ViewModels have different scopes than activities or fragments. While a ViewModel is alive and running, an activity can be in any of its lifecycle states. Activities and fragments can be destroyed and created again while the ViewModel is unaware.
Passing a reference of the View (activity or fragment) to the ViewModel is a serious risk. Lets assume the ViewModel requests data from the network and the data comes back some time later. At that moment, the View reference might be destroyed or might be an old activity that is no longer visible, generating a memory leak and, possibly, a crash.
The communication between the different layers follow the above diagram using the reactive paradigm, observing changes on components without need of callbacks avoiding leaks and edge cases related with them.
Values in Constants.kt file must be filled.
const val API_URL = "https://sample-node-social-app.herokuapp.com/" const val PREF_USER_TOKEN_VALUE = "PREF_USER_TOKEN_VALUE" const val PREF_USER_ID_VALUE = "PREF_USER_ID_VALUE" const val PREF_USER_TOKEN = "user_token_code.xml" const val ALGOLIA_APPLICATION_ID = "xxxx" const val ALGOLIA_SEARCH_ONLY_API_KEY = "xxxxx" const val ALGOLIA_ADMIN_API_KEY = "xxxxx" const val ALGOLIA_INDEX_NAME = "user-list"
This is project is a sample, to inspire you and should handle most of the common cases, but obviously not all. If you need to take a look at additional resources to find solutions for your project, visit these interesting projects:
The open-source community create and maintains tons of awesome libraries making your job more easy, giving the opportunity to use them in your developments. Here are a very important collection of them:
Avoid reinventing the wheel by following these guidelines:
Google Developers Codelabs provide a guided, tutorial, hands-on coding experience. Most codelabs will step you through the process of building a small application, or adding a new feature to an existing application. They cover a wide range of android concepts to learn and practice:
Thank You Sanchit Sharma - Dribble
Logo - FlatIcon
Thank Yoy @nuhkoca for guiding projects and documentation brief descriptions.
Copyright 2019 Arda Kazancı Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.