GithubRepo APP This App follow MVVM architecture along with repository as an abstraction layer which interacts with Database and Network to fetch the data, This app also follow single source of truth as required, it fetches only from db, Network calls are made in the following scenarios
- If app is opened for the first time and there is no data in db
- If user uses pull-to-refresh for force fetch
- If the data is older than 2 hours TechStack used in this app
- Retrofit and Okhttp with Coroutines : For Networking
- Room with Livedata: For offline support
- Espresso: For activity testing with all states
- Mockito: For Unit Testing of Repository
- Dagger2 : For dependency injection
Every response from network and db are wrapped in a single data type RESOURCE, with status as a field which defines the state in which the call is. There are three States LOADING, ERROR, SUCCESS
In loading state, shimmer animation is loaded and other views are hidden In error state, given error screen is loaded and other views are hidden In success state, list of trending repos along with option to sort the list is loaded and loading and error screens are hidden.
Every response object from network call is added with current timestamp, so that next time when it is fetched from room db, we can check if it is older than 2 hours and if we need to fetch from remote again.
Handle the offline data based on sortby option. If user is offline by default it shows DAILY data, and user can choose the data from option menu. If user select the data which is sort by monthly option, app display the offline data for MONTHLY use and same for WEEKLY user as well.