<?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" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arman Chatikyan on Medium]]></title>
        <description><![CDATA[Stories by Arman Chatikyan on Medium]]></description>
        <link>https://medium.com/@chatikyan?source=rss-22e5327e174------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RfVnfyGDeyNdA04isYCaag.jpeg</url>
            <title>Stories by Arman Chatikyan on Medium</title>
            <link>https://medium.com/@chatikyan?source=rss-22e5327e174------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 07:51:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chatikyan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Remote Compose: Back to the Future]]></title>
            <link>https://medium.com/@chatikyan/remote-compose-back-to-the-future-454b8e824fad?source=rss-22e5327e174------2</link>
            <guid isPermaLink="false">https://medium.com/p/454b8e824fad</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[remote-compose]]></category>
            <category><![CDATA[server-driven-ui]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Arman Chatikyan]]></dc:creator>
            <pubDate>Mon, 09 Mar 2026 11:27:25 GMT</pubDate>
            <atom:updated>2026-03-09T15:35:40.651Z</atom:updated>
            <content:encoded><![CDATA[<p><em>”Roads? Where we’re going, we don’t need roads.”</em></p><p>And apparently, where we’re going, we don’t need app updates to change the UI either. Let’s go back to the future and see what Remote Compose has to offer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YM-C0y6Tntd3Q4xaw5hyzg.png" /></figure><h3><strong>What is Remote Compose?</strong></h3><p>AndroidX just quietly dropped something interesting. <a href="https://developer.android.com/jetpack/androidx/releases/compose-remote"><strong>Remote Compose</strong></a> is a framework that lets you define UI on a server and render it natively on Android.</p><p>The core idea: you build a UI document on one side (server/backend), and an Android device just plays it. No WebViews, no JSON schema mapping, no cross-platform compromises.</p><p>If you’ve worked with server-driven UI before, custom JSON-to-View mappers, the Airbnb approach, or the dreaded WebView path, you know the trade-offs. JSON schemas can’t express complex animations. WebViews kill performance. Custom DSLs become maintenance nightmares.</p><p>Remote Compose takes a different approach. Instead of describing <strong><em>what</em></strong> to render, it captures the actual <strong><em>drawing operations</em></strong>. The result is a compact binary document that can be transmitted and played natively.</p><p><em>Think of it as sending a DeLorean through time, except instead of a person, you’re sending an entire UI</em></p><h3><strong>The Flux Capacitor ⚡</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*9VWG8Xbw3Kb6Xzcc5Im8bQ.png" /></figure><p>So how does this time machine work? The architecture splits into two sides.</p><p><strong>Creation</strong> — the server, your “1985”. You write Compose-like code on a plain JVM. <strong>RemoteComposeWriter</strong> captures everything, columns, rows, text, modifiers, click handlers, into a binary format (.rc file).</p><p><strong>Playback</strong> — the Android app, your “future”. The app downloads the bytes and feeds them to <strong>RemoteComposePlayer</strong>. That’s it. The player renders everything natively.</p><p>The client doesn’t need to know what a “button” is. It just executes drawing operations.</p><h3><strong>“Great Scott!”— Building a Document</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tyH8JUDfl7WJ9VcZsl8quQ.png" /></figure><p>Let’s build a simple button. This runs on a <strong>plain JVM, </strong>no Android SDK required. You need remote-creation-core and <strong>remote-creation-jvm</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5fd248f2116cd9b9f38052a349745de/href">https://medium.com/media/c5fd248f2116cd9b9f38052a349745de/href</a></iframe><p>That <strong>writer.encodeToByteArray()</strong> gives you a ByteArray, your entire UI, ready to transmit.</p><p><strong>Playing It on Android</strong></p><p>The Android side is beautifully simple. The official docs don’t have a complete rendering example yet (it’s alpha), but here’s all you need</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dda474e10b9c36c237ba2055cd258484/href">https://medium.com/media/dda474e10b9c36c237ba2055cd258484/href</a></iframe><p>Download bytes, call <strong>setDocument()</strong>, handle click actions. The player takes care of layout, drawing, touch handling, scrolling — everything.</p><h3><strong>88 Miles Per Hour 🚗</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XGc5sJPIc0SEMUuBtjancA.png" /></figure><p>I wanted to push this further. What if you could design the UI visually and see it on the device, without writing any code at all?</p><p>So I built a web editor.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_cuuJEYnlWY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_cuuJEYnlWY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_cuuJEYnlWY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b026bff2f9be8f6aaddc0e4bb960c17/href">https://medium.com/media/7b026bff2f9be8f6aaddc0e4bb960c17/href</a></iframe><p>The pipeline:</p><p>1. <strong>Drag and drop</strong> UI elements in the browser<br>2. <strong>Click Deploy, </strong>pushes layout as JSON to GitHub<br>3. <strong>GitHub Action</strong> converts JSON → binary .rc document using <strong>RemoteComposeWriter<br></strong>4. <strong>Android app</strong> downloads the .rc and renders it</p><p>The preview in the web editor is powered by Compose for Web (Kotlin/Wasm), so what you see in the browser closely matches the device.</p><p>The entire creation pipeline is server-side. No Android SDK involved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2IquUSFmhQHVd5NTquZ1A.png" /></figure><p>At the time of writing, Remote Compose is at 1.0.0-alpha05. It’s early. APIs will change. But the foundation is solid. And with Google I/O around the corner, I wouldn’t be surprised to see Remote Compose get more attention.</p><p><strong>And that’s it for today</strong></p><p>Remote Compose gives us a new way to think about Android UI. I have more ideas to explore with this, stay tuned and clap if you like the article.</p><p>You can find me on X — <a href="https://x.com/ArmanChatikyan">https://x.com/ArmanChatikyan</a> <br>Linkedin — <a href="https://www.linkedin.com/in/chatikyan">https://www.linkedin.com/in/chatikyan</a></p><p>Thanks for reading this article. I hope you enjoyed it.</p><p><strong>Resources:</strong></p><p><strong>Remote Compose </strong>— <a href="https://developer.android.com/jetpack/androidx/releases/compose-remote">https://developer.android.com/jetpack/androidx/releases/compose-remote</a><br><strong>Web Editor</strong>— <a href="https://armcha.github.io/remotecompose/">https://armcha.github.io/remotecompose/</a><br><strong>Converter</strong> — <a href="https://github.com/armcha/remotecompose">https://github.com/armcha/remotecompose</a><br><strong>Android Player </strong>— <a href="https://github.com/armcha/remotecompose-android">https://github.com/armcha/remotecompose-android</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=454b8e824fad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jetpack-Glance: No way to custom fonts ]]></title>
            <link>https://proandroiddev.com/jetpack-glance-no-way-to-custom-fonts-e761b789567d?source=rss-22e5327e174------2</link>
            <guid isPermaLink="false">https://medium.com/p/e761b789567d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[glance]]></category>
            <category><![CDATA[widget]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[custom-fonts]]></category>
            <dc:creator><![CDATA[Arman Chatikyan]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 09:58:56 GMT</pubDate>
            <atom:updated>2023-11-12T04:53:25.520Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OfyHPkuXltET7VFHEc6Cow.jpeg" /></figure><p>In this publication, I’m addressing the challenges faced when creating a widget that requires custom fonts.</p><p>Let’s begin by introducing the results of what we will get. The idea is to show the upcoming events in a list, which are using custom fonts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*linzaQaMw-OjvfFqmvhUGA.gif" /></figure><p>And the empty state, which should show “Nothing” text, using the <a href="https://www.behance.net/gallery/59558741/TUESDAY-NIGHT-FREE-SIGNATURE-FONT">Tuesday Night Font</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*mvshv60gQWwZkVci2NivnA.jpeg" /></figure><h3>The bad guy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HWPJvyfnR_StpGkcJkqoHg.jpeg" /></figure><p>After reading the Glance documentation, I discovered that it allows font customization, but it’s limited to a few fonts and font families existing in the system. The <a href="https://developer.android.com/reference/kotlin/androidx/glance/text/FontFamily">documentation</a> says.</p><blockquote>Defaults are provided, but it is also possible to supply a custom family. If this is found on the system it will be used, otherwise it will fallback to a system default.</blockquote><p>Can I provide a custom font? It has a simple answer, no, limitations with widgets prevent Glance from displaying custom fonts. There are only a few built-in fonts which we can use.</p><h3>The solution</h3><p>In this example, I’m using the <a href="https://developer.android.com/jetpack/androidx/releases/glance#version_100_3">version 1.0.0</a>. <br>Basically, if the system does not provide a built-in UI or widget, we can draw it with <strong>Canvas</strong> and fortunately, this helps me to draw a custom font with <strong>Canvas</strong>. Let’s move forward to see how it actually happens.<br>At first, we should create a simple widget.</p><p>With the first step, you should declare the receiver inside the <strong>AndroidManifest</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/014cc3ba3a6f4cdcb50721cd74565191/href">https://medium.com/media/014cc3ba3a6f4cdcb50721cd74565191/href</a></iframe><p>Next, we need to add information to the widget by creating a straightforward XML file inside the res/xml folder and naming it event_widget_info.xml. This XML file should include specific parameters that we need to define for the widget.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d11f9c87a56683b34dbe1f1a38e41951/href">https://medium.com/media/d11f9c87a56683b34dbe1f1a38e41951/href</a></iframe><p>After we are done with the <strong>XML</strong>, let&#39;s move forward to the code part. <br>At first, we need to create a <strong>GlanceAppWidgetReceiver</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/371cbdf49f743f3728caf996be3f2d9f/href">https://medium.com/media/371cbdf49f743f3728caf996be3f2d9f/href</a></iframe><p>Then actually the <strong>EventsWidget</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef42db67fd9cfee0d4c9904de659eb77/href">https://medium.com/media/ef42db67fd9cfee0d4c9904de659eb77/href</a></iframe><p>After this, you will see a simple widget with simple text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Dik6n3ZbLw35OqqCMMWvWQ.jpeg" /></figure><p>Let&#39;s dig deeper to understand how we can actually apply the custom fonts for the widget.<br>For that purpose, I have created a <strong>GlanceText</strong>, which we can use in this simple way.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/692ddff37a4c82ba8a7c236e71c0efb0/href">https://medium.com/media/692ddff37a4c82ba8a7c236e71c0efb0/href</a></iframe><p>Here is the result using the <strong>GlanceText</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*f6jkvjBnKIN30gBWSKntbw.jpeg" /></figure><h3>Old friends are coming to help</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6TgmuJZunSeyzRm70WHTTA.png" /></figure><p>How actually <strong>GlanceText</strong> works under the hood, it uses <strong>Canvas</strong> to overcome custom font limitations in Jetpack Glance, at first I’m creating a <strong>TextPaint</strong> and then giving it the custom font and then actually drawing it with the paint. Here is the whole code, which makes it happen. Basically, you can control <strong>letterSpacing</strong>, <strong>textColor</strong>, <strong>fontSize</strong> and any other properties, which <strong>TextPaint</strong> can handle.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8dccf08c360a63d574202383b611f3e2/href">https://medium.com/media/8dccf08c360a63d574202383b611f3e2/href</a></iframe><p>And the code of the <strong>GlanceText</strong> which uses an <strong>Image</strong> under the hood.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94a9a48beb22bbe98d77ca5be4324731/href">https://medium.com/media/94a9a48beb22bbe98d77ca5be4324731/href</a></iframe><p>Basically, here you can draw anything with the canvas.</p><p>In our next article, I will try to share my experiments of creating an animation inside the widget. And in the end, I want to share one more example, where I used the <strong>GlanceText</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*gi9Hzpssnjqmbt8A-P3QZw.jpeg" /></figure><p>You can find the full code of this example in my Github <a href="https://github.com/armcha/EventsWidget"><strong>repository</strong></a><strong>.</strong></p><h3>And that’s it for today 🤩</h3><p>Jetpack Glance gives us a new way to reimagine the Widgets. I have some ideas which will be covered in upcoming articles, stay tuned and clap if you like the article.</p><p>You can find me on X <a href="https://twitter.com/ArmanChatikyan"><strong>@chatikyan</strong></a><strong> <br>Thanks for reading this article. I hope you enjoyed it.</strong></p><h3>THE END</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e761b789567d" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/jetpack-glance-no-way-to-custom-fonts-e761b789567d">Jetpack-Glance: No way to custom fonts 🕸</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Motion Knight]]></title>
            <link>https://proandroiddev.com/the-motion-knight-b8f84052dd17?source=rss-22e5327e174------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8f84052dd17</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[motionlayout]]></category>
            <dc:creator><![CDATA[Arman Chatikyan]]></dc:creator>
            <pubDate>Thu, 13 Sep 2018 13:19:28 GMT</pubDate>
            <atom:updated>2018-09-13T16:39:11.169Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8NoHtY8BSpE_SgDNRK5Qhw.png" /></figure><p>When Youtube for android introduced a new design, nearly 2 months ago, the animations were amazing, and I was thinking to create something like this, but as you know, every developer has main projects, which could not be delayed 😩.</p><p>And while I was busy with my main project, Android team introduced <a href="https://developer.android.com/reference/android/support/constraint/motion/MotionLayout"><strong>MotionLayout </strong></a>in Google IO, so I decided to create the animation like Youtube android app with <strong>MotionLayout</strong>.</p><p>You can <a href="https://github.com/armcha/MotionLayout_youtube_animation"><strong>clone</strong></a><strong> </strong>the project while you are reading not to waste time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*fQruawrBZFC-KNH6DOEcIQ.gif" /></figure><p>What is <strong>MotionLayout</strong>?</p><p><strong>MotionLayout</strong> is a new class available in the <strong>ConstraintLayout</strong> <strong>2.0</strong> library to help Android developers manage motion and widget animation in their applications.</p><p>The <strong>MotionLayout</strong> widget can do everything the <strong>ConstraintLayout</strong> widget can.</p><p>Now let’s begin real implementation.</p><h3>Step 1</h3><p>First, we need to add <strong>ConstraintLayout 2</strong> dependencies to our build gradle.</p><blockquote>implementation <strong>‘androidx.constraintlayout:constraintlayout:2.0.0-alpha2’</strong></blockquote><p>Then let’s create regular activity with the container inside to add <strong>VideoFragment</strong> later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93922757b7db6273749f867d691f5095/href">https://medium.com/media/93922757b7db6273749f867d691f5095/href</a></iframe><h4>Step 2</h4><p>For the second step, let&#39;s create our <strong>VideoFragment</strong> and open it inside <strong>MainActivity</strong> onCreate method.</p><p>The <strong>VideoFragment</strong> layout will be something like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c4660122936c5a42f94a56c53699b86/href">https://medium.com/media/4c4660122936c5a42f94a56c53699b86/href</a></iframe><p>For <strong>MotionLayout</strong> to apply its animations we need to keep its description in the separate file.</p><p>A motion scene is an XML file that contains description about the animation we want to create with a <strong>MotionLayout</strong>.</p><p>We will keep it in the separate file. For <strong>VideoFragment</strong> let&#39;s create <strong><em>youtube_scene.xml</em></strong> scene description.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69e7a851e87431b7733f00b15cbe86b4/href">https://medium.com/media/69e7a851e87431b7733f00b15cbe86b4/href</a></iframe><p>With <strong>ConstraintSet </strong>we describe our layout opened state scene and with collapsed <strong>ConstraintSet</strong>-closed state scene. The <strong>MotionLayout</strong> will make smooth transition from opened state to closed and vice verse.</p><p>With <strong>OnSwipe</strong> tag we specify that motion layout will also change the scene by swipe. This also could be performed by click with <strong>OnClick </strong>tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*kEFC-aDbJE4qbgfPFA_EtA.gif" /></figure><h3>Step 3</h3><p>Seems it works as we wished. Now let&#39;s add <strong>BottomNavigation</strong> and also create motion screen for <strong>MainActivity</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/529d2dfe1d74631826972547f7f91a1e/href">https://medium.com/media/529d2dfe1d74631826972547f7f91a1e/href</a></iframe><p>Bellow is the motion scene of <strong>MainActivity</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11552401b3ddc177ced0eba9a72ad5cc/href">https://medium.com/media/11552401b3ddc177ced0eba9a72ad5cc/href</a></iframe><p><strong>KeyAttribute</strong> lets us specify widget attributes changes at a given point in time during the animation. In our example, <strong>BottomNavigation</strong> will make <strong>transitionY</strong> from the start and will end when our animation will reach its 75 percent.</p><p>This motion scene will allow us to hide or show the <strong>BottomNavigation</strong>, while our video view is moving. As you noticed we did not add <strong>OnSwipe</strong> tag to <strong><em>main_scene.xml</em></strong> and its motion layout will not react to user’s swipe gesture. If we add <strong>OnSwipe</strong> tag to our main scene transition, it will conflict with the video scene.</p><p><strong>MotionScene</strong> also has a progress field we can specify the transition progress from 0 to 1.</p><p>So we will send the progress from <strong>VideoFragment MotionLayout </strong>to<strong> MainActivity MotionLayout</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de54cbf585e325d0ca04bd1510445e38/href">https://medium.com/media/de54cbf585e325d0ca04bd1510445e38/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*0TMIuSm2SuqfMKmd2anK-A.gif" /></figure><p>Looks amazing!</p><h3>Step 4</h3><p>However, we have a problem here 🤔: <strong>MotionLayout</strong> covers the whole screen and handles all touches by default, but when the <strong>MotionLayout</strong> content is collapsed, we want it to react to only <strong>videoViewContainer</strong> touches and not to the whole content. For that, I created <strong>SingleViewTouchableMotionLayout</strong> to handle only the touches of our <strong>videoViewContainer</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bac9086d885e32d267eb3595f5a6bfe2/href">https://medium.com/media/bac9086d885e32d267eb3595f5a6bfe2/href</a></iframe><p>That <strong>TODO</strong> is still actual 😄</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*rz2dMs0Fb7TUE0lqw1eRgQ.gif" /></figure><p>Now our <strong>MotionLayout</strong> will handle touches only from <strong>videoViewContainer </strong>and definitely more like Youtube animation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*2zNyEJWQKVAKfp28Pi10SA.png" /></figure><blockquote>-How about a magic trick?</blockquote><blockquote>-I’m gonna make this pencil disappear.</blockquote><blockquote>-Ta-daa! It’s… it’s gone.</blockquote><p>Of course, there are still many details which we did not cover in this article, but I think I could give the main idea how it is easy and interesting to make various animations and transitions using motion layout.</p><p>As a bonus I created also one more example with <strong>MotionLayout</strong>, you can find the code for this example <a href="https://github.com/armcha/MotionLayout_example"><strong>here</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*DYuIMA3NhHcbU-IWnMJZbg.gif" /></figure><p>Although <strong>MotionLayout</strong> is an early release and there are still some bugs and some limitations like not supporting nested views, it is a very amazing view with great potential. 😍 😍</p><p>I am also planning to write about <strong>KeyFrameSet,</strong> <strong>KeyAttribute,</strong> <strong>KeyCycle, and CustomAttribute </strong>in my next article and hope that this article will interest you.</p><p>I also recommend you to read an <a href="https://medium.com/google-developers/introduction-to-motionlayout-part-i-29208674b10d">article series</a> from<strong> Nicolas Roard</strong>. <strong>📖</strong></p><blockquote>Big thanks to <strong>John Hoford</strong> and <strong>Nicolas Roard</strong>! <em>👏 👏</em></blockquote><p>You can find me on twitter <a href="https://twitter.com/ArmanChatikyan"><strong>@chatikyan</strong></a><strong> 📑</strong></p><p><strong>Thanks for reading this article. Hope you enjoyed it. You can find the full code </strong><a href="https://github.com/armcha/MotionLayout_youtube_animation"><strong>here</strong></a><strong>.</strong></p><h4>THE END</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8f84052dd17" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/the-motion-knight-b8f84052dd17">The Motion Knight</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RecyclerView plusAssign Kotlin power]]></title>
            <link>https://medium.com/hackernoon/recyclerview-plus-assign-kotlin-power-6f93ce980154?source=rss-22e5327e174------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f93ce980154</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Arman Chatikyan]]></dc:creator>
            <pubDate>Thu, 14 Dec 2017 12:31:52 GMT</pubDate>
            <atom:updated>2019-04-29T11:18:33.630Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mU-dHEyAcrcOz-kHU0YFLQ.png" /></figure><p>It is common to create lists with recyclerview in almost every project, which take us to create Adapter and ViewHolder for every list. In some cases we go through this process too many times, when there are many lists in our app.</p><p>In this article we use Kotlin features to create simple lists in easier and faster way .</p><p>Let’s begin with introducing the results of what we will get.</p><pre>recyclerView.<strong><em>setUp</em></strong>(users, R.layout.<em>item_layout</em>, <strong>{<br>    </strong>nameText.<em>text </em>= <strong>it</strong>.<strong>name<br>    </strong>surNameText.<em>text </em>= <strong>it</strong>.<strong>surname<br>}</strong>)</pre><p><strong><em>Of course for this magic we also need kotlin android extensions.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*P5As6a6ouzrmKNiTNQ3Szg.png" /></figure><h4>Step 1</h4><p>Let’s create an AbstractAdapter in a generic way</p><p>We need to pass to the constructor the actual list of items and layout res id</p><pre><strong><br>abstract class </strong>AbstractAdapter&lt;ITEM&gt; <strong>constructor</strong>(<br>        <strong>protected var itemList</strong>: List&lt;ITEM&gt;,<br>        <strong>private val layoutResId</strong>: Int)<br>    : RecyclerView.Adapter&lt;AbstractAdapter.Holder&gt;() {<br><br>    <strong>class </strong>Holder(itemView: View) : RecyclerView.ViewHolder(itemView)<br>}</pre><p>Also, we need to create our view holder extending from base ViewHolder and implement our adapter’s onBindViewHolder and onCreateViewHolder as we always do when creating recyclerview.</p><pre><strong>override fun </strong>getItemCount() = <strong>itemList</strong>.<strong>size<br><br>override fun </strong>onCreateViewHolder(parent: ViewGroup,<br>                                viewType: Int): Holder {<br>    <strong>val </strong>view = parent <em>inflate </em><strong>layoutResId<br>    return </strong>Holder(view)<br>}<br><br><strong>override fun </strong>onBindViewHolder(holder: Holder, position: Int) {<br>    <strong>val </strong>item = <strong>itemList</strong>[position]<br>    holder.<strong>itemView</strong>.<em>bind</em>(item)<br>}<br><br><strong>protected open fun </strong>View.bind(item: ITEM) {<br>}<br><br><strong>class </strong>Holder(itemView: View) : RecyclerView.ViewHolder(itemView)</pre><p>And we also need to create adapter extending from our abstract adapter, don’t panic, it’s shorter, let’s name it Kadapter.</p><pre><strong>class </strong>Kadapter&lt;ITEM&gt;(items: List&lt;ITEM&gt;,<br>                     layoutResId: Int,<br>                     <strong>private val bindHolder</strong>: View.(ITEM) -&gt; Unit)<br>    : AbstractAdapter&lt;ITEM&gt;(items, layoutResId) {<br><br>    <strong>override fun </strong>onBindViewHolder(holder: Holder, position: Int) {<br>        holder.<strong>itemView</strong>.<strong>bindHolder</strong>(<strong>itemList</strong>[position])<br>    }<br>}</pre><h4>Step 2</h4><p>Let’s see how our advanced Adapter is going to be used:</p><pre><strong>val </strong>adapter = Kadapter(users, R.layout.<em>item_layout</em>) <strong>{<br>    </strong>nameText.<em>text </em>= <strong>it</strong>.<strong>name<br>    </strong>surNameText.<em>text </em>= <strong>it</strong>.<strong>surname<br>}<br></strong>recyclerView.<em>adapter </em>= adapter<br>recyclerView.<em>layoutManager </em>= LinearLayoutManager(<strong>this</strong>)</pre><p>We can just use it in this way, or go deeper. For that let’s move forward and add more stuff.</p><h4>Superhero landing! He’s going to do a superhero landing!</h4><p>Let’s create an extension to recycler view.</p><pre><strong>fun </strong>&lt;ITEM&gt; RecyclerView.setUp(items: List&lt;ITEM&gt;,<br>                              layoutResId: Int,<br>                              bindHolder: View.(ITEM) -&gt; Unit,<br>                              manager: RecyclerView.LayoutManager = LinearLayoutManager(<strong>this</strong>.<em>context</em>)): Kadapter&lt;ITEM&gt; {<br><br>    <strong>return </strong>Kadapter(items, layoutResId, <strong>{<br>        </strong>bindHolder(<strong>it</strong>)<br>    <strong>}</strong>).<em>apply </em><strong>{<br>        </strong><em>layoutManager </em>= manager<br>        <em>adapter </em>= <strong>this<br>    }<br></strong>}</pre><p>It will encapsulate adapter and layout manager, also we can change layout manager default implementation.</p><h4>Step 3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ZC7ZU-zUzWIXDMqIcwzdA.png" /></figure><p>Everything was fine so far, but if we try to click the item in the list, nothing will happen. We need to take care about that. Let’s implement onClickListener.</p><p>For that we need to add click logic in our abstract adapter. Our onCreateViewHolder becomes this.</p><pre><strong>override fun </strong>onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {<br>    <strong>val </strong>view = parent <em>inflate </em><strong>layoutResId<br>    val </strong>viewHolder = Holder(view)<br>    <strong>val </strong>itemView = viewHolder.<strong>itemView<br>    </strong>itemView.setOnClickListener <strong>{<br>        val </strong>adapterPosition = viewHolder.<em>adapterPosition<br>        </em><strong>if </strong>(adapterPosition != RecyclerView.<em>NO_POSITION</em>) {<br>            <strong>onItemClick</strong>(itemView, adapterPosition)<br>        }<br>    <strong>}<br>    return </strong>viewHolder<br>}</pre><pre><strong>protected open fun </strong>onItemClick(itemView: View, position: Int) {<br>}</pre><p>We also need to add onClick logic to our adapter implementation and extensions we created before. The final code of kadapter looks like this:</p><pre><strong>class </strong>Kadapter&lt;ITEM&gt;(items: List&lt;ITEM&gt;,<br>                     layoutResId: Int,<br>                     <strong>private val bindHolder</strong>: View.(ITEM) -&gt; Unit)<br>    : AbstractAdapter&lt;ITEM&gt;(items, layoutResId) {<br><br>    <strong>private var itemClick</strong>: ITEM.() -&gt; Unit = <strong>{}<br><br>    constructor</strong>(items: List&lt;ITEM&gt;,<br>                layoutResId: Int,<br>                bindHolder: View.(ITEM) -&gt; Unit,<br>                itemClick: ITEM.() -&gt; Unit = <strong>{}</strong>) : <strong>this</strong>(items, layoutResId, bindHolder) {<br>        <strong>this</strong>.<strong>itemClick </strong>= itemClick<br>    }<br><br>    <strong>override fun </strong>onBindViewHolder(holder: Holder, position: Int) {<br>        holder.<strong>itemView</strong>.<strong>bindHolder</strong>(<strong>itemList</strong>[position])<br>    }<br><br>    <strong>override fun </strong>onItemClick(itemView: View, position: Int) {<br>        <strong>itemList</strong>[position].<strong>itemClick</strong>()<br>    }<br>}</pre><p>And final code for extension</p><pre><strong>fun </strong>&lt;ITEM&gt; RecyclerView.setUp(items: List&lt;ITEM&gt;,<br>                              layoutResId: Int,<br>                              bindHolder: View.(ITEM) -&gt; Unit,<br>                              itemClick: ITEM.() -&gt; Unit = <strong>{}</strong>,<br>                              manager: RecyclerView.LayoutManager = LinearLayoutManager(<strong>this</strong>.<em>context</em>)): Kadapter&lt;ITEM&gt; {<br>    <strong>return </strong>Kadapter(items, layoutResId, <strong>{<br>        </strong>bindHolder(<strong>it</strong>)<br>    <strong>}</strong>, <strong>{<br>        </strong>itemClick()<br>    <strong>}</strong>).<em>apply </em><strong>{<br>        </strong><em>layoutManager </em>= manager<br>        <em>adapter </em>= <strong>this<br>    }<br></strong>}</pre><p>Now let’s see what we achieved.</p><p>We can create adapter without click listener and with click listener.</p><pre>recyclerView.<em>setUp</em>(users, R.layout.<em>item_layout</em>, <strong>{<br>    </strong>nameText.<em>text </em>= <strong>it</strong>.<strong>name<br>    </strong>surNameText.<em>text </em>= <strong>it</strong>.<strong>surname<br>}</strong>)</pre><p>And with click</p><pre>recyclerView.<em>setUp</em>(users, R.layout.<em>item_layout</em>, <strong>{<br>    </strong>nameText.<em>text </em>= <strong>it</strong>.<strong>name<br>    </strong>surNameText.<em>text </em>= <strong>it</strong>.<strong>surname<br>}</strong>, <strong>{<br>    </strong>toast(<strong>&quot;Clicked $name&quot;</strong>)<br><strong>}</strong>)</pre><p>As a bonus we can add base methods to our abstract adapter, such as add, remove, update of course using diffUtils.</p><p>The bottom line of this article is demonstrating some of the powerful features of <a href="https://hackernoon.com/tagged/kotlin">Kotlin</a> + <a href="https://hackernoon.com/tagged/android">Android</a>, which makes the code more flexible. Now you can go further if interested.</p><p><strong>Thanks for reading this article. You can find full code </strong><a href="https://github.com/armcha/Kadapter"><strong>there</strong></a><strong>.</strong></p><p><strong>Let’s become friends on </strong><a href="https://twitter.com/ArmanChatikyan"><strong>Twitter</strong></a><strong>, </strong><a href="https://github.com/armcha/"><strong>Github </strong></a><strong>and </strong><a href="https://web.facebook.com/chatikyana"><strong>Facebook</strong></a><strong>. If you enjoyed the writings then please use the clap below to recommend this article so that others can see it.</strong></p><p><strong>We will also love to hear your comments and suggestions :)</strong></p><p><strong>Thanks.</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f93ce980154" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/recyclerview-plus-assign-kotlin-power-6f93ce980154">RecyclerView plusAssign Kotlin power</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVP + Android Architecture Components = ❤]]></title>
            <link>https://medium.com/hackernoon/mvp-android-architecture-components-aef55e15bfe3?source=rss-22e5327e174------2</link>
            <guid isPermaLink="false">https://medium.com/p/aef55e15bfe3</guid>
            <category><![CDATA[architecture-components]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mvp]]></category>
            <category><![CDATA[viewmodel]]></category>
            <category><![CDATA[lifecycle]]></category>
            <dc:creator><![CDATA[Arman Chatikyan]]></dc:creator>
            <pubDate>Sat, 27 May 2017 17:09:40 GMT</pubDate>
            <atom:updated>2017-08-28T14:22:43.943Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*QPOfsrqKjkdP-d1sqf6WCw.gif" /></figure><p>Few days ago, during Google I/O was presented <a href="https://developer.android.com/topic/libraries/architecture/index.html"><strong>Android Architecture Components</strong></a>. We decided to combine these components with MPV Architecture. So, let’s see what we got in a result.</p><p>One of the common problems working with MPV Architecture is <strong>to keep Presenter’s state </strong>while changing screen orientation. There are some solutions for that (Loaders, retainInstance, Mosby, <a href="https://github.com/Arello-Mobile/Moxy">Moxy</a> and so on).</p><p>One of those Architecture Components presented during the I/O was a <a href="https://developer.android.com/topic/libraries/architecture/viewmodel.html"><strong>ViewModel</strong></a><strong>.</strong></p><p>“<em>The ViewModel class is designed to store and manage UI-related data so that the data survives configuration changes such as screen rotations.</em>” — from official documentation.</p><p>It gives us an opportunity to save the object during screen orientation change.</p><p>The other component is <a href="https://developer.android.com/topic/libraries/architecture/lifecycle.html"><strong>Lifecycle</strong></a><strong>, </strong>which we will use.</p><p>“<em>The android.arch.lifecycle package provides classes and interfaces that let you build lifecycle-aware components — which are components that can automatically adjust their behavior based on the current lifecycle of an activity or fragment.</em>” - from official documentation.</p><p><strong>1. Before orientation change</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*TVxbF08RjwtZHlqEW-ijIg.png" /></figure><p><strong>2. After orientation change</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*8I7cAZwfslXHrV0VMd87sA.png" /></figure><p>From the beginning let’s design our <strong>Presenter</strong> and <strong>View</strong>. Let’s create a <strong>Contract Interface.</strong></p><pre><strong>public interface </strong>BaseContract {<br><br>    <strong>interface </strong>View {<br><br>    }<br><br>    <strong>interface </strong>Presenter&lt;V <strong>extends </strong>BaseContract.View&gt; {<br>        <br>        <strong>void </strong>attachLifecycle(Lifecycle lifecycle);<br><br>        <strong>void </strong>detachLifecycle(Lifecycle lifecycle);<br><br>        <strong>void </strong>attachView(V view);<br><br>        <strong>void </strong>detachView();<br><br>        V getView();<br><br>        <strong>boolean </strong>isViewAttached();<br><br>        <strong>void </strong>onPresenterDestroy();<br>    }<br>}</pre><p>After this, we need to create <strong>Presenter </strong>that implements our <strong>Presenter Contract</strong>.</p><pre><strong>public abstract class </strong>BasePresenter&lt;V <strong>extends </strong>BaseContract.View&gt; <strong>implements </strong>LifecycleObserver, BaseContract.Presenter&lt;V&gt; {<br><br>    <strong>private </strong>V <strong>view</strong>;<br><br>    @Override<br>    <strong>final public </strong>V getView() {<br>        <strong>return view</strong>;<br>    }<br><br>    @Override<br>    <strong>final public void </strong>attachLifecycle(Lifecycle lifecycle) {<br>        lifecycle.addObserver(<strong>this</strong>);<br>    }<br><br>    @Override<br>    <strong>final public void </strong>detachLifecycle(Lifecycle lifecycle) {<br>        lifecycle.removeObserver(<strong>this</strong>);<br>    }<br><br>    @Override<br>    <strong>final public void </strong>attachView(V view) {<br>        <strong>this</strong>.<strong>view </strong>= view;<br>    }<br><br>    @Override<br>    <strong>final public void </strong>detachView() {<br>        <strong>view </strong>= <strong>null</strong>;<br>    }<br><br>    @Override<br>    <strong>final public boolean </strong>isViewAttached() {<br>        <strong>return view </strong>!= <strong>null</strong>;<br>    }<br>}</pre><p>So, we have a <strong>Presenter</strong>, which attaches and detaches the <strong>View</strong> and <strong>Lifecycle Observer</strong>.</p><p>With the next step, let’s create our <strong>Activity</strong>. Here we have a problem: the presenter will be <strong>recreating </strong>every time after the orientation change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*MHRIeHFc78iif3PA8MQXRg.png" /></figure><p>Let’s go ahead.</p><p>The <a href="https://developer.android.com/reference/android/arch/lifecycle/ViewModel.html"><strong>ViewModel</strong></a> is automatically retained during configuration changes so the data it holds is immediately available to the next activity or fragment instance. This will help us not to <strong>initialize </strong>the Presenter every time.</p><p>For that, we will create the <strong>Class</strong>, which extends from <strong>ViewModel</strong>. It will receive and return our presenter’s object. <strong>ViewModel </strong>also has <strong>onCleared()</strong> method. If the activity is re-created, it receives the same <strong>ViewModel </strong>instance that was created by the previous activity. When the owner activity is finished, the Framework calls <a href="https://developer.android.com/reference/android/arch/lifecycle/ViewModel.html"><strong>ViewModel</strong></a><strong>’s </strong><a href="https://developer.android.com/reference/android/arch/lifecycle/ViewModel.html#onCleared()"><strong>onCleared()</strong></a> method so that it can clean up resources.</p><pre><strong>public final class </strong>BaseViewModel&lt;V <strong>extends </strong>BaseContract.View, P <strong>extends </strong>BaseContract.Presenter&lt;V&gt;&gt; <strong>extends </strong>ViewModel {<br><br>    <strong>private </strong>P <strong>presenter</strong>;<br><br>    <strong>void </strong>setPresenter(P presenter) {<br>        <strong>if </strong>(<strong>this</strong>.<strong>presenter </strong>== <strong>null</strong>) {<br>            <strong>this</strong>.<strong>presenter </strong>= presenter;<br>        }<br>    }<br><br>    P getPresenter() {<br>        <strong>return this</strong>.<strong>presenter</strong>;<br>    }<br><br>    @Override<br>    <strong>protected void </strong>onCleared() {<br>        <strong>super</strong>.onCleared();<br>        <strong>presenter</strong>.onPresenterDestroy();<br>        <strong>presenter </strong>= <strong>null</strong>;<br>    }<br>}</pre><p>In our next step we will create the <strong>BaseViewModel </strong>instance inside the Activity.</p><p>Also we must give the <strong>Lifecycle </strong>to the <strong>Presenter</strong>. So we need <strong>LifecycleRegistry. </strong>And the Activity must implement to the <strong>LifecycleRegistryOwner.</strong></p><pre><strong>public abstract class </strong>BaseActivity&lt;V <strong>extends </strong>BaseContract.View, P <strong>extends </strong>BaseContract.Presenter&lt;V&gt;&gt; <strong>extends </strong>AppCompatActivity <strong>implements </strong>BaseContract.View, LifecycleRegistryOwner {<br><br>    <strong>private final </strong>LifecycleRegistry <strong>lifecycleRegistry </strong>= <br>             <strong>new </strong>LifecycleRegistry(<strong>this</strong>);<br>    <strong>protected </strong>P <strong>presenter</strong>;<br><br>    @CallSuper<br>    @Override<br>    <strong>protected void </strong>onCreate(@Nullable Bundle savedInstanceState) {<br>        <strong>super</strong>.onCreate(savedInstanceState);<br>        BaseViewModel&lt;V, P&gt; viewModel = <br>            ViewModelProviders.<em>of</em>(<strong>this</strong>).get(BaseViewModel.<strong>class</strong>);<br>        <strong>if </strong>(viewModel.getPresenter() == <strong>null</strong>) {<br>            viewModel.setPresenter(initPresenter());<br>        }<br>        <strong>presenter </strong>= viewModel.getPresenter();<br>        <strong>presenter</strong>.attachLifecycle(getLifecycle());<br>        <strong>presenter</strong>.attachView((V) <strong>this</strong>);<br>    }<br><br>    @Override<br>    <strong>public </strong>LifecycleRegistry getLifecycle() {<br>        <strong>return lifecycleRegistry</strong>;<br>    }<br><br>    @CallSuper<br>    @Override<br>    <strong>protected void </strong>onDestroy() {<br>        <strong>super</strong>.onDestroy();<br>        <strong>presenter</strong>.detachLifecycle(getLifecycle());<br>        <strong>presenter</strong>.detachView();<br>    }<br><br>    <strong>protected abstract </strong>P initPresenter();<br>}</pre><p>At the first time creating the Activity, we must create a Presenter and give it to the <strong>ViewModel</strong>. The next time when the activity recreates, we just reuse our <strong>Presenter </strong>from the <strong>ViewModel</strong>.</p><p>At the first time creating Presenter, we must attach <strong>Lifecycle </strong>and <strong>View</strong>. For avoiding memory leak, we also need to detach <strong>Lifecycle </strong>and <strong>View </strong>in <strong>onDestroy()</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*ZT77cCGXeQiviyvB_AMIIg.jpeg" /></figure><p>As a bonus, we also have <strong>Activity Lifecycle</strong> <a href="https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.Event.html#ON_ANY">events</a> inside presenter.</p><pre>@OnLifecycleEvent(value = Lifecycle.Event.<strong><em>ON_CREATE</em></strong>)<br><strong>protected void </strong>onCreate() {<br>    <br>}</pre><p>For the complete puzzle, something lacks. It is a state of <strong>Views</strong>.</p><p>For that, we must have <strong>Bundle getStateBundle()</strong> in our <strong>BaseContract</strong>, and <strong>Bundle </strong>stateBundle in the <strong>Presenter</strong>, which will keep and return our <strong>View </strong>state.</p><p>The final Presenters is like that:</p><pre><strong>public abstract class </strong>BasePresenter&lt;V <strong>extends </strong>BaseContract.View&gt; <strong>implements </strong>LifecycleObserver, BaseContract.Presenter&lt;V&gt; {<br><br>    <strong>private </strong>Bundle <strong>stateBundle</strong>;<br>    <strong>private </strong>V <strong>view</strong>;<br><br>    @Override<br>    <strong>final public </strong>V getView() {<br>        <strong>return view</strong>;<br>    }<br><br>    @Override<br>    <strong>final public void </strong>attachLifecycle(Lifecycle lifecycle) {<br>        lifecycle.addObserver(<strong>this</strong>);<br>    }<br><br>    @Override<br>    <strong>final public void </strong>detachLifecycle(Lifecycle lifecycle) {<br>        lifecycle.removeObserver(<strong>this</strong>);<br>    }<br><br>    @Override<br>    <strong>final public void </strong>attachView(V view) {<br>        <strong>this</strong>.<strong>view </strong>= view;<br>    }<br><br>    @Override<br>    <strong>final public void </strong>detachView() {<br>        <strong>view </strong>= <strong>null</strong>;<br>    }<br><br>    @Override<br>    <strong>final public boolean </strong>isViewAttached() {<br>        <strong>return view </strong>!= <strong>null</strong>;<br>    }<br><br>    @Override<br>    <strong>final public </strong>Bundle getStateBundle() {<br>        <strong>return stateBundle </strong>== <strong>null </strong>? <br>                <strong>stateBundle </strong>= <strong>new </strong>Bundle() : <strong>stateBundle</strong>;<br>    }<br><br>    @CallSuper<br>    @Override<br>    <strong>public void </strong>onPresenterDestroy() {<br>        <strong>if </strong>(<strong>stateBundle </strong>!= <strong>null </strong>&amp;&amp; !<strong>stateBundle</strong>.isEmpty()) {<br>            <strong>stateBundle</strong>.clear();<br>        }<br>    }<br>}</pre><p><strong>Thanks for reading this article. You can find full code </strong><a href="https://github.com/armcha/MVP-Architecture-Components"><strong>there</strong></a><strong>.</strong></p><p><strong>Let’s become friends on </strong><a href="https://twitter.com/ArmanChatikyan"><strong>Twitter</strong></a><strong>, </strong><a href="https://github.com/armcha/"><strong>Github </strong></a><strong>and </strong><a href="https://web.facebook.com/chatikyana"><strong>Facebook</strong></a><strong>. If you enjoyed the writings then please use the ❤ heart below to recommend this article so that others can see it.</strong></p><p><strong>We will also love to hear your comments and suggestions :)</strong></p><p><strong>Thanks.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aef55e15bfe3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/mvp-android-architecture-components-aef55e15bfe3">MVP + Android Architecture Components = ❤</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>