How to make Reddit like Android Kotlin app

Recently Google introduce Kotlin as a official language for Android and I really love Kotlin! and for me is the future of Java (today) but this is just my opinion 🙂

Welcome to this series of articles where we are going to learn Kotlin, a new JVM language, while developing an Android App. I hope it will help you to learn this incredible language in the context of Android. This stories will be separated in different Parts. In the Content section you will have the different Parts and the main topics that are going to be discussing there, each Part will include different Kotlin features.

My intention is not to create the best App in the world (I can’t do that hahah) but I’ll try to explain Kotlin and it’s main features while developing this app.

The App: Keddit

The App that we are going to develop is a small Reddit Client. It’ll present the latest news from Reddit with an infinite scroll to continuously load more news while you scroll down, showing the title, image, number of comments, time published and the author of the news.

Libraries that we are going to use:

  • Retrofit 2.0: To consume public Reddit API.
  • RxJava: We will use Observables to decouple the UI thread with our background tasks. In this case to call the API and return this values to the UI.
  • Picasso: Load images from Reddit.
  • RecyclerView: We will use the RecyclerView to present the information and also to provide the infinite scroll behaviour.
  • Kotlin Android Extensions: to bind the UI (Views) with code.
  • Dagger 2: Dependency Injection

Here is step by step tutorial to make Reddit like Android app using Kotlin named as Keddit.


Why Kotlin better than Java For Android Development

In this article we discuss about Kotlin and why it is better than Java for Android development.

Part 1: Configuring Android Studio with Kotlin

In this Part we are going to configure an Android Studio project to use Kotlin and leave everything prepared for the next story to start developing the Keddit App from the beginning and learning some Kotlin concepts.

Part 2: MainActivity.kt: Syntax, Null Safety and more…

In this Part we are going to focus on understanding some basic syntax of the language and also adding all the code that we need for the MainActivity.kt in order to open our fragment.

Part 3: NewsFragment.kt: Extension Functions, Android Extensions…

In this Part we are going to see different Kotlin concepts that will help us to create our NewsFragment fragment.

Part 4: RecyclerView — Delegate Adapters & Data Classes with Kotlin

In this 4th Part we are going to cover these topics about Kotlin:

  1. Init Constructor
  2. Object Expressions
  3. Single Expressions
  4. Data Classes
  5. Ranges
  6. List & Lambdas (introduction)

Part 5: Kotlin, RxJava & RxAndroid

In this article we are discussing about RxJava in Kotlin.

Part 6: API — Retrofit & Kotlin

Now it’s time to make a real API call and demonstrate that our abstraction with RxJava really works! and of course to show some real news in the App 🙂

Part 7: Infinite Scroll: Higher-Order functions & Lambdas

We need now is to allow the user to see not only the first 10 news but the next news that also belongs to this Top Reddit news.

Part 8: Orientation Change (Parcel-able & Data Classes)

In this story we are going to review how to properly manage the orientation change in the device, in fact, we are going to see how to handle runtime changes so we don’t lose the already requested news and continue at the same point.

Part 9: Unit Test with Kotlin (Mockito, RxJava & Spek)

Let’s talk about Unit Test in Keddit App.

Part 10: Kotlin & Dagger 2 (Dependency Injection)

In this article we discuss about dependency injection in Kotlin.

Part 11: Continuous Integration with Kotlin (BuddyBuild)

It would be great if a new build is run every time we push new code to the repository, the unit tests are run automatically for us and also to receive an alert if the build has failed. Let’s do it with our Keddit App.

Apart from this you can run your demo kotlin program in online compiler. Hope you like my articles. So please comment us and if any issues and problem occurs then commit me.

By Juan Ignacio Saravia

Juan Ignacio Saravia is an Android enthusiast with over 7 year experience in the Android platform and is currently working in Globant, Argentina. You can follow him on medium and twitter.

Share your thoughts

Leave a Reply

Loading Facebook Comments ...
Loading Disqus Comments ...