Skip to content

softpian/Kotlin-MVP-RxJava-Dagger2

Repository files navigation

Kotlin-MVP-RxJava-Dagger2

Android Photo application implementing MVP Architecture, RxJava and Dagger 2 with Kotlin programming language

Introduction

This application embraces trendy and popular Android development skills, even though the user scenario of this application is simple.

Kotlin

This Android application was written in Kotlin programming language.

Kotlin is an attractive language because it is not only pretty concise but also 100% interoperable with Java and Android, bringing many advantages of a modern language to the Android platform.

For more information using Kotlin for Android development, please refer to http://kotlinlang.org/docs/reference/android-overview.html.

Android MVP Architecture

This repository contains a Photo application implementing Android MVP Architecture.

The application illustrates how to implement Model-View-Presenter (MVP) architecture pattern based on Android.

Please refer to Android Architecture Blueprints for detailed information about Android Model-View-Presenter Architecture

Model-View-Presenter pattern consists of :

  • The Model - defines data to be displayed and exposes them to the View through the presenter

  • The View - displays data (the model), receives user's actions and routes to the presenter

  • The Presenter - acts upon the model and the view, retrieves data from repositories (the model), and formats it for display in the view

Here is MVP architecture of this application.

RxJava

This Kotlin application was implemented based on Reactive Programming using RxJava that extends Observer pattern to support sequences of data/events.

RxJava was used as follows:

  • Making RESTful API calls and processing responses - RxJava2 Adapter of Retrofit which makes Observable object used for receiving a response instead of normal Call object.

  • Processing UI events, especially from EditText - RxBinding

  • Scheduling on the main thread - RxAndroid which makes modules observe the task's result or outcome on the main thread

Please refer to https://github.com/ReactiveX/RxJava for more detailed information about RxJava.

Dagger 2

The application implements Dependency Injection design pattern with Dagger 2.

Dagger 2 is a dependency injection framework maintained by Google which is one of the most efficient dependency injection frameworks built to date.

It analyzes dependencies and generates code to help wire them together based on annotations such as @Component, @Module, @Provides and so on.

Please refer to https://google.github.io/dagger for more information on Dagger 2.

flickr RESTful API

This application uses RESTful API of flickr which is a popular image/video hosting service in order to get photos.

It receives photo data formatted in JSON and converts it to Java Objects including photo URL, title, owner's name, date, description, viewer's count, comment's count and so on.

Please visit https://www.flickr.com/services/api/ for more detailed information.

Android development skills

This repository is able to help understand how to use the following skills.

  • How to implement Android Model-View-Presenter architecture pattern with Kotlin
  • How to use RxJava, RxBinding and RxAndroid for Reactive programming in Android development with Kotlin
  • How to apply the dependency injection design pattern to Android application with Dagger 2 framework
  • How to call RESTful API with Retrofit
  • How to integrate Retrofit with RxJava through RxJava Call adapter of Retrofit
  • How to use OkHttp Logging Interceptor in order to debug HTTP request/response data
  • How to convert JSON to Java Objects with Gson
  • How to load images from a remote server with Glide
  • How to reduce boilerplate codes with Kotlin Android Extensions
  • How to implement the Android material design using CoordinatorLayout, AppBarLayout, CollapsingToolbarLayout and so on

Screenshots

KotlinPhotoMVP screenshot

Getting Started

In your local.properties file, put your own key given from flickr :

flickrApiKey="yourOwnAPIKey"

For example, you should write it as below. (The following API Key is not a real one. Never use it in your application.)

flickrApiKey="788a5fnd5r134id6a792ff39pp68dcs3"

Libraries Used

  • RxJava - Java VM implementation of Reactive Extensions
  • RxBinding - RxJava binding APIs for Android UI widgets from the platform and support libraries
  • RxAndroid - Module providing a Scheduler that schedules on the main thread
  • Dagger 2 - Framework to implement Dependency injection pattern for Android and Java
  • Retrofit - Type-safe HTTP client for Android and Java which makes it easier to consume RESTful API services.
  • Retrofit 2 RxJava 2 Adapter - Helps handle a response from the server with RxJava as custom Call adapter
  • OkHttp Logging Interceptor - Logs HTTP request and response data with different logging levels in order to debug HTTP error
  • Gson - JSON library for Android and Java which makes it easy to parse JSON into Java objects. Used with Retrofit Gson converter
  • Glide - A fast and efficient image loading library for Android focused on smooth scrolling which offers an easy to use

Reference

License

Copyright Jaemoon Hwang <[email protected]>

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.

About

Android Photo application implementing MVP Architecture, RxJava and Dagger2 with Kotlin programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages