Skip to content
There is a Bengali Tutorial blog post for this repository. If you understand Bengali then check it out.
Kotlin Java
Branch: master
Clone or download
Latest commit 3a08133 Jan 10, 2020
Type Name Latest commit message Commit time
Failed to load latest commit information.
app code formatted Jan 10, 2020
gradle/wrapper remove context from presentation layer Dec 4, 2019
build.gradle gradle update Dec 7, 2019
gradlew.bat ui done Jun 18, 2019
settings.gradle ui done Jun 18, 2019

Android MVP Architecture Sample (Kotlin + Retrofit) - Weather App

MVP Architecture is one of the most popular architecture to develop a maintanable and managable codebase. We are developing a sample Weater Forecast Android App with MVP Architecture using Kotlin language and Retrofit network calling library.

There is another repository for the same project in MVVM Architecture. Check MVVM repository from here.

Project Description

We will develop a weather forecast Android Application with MVP architecture. The UI will be as like as above screenshot. There is a Spinner with some City name. After selection a city user need to hit the View Weather button. Then App will send request to Open Weather web API and show the weather information in the UI.

Open Weather API

We will use Open Weather Map API for collecting weather information. To get the real weather information of a city, you need to sign up and get your own APP ID. Otherwise you can test the API with their sample BASE URL and sample APP ID without creating account.

Project Setup

Clone the project and open it using Android Studio. Then open your file under Gradle Scripts. You need to specify the base_url and app_id in your file. Store your API secret in plain string file or Kotlin file is very risky. For security purpose it's better store in file than plain string/Kotlin file.

Use Sample API without creating account

Add below lines at the end of your file. Then run the project. You'll get dummy or static API response from Open Weather API.

#this is sample Base URL

#this is sample App ID of Open Weather API

Use Real APP ID after sign up and activation of your APP ID

After Sign up at the website collect your own APP ID from their API Keys page. Then add below lines with your APP ID at the end of file.

#this is real Base URL

#this is real App ID of Open Weather API

The BASE URL and APP ID will be fetched from build.gradle file and will be stored it in BuildConfig. And Retrofit API call will use the BASE URL and APP ID from BuildConfig.

Note: The free version of Open Weather API allows maximum 60 API calls per minute.

Run the project

Sync the Gradle and run the project. Install APK on your emulator or real device. Turn on the internet of your testing device. For better understanding, please read the comments of every methods. Hope, these comments will help you to feel the MVP Architecture.


There are some other ways of implementation of MVP. There are some arguments about the responsibilities of presenter and model. After understanding the basic part of MVP Architecture you can test them one by one. For simplicity, I've ignored dependency injection in this project. I will create another repository of MVP with dependency injection Dagger 2.

You can’t perform that action at this time.