REST countries sample app that loads information from REST countries API V3 to show an approach to using some of the best practices in Android Development.

Overview

MAJORITY assignment solution in Kotlin via MVVM Repository Pattern.

REST countries sample app that loads information from REST countries API V3 to show an approach to using some of the best practices in Android Development.

Cache Strategy

On the very first launch app send the request to the API and fetch the data,after successfully fetch save all the data in the local cache DataStoredPreference. On the next launch app will check need to fetch the data from the api or show the local storage data. it's depends on the fetch interval defined in FETCH_INTERVAL_IN_SEC in Constants.kt. Current interval is 24 Hours.You can change it from Constants.kt.

Libraries Used

  • Foundation - Components for core system capabilities, Kotlin extensions and support for multidex and automated testing.
    • Android KTX - Write more concise, idiomatic Kotlin code.
    • Test - An Android testing framework for unit and runtime UI tests.
  • Architecture - 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.
    • Data Binding - Declaratively bind observable data to UI elements.
    • Lifecycles - Create a UI that automatically responds to lifecycle events.
    • LiveData - Build data objects that notify views when the underlying database changes.
    • Navigation - Handle everything needed for in-app navigation.
    • Room - Access your app's SQLite database with in-app objects and compile-time checks.
    • ViewModel - Store UI-related data that isn't destroyed on app rotations. Easily schedule asynchronous tasks for optimal execution.
  • UI - Details on why and how to use UI Components in your apps - together or separate
  • Third party and miscellaneous libraries
    • Picasso for image loading
    • Hilt: for dependency injection
    • Kotlin Coroutines for managing background threads with simplified code and reducing needs for callbacks
    • SSP An android lib that provides a new size unit - ssp (scalable sp). This size unit scales with the screen size based on the sp size unit (for texts). It can help Android developers with supporting multiple screens.
    • SDP An android lib that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens.

Upcoming features

Updates will include incorporating additional Jetpack components and updating existing components as the component libraries evolve.

TestCases are pending due to very tight work schedule these days.

API Response

Countries API return alot of data but currently I am using this data. Sample JSON.

[
  {
    "name": {
      "common": "Malaysia",
      "official": "Malaysia"
    },
    "unMember": true,
    "currencies": {
      "MYR": {
        "name": "Malaysian ringgit",
        "symbol": "RM"
      }
    },
    "capital": [
      "Kuala Lumpur"
    ],
    "region": "Asia",
    "subregion": "South-Eastern Asia",
    "languages": {
      "eng": "English",
      "msa": "Malay"
    },
    "population": 32365998,
    "timezones": [
      "UTC+08:00"
    ],
    "continents": [
      "Asia"
    ],
    "flags": {
      "png": "https://flagcdn.com/w320/my.png"
    },
    "startOfWeek": "sunday"
  }
]

MVVM Repository Pattern

The repository pattern is a structural design pattern. It’s instrumental for organizing how you access data. It also helps divide concerns into smaller parts.

Repository operations delegate to a relevant datasource. Datasources can be remote or local. The repository operation has logic that determines the relevance of a given datasource. For instance, the repository can provide a value from a local datasource or ask a remote datasource to load from the network.

Android Studio IDE setup

For development, the latest version of Android Studio is required. The latest version can be downloaded from here.

All the dependencies are declared in the build.gradle file. No need to take any extra measure. Just import this project via Android Studio :)

You might also like...
 Movie app that receives popular movies and allows the user to search for the specific movie through the Rest API with help of retrofit library &MVVM architecture.
Movie app that receives popular movies and allows the user to search for the specific movie through the Rest API with help of retrofit library &MVVM architecture.

MovieClue Millions of movies, TV shows and people to discover. Explore now Movie app that recieves popular movies and allow the user to search for spe

Android app that uses TMDB API to show info about movies.
Android app that uses TMDB API to show info about movies.

Movies App: Projeto Integrador - Vitória Code 2021 🎬 Sobre o projeto Esse é um aplicativo Android feito em Kotlin que oferece aos usuários uma listag

🏞 A simple android app to show random images with Lorem Picsum API.
🏞 A simple android app to show random images with Lorem Picsum API.

LoremPicsum A simple android app to show random images with Lorem Picsum API. Used skills Android Multi-Module RecyclerView MVVM with AAC ViewModel &

With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces.
With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces.

Viola Viola android face detection library detects faces automatically from a bitmap, crop faces using the predefined algorithms, and provides supplem

RickAndMortyApp - Rick and morty, app about characters information
RickAndMortyApp - Rick and morty, app about characters information

Rick And Morty App 🇧🇷 Aplicativo com tema do Rick and Morty, interatividade co

ATH Sample is a sample Authentication and Authorization Application with Kotlin Language and MVVM architecture.
ATH Sample is a sample Authentication and Authorization Application with Kotlin Language and MVVM architecture.

ATH Sample ATH Sample is a sample Authentication and Authorization Application with Kotlin Language and MVVM architecture. Overview ATH Sample is a sa

WordMasterKMP - WIP Kotlin Multiplatform sample inspired by Wordle and also Word Master web sample
WordMasterKMP - WIP Kotlin Multiplatform sample inspired by Wordle and also Word Master web sample

WordMasterKMP WIP Kotlin Multiplatform sample inspired by Wordle and also Word M

An awesome list that curates the best KMM libraries, tools and more.

Awesome KMM Kotlin Multiplatform Mobile (KMM) is an SDK designed to simplify creating cross-platform mobile applications. With the help of KMM, you ca

Main goal of this project is to find the best route from one country to another

Route-service Main goal of this project is to find the best route from one country to another. Data is presented as json format. I've implemented A* p

Owner
Rehan Sarwar
AWS Certified | Mobile App Developer
Rehan Sarwar
Sample Android Clean Architecture on App focused on written in Kotlin, following best practices using Jetpack with Compose.

Rick And Morty Jetpack Compose Sample App Table of Contents About the Project Architecture Features Environment Setup Contact About The Project This S

Mert Toptas 132 Jan 2, 2023
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Madalin Valceleanu 2.3k Jan 4, 2023
📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.

NotyKT ??️ NotyKT is the complete Kotlin-stack note taking ??️ application ?? built to demonstrate a use of Kotlin programming language in server-side

Shreyas Patil 1.4k Jan 4, 2023
Android Clean Architecture in Rorty is a sample project that presents modern, approach to Android application development using Kotlin and latest tech-stack.

Android Clean Architecture in Rorty is a sample project that presents modern, approach to Android application development using Kotlin and latest tech-stack.

Mr.Sanchez 176 Jan 4, 2023
CleanArchitecture is a sample project that presents a modern, 2021 approach to Android application development.

CleanArchitecture is a sample project that presents a modern, 2021 approach to Android application development. The goal of the pro

Shushant tiwari 0 Nov 13, 2021
This is a sample app to use [Molecule library] and solve some scoping problems in Android development.

Android sample app Problem It's started when P.Y. in Twitter shared this tweet and his post, which is a correct complain about introducing a new set o

Hadi 37 Oct 28, 2022
Sample project that shows an approach for designing a multi-module architecture for Jetpack Compose Android applications.

Compose Multi-Module Architecture Sample Sample project that shows an approach for designing a multi-module architecture for Jetpack Compose Android a

Pavlo Stavytskyi 77 Jan 3, 2023
UserLoc - A API call using Retrofit to obtain list of users details and show on UI in recycler view and google map

UserLoc This uses a API call using Retrofit to obtain list of users details and

Rohit Kumar 0 Jun 22, 2022
ViewModel LiveData Sample - Sample of using ViewModel, LiveData and Data Binding

ViewModel_LiveData_Sample Sample Code for Lesson 8 using ViewModel, LiveData and

null 0 Mar 18, 2022
Anime quotes rest api app with mvvm, LiveData, Coroutines, Navigation Component etc

AnimeQuote Anime quotes image rest api app with mvvm, LiveData, Coroutines, Navigation Component, clean achitecture etc An app created during mentorin

Ehma Ugbogo 4 Jun 11, 2021