<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ rxjava - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ rxjava - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 26 Jul 2026 20:14:30 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/rxjava/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ A complete roadmap for learning RxJava ]]>
                </title>
                <description>
                    <![CDATA[ By Ayusch Jain This article was originally posted here I wish someone had written an article like this when I started my learning journey with RxJava in 2017. I wish there had been a perfect book or some kind of an online school which taught me how... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/a-complete-roadmap-for-learning-rxjava-9316ee6aeda7/</link>
                <guid isPermaLink="false">66c342494f7405e6476b0148</guid>
                
                    <category>
                        <![CDATA[ Android ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Computer Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ mobile app development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ rxjava ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 14 Feb 2019 22:15:55 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*gaQI9yDYH86yIlrLE0tyaQ.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ayusch Jain</p>
<blockquote>
<p>This article was originally posted <a target="_blank" href="https://ayusch.com/the-complete-rxjava-roadmap/">here</a></p>
</blockquote>
<p>I wish someone had written an article like this when I started my learning journey with RxJava in 2017. I wish there had been a perfect book or some kind of an <a target="_blank" href="http://microverse.org">online school</a> which taught me how to get started with Rx the right way.</p>
<p>There has been so much hype right now around <strong>RxJava</strong> and Reactive Programming in general. Everyone seems to promote it, but no one seems to have an idea about how a novice programmer who is just starting out with RxJava should go about this journey.</p>
<p>All this has a reason! RxJava has a steep learning curve and there is no one way to master it. Some prefer the docs (which are excellent, by the way), some prefer books about RxJava with some examples, while some crazy ones (including me <em>facepalm</em>) commit the mistake of diving right into the code after watching a YouTube video of a talk by Kaushik Gopal on how to get started with RxJava and start refactoring their code.</p>
<p>The last method is absolutely dangerous, and instead of solving your problems with Rx, you’ll just end up creating new ones. So, I suggest that you follow the roadmap given below to get started with RxJava.</p>
<p>While this is by no means the only way to go about it, after having experience of almost 1.5 years with <strong>RxJava</strong> (and still learning), I wish someone had told me these things when I was beginning my journey. If you follow the given roadmap religiously, I can ensure you that you’ll have a strong foundation in RxJava which you can then build upon to unleash its full potential.</p>
<p>I have divided the entire roadmap into four phases:</p>
<ul>
<li><strong>The Discovery</strong>: Say hello to the world of Reactive Programming.</li>
<li><strong>The disillusionment</strong>: World ain’t all sunshine and rainbows.</li>
<li><strong>Eureka!</strong></li>
<li><strong>Sky’s the limit</strong></li>
</ul>
<p>So, let’ get straight into it.</p>
<h3 id="heading-phase-1">Phase 1</h3>
<h4 id="heading-the-discovery-say-hello-to-the-world-of-reactive-programming">The Discovery: Say hello to the world of Reactive Programming</h4>
<p>I could have also titled this phase “The Motivation”, because this is the very initial phase where you’ve heard about <strong>RxJava</strong> from a friend of yours or someone on LinkedIn posted about it or you just happen to stumble upon a piece of code with Observables flying around all over the place.</p>
<p>Whatever the case, when you first go about looking at a piece of <strong>RxJava routine</strong> (even the simplest one), you might be intimidated by all the methods being called one after the other in a single chain. But you’ll notice that the code looks neater than any other you’ve ever seen. And it accomplishes unimaginably complex tasks with simple method chains while you’ve been forming AsynTask and thinking about multiple <strong>Retrofit/Volley</strong> calls in your head.</p>
<p>Tasks such as making multiple API calls one after the other, making API calls and saving into a database and returning a success or a failure etc… are being <strong>accomplished within 20–25 lines of code.</strong> You’ll be intimidated but at the same time inclined to find out what this tool is, and how you can also get started writing such neat code.</p>
<p><strong>So, in order to get you started here is a list of things I need you to do in this phase:</strong></p>
<p>I suggest that you <strong>watch this talk by Kaushik Gopal</strong> at least twice (it took me 4 replays to get a hold of it. I had the talk downloaded on my computer) to completeness. According to me, it’s the gold standard of anyone looking to dive into reactive programming.</p>
<p>Kaushik Gopal beautifully explains the nuances of RxJava and provides real-world examples, with a hint of abstraction on the absolute technicalities, easily understandable by any beginner. He divides any RxJava routine into 4 basic constructs (even my article on RxJava: <a target="_blank" href="https://disq.us/?url=https%3A%2F%2Fayusch.com%2Funderstanding-rxjava-basics%2F&amp;key=7M4ry_gpESP38RXOsGVmaQ"><strong>Understanding RxJava Basics</strong></a> is inspired by his talk).</p>
<p>Surely on the first attempt, you won’t be able to get a hold of what exactly is an observable and how the observer pattern works. That’s why I suggest that you watch it at least twice.</p>
<p><strong>Here’s what you should be clear about from this talk (at least):</strong></p>
<ul>
<li>What is an Observable?</li>
<li>What is a Subscriber?</li>
<li>How do Observables and Subscribers work together?</li>
<li>What is an operator (not the specific functionality, but what an operator does)?</li>
</ul>
<p>Replay it as many times as you want, but you should be absolutely clear about the above 4 questions after you’re done. You can also refer to the text available online along with this video. Don’t move forward unless and until you understand the above nuances clearly else, you’ll end up being more confused than before.</p>
<p>Once you’re done, go ahead and watch this talk by Christina Lee:</p>
<p>Watch this talk once, but I want you to focus especially from <strong>28:20–32:50</strong>. During these 4 minutes, she gives an absolutely beautiful explanation on <strong>what the two most used operators</strong> in any RxJava routine, observeOn() and subscribeOn() do and how they’re used together, using an example.</p>
<p>These operators are together included as one of the main constructs, in the <strong>4 constructs of RxJava</strong> explained by Kaushik Gopal. And believe me, they are really important in your journey with reactive programming and RxJava in general.</p>
<p><strong>Create a project in Android Studio</strong> (if you are an android developer) or any IDE of your choice and run the exact same code that Christina provides. Once you set that up, you can play around by changing the order of observeOn and subscribeOn and see how they behave. Try adding multiples of these and see who dominates and what’s the output. You’ll get a good grasp on the functions of these operators once you do this exercise.</p>
<blockquote>
<p><strong>Don’ts</strong>: YouTube would recommend multiple talks on RxJava by <strong>Jake Wharton</strong>, but I highly suggest that you ignore those for the time being. Those talks can get really intimidating after some time and you’ll most likely drop off somewhere in between and maybe even give up on RxJava altogether. So, stay away from them for the time being.</p>
</blockquote>
<h3 id="heading-phase-2">Phase 2</h3>
<h4 id="heading-the-disillusionment-the-world-aint-all-sunshine-and-rainbows">The Disillusionment: the world ain’t all sunshine and rainbows</h4>
<p>This phase could also be named “The Struggle”. This is the phase where you need to start getting your hands dirty by writing some actual RxJava code.</p>
<p><strong>I’d suggest that you start by making some API calls with RxJava and I’ve already published a post for this exact same purpose: <a target="_blank" href="https://ayusch.com/networking-with-retrofit-rxjava-mvp/">Networking with Retrofit-RxJava-MVP Architecture</a></strong></p>
<p>Understand what’s going on here. You’ve probably already made some API calls in your Android Development journey using Retrofit/Volley. But this article will explain how to put them together properly in order to get separation of concerns and make your code more modular and ultimately easy to understand and scale at some later stage.</p>
<p>It also includes the use of MVP Pattern which is really simple but you can omit that if it gets too technical. Just <strong>focus on creating the Adapter, the API service interface, and the UserTask</strong>. Rest assured that it’s all just simple Android code. You can invoke UserTask from anywhere and get the result in a callback.</p>
<p>Once you’ve done this, you’ll get a gist of what it’s like to work with RxJava.</p>
<p>Next, you should develop an app yourselves which involves networking. You could you the fakeJson web service/make a twitter client/consume a rotten tomatoes API, or anything which involves networking. You’ll find out how different operators such as <strong>Map</strong> and <strong>FlatMap</strong> come in handy while transforming your observables into something of your requirement.</p>
<p>As you do that, you’ll start feeling more confident with RxJava routines and observe that most of the code is the same across these applications. Of course, there will be different operators used and a difference in your models. But the overall gist is somewhat similar.</p>
<p>Now you’re ready for <strong>Phase 3</strong> and getting to that Eureka moment ?</p>
<h3 id="heading-phase-3">Phase 3</h3>
<h4 id="heading-eureka">Eureka!</h4>
<p>This is the phase where you’ll get out of your comfort zone and start exploring what RxJava can do for your <strong>Android</strong> app rather than just networking. This is where you’ll learn about the art of state management with RxJava and how you can Rxify almost everything in your code. In this section, I’ll push you to start State Management with RxJava.</p>
<p>This is also the point where you are ready to watch all of <strong>Jake Wharton’s</strong> talks on RxJava. Actually, this will be your task in this phase, but first, let’s understand what is state management.</p>
<p><strong>What is state management?</strong></p>
<p>Let’s think of an <strong>example</strong>. Say, you have a simple login/signup application where you ask the user for their username and password and when they click a button, you sign them in/direct to a signup page.</p>
<p>Now as soon as the user enters his details and clicks the submit button, a loader is shown while the app sends the data to a backend service and waits for the response. We can say that currently, our app is in an “inProgress” state.</p>
<p>As the result is returned, the app reverts back to the “<strong>Idle</strong>” state.</p>
<p>To elaborate further, let’s talk about the submit button. When the text fields are empty, i.e. the user hasn’t entered anything yet, then the button should be disabled. So, “disabled” becomes a state of the button. When the user has entered the info and the fields are validated, the button should be in “enabled” state.</p>
<p>So, you see, everything you see on the screen, exists in a particular state. Right from that button, to the progress bar, everything is in a particular state.</p>
<p><strong>All’s good but what to do now?</strong></p>
<p>Here’s what I want you to do.</p>
<p><strong>Start</strong> by watching this talk about state management by Jake Wharton:</p>
<p>This talk is for <strong>advanced</strong> developers and I had to watch it at least 10 times to wrap my head around what was going on. But watching a video alone won’t make you a pro at RxJava. You’ll need to state manage your applications using RxJava.</p>
<p>To practice with state management, I’d suggest picking up any simple idea/one single screen and start state managing it with RxJava. For example, if your app includes a login/signup screen, you can perform its state management using RxJava as mentioned above.</p>
<p><strong>Here are a couple of ideas for you:</strong></p>
<ul>
<li><strong>Develop a login/registration app</strong>. After the user logs in, consume the Rotten Tomatoes API. Allow a search functionality so the user can search for movies according to his liking. In all of this, the progress bars and the animations must be states which would be managed within RxJava streams. Rx would also be used for making API calls.</li>
<li><strong>Check out <a target="_blank" href="https://github.com/kaushikgopal/RxJava-Android-Samples">this</a> repository</strong> by Kaushik Gopal which includes an example of form validation with RxJava. Clone it, and try and understand the code. Once you’re comfortable, start implementing it yourself. Think of what all states you could add to it to increase the complexity. For example, a checkbox to reveal the password.</li>
</ul>
<p>You’ll definitely get your Eureka moment in this phase where you realize the vast potential of RxJava and how you can possibly do anything with it and make your code neater.</p>
<h3 id="heading-phase-4">Phase 4</h3>
<h4 id="heading-skys-the-limit">Sky’s the limit</h4>
<p>I’ll leave this section blank for you. Now it’s up to you to tell me about all the creative ways you’ve used <strong>RxJava</strong> in your code and how RxJava has made your life easier than before. One thing I’ve noticed as I’ve started writing these blogs is that these have definitely helped me become a better Android developer as I’m accountable for everything I post.</p>
<p>In this post, I’ve shared everything that worked for me and what I think will work for you. If you have any suggestions, let me know in the comments section below. I urge you to share your learnings with everyone and help each other grow and become better engineers.</p>
<p>Like what you read? Don’t forget to share this post on <a target="_blank" href="https://www.facebook.com/AndroidVille"><strong>Facebook</strong></a>, <strong>Whatsapp</strong>, and <strong>LinkedIn</strong>.</p>
<p>You can follow me on <a target="_blank" href="https://www.linkedin.com/in/ayuschjain">LinkedIn</a>, <a target="_blank" href="https://www.quora.com/profile/Ayusch-Jain">Quora</a>, <a target="_blank" href="https://twitter.com/ayuschjain">Twitter</a>, and <a target="_blank" href="https://www.instagram.com/androidville/">Instagram</a> where I <strong>answer</strong> questions related to <strong>Mobile Development, especially Android and Flutter</strong>.</p>
<p><strong>If you want to stay updated with all the latest articles, subscribe to the weekly newsletter by entering your email address in the form on the top right section of this page.</strong></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to set up networking in your Android app with Retrofit-RxJava-MVP ]]>
                </title>
                <description>
                    <![CDATA[ By Ayusch Jain This article was originally posted here In this Android App development tutorial, I’ll be demonstrating how you can setup Retrofit and RxJava for networking in your android application along with MVP Architecture. We’ll be developing... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-set-up-networking-in-your-android-app-with-retrofit-rxjava-mvp-108e7153521a/</link>
                <guid isPermaLink="false">66c35487c45f383e42e907a8</guid>
                
                    <category>
                        <![CDATA[ Android ]]>
                    </category>
                
                    <category>
                        <![CDATA[ mobile app development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ rxjava ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 06 Feb 2019 15:31:14 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*_qQps59angkeAdcbql2rnA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ayusch Jain</p>
<blockquote>
<p>This article was originally posted <a target="_blank" href="https://ayusch.com/networking-with-retrofit-rxjava-mvp">here</a></p>
</blockquote>
<p>In this Android App development tutorial, I’ll be demonstrating how you can setup Retrofit and RxJava for networking in your android application along with MVP Architecture.</p>
<p>We’ll be developing a very barebones application which will display some data in recyclerview. The data will be obtained from a fake JSON API hosted on <a target="_blank" href="https://jsonplaceholder.typicode.com">https://jsonplaceholder.typicode.com</a>. The application will display data in three columns namely ID, Title and Body.</p>
<p>Here are the prerequisites to this tutorial:</p>
<ul>
<li><a target="_blank" href="https://ayusch.com/mvp-architecture-android/">How to Implement MVP Architecture in Android</a></li>
<li><a target="_blank" href="https://ayusch.com/understanding-rxjava-basics">Understanding RxJava Basics</a></li>
</ul>
<p>Once you go through the above two, you are ready to move forward with this article. I’ve divided this into 4 phases:</p>
<ul>
<li>Setting up the project and building layouts.</li>
<li>Setting up MVP Architecture.</li>
<li>Creating Model class for data and adapter for RecyclerView.</li>
<li>Setting up Networking with Retrofit and RxJava.</li>
</ul>
<p>So, let’s get started!</p>
<blockquote>
<p>Note: Some <a target="_blank" href="http://microverse.org">online schools</a> such as Udemy and Lynda also have good tutorials on RxJava</p>
</blockquote>
<h3 id="heading-phase-1-setting-up-the-project-and-building-layouts">Phase 1: Setting up the project and building layouts.</h3>
<h4 id="heading-create-a-new-project">Create a new project</h4>
<p>Create a new project in android studio. Go to File -&gt; New Project and select <strong>“Empty Activity”.</strong> Then click Finish.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/QBay9VeS0891s9mHP3ExEtJ-zAGTa8QBOyrl" alt="Image" width="800" height="640" loading="lazy"></p>
<h4 id="heading-adding-a-recyclerview"><strong>Adding a Recyclerview</strong></h4>
<p>To add a recyclerview to your project, open app level build.gradle file and add the following dependency at the bottom:</p>
<pre><code>implementation <span class="hljs-string">'com.android.support:design:28.0.0'</span>
</code></pre><blockquote>
<p><em>Note: You can also add recyclerview directly instead of the entire design library, but most of you might already have it included so I’m including the design library in this example. You can include just the recyclerview as well.</em></p>
</blockquote>
<p>Now head over to your main layout file, in my case activity_main.xml and add a recyclerview inside the root layout:</p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">LinearLayout</span> <span class="hljs-attr">xmlns:android</span>=<span class="hljs-string">"http://schemas.android.com/apk/res/android"</span>
    <span class="hljs-attr">xmlns:app</span>=<span class="hljs-string">"http://schemas.android.com/apk/res-auto"</span>
    <span class="hljs-attr">xmlns:tools</span>=<span class="hljs-string">"http://schemas.android.com/tools"</span>
    <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"match_parent"</span>
    <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"match_parent"</span>
    <span class="hljs-attr">tools:context</span>=<span class="hljs-string">".UserActivity"</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">android.support.v7.widget.RecyclerView</span>
        <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@+id/recyclerview"</span>
        <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"match_parent"</span>
        <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"match_parent"</span> /&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">LinearLayout</span>&gt;</span>
</code></pre>
<h4 id="heading-building-recyclerview-item">Building Recyclerview Item</h4>
<p>Now let’s start building the RecyclerView rows. Here we are only concerned about the architecture of our Android application and how Retrofit, RxJava and MVP Architecture can work in tandem, so don’t complain about the look of the UI :P. You can definitely go ahead and beautify it.</p>
<p>We’ll be creating a really simple three column layout. The first column will display the ID of the item, the second column will display the Title, and finally, the third column will display the body/description.</p>
<p>Go to res-&gt;layout and right click on the layout folder. Create a new <strong>“Layout Resource File”.</strong> Name it whatever you want, in my case I’ll name it <strong>recycler_item.</strong></p>
<p>To create a three-column layout, add a LinearLayout as the root. Then add three textviews and set their width to 0 and their weight to 1,2,3 respectively. This will divide the entire width of your screen into 3 columns in the proportion 1:2:3.</p>
<p>Here’s how your layout will look like:</p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">LinearLayout</span> <span class="hljs-attr">xmlns:android</span>=<span class="hljs-string">"http://schemas.android.com/apk/res/android"</span>
    <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"match_parent"</span>
    <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"wrap_content"</span>
    <span class="hljs-attr">android:layout_marginTop</span>=<span class="hljs-string">"16dp"</span>
    <span class="hljs-attr">android:orientation</span>=<span class="hljs-string">"horizontal"</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">TextView</span>
        <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@+id/user_id"</span>
        <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"0dp"</span>
        <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"wrap_content"</span>
        <span class="hljs-attr">android:layout_weight</span>=<span class="hljs-string">"1"</span>
        <span class="hljs-attr">android:gravity</span>=<span class="hljs-string">"center"</span>
        <span class="hljs-attr">android:padding</span>=<span class="hljs-string">"4dp"</span>
        <span class="hljs-attr">android:text</span>=<span class="hljs-string">"id"</span> /&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">TextView</span>
        <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@+id/user_title"</span>
        <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"0dp"</span>
        <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"wrap_content"</span>
        <span class="hljs-attr">android:layout_weight</span>=<span class="hljs-string">"2"</span>
        <span class="hljs-attr">android:gravity</span>=<span class="hljs-string">"center"</span>
        <span class="hljs-attr">android:padding</span>=<span class="hljs-string">"4dp"</span>
        <span class="hljs-attr">android:text</span>=<span class="hljs-string">"Title"</span> /&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">TextView</span>
        <span class="hljs-attr">android:id</span>=<span class="hljs-string">"@+id/user_body"</span>
        <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">"0dp"</span>
        <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">"wrap_content"</span>
        <span class="hljs-attr">android:layout_weight</span>=<span class="hljs-string">"3"</span>
        <span class="hljs-attr">android:gravity</span>=<span class="hljs-string">"center"</span>
        <span class="hljs-attr">android:padding</span>=<span class="hljs-string">"4dp"</span>
        <span class="hljs-attr">android:text</span>=<span class="hljs-string">"Body"</span> /&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">LinearLayout</span>&gt;</span>
</code></pre>
<p><strong>Again, since this is not a design tutorial the UI might not look very pretty, so feel free to customize it as you like ?</strong></p>
<p>Now with the layouts all done, we can head over to set up our android application in accordance with MVP Architecture. Again, if you aren’t really familiar with MVP, I strongly suggest that you have a look here: <a target="_blank" href="https://ayusch.com/mvp-architecture-android/">MVP Architecture in Android</a>.</p>
<h3 id="heading-phase-2-setting-up-mvp-architecture">Phase 2: Setting up MVP Architecture</h3>
<h4 id="heading-creating-the-contract">Creating the contract</h4>
<p>Many people like to keep their View and Presenter interfaces in different files, but according to Google’s suggested guidelines, I like to create an outer interface (Wrapper) named <strong>Contract</strong> and then place my View and Presenter Interfaces inside it.</p>
<p>The benefit of this is that you won’t have to go looking at different files for the view and presenter associated with a single activity, it’s all in a single place. That’s how I like it, but feel free to explore other techniques.</p>
<p>So now let’s create a UserActivityContract. Create a new package named <strong>“contract”.</strong> Inside that package, create a new Java Interface UserActivityContract.</p>
<p>Within <strong>UserActivityContract</strong>, add two nested interfaces: View and Presenter. This is how your contract will look like at the end:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">UserContract</span> </span>{
    <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">View</span> </span>{

    }

    <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Presenter</span> </span>{

    }

}
</code></pre>
<p>Now let’s add some methods to these. Let’s talk about the View first, we’ll be doing 3 major things inside our view:</p>
<ul>
<li>Initial setup of recyclerview (adding layout manager).</li>
<li>Creating an adapter from recyclerview using the list of users obtained from the API.</li>
<li>Showing some error message in case any error occurs.</li>
</ul>
<p>So, let’s add a method for each one of these:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">UserContract</span> </span>{
    <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">View</span> </span>{
        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span></span>;

        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">showError</span><span class="hljs-params">(String message)</span></span>;

        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">loadDataInList</span><span class="hljs-params">(List&lt;User&gt; users)</span></span>;
    }

    <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Presenter</span> </span>{

    }

}
</code></pre>
<p>Next, let’s talk about the Presenter. The only real task of the presenter is to get the data from the API and send it to the View. So, add a method <strong>loadUsers()</strong> we’ll be making our API call here and passing the result to view if successful, else an error message.</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">UserContract</span> </span>{
    <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">View</span> </span>{
        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span></span>;

        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">showError</span><span class="hljs-params">(String message)</span></span>;

        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">loadDataInList</span><span class="hljs-params">(List&lt;User&gt; users)</span></span>;
    }

    <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Presenter</span> </span>{

        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">start</span><span class="hljs-params">()</span></span>;

        <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">loadUsers</span><span class="hljs-params">()</span></span>;
    }

}
</code></pre>
<p>Notice that apart from loadUsers(), we have also added a method named <strong>start(),</strong> this is more of like an initializer method for the presenter. You can perform all sorts of init tasks here such as initializing some variables, calling a method of the view to show some init messages etc. Here I’m using it to initialize the Recyclerview inside my UserActivity.java class.</p>
<h4 id="heading-creating-presenter-and-implementing-view">Creating Presenter and Implementing View</h4>
<p>Once done with the interfaces, it’s time to implement them.</p>
<p>Create a new class named UserPresenter and implement UserContract.Presenter on it and implement the required methods.</p>
<p>Now, open your UserActivity.java class and implement the interface UserContract.View and implement all the required methods. Add a field for the presenter in your activity and initialize it in onCreate as shown below:</p>
<pre><code class="lang-java">mPresenter = <span class="hljs-keyword">new</span> UserPresenter(<span class="hljs-keyword">this</span>);
mPresenter.start();
</code></pre>
<p>This will call the constructor of our presenter and bind the View and Presenter together. When we call the start method on presenter, presenter in-turn calls the init() method which starts our initialization process.</p>
<p><strong>With this,</strong> we finish <strong>Phase 2</strong> of our project. Now let’s head over to <strong>Phase 3</strong> and create our model class and a custom adapter to bind data to recyclerview.</p>
<h3 id="heading-phase-3-creating-model-class-for-data-and-adapter-for-recyclerview">Phase 3: Creating Model class for data and adapter for RecyclerView</h3>
<h4 id="heading-creating-the-model">Creating the model</h4>
<p>Let’s go ahead and create our model which will be a POJO class for our data. If you look closely at the JSON response, it consists of 4 fields: id, userId, title, body. And all of this inside a JSON object. And many such JSON objects in an array. So, this is a fairly simple POJO class to create.</p>
<p>But before this, let’s add a dependency for GSON, which will be used to parse the JSON response. Add the following line to your dependencies:</p>
<pre><code>implementation <span class="hljs-string">'com.squareup.retrofit2:converter-gson:2.4.0'</span>
</code></pre><blockquote>
<p><em>Note: This is not the actual GSON dependency, this is a converter which uses GSON for serialization to and from JSON.</em></p>
</blockquote>
<p>Now, create a package named <strong>model</strong> and inside it, create a java file named <strong>User</strong>. Add the four fields and annotate each of the fields with <strong>@SerializedName</strong>. Now let’s create getters and setters for the fields. Android Studio does this automatically for you, just press ALT+INS on your keyboard and select getters and setters.</p>
<p>This is how your POJO class would look like at the end:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">User</span></span>{

   <span class="hljs-meta">@SerializedName("id")</span>
   <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> id;

   <span class="hljs-meta">@SerializedName("title")</span>
   <span class="hljs-keyword">private</span> String title;

   <span class="hljs-meta">@SerializedName("body")</span>
   <span class="hljs-keyword">private</span> String body;

   <span class="hljs-meta">@SerializedName("userId")</span>
   <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> userId;

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setId</span><span class="hljs-params">(<span class="hljs-keyword">int</span> id)</span></span>{
      <span class="hljs-keyword">this</span>.id = id;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">getId</span><span class="hljs-params">()</span></span>{
      <span class="hljs-keyword">return</span> id;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setTitle</span><span class="hljs-params">(String title)</span></span>{
      <span class="hljs-keyword">this</span>.title = title;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getTitle</span><span class="hljs-params">()</span></span>{
      <span class="hljs-keyword">return</span> title;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setBody</span><span class="hljs-params">(String body)</span></span>{
      <span class="hljs-keyword">this</span>.body = body;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getBody</span><span class="hljs-params">()</span></span>{
      <span class="hljs-keyword">return</span> body;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setUserId</span><span class="hljs-params">(<span class="hljs-keyword">int</span> userId)</span></span>{
      <span class="hljs-keyword">this</span>.userId = userId;
   }

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">getUserId</span><span class="hljs-params">()</span></span>{
      <span class="hljs-keyword">return</span> userId;
   }

   <span class="hljs-meta">@Override</span>
   <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">toString</span><span class="hljs-params">()</span></span>{
      <span class="hljs-keyword">return</span> 
         <span class="hljs-string">"User{"</span> + 
         <span class="hljs-string">"id = '"</span> + id + <span class="hljs-string">'\''</span> + 
         <span class="hljs-string">",title = '"</span> + title + <span class="hljs-string">'\''</span> + 
         <span class="hljs-string">",body = '"</span> + body + <span class="hljs-string">'\''</span> + 
         <span class="hljs-string">",userId = '"</span> + userId + <span class="hljs-string">'\''</span> + 
         <span class="hljs-string">"}"</span>;
      }
}
</code></pre>
<blockquote>
<p><em>Note: toString method is optional. I like to include it because when printing log statements, it prints the formatted json.</em></p>
</blockquote>
<h3 id="heading-creating-recyclerview-adapter">Creating RecyclerView Adapter</h3>
<p>Let’s now create the recyclerview adapter. Create a package named adapter and create a new Java class named <strong>CustomAdapter.java</strong> inside it. Extend the class from RecyclerView.Adapter class. It will show an error, just press ALT+Enter and override all the required methods.</p>
<p>Inside <strong>CustomAdapter.java</strong> create a nested class named MyViewHolder and extend it from RecyclerView.ViewHolder. Then create a constructor and initialize all the textviews as shown below:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CustomAdapter</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">Adapter</span>&lt;<span class="hljs-title">CustomAdapter</span>.<span class="hljs-title">MyViewHolder</span>&gt; </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">CustomAdapter</span><span class="hljs-params">(List&lt;User&gt; userList)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> MyViewHolder <span class="hljs-title">onCreateViewHolder</span><span class="hljs-params">(ViewGroup parent, <span class="hljs-keyword">int</span> viewType)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onBindViewHolder</span><span class="hljs-params">(MyViewHolder holder, <span class="hljs-keyword">int</span> position)</span> </span>{

    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">getItemCount</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> userList.size();
    }

    <span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyViewHolder</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">ViewHolder</span> </span>{

        TextView tvId, tvTitle, tvBody;

        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">MyViewHolder</span><span class="hljs-params">(View itemView)</span> </span>{
            <span class="hljs-keyword">super</span>(itemView);
            tvId = (TextView) itemView.findViewById(R.id.user_id);
            tvTitle = (TextView) itemView.findViewById(R.id.user_title);
            tvBody = (TextView) itemView.findViewById(R.id.user_body);
        }
    }

}
</code></pre>
<p>We’ll be passing a list of users to this adapter and we would be doing that in the <strong>constructor</strong>. So, first create a field <strong>List&lt;Us</strong>er&gt; and then create a constructor which will take a List as its argument. Now, set the field property to the one obtained in the constructor.</p>
<p>When you overrode the methods, you got onCreateViewHolder. In that method, we’ll inflate our layout for the recyclerview item and return a view holder from it. Head over to onCreateViewHolder and add the following code:</p>
<pre><code class="lang-java"><span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> MyViewHolder <span class="hljs-title">onCreateViewHolder</span><span class="hljs-params">(ViewGroup parent, <span class="hljs-keyword">int</span> viewType)</span> </span>{
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_item, parent, <span class="hljs-keyword">false</span>);
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> MyViewHolder(view);
}
</code></pre>
<p>Now, in <strong>onBindViewHolder</strong>, we’ll bind the data to our views. This is how the final adapter would look like:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CustomAdapter</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">Adapter</span>&lt;<span class="hljs-title">CustomAdapter</span>.<span class="hljs-title">MyViewHolder</span>&gt; </span>{

    List&lt;User&gt; userList = <span class="hljs-keyword">new</span> ArrayList&lt;&gt;();

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">CustomAdapter</span><span class="hljs-params">(List&lt;User&gt; userList)</span> </span>{
        <span class="hljs-keyword">this</span>.userList = userList;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> MyViewHolder <span class="hljs-title">onCreateViewHolder</span><span class="hljs-params">(ViewGroup parent, <span class="hljs-keyword">int</span> viewType)</span> </span>{
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_item, parent, <span class="hljs-keyword">false</span>);
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> MyViewHolder(view);
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onBindViewHolder</span><span class="hljs-params">(MyViewHolder holder, <span class="hljs-keyword">int</span> position)</span> </span>{
        holder.tvTitle.setText(userList.get(position).getTitle());
        holder.tvId.setText(userList.get(position).getId()+<span class="hljs-string">""</span>);
        holder.tvBody.setText(userList.get(position).getBody());
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">getItemCount</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> userList.size();
    }

    <span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyViewHolder</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">ViewHolder</span> </span>{
        TextView tvId, tvTitle, tvBody;
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">MyViewHolder</span><span class="hljs-params">(View itemView)</span> </span>{
            <span class="hljs-keyword">super</span>(itemView);
            tvId = (TextView) itemView.findViewById(R.id.user_id);
            tvTitle = (TextView) itemView.findViewById(R.id.user_title);
            tvBody = (TextView) itemView.findViewById(R.id.user_body);
        }
    }

}
</code></pre>
<h3 id="heading-phase-4-setting-up-networking-with-retrofit-and-rxjava">Phase 4: Setting up Networking with Retrofit and RxJava</h3>
<p>This is the crux of our android application. This is what you all came here for, so let’s get started.</p>
<p>I’ve divided setting up networking in our project into 4 parts:</p>
<ul>
<li>Creating a Retrofit adapter.</li>
<li>Setting up an API Service interface which defines our endpoints.</li>
<li>Creating a NetworkingUtil class to bind the Adapter and Service.</li>
<li>Creating a Utility class to make API calls and return the result to the presenter.</li>
</ul>
<p>So, let’s get started.</p>
<h4 id="heading-creating-a-retrofit-adapter">Creating a Retrofit Adapter</h4>
<p>Create a package named “networking”, and inside networking, create another package named “adapter” (this is how I like my package management and is by no means the recommended way of doing things, but it suits me so +1).</p>
<p>Inside that package, create a class named RetrofitAdapter. In this class we’ll define the following things:</p>
<ul>
<li>A converter factory to parse JSON response into our POJO class.</li>
<li>A call adapter factory.</li>
<li>A base URL.</li>
</ul>
<p>Let’s start by adding a <strong>BASE_URL</strong> filed at the top. Set the base URL to <a target="_blank" href="https://jsonplaceholder.typicode.com">https://jsonplaceholder.typicode.com</a></p>
<p>Now, create a static instance of Gson and Retrofit at the top. Now, create a synchronized method as shown below and add the following code. I’ll explain what’s going on:</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">synchronized</span> Retrofit <span class="hljs-title">getInstance</span><span class="hljs-params">()</span> </span>{

    <span class="hljs-keyword">if</span> (retrofit == <span class="hljs-keyword">null</span>) {
        <span class="hljs-keyword">if</span> (gson == <span class="hljs-keyword">null</span>) {
            gson = <span class="hljs-keyword">new</span> GsonBuilder().setLenient().create();
        }

        retrofit = <span class="hljs-keyword">new</span> Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();

    }

    <span class="hljs-keyword">return</span> retrofit;
}
</code></pre>
<p>We are creating a singleton instance of retrofit, if the instance is already created, we just return it, else we create a new one.</p>
<p>To create a new instance, we are using the Retrofit.Builder() method. We set the Base URL to the URL declared at the top, we set the converter factory as Gson which will parse the JSON response for us and add a call adapter factory from RxJava 2.</p>
<blockquote>
<p><em>Now, you may ask what is a call adapter? So, a call adapter is basically a tool which manages the execution, and response handling of retrofit. When the client receives a response from the server, it’s meaningless to the user as it is in bytes. So the call adapter converts those bytes into meaningful java objects.</em>  </p>
<p><em>To know more about call adapters take a look at this awesome article : <a target="_blank" href="https://futurestud.io/tutorials/retrofit-2-introduction-to-call-adapters">https://futurestud.io/tutorials/retrofit-2-introduction-to-call-adapters</a></em></p>
</blockquote>
<p>Since we have added <strong>RxJavaCallAdapter</strong> factory, it wraps our responses into <strong>RxJava</strong> types.</p>
<p>This is how our <strong>RetrofitAdapter.java class</strong> looks when complete:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">RetrofitAdapter</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> Retrofit retrofit;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> Gson gson;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> String BASE_URL = <span class="hljs-string">"https://jsonplaceholder.typicode.com"</span>;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">synchronized</span> Retrofit <span class="hljs-title">getInstance</span><span class="hljs-params">()</span> </span>{

        <span class="hljs-keyword">if</span> (retrofit == <span class="hljs-keyword">null</span>) {
            <span class="hljs-keyword">if</span> (gson == <span class="hljs-keyword">null</span>) {
                gson = <span class="hljs-keyword">new</span> GsonBuilder().setLenient().create();
            }

            retrofit = <span class="hljs-keyword">new</span> Retrofit.Builder()
                    .baseUrl(BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create(gson))
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .build();

        }

        <span class="hljs-keyword">return</span> retrofit;
    }

}
</code></pre>
<h4 id="heading-creating-an-api-service">Creating an API Service</h4>
<p>Now, we’ll create an interface to define our URL endpoints.</p>
<p>Create a package named API inside the networking package. Inside API, create a Java Interface named UserService.java</p>
<p>In our very short and concise example, we’ll be calling just a single endpoint, so we’ll have only one method. You can call many different endpoints such as for login, signup, logout etc…</p>
<p>Add a method declaration <strong>getUsers()</strong> and annotate it with the type of request (GET or POST) and pass the endpoint.</p>
<p>This is how your interface must look like at the end. Note that we are returning an <strong>Observable</strong> of type <strong>List</strong>, at the end. Our RxJava call adapter does the work of creating an observable out of the response from the server.</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">UserService</span> </span>{

    <span class="hljs-meta">@GET("/posts/")</span>
    Observable&lt;List&lt;User&gt;&gt; getUsers();

}
</code></pre>
<h4 id="heading-binding-adapter-and-service">Binding Adapter and Service</h4>
<p>We need to bind our adapter class to the service. For this, create a utils package inside the networking package and create a new class named <strong>NetworkingUtils.</strong></p>
<p>Create a static UserService instance and a method which will return a singleton instance of the userService.</p>
<p>This is how your <strong>NetworkingUtils</strong> would look like at the end:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">NetworkingUtils</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> UserService userService;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> UserService <span class="hljs-title">getUserApiInstance</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">if</span> (userService == <span class="hljs-keyword">null</span>)
            userService = RetrofitAdapter.getInstance().create(UserService.class);

        <span class="hljs-keyword">return</span> userService;
    }

}
</code></pre>
<h4 id="heading-creating-a-utility-class-to-make-api-calls">Creating a Utility class to make API calls</h4>
<p>I’ve seen people do this in the Interactor. Interactor is just another layer in your MVP Architecture — some people prefer to include it, some don’t. In some projects, you’ll find Data Managers instead of an Interactor. It all comes down to your personal requirements/preference, but I personally don’t like using interactors (just like I don’t like JS :P) so I am creating a <strong>UserTask</strong> here.</p>
<p>But just before creating this class, let’s create a custom callback class which we can use to receive errors and results. In the root package, create a package named callback and create an interface named Callback inside this package. It will contain two methods, one for the result and other for error. This is how it’ll look like:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Callback</span>&lt;<span class="hljs-title">T</span>&gt; </span>{
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">void</span> <span class="hljs-title">returnResult</span><span class="hljs-params">(T t)</span></span>;
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">void</span> <span class="hljs-title">returnError</span><span class="hljs-params">(String message)</span></span>;
}
</code></pre>
<p>In the root package, create a package named <strong>utils</strong>. Inside this package create a java class named UserTask. This class will be responsible to make API calls and return the result to the presenter which will show the result or the error depending upon what we get.</p>
<p>If you aren’t familiar with RxJava, I strongly recommend having a look here: <a target="_blank" href="https://ayusch.com/understanding-rxjava-basics/">Understanding RxJava Basics</a>.</p>
<p>I’ve explained all about how observeOn and subscribeOn work and what are their roles. Once you’ve gone through it, you’re good to go.</p>
<p>In our <strong>onNext</strong> method, we’ll return the result, and in onError, we’ll return the error.</p>
<p>This is how UserTask.java class looks like at the end:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UserTask</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">getUsers</span><span class="hljs-params">(<span class="hljs-keyword">final</span> Callback&lt;List&lt;User&gt;&gt; callback)</span> </span>{
        NetworkingUtils.getUserApiInstance()

                .getUsers()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(<span class="hljs-keyword">new</span> Observer&lt;List&lt;User&gt;&gt;() {
                    <span class="hljs-meta">@Override</span>
                    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onSubscribe</span><span class="hljs-params">(Disposable d)</span> </span>{

                    }

                    <span class="hljs-meta">@Override</span>
                    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onNext</span><span class="hljs-params">(List&lt;User&gt; users)</span> </span>{
                        callback.returnResult(users);
                    }

                    <span class="hljs-meta">@Override</span>
                    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onError</span><span class="hljs-params">(Throwable e)</span> </span>{
                        callback.returnError(e.getMessage());
                    }

                    <span class="hljs-meta">@Override</span>
                    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onComplete</span><span class="hljs-params">()</span> </span>{

                    }
                });
    }

}
</code></pre>
<h3 id="heading-finishing-up">Finishing Up</h3>
<p>With the major part of the work already done, we’re now left with passing the result from presenter to the view and setting the adapter for RecyclerView.</p>
<p>To do this, head over to <strong>UserPresenter.java</strong> class and in the loadUsers method, call <strong>UserTask.getUser()</strong> and provide a callback which returns the result or error.</p>
<p>In the returnResult method, we’ll call <strong>mView.loadDataInList()</strong> method passing a list of users successfully obtained. In the returnError method, we’ll call the <strong>mView.showError()</strong> method which’ll display errors if any. With this, our presenter class is complete, here’s how it looks like at the end:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UserPresenter</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">UserContract</span>.<span class="hljs-title">Presenter</span> </span>{
    UserContract.View mView;

    UserPresenter(UserContract.View mView) {
        <span class="hljs-keyword">this</span>.mView = mView;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">loadUsers</span><span class="hljs-params">()</span> </span>{
        UserTask.getUsers(<span class="hljs-keyword">new</span> Callback&lt;List&lt;User&gt;&gt;() {
            <span class="hljs-meta">@Override</span>
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">returnResult</span><span class="hljs-params">(List&lt;User&gt; users)</span> </span>{
                mView.loadDataInList(users);
            }

            <span class="hljs-meta">@Override</span>
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">returnError</span><span class="hljs-params">(String message)</span> </span>{
                mView.showError(message);
            }
        });
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">start</span><span class="hljs-params">()</span> </span>{
        mView.init();
    }

}
</code></pre>
<p>In <strong>UserActivity.java</strong>, inside the loadDataInList method, instantiate our customAdapter and set it to recyclerview, and in showError method, just display a toast message. This is how our UserActivity.java looks like at the end:</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UserActivity</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">AppCompatActivity</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">UserContract</span>.<span class="hljs-title">View</span> </span>{

    <span class="hljs-keyword">private</span> UserContract.Presenter mPresenter;
    <span class="hljs-keyword">private</span> RecyclerView recyclerview;
    CustomAdapter adapter;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onCreate</span><span class="hljs-params">(Bundle savedInstanceState)</span> </span>{
        <span class="hljs-keyword">super</span>.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mPresenter = <span class="hljs-keyword">new</span> UserPresenter(<span class="hljs-keyword">this</span>);
        mPresenter.start();
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span> </span>{
        recyclerview = findViewById(R.id.recyclerview);
        RecyclerView.LayoutManager manager = <span class="hljs-keyword">new</span> LinearLayoutManager(<span class="hljs-keyword">this</span>);
        recyclerview.setLayoutManager(manager);
        mPresenter.loadUsers();
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">loadDataInList</span><span class="hljs-params">(List&lt;User&gt; users)</span> </span>{
        adapter = <span class="hljs-keyword">new</span> CustomAdapter(users);
        recyclerview.setAdapter(adapter);
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">showError</span><span class="hljs-params">(String message)</span> </span>{
        Toast.makeText(<span class="hljs-keyword">this</span>,message,Toast.LENGTH_LONG).show();
    }

}
</code></pre>
<h3 id="heading-conclusion">Conclusion</h3>
<p>This is how you can set up your android application to use Retrofit, RxJava and MVP Architecture in tandem with each other. Let me know if you have any suggestions, in the comments section below or shoot me an email and I’ll respond asap ?</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/P0ZFbZwgADBFSwaND5ByjyNAUh38E6qBRuLP" alt="Image" width="800" height="308" loading="lazy"></p>
<p><em>Like what you read? Don’t forget to share this post on <a target="_blank" href="https://www.facebook.com/AndroidVille"><strong>Facebook</strong></a>, <strong>Whatsapp</strong>, and <strong>LinkedIn</strong>.</em></p>
<p><em>You can follow me on <a target="_blank" href="https://www.linkedin.com/in/ayuschjain">LinkedIn</a>, <a target="_blank" href="https://www.quora.com/profile/Ayusch-Jain">Quora</a>, <a target="_blank" href="https://twitter.com/ayuschjain">Twitter</a>, and <a target="_blank" href="https://www.instagram.com/androidville/">Instagram</a> where I <strong>answer</strong> questions related to <strong>Mobile Development, especially Android and Flutter</strong>.</em></p>
<p><strong><em>If you want to stay updated with all the latest articles, subscribe to the weekly newsletter by entering your email address in the form on the top right section of this page.</em></strong></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ RxAndroid and Retrofit 2.0 ]]>
                </title>
                <description>
                    <![CDATA[ By Ahmed Rizwan Ok, so this isn’t new or anything, but I thought let’s just make a simple tutorial with the new Retrofit 2.0. This should give us a starting point. This isn’t a tutorial for RxAndroid. If you don’t know much about RxAndroid, you shoul... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/rxandroid-and-retrofit-2-0-66dc52725fff/</link>
                <guid isPermaLink="false">66c35e34e9895571912a0d06</guid>
                
                    <category>
                        <![CDATA[ android app development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ mobile app development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Retrofit ]]>
                    </category>
                
                    <category>
                        <![CDATA[ rxjava ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 17 Sep 2015 01:20:38 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*OlU3vLjcEhu-oKeGeAdqyA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ahmed Rizwan</p>
<p>Ok, so this isn’t new or anything, but I thought let’s just make a simple tutorial with the new Retrofit 2.0. This should give us a starting point.</p>
<p>This isn’t a tutorial for RxAndroid. If you don’t know much about RxAndroid, you should first check <a target="_blank" href="https://medium.com/@ahmedrizwan/rxandroid-and-kotlin-part-1-f0382dc26ed8">this</a> out.</p>
<p>Let’s get into it then. Here are the things you’ll need before we start:</p>
<ol>
<li><a target="_blank" href="https://github.com/ReactiveX/RxAndroid">RxAndroid</a> and <a target="_blank" href="https://github.com/square/retrofit">Retrofit</a></li>
<li><a target="_blank" href="https://github.com/google/gson">Gson</a> (I’ll be using Gson, you can use other parsers as well)</li>
<li>An Internet connection!</li>
</ol>
<p>So after you’ve added the dependencies, your gradle files should look something like this (ignore the <a target="_blank" href="https://github.com/evant/gradle-retrolambda">Retrolambda</a> plugin, I just added it for code conciseness because… Lambdas! <em>_</em>):</p>
<p>Now you might be wondering, what is Retrofit exactly? Well, Retrofit is an HTTP Client, but it’s type-safe. That means you can transform an HTTP API into a Java Interface. This makes it ridiculously convenient to interact with the API.</p>
<h3 id="heading-the-starting-example">The Starting Example</h3>
<p>In the example, I’m going to use the <a target="_blank" href="http://openweathermap.org">OpenWeather API</a> and I’ll keep it as simple as possible. I’ll just get the <a target="_blank" href="http://openweathermap.org/current">weather forecast for today</a> in three steps.</p>
<h4 id="heading-step-1-generate-java-model-pojo-classes-from-json">Step 1: Generate Java Model (Pojo) classes from JSON</h4>
<p>Here’s the API URL:</p>
<pre><code>http:<span class="hljs-comment">//api.openweathermap.org/data/2.5/weather?q=London</span>
</code></pre><p>And the response returned when you call it is:</p>
<pre><code>{ “coord”: { “lon”: <span class="hljs-number">-0.13</span>, “lat”: <span class="hljs-number">51.51</span> }, “weather”: [ { “id”: <span class="hljs-number">521</span>, “main”: “Rain”, “description”: “shower rain”, “icon”: “<span class="hljs-number">09</span>d” } ], “base”: “cmc stations”, “main”: { “temp”: <span class="hljs-number">289.49</span>, “pressure”: <span class="hljs-number">993</span>, “humidity”: <span class="hljs-number">67</span>, “temp_min”: <span class="hljs-number">285.93</span>, “temp_max”: <span class="hljs-number">291.15</span> }, “wind”: { “speed”: <span class="hljs-number">8.7</span>, “deg”: <span class="hljs-number">210</span>, “gust”: <span class="hljs-number">14.4</span> }, “rain”: { “<span class="hljs-number">1</span>h”: <span class="hljs-number">1.02</span> }, “clouds”: { “all”: <span class="hljs-number">40</span> }, “dt”: <span class="hljs-number">1442242382</span>, “sys”: { “type”: <span class="hljs-number">1</span>, “id”: <span class="hljs-number">5091</span>, “message”: <span class="hljs-number">0.0052</span>, “country”: “GB”, “sunrise”: <span class="hljs-number">1442208848</span>, “sunset”: <span class="hljs-number">1442254609</span> }, “id”: <span class="hljs-number">2643743</span>, “name”: “London”, “cod”: <span class="hljs-number">200</span>}
</code></pre><p>Looks pretty messy, right? Well, don’t worry, just go to this awesome <a target="_blank" href="http://www.jsonschema2pojo.org">website</a> and paste in the JSON. It’ll come out looking like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*pD1QD3UiI0A4M9yidSIaVQ.png" alt="Image" width="800" height="710" loading="lazy"></p>
<p>If the JSON has to many model classes to be generated, the easier thing to do is generate a <strong>Jar</strong> and download it, extract it, and then add the files. Otherwise just click on Preview, and copy-paste the classes you need. Do remove the <strong>@Generated(“org.jsonschema2pojo”)</strong> from each model class, as this annotation isn’t recognized by Android by default.</p>
<p>I downloaded the Jar because there are a lot of classes. And also because I’m lazy. :)</p>
<p>After extracting and adding the classes, now the project tree looks something like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*HCtSwhgbB3ERajLMixmuyQ.png" alt="Image" width="800" height="540" loading="lazy"></p>
<p>So far, so good!</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*8Aok7yzCTbxShebikqfTsw.png" alt="Image" width="800" height="525" loading="lazy">
<em>Just an evil raccoon being evil.</em></p>
<h4 id="heading-step-2-create-retrofit-interface-for-your-api-calls">Step 2: Create Retrofit Interface for your API calls</h4>
<p>For Retrofit, you have to create an interface for the endpoints of your API.</p>
<p>When creating the interface, you should ask yourself: what exactly is the meaning of life? And secondly: what information do I need from the API?</p>
<p>For me, the answer to both questions is WeatherData (the top-most object). Now let’s examine the URL:</p>
<pre><code>http:<span class="hljs-comment">//api.openweathermap.org/data/2.5/weather?q=London</span>
</code></pre><p>There’s a <strong>query</strong> at the very end, so I’ll do this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*MDro75UsBFVQHUVFVgAtEg.png" alt="Image" width="800" height="145" loading="lazy"></p>
<pre><code>Note: <span class="hljs-keyword">in</span> Retrofit <span class="hljs-number">2.0</span>, the endpoint path string should NOT start <span class="hljs-keyword">with</span> “/”
</code></pre><pre><code>@GET(<span class="hljs-string">"/weather?"</span>) --&gt; incorrect@GET(<span class="hljs-string">"weather?"</span>)  --&gt; correct
</code></pre><p>Now as parameter, I’ll send the query value using the @Query annotation.</p>
<p>As you’ll notice, I’m returning the <strong>Observable</strong> of WeatherData. That’s Rx right there!</p>
<h4 id="heading-step-3-create-the-retrofit-adapter-and-weatherservice-instance">Step 3: Create the Retrofit Adapter and WeatherService instance</h4>
<p>Now in our Activity, we have to create a Retrofit adapter using the Base URL, along with some other info. Once built, we can initiate an object of <strong>WeatherService</strong> interface, then call the method.</p>
<p>Take a look at this delicious code:</p>
<p>So the question here is what the hell are those <em>addCallAdapter</em> and <em>addConverterFactory</em> methods doing there?</p>
<p>Well in order for our calls to return type <strong>Observable</strong>, we have to set the call adapter to <strong>RxJavaCallAdapter</strong>.</p>
<p>And addConverFactory is there to tell Retrofit which sort of converter I want it to use for serializing the JSON. I prefer the GSON converter. There are other converters available too.</p>
<p>So, for these two you need to add their dependencies to your gradle:</p>
<pre><code>compile <span class="hljs-string">'com.squareup.retrofit2:adapter-rxjava:2.0.2'</span>compile <span class="hljs-string">'com.squareup.retrofit2:converter-gson:2.0.0'</span>
</code></pre><p>Now run the code, and voila! It’ll log the weather description.</p>
<h3 id="heading-a-different-example">A Different Example</h3>
<p>So yeah… Another example! Because why not? This time, I’ll try out the GitHub API. Again just 3 steps.</p>
<p>First, the API call URL:</p>
<pre><code>https:<span class="hljs-comment">//api.github.com/users/ahmedrizwan</span>
</code></pre><p>and the response:</p>
<pre><code>{    <span class="hljs-string">"login"</span>: <span class="hljs-string">"ahmedrizwan"</span>,    <span class="hljs-string">"id"</span>: <span class="hljs-number">4357275</span>,    <span class="hljs-string">"avatar_url"</span>: <span class="hljs-string">"https://avatars.githubusercontent.com/u/4357275?v=3"</span>,    <span class="hljs-string">"gravatar_id"</span>: <span class="hljs-string">""</span>,    <span class="hljs-string">"url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan"</span>,    <span class="hljs-string">"html_url"</span>: <span class="hljs-string">"https://github.com/ahmedrizwan"</span>,    <span class="hljs-string">"followers_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/followers"</span>,    <span class="hljs-string">"following_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/following{/other_user}"</span>,    <span class="hljs-string">"gists_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/gists{/gist_id}"</span>,    <span class="hljs-string">"starred_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/starred{/owner}{/repo}"</span>,    <span class="hljs-string">"subscriptions_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/subscriptions"</span>,    <span class="hljs-string">"organizations_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/orgs"</span>,    <span class="hljs-string">"repos_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/repos"</span>,    <span class="hljs-string">"events_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/events{/privacy}"</span>,    <span class="hljs-string">"received_events_url"</span>: <span class="hljs-string">"https://api.github.com/users/ahmedrizwan/received_events"</span>,    <span class="hljs-string">"type"</span>: <span class="hljs-string">"User"</span>,    <span class="hljs-string">"site_admin"</span>: <span class="hljs-literal">false</span>,    <span class="hljs-string">"name"</span>: <span class="hljs-string">"ahmed"</span>,    <span class="hljs-string">"company"</span>: <span class="hljs-literal">null</span>,    <span class="hljs-string">"blog"</span>: <span class="hljs-string">"https://medium.com/@ahmedrizwan"</span>,    <span class="hljs-string">"location"</span>: <span class="hljs-literal">null</span>,    <span class="hljs-string">"email"</span>: <span class="hljs-string">"ahmedrizwan@outlook.com"</span>,    <span class="hljs-string">"hireable"</span>: <span class="hljs-literal">true</span>,    <span class="hljs-string">"bio"</span>: <span class="hljs-literal">null</span>,    <span class="hljs-string">"public_repos"</span>: <span class="hljs-number">19</span>,    <span class="hljs-string">"public_gists"</span>: <span class="hljs-number">0</span>,    <span class="hljs-string">"followers"</span>: <span class="hljs-number">25</span>,    <span class="hljs-string">"following"</span>: <span class="hljs-number">16</span>,    <span class="hljs-string">"created_at"</span>: <span class="hljs-string">"2013-05-06T18:32:59Z"</span>,    <span class="hljs-string">"updated_at"</span>: <span class="hljs-string">"2016-07-08T11:29:26Z"</span>}
</code></pre><p>Again, the JSON looks pretty messy.</p>
<h4 id="heading-step-1-generate-the-pojos-plain-old-java-objects"><strong>Step 1: Generate the Pojos (plain old Java objects)</strong></h4>
<p>I copied the response and pasted it <a target="_blank" href="http://www.jsonschema2pojo.org">here</a> (yet again):</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*gHJzvU0FcKSNWe6yTjSvLg.png" alt="Image" width="800" height="633" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*67owad0Zun8o84QOrAWaUA.png" alt="Image" width="800" height="597" loading="lazy"></p>
<p>And clicked on Preview.</p>
<p>Then I copied the Github class into my Project. <em>music intensifies</em></p>
<h4 id="heading-step-2-create-interface-for-endpoints"><strong>Step 2: Create Interface for Endpoints</strong></h4>
<p>Now examine the API URL. And I mean, really examine it. You’ll see the endpoint starts from users and ends with the username.</p>
<pre><code>https:<span class="hljs-comment">//api.github.com/users/ahmedrizwan</span>
</code></pre><p>So the interface I created looks like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*jabUA4iGndv51G0d7Pi_9A.png" alt="Image" width="800" height="144" loading="lazy"></p>
<p>I created a call method, and used <strong>@Path</strong> annotation to replace the value of <em>{username}</em> in the EndPoint string dynamically.</p>
<h4 id="heading-step-3-create-adapter-and-instance-of-githubservice"><strong>Step 3: Create adapter and instance of GithubService</strong></h4>
<p>Here’s the beautiful code for doing just that:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*gEbFR7b6wmJWNJg1sSe9sA.png" alt="Image" width="800" height="285" loading="lazy"></p>
<p>You’ll notice I’m mapping the user object to String (you can do that with Rx. So Its output becomes:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*hoXm3j3xqKF9HbEBWK73kQ.png" alt="Image" width="800" height="63" loading="lazy"></p>
<p>So this is it. Although the article doesn’t cover everything Retrofit and RxAndroid can do (of course), I hope it will get you off to a good start.</p>
<p>Happy coding!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
