<?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 Ozan Topuz on Medium]]></title>
        <description><![CDATA[Stories by Ozan Topuz on Medium]]></description>
        <link>https://medium.com/@ozantopuz?source=rss-fc5b0e8ab553------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8PQs_j1EMYYUzsSZ.</url>
            <title>Stories by Ozan Topuz on Medium</title>
            <link>https://medium.com/@ozantopuz?source=rss-fc5b0e8ab553------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 10:24:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ozantopuz/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[TL;DR Android Programming Tips #1 — Context]]></title>
            <link>https://medium.com/android-news/tl-dr-android-programming-tips-1-context-e6fbf61c2097?source=rss-fc5b0e8ab553------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6fbf61c2097</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[context]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-programming]]></category>
            <dc:creator><![CDATA[Ozan Topuz]]></dc:creator>
            <pubDate>Sun, 08 Dec 2019 18:51:43 GMT</pubDate>
            <atom:updated>2019-12-17T11:11:57.154Z</atom:updated>
            <content:encoded><![CDATA[<h3>TL;DR Android Programming Tips #1 — Context</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQ5ep7M2lP2l7DhNlc5Kaw.png" /></figure><h3>Context</h3><p>It is the context of the current state of the application/object. <br>getApplicationContext() and getActivityContext() are both instances of Context. So when should you use them and what is the best way to use a context? Let’s clarify them with examples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a53f1d06b4aeaed7d8dd2f3991bedc73/href">https://medium.com/media/a53f1d06b4aeaed7d8dd2f3991bedc73/href</a></iframe><p>getActivityContext() which tied to the lifecycle of an Activity. So you should only use getActivityContext() if you need a context whose lifecycle is attached to the current context.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a2591fb84317eb67307484df789f49a/href">https://medium.com/media/3a2591fb84317eb67307484df789f49a/href</a></iframe><p>getApplicationContext() is tied to the lifecycle of an Application. So you should only use getApplicationContext() if you need a context whose lifecycle is separate from the current context.</p><p>If you use getActivityContext() here, it will lead to the memory leak and Activity of the context cannot be garbage collected.</p><p>For example, if you are using Toast, you can use both of them because a toast can be raised from anywhere within your application and is not attached to a window.</p><p>Last but not least, if you are launching a new Activity, you should use getActivityContext() in its Intent so that the new launching activity is connected to the current activity in terms of the Activity stack. However, you should use getApplicationContext(), If you want to set the flag Intent.FLAG_ACTIVITY_NEW_TASK.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6fbf61c2097" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/tl-dr-android-programming-tips-1-context-e6fbf61c2097">TL;DR Android Programming Tips #1 — Context</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Modular Android App Architecture]]></title>
            <link>https://proandroiddev.com/build-a-modular-android-app-architecture-25342d99de82?source=rss-fc5b0e8ab553------2</link>
            <guid isPermaLink="false">https://medium.com/p/25342d99de82</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[modular-architecture]]></category>
            <category><![CDATA[google-io-2019]]></category>
            <dc:creator><![CDATA[Ozan Topuz]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 08:56:34 GMT</pubDate>
            <atom:updated>2019-07-14T17:04:17.731Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is a summary of the “Build a Modular Android App Architecture” presentation from Yigit Boyar and Florina Muntenescu in Google I/O’19.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fAN1TKy33XnXSgjWYQGyyQ.png" /></figure><p>In Google I/0 19, they talked about how to create a modular Android Application architecture. They emphasize the fact that developers should be segregated to specialise in different aspects when developing the application in order to provide a clean and organised application.</p><h3>Faster Compilation</h3><p>If you have a monolithic layouts folder, it’s going to be very hard to look at it and understand what’s going on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yJspeL7VqyaLwEkV66Npww.png" /></figure><p>Instead, If you group those layouts, it will be so much easier. When you’re looking for something, you’ll find it there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n47XfzGRrAya11IASTD4nw.png" /></figure><p>By the way, you have this monolithic application on the left and the modularized application on the right, if you want to change the same file in both of these scenarios, this is how it’s going to invalidate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kbd2Umh4K2QR5nikpiy0ZQ.png" /></figure><h3>Faster CI</h3><p>It is possible to run your continuous integration service faster by having small modules which have bigger modules depending on them. For example, if you need to test module 5; you would only need to run the modules that depend on it. As the other modules are not impacted, there would be no point running any other module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ujp5FfuGSqmrAMik0BzORA.png" /></figure><h3>Good for Business</h3><p>From the Play Store statistics, it has been determined that the number of users drops between the moment they install the app and the moment they can start using the app. To prevent this; you can modularize your application with app bundle in order to reduce the installation size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KXR0XX_CVQBi1qlJqm8beA.png" /></figure><h3>Module</h3><p>The Android App Bundle packaging concept involves the greater library modules as well as the dynamic feature modules. For example, we can have a base app which is dependent on module 1, also known to be the android library. This means the app can reach the code and resources from module 1. Furthermore, we can have other modules i.e. module 2 and module 3 which can be the dynamic feature modules. These can be used for on-demand code loading via dynamic delivery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uQqvhDooP75EbJMrnieYSg.png" /></figure><p>Developers are able to decide the dynamic feature module based on the 80/20 principle that state; “80% of the users are using 20% of the app”. This way it is wise to look into the un-used 80% features that are not part of the core flow of the app. These un-used features can be downloaded and/or uninstalled later which would make the on-demand false, cleaning up more space within the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCf5W_NU_Ui21xxgcuavjA.png" /></figure><h3>Layer Modularization</h3><p>We have two options to modularize our application. One of them is based on features, the other uses a layer modularization. The two options have different advantages. Let me put it this way, feature modularization provides you encapsulation, and also the possibility of on-demand delivery. On the other part, layer modularization provides you isolation, allows you to isolate your third-party dependencies or the layers in your app, and also brings structure to your app. By the way, you can use both together, however, if you have a monolithic application for your app, you should use layer modularization first, as time goes by, add the feature modularization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xh1wecHpsM5io3EL2SzlTA.png" /></figure><h3>Working with Dynamic Feature Modules</h3><p>Working with dynamic feature modules brings a few challenges even if you use on-demand delivery. One of these challenges is with navigation. For example, we have the MainActivity and want to navigate to the AboutActivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50oyHh1E_TLBXN5rNeleIw.png" /></figure><p>Normally, you can navigate something as above but you’ll get the compile error. To overcome this, what you can do is just use Intent.setClassName and pass the component name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6DFjX5XsqqfAfYEq_eXdw.png" /></figure><p>I know this looks a bit strange because it’s hardcoded. And indeed, it means that when you have to refactor your code, you need to make sure that you’re also updating this string.</p><h4>Discovering Dependencies</h4><p>You can skim through the structure that I will tell you through the following images. For example, we have a search activity that is part of the search module, and we want to be able to search for news in Designer News and Dribble. However, Designer News, Dribble and search are three completely different modules, for this reason, we don’t know how to do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o7jWzf1xR5Nd_OfgO6pfhA.png" /></figure><p>We should use the Common Core library that is shared between all of these defining the DataSource interface implemented by the Designer News and Dribble. Thereafter, the search holds a set of these DataSources and knows how to query the data. But things are not that easy because there are a lot of classes that you need to instantiate when you create a module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23KCDSaeILu1PFlRpBqWug.png" /></figure><h4>Databases</h4><p>When you start modularizing your application, you will probably face problems with databases, which you can solve using two different ways. One option is you can just have one database for all of your application, which is what you usually do when you’re in a monolithic application. The other option is creating a core database for the common functionality, and then have separate databases for your features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qQPA5_a6THdKRJzxcyD5yA.png" /></figure><h3>Android Free Modules</h3><p>Android free modules have advantages and disadvantages, the first of the advantages is that you could reuse the modules. We need to implement only a unit test for having Android free modules.</p><p>When you read about the architecture and the theory around architecture and clean architecture, one of the things that you’ll see, one of the guidelines is that you should minimize dependencies to make sure that you’re not depending on classes that you’re not using. This also means that you’re able to do a clear separation of concerns, making sure that your business logic doesn’t depend on any UI classes.</p><p>If you would like to watch the video this topic is about you can find the link below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPZBg5DIzNww%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPZBg5DIzNww&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPZBg5DIzNww%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cd57e1677e7536b23d556ffb0736bab/href">https://medium.com/media/4cd57e1677e7536b23d556ffb0736bab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25342d99de82" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/build-a-modular-android-app-architecture-25342d99de82">Build a Modular Android App Architecture</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[Android UI Programming with RxBinding]]></title>
            <link>https://medium.com/@ozantopuz/android-ui-programming-with-rxbinding-c73ca64167be?source=rss-fc5b0e8ab553------2</link>
            <guid isPermaLink="false">https://medium.com/p/c73ca64167be</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[rxandroid]]></category>
            <category><![CDATA[rxkotlin]]></category>
            <category><![CDATA[rxbindings]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Ozan Topuz]]></dc:creator>
            <pubDate>Sat, 13 Oct 2018 12:28:59 GMT</pubDate>
            <atom:updated>2018-10-23T01:18:33.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*elgmuA43BFmi2_nW-CR0Mg.png" /></figure><p>RxBinding APIs for Android UI widgets from the platform and support libraries.</p><blockquote>Firstly, you can find RxBinding Library in the link below.</blockquote><p><a href="https://github.com/JakeWharton/RxBinding">JakeWharton/RxBinding</a></p><p>RxBinding is a set of libraries that allow you to react to user interface events via the RxJava paradigm.</p><p>Platform bindings:</p><pre>implementation &#39;com.jakewharton.rxbinding2:rxbinding:2.2.0&#39;</pre><p>‘support-v4’ library bindings:</p><pre>implementation &#39;com.jakewharton.rxbinding2:rxbinding-support-v4:2.2.0&#39;</pre><p>‘appcompat-v7’ library bindings:</p><pre>implementation &#39;com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.2.0&#39;</pre><p>‘design’ library bindings:</p><pre>implementation &#39;com.jakewharton.rxbinding2:rxbinding-design:2.2.0&#39;</pre><p>‘recyclerview-v7’ library bindings:</p><pre>implementation &#39;com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:2.2.0&#39;</pre><p>‘leanback-v17’ library bindings:</p><pre>implementation &#39;com.jakewharton.rxbinding2:rxbinding-leanback-v17:2.2.0&#39;</pre><p>So, let’s start to compare RxBinding and default binding.</p><h3><strong>TextView</strong></h3><p>Default</p><pre>editText.addTextChangedListener(object : TextWatcher {<br>    override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {<br><br>        if (s.<em>isEmpty</em>()){<br>            Toast.makeText(this, &quot;error&quot;, Toast.<em>LENGTH_SHORT</em>).<em>show<br>        </em>}<br>    }<br><br>    override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {<br>  <em><br>    </em>}<br><br>    override fun afterTextChanged(s: Editable) {<br><br><em>    </em>}<br>})</pre><p>RxBinding</p><pre>RxTextView.textChanges(editText).subscribe <strong>{ </strong>it <strong>-&gt; <br>    </strong>if (it.<em>isEmpty</em>()) Toast.makeText(this, &quot;error&quot;, Toast.<em>LENGTH_SHORT</em>).<em>show<br></em><strong>}</strong></pre><h3>ViewPager</h3><p>Default</p><pre>viewPager.addOnAdapterChangeListener(object : ViewPager.OnPageChangeListener {<br>    override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {<br><br>    }<br><br>    override fun onPageSelected(position: Int) {<br>        if (position == 1){<br>            button.<em>visibility </em>= <em>VISIBLE<br>        </em>}<br>    }<br><br>    override fun onPageScrollStateChanged(state: Int) {<br><br>    }<br>})</pre><p>RxBinding</p><pre>RxViewPager.pageSelections(viewPager).subscribe <strong>{<br>    </strong>it <strong>-&gt; </strong>if (it == 1) button.<em>visibility </em>= <em>VISIBLE<br></em><strong>}</strong></pre><h3>Button</h3><p>Default</p><pre>button.setOnClickListener <strong>{<br>    </strong>Toast.makeText(this, &quot;OK&quot;, Toast.<em>LENGTH_SHORT</em>).show()<br><strong>}</strong></pre><p>RxBinding</p><pre>RxView.clicks(button).subscribe <strong>{ </strong>Toast.makeText(this, &quot;OK&quot;, Toast.<em>LENGTH_SHORT</em>).show() <strong>}</strong></pre><h3>CompoundButton</h3><p>Default</p><pre>compoundButton.setOnCheckedChangeListener <strong>{ </strong>compoundButton, b <strong>-&gt; </strong>isChecked = b <strong>}</strong></pre><p>RxBinding</p><pre>RxCompoundButton.checkedChanges(compoundButton).subscribe <strong>{ </strong>isChecked = <strong>it }</strong></pre><p><strong>This story is published in </strong><a href="http://blog.usejournal.com/"><strong>Noteworthy</strong></a><strong>, where 10,000+ readers come every day to learn about the people &amp; ideas shaping the products we love.</strong></p><p><a href="http://blog.usejournal.com/"><strong>Follow our publication</strong></a><strong> to see more product &amp; design stories featured by the </strong><a href="https://usejournal.com/?/utm_source=usejournal.com&amp;utm_medium=blog&amp;utm_campaign=guest_post"><strong>Journal</strong></a><strong> team.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c73ca64167be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Kotlin]]></title>
            <link>https://medium.com/@ozantopuz/introduction-to-kotlin-97162dc80c23?source=rss-fc5b0e8ab553------2</link>
            <guid isPermaLink="false">https://medium.com/p/97162dc80c23</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[kotlindev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Ozan Topuz]]></dc:creator>
            <pubDate>Wed, 18 Jul 2018 19:54:00 GMT</pubDate>
            <atom:updated>2018-07-19T23:33:43.736Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Ou2bvBB0pRQqrHOE4O_VA.jpeg" /></figure><p>Hello Developers, today I am writing an introduction for Kotlin. As you know, in 2017 Google announced that Kotlin has become a first-class language on Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*xuYj6HV1t9tREKFodxj9Qg.gif" /></figure><p>For Android developers, Kotlin support is a chance to use a modern and powerful language, helping solve common headaches such as runtime exceptions and source code verbosity. Kotlin is easy to get started with and can be gradually introduced into existing projects, which means that your existing skills and technology investments are preserved.</p><p>So let’s start without losing any more time!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FQw4X3FPbL62C9dvcKxq%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FQw4X3FPbL62C9dvcKxq%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FQw4X3FPbL62C9dvcKxq%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="310" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e4cce386996c91cff45f24891dab71d/href">https://medium.com/media/8e4cce386996c91cff45f24891dab71d/href</a></iframe><p>We will learn Kotlin with small simple annotated examples.</p><p>First of all, Let’s print “Hello World”; the classical introduction</p><pre>println(“Hello World”)</pre><p>Now let’s examine variables. Kotlin have two variables, one of them is var(a mutable variable). The other variable is val(a immutable variable).</p><p>We don’t have to write a type because the compiler infers the type.</p><pre>var text = &quot;Hello World&quot; // variable</pre><pre>val x = 1 // constant</pre><pre>val isKotlin = true</pre><pre>val character = &#39;x&#39;</pre><pre>var fl = 1.5f</pre><p>I have news for Android developers using Java, In an effort to get rid of the world of NullPointerException, variable types in Kotlin don’t allow the assingment of null.</p><pre>var neverNull: String = &quot;This can&#39;t be null&quot;</pre><pre>var nullable: String? = &quot;This can be null&quot;</pre><p>In Kotlin there are two types of equality: Structural equality (a check for equals()), and referential equality (two references point to the same object)</p><pre>val colors1 = setOf(&quot;Blue&quot;, &quot;Yellow&quot;, &quot;Red&quot;)</pre><pre>val colors2 = setOf(&quot;Red&quot;, &quot;Blue&quot;, &quot;Yellow&quot;)</pre><pre>println(colors1 == colors2)   // true</pre><pre>println(colors1 === colors2)  // false</pre><p>Functions in Kotlin are declared using the fun keyword.</p><pre>fun sum(x: Int, y: Int): Int {                                      <br>    return x + y<br>}</pre><pre>fun multiply(x: Int, y: Int) = x * y</pre><pre>fun thanks(name: String): String { <br>    return &quot;Thank you $name for everything&quot; <br>}</pre><pre>fun printMessageWithPrefix(message: String, prefix : String = &quot;&quot;) {<br>    <em>println</em>(&quot;[$prefix] $message&quot;)<br>}</pre><p>Functions which don’t return anything has a return type of Unit. The Unit type corresponds to void in Java.</p><pre>fun printAvg(d1: Double, d2: Double): Unit {<br>    println(&quot;Avg of ($d1 and $d2) = ${(d1 + d2)/2}&quot;)<br>} </pre><p>You can pass a variable number of arguments to a function by declaring the function with a vararg parameter.</p><pre>fun sum(vararg numbers: Double): Double {<br>    var result: Double = 0.0<br>    for(number in numbers) {<br>        result += number<br>    }<br>    return result<br>}</pre><pre>sum(1.5, 2.0)  // Result = 3.5<br><br>sum(1.5, 2.0, 3.5, 4.0, 5.8, 6.2)  // Result = 23.0<br><br>sum(1.5, 2.0, 3.5, 4.0, 5.8, 6.2, 8.1, 12.4, 16.5)  // Result = 60.0</pre><p>There is no ‘traditional for loop’ in Kotlin unlike Java and other languages.</p><p>In Kotlin, ‘for loop’ is used to iterate through ranges, arrays, maps and so on (anything that provides an iterator).</p><pre>val animals = listOf(&quot;cat&quot;, &quot;tiger&quot;, &quot;lion&quot;)</pre><pre>for (animal in animals) println(&quot;$animal is an animal&quot;)</pre><pre>outputs: cat is an animal, tiger is an animal, lion is an animal</pre><pre>for (i in 1..10) println(i)</pre><pre>outputs: 1,2,3,4,5,6,7,8,9,10</pre><pre>for (i in 5..1) println(i)</pre><pre>outputs: 5,4,3,2,1</pre><pre>for (i in 5 downTo 1) print(i)</pre><pre>outputs: 5,4,3,2,1    </pre><pre>for (i in 1..5 step 2) print(i)</pre><pre>outputs: 1,3,5</pre><pre>for (i in 5 downTo 1 step 2) print(i)</pre><pre>outputs: 5,3,1</pre><blockquote>In addition, Kotlin is very similar to Swift which can be compared in the link below.</blockquote><p><a href="http://nilhcem.com/swift-is-like-kotlin/">Swift is like Kotlin</a></p><h4>More where this came from</h4><p>This story is published in <a href="http://blog.usejournal.com/">Noteworthy</a>, where thousands come every day to learn about the people &amp; ideas shaping the products we love.</p><p>Follow our publication to see more product &amp; design stories featured by the <a href="https://usejournal.com/?utm_source=usejournal.com&amp;utm_medium=blog&amp;utm_campaign=guest_post">Journal</a> team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97162dc80c23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Lottie for Android]]></title>
            <link>https://medium.com/@ozantopuz/introduction-to-lottie-for-android-6b82b27afaaf?source=rss-fc5b0e8ab553------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b82b27afaaf</guid>
            <category><![CDATA[lottie]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ozan Topuz]]></dc:creator>
            <pubDate>Mon, 15 May 2017 11:44:38 GMT</pubDate>
            <atom:updated>2018-07-30T21:49:15.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nxquO5TPptSamwl0G65Jg.png" /></figure><p><a href="https://airbnb.design/lottie/">Lottie</a> is an open-source animation tool by the amazing folks at <a href="https://www.airbnb.com/">Airbnb</a>. It is a library for iOS, Android and React Native platforms that renders After Effects animations, allowing apps to use animations as easily as they use static images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*6vOESJoSzxIoIdqHnx5Evw.gif" /></figure><p>Today we will see how simple it is to use it in your projects. Let’s take a look at a simple example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*s2afqyqNs-oX0usXWFlmJw.gif" /></figure><p><em>So let’s cut to the chase and see how can we use it:</em></p><h3><strong>Step 1:</strong></h3><p>Set up the project in Android Studio with default activity.</p><p>In app’s <em>build.gradle,</em> add the dependencies.</p><pre>compile &#39;com.airbnb.android:lottie:2.0.0-rc1&#39;</pre><p><strong>Note:</strong> Lottie supports ICS (API 14) and above.</p><h3>Step 2:</h3><p>Add Lottie animation JSONs in your assets folder.</p><p>You can find animations for Lottie in <a href="http://www.lottiefiles.com/">lottiefiles</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*fgyfjz7ODGpiM3uAR21tsg.gif" /></figure><h3><strong>Step 3:</strong></h3><p>Let’s create the XML for our first animation. This is how we are going to lay down our animation:</p><pre>&lt;com.airbnb.lottie.LottieAnimationView<br>    android:id=&quot;@+id/intro_lottie_animation_view&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    app:lottie_fileName=&quot;servishero_loading.json&quot;<br>    app:lottie_loop=&quot;false&quot;<br>    app:lottie_autoPlay=&quot;true&quot;/&gt;</pre><p><strong>Notes:</strong></p><ul><li>Set lottie_fileName to your JSON file’s name for Lottie</li><li>Set lottie_loop to “true” to enable looping</li><li>Set lottie_autoPlay to “true” to enable auto playing</li></ul><p>You can find further customization options in the <a href="https://github.com/airbnb/lottie-android">Lottie documentation</a>.</p><h3>Step 4:</h3><p>It’s time to show the real power of Lottie with using its listener and action methods. This is what differentiates Lottie from e.g a gif animation.</p><p>Now we set up our related java file:</p><pre>public class IntroFragment extends Fragment {<br><br>    @BindView(R.id.<em>intro_lottie_animation_view</em>)<br>    LottieAnimationView mLottie;<br>    private Unbinder mUnbinder;<br><br>    public static IntroFragment newInstance(Context context) {<br>        return (IntroFragment) IntroFragment.<em>instantiate</em>(context, IntroFragment.class.getName());<br>    }<br><br>    @Nullable<br>    @Override<br>    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {<br>        View view = inflater.inflate(R.layout.<em>fragment_intro</em>, container, false);<br>        mUnbinder = ButterKnife.<em>bind</em>(this, view);<br>        return view;<br>    }<br><br>    @Override<br>    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {<br>        super.onViewCreated(view, savedInstanceState);<br>    }<br><br>    @Override<br>    public void onStart() {<br>        super.onStart();<br>        <strong>mLottie.playAnimation();</strong><br>    }<br><br>    @Override<br>    public void onStop() {<br>        super.onStop();<br>        <strong>mLottie.cancelAnimation();</strong><br>    }</pre><p>You can use onAnimationStart() method for listening animation start:</p><pre>@Override public void onAnimationStart(Animator animation) {<br>    Toast.<em>makeText</em>(getActivity(), &quot;Downloading...&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>}</pre><p>You can use onAnimationEnd() method for listening animation end:</p><pre>@Override public void onAnimationEnd(Animator animation) {<br>    Toast.<em>makeText</em>(getActivity(), &quot;Finished&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>}</pre><p>You can use onAnimationCancel() method for listening animation cancel:</p><pre>@Override public void onAnimationCancel(Animator animation) {<br>    Toast.<em>makeText</em>(getActivity(), &quot;Cancel&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>}</pre><p>You can use onAnimationRepeat() method for listening animation repeat:</p><pre>@Override public void onAnimationCancel(Animator animation) {<br>    Toast.<em>makeText</em>(getActivity(), &quot;Cancel&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>}</pre><p>You can use playAnimation() method for actioning animation play:</p><pre>@Override<br>public void onStart() {<br>    super.onStart();<br>    mLottie.playAnimation();<br>}</pre><p>You can use cancelAnimation() method for actioning animation cancel:</p><pre>@Override<br>public void onStop() {<br>    super.onStop();<br>    mLottie.cancelAnimation();<br>}</pre><h3>Result:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*opEVU5y7nCNio9uidv60LQ.gif" /></figure><p>You can find the completed project on Github:</p><p><a href="https://github.com/ozantopuz/lottie-android-introduction">ozantopuz/lottie-android-introduction</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b82b27afaaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>