<?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 Smital Desai on Medium]]></title>
        <description><![CDATA[Stories by Smital Desai on Medium]]></description>
        <link>https://medium.com/@desaismital?source=rss-e1c9d9b2149a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ip2vS5X1feq02CMz</url>
            <title>Stories by Smital Desai on Medium</title>
            <link>https://medium.com/@desaismital?source=rss-e1c9d9b2149a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 20:29:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@desaismital/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[Topeka : Transition Animations [ 2]]]></title>
            <link>https://medium.com/@desaismital/topeka-transition-animations-2-10f9f1cf998?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/10f9f1cf998</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Thu, 02 Jan 2020 17:47:31 GMT</pubDate>
            <atom:updated>2020-01-03T03:10:09.128Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTxAMcAnyGTXLdZNw2w9Qw.png" /></figure><h3>Topeka : Transition Animations [2 ]</h3><p>Learn transition animations technique from the open source Topeka App.</p><p>Welcome to the 2nd part of this series. This time we will take a look at the transition that takes place when user clicks on Category and reaches the quiz section. If you haven’t gotten a chance to look at the first part , i would encourage you to take a look at</p><p><a href="https://medium.com/@desaismital/topeka-transition-animations-1-9ebe542fd763">Topeka : Transition Animations [ 1 ]</a></p><p>Now, lets take a look at how this transition looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gc54oTYRuqRO6Agf0LQcDQ.gif" /></figure><p><strong>Observations:</strong></p><ul><li>Once you choose the category — text description flows and gets set as toolbar title</li><li>Once the transition is over the back button appears over the toolbar</li><li>Imageview at the center of the screen is scales and fades in after certain time</li></ul><p>This is how the <strong>v21/quiz_shared_enter.xml</strong> defines the transition</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253C%21--suppress%252520AndroidElementNotAllowed%252520--%25253E%25250A%25253CtransitionSet%252520xmlns%25253Aandroid%25253D%252522http%25253A%25252F%25252Fschemas.android.com%25252Fapk%25252Fres%25252Fandroid%252522%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520android%25253Ainterpolator%25253D%252522%252540android%25253Ainterpolator%25252Ffast_out_slow_in%252522%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520android%25253Aduration%25253D%252522%252540integer%25252Ftoolbar_transition_duration%252522%25253E%25250A%25250A%252520%252520%252520%252520%25253CchangeBounds%25252F%25253E%25250A%252520%252520%252520%252520%25253CarcMotion%252520android%25253AmaximumAngle%25253D%25252250%252522%25252F%25253E%25250A%252520%252520%252520%252520%25253Ctransition%252520class%25253D%252522com.google.samples.apps.topeka.widget.TextResizeTransition%252522%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctargets%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AtargetId%25253D%252522%252540id%25252Fcategory_title%252522%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253C%25252Ftargets%25253E%25250A%252520%252520%252520%252520%25253C%25252Ftransition%25253E%25250A%25253C%25252FtransitionSet%25253E&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253C%21--suppress%25252520AndroidElementNotAllowed%25252520--%2525253E%2525250A%2525253CtransitionSet%25252520xmlns%2525253Aandroid%2525253D%25252522http%2525253A%2525252F%2525252Fschemas.android.com%2525252Fapk%2525252Fres%2525252Fandroid%25252522%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520android%2525253Ainterpolator%2525253D%25252522%25252540android%2525253Ainterpolator%2525252Ffast_out_slow_in%25252522%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520android%2525253Aduration%2525253D%25252522%25252540integer%2525252Ftoolbar_transition_duration%25252522%2525253E%2525250A%2525250A%25252520%25252520%25252520%25252520%2525253CchangeBounds%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253CarcMotion%25252520android%2525253AmaximumAngle%2525253D%2525252250%25252522%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253Ctransition%25252520class%2525253D%25252522com.google.samples.apps.topeka.widget.TextResizeTransition%25252522%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctargets%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AtargetId%2525253D%25252522%25252540id%2525252Fcategory_title%25252522%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%2525252Ftargets%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253C%2525252Ftransition%2525253E%2525250A%2525253C%2525252FtransitionSet%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5412aa554d443dc9822006ead28b22be/href">https://medium.com/media/5412aa554d443dc9822006ead28b22be/href</a></iframe><p>First interesting observation:</p><p>How does the back button appears after the toolbar text has finished transitioning ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9cK8k_YjhWbyRgD2JZvVhA.png" /></figure><p>I think its pretty clear now about what happens.</p><p>At the start of the shared element transition ( Toobar Text ) , in the <strong>onSharedElementStart() </strong>callback , we set the scaleX, scaleY property of the back button to 0 , effectively making it disappear.</p><p>At the end of the shared element transition ( Toobar Text ), in the <strong>onSharedElementEnd() </strong>callback, we set the scaleX, scaleY to 1 and fade in the back Button.</p><ul><li>Once you choose the category — text description flows and gets set as toolbar title</li></ul><p>Overall Intention is to animate the textsize and text padding change of the shared textview in the CategoryActivity and QuizActivity. This is achived using <strong>TextSharedElementCallback</strong> and <strong>TextResizeTransition</strong></p><p>So lets see first about when the overridden methods in the TextSharedElementCallback() are called.</p><p>onSharedElementStart()</p><p>=&gt; In Activity Transitions, <strong>onSharedElementStart is called immediately before capturing the start of the shared element state on enter and reenter transitions</strong> and immediately before capturing the end of the shared element state for exit and return transitions.</p><p>onSharedElementEnd()</p><p>=&gt; In Activity Transitions,<strong> onSharedElementEnd is called immediately before capturing the end of the shared element state on enter and reenter transitions </strong>and immediately before capturing the start of the shared element state for exit and return transitions</p><p>Please refer to <a href="https://developer.android.com/reference/android/app/SharedElementCallback">https://developer.android.com/reference/android/app/SharedElementCallback</a></p><p>This is how the shared element transition happens</p><ol><li>In the constructor of TextSharedElementCallback, inital size and padding of the textview is passed [ That is the value present in CategoryActivity ]</li><li>Now when the TextSharedElementCallback -&gt; OnSharedElementStart is called, the measured value of textview size and padding is stored in local variables and the textSize and padding has been set to the one calculated in #1 [ This becomes initial state ]</li><li>These values are then passed to custom transition defined in TextResizeTransition</li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dseti%26wt%3Dnone%26l%3Dtext%252Fx-kotlin%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Doverride%252520fun%252520captureStartValues%28values%25253A%252520TransitionValues%29%252520%25253D%252520captureValues%28values%29&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dseti%26wt%3Dnone%26l%3Dtext%25252Fx-kotlin%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Doverride%25252520fun%25252520captureStartValues%28values%2525253A%25252520TransitionValues%29%25252520%2525253D%25252520captureValues%28values%29&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/62e44396ad92e02643c02703dbb9da7b/href">https://medium.com/media/62e44396ad92e02643c02703dbb9da7b/href</a></iframe><p>4. Now when the TextSharedElementCallback -&gt; OnSharedElementEnd is called, the stored values in #2 are set again on the textView which are the final values in the QuizActivity</p><p>5. These values are then passed to custom transition defined in TextResizeTransition</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dseti%26wt%3Dnone%26l%3Dtext%252Fx-kotlin%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Doverride%252520fun%252520captureEndValues%28values%25253A%252520TransitionValues%29%252520%25253D%252520captureValues%28values%29&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dseti%26wt%3Dnone%26l%3Dtext%25252Fx-kotlin%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Doverride%25252520fun%25252520captureEndValues%28values%2525253A%25252520TransitionValues%29%25252520%2525253D%25252520captureValues%28values%29&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf439f2fa265288330fe692c97aefb94/href">https://medium.com/media/bf439f2fa265288330fe692c97aefb94/href</a></iframe><p>6. The captured values in #3 and #5 are then animated in the custom transition defined in TextResizeTransition by overriding <strong>createAnimator()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VrfLv3Z3uAEedd5-TCVajg.png" /></figure><p>We can actually see the effect by totally commenting out the TextSharedElementCallback Implementation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VomALsPriEyR34InDiM6hA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lEFuIlqxUXQ9AzmG5xnQ3A.gif" /></figure><p>Here we can see that the textSize and padding of the shared textView is already at its final state without the animation</p><p>If we just implement the onSharedElementStart</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZuE_7klNaWbKUzHL8nAyzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNqPaXFupF85fBZxc7xsXA.gif" /></figure><p>We can see that the even after the transition, the size of the textView is same as that of the calling activity and since we are not redrawing the textView after final state, the back button gets drawn on top of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6WQdY-X0Tw2zXspHwiVcZg.png" /></figure><p>That is it really that i wanted to share in this post. If you liked the article, please clap for it and don’t forget to share with other devs. I am going to continue and explore the animations in this app further and will continue to share my learnings.</p><p>You can follow me on twitter <a href="https://medium.com/u/1b7ecfd2b3e6?source=post_page-----9ebe542fd763----------------------">Smital Desai</a> for #android and #python content. Thank you for reading the post.</p><p><strong>Resources:</strong></p><ul><li><a href="https://www.androiddesignpatterns.com/2014/12/activity-fragment-transitions-in-android-lollipop-part1.html">https://www.androiddesignpatterns.com/2014/12/activity-fragment-transitions-in-android-lollipop-part1.html</a></li><li><a href="https://developer.android.com/training/transitions">https://developer.android.com/training/transitions</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10f9f1cf998" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Topeka : Transition Animations [ 1 ]]]></title>
            <link>https://medium.com/@desaismital/topeka-transition-animations-1-9ebe542fd763?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ebe542fd763</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Mon, 30 Dec 2019 02:57:08 GMT</pubDate>
            <atom:updated>2020-01-03T02:53:23.165Z</atom:updated>
            <content:encoded><![CDATA[<h3>Topeka : Transition Animations [ 1 ]</h3><p>Learn transition animations technique from the open source Topeka App.</p><p>There are various ways in which animations can be implemented in Android and sometimes it can be overwhelming. Animations are really necessary for <strong>delightful user experience</strong> but implementing them can be quite challenging, especially if you are not working closely with designers or worst you have to make these challenging job of crafting beautiful user experience when you are like me; in a sense having limited creative skills for visualising and creating such animations.</p><p>This is where i think we are very fortunate to have lot of open source apps to borrow inspiration from.</p><ul><li><a href="https://github.com/chrisbanes/cheesesquare">chrisbanes/cheesesquare</a></li><li><a href="https://github.com/android/plaid">android/plaid</a></li></ul><p>Even when i was new to the android app development, I tried the same approach to learn from Plaid-1.0. This was mostly to learn from the app and really jot down important features from learnings.</p><p><a href="https://smithdroid.blogspot.com/2016/01/learnings-from-nick-butchers-plaid-app.html">Learnings from Nick Butcher&#39;s Plaid App - Part-1</a></p><p>Its been quite a journey from android animation apis and I thought why not do the same exercise again to learn modern android animations and I reached out to Plaid but its getting re-rewritten so i had to hold my horses and i looked further and landed on <strong>Topeka App.</strong></p><p><a href="https://github.com/android/topeka">android/topeka</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6AybbRZMpQkeJCzhF4l20w.gif" /></figure><p>So if you haven’t come across this app yet, Please download it and load it up in the emulator. Now if you are like me, I can see that there are beautiful transitions happening</p><ul><li>from SignIn page to category page : Shared Element transition of Avatar image but at this point i am not sure about the curved path that it took</li><li>Category page slides in from left</li><li>Click on the category , we move to Quiz screen : Shared element transition but wait the title really moved to ToolBar. Amazing but i not sure how do we achieve that using shared element transition. The back button starts to appear only after the tool bar text shared element transition is over. Looks slick.</li><li>Once you press the play button : There is reveal animation</li><li>Once you press submit fab : It turns into Rectangle, the color of the rectangle is green / red based on the accuracy of the answer and it moves off of the screen. At this point, I am like no way , how in the world would you do that</li></ul><p>The first and foremost question to ask ourselves is, how do we take a closer look at these animations to even confirm if what i am saying is right or may be not entirely true. Go to Settings -&gt; Developer Options -&gt; Drawer Section and make animation related scales to 5x. The result of that is animations will be played slower and you can actually pick out about what is happening.</p><p>Now lets take a look at the same steps and see if we are able to get more granular steps involved in these beautiful transitions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGT9YTQC4iUeU28z0pgwDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*weGNzKlOtAbPBTpEcBf3-g.gif" /></figure><p>Now that is pretty neat and I hope that we are now in a state to understand what is going on during the transitions at least visually.</p><p>This is really important step towards understanding what the implementation would look like and that is what we are going to cover in the next section.</p><p>If you are totally new to content and shared element transitions , Please read this blog by none other than <a href="https://medium.com/u/f61fb1c467cd">Alex Lockwood</a>. He does a great job of explaining what transition animation is and why its useful.</p><p><a href="https://www.androiddesignpatterns.com/2014/12/activity-fragment-transitions-in-android-lollipop-part1.html">Getting Started with Activity &amp; Fragment Transitions (part 1)</a></p><p>I don’t have to repeat so here is the gist about the activity transition API , taken from the <a href="https://medium.com/u/f61fb1c467cd">Alex Lockwood</a>’s blog. Thanks <a href="https://medium.com/u/f61fb1c467cd">Alex Lockwood</a> for such a great explanation.</p><p>My key takeaways from the blog</p><ul><li>The transition framework provides a convenient API for animating between different UI states in an application</li><li>Transitions abstract the idea of Animators from the developer</li><li>As a result, Transitions can significantly reduce the amount of code you write in your activities and fragments: all the developer must do is set the views’ start and end values and the Transition will automatically construct an animation based on the differences</li><li>animations between scenes can be easily changed by using different Transition objects</li></ul><p>And this is how the transition api looks like for the activity transitions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWOzztDxJ-LheOPZE9sXQg.png" /></figure><p>Now, lets see how the transition from Signin to Category is implemented in Topeka app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2811GVhllOWrZrqM0_dfLg.gif" /></figure><ul><li>SignInActivity has an Avatar Imageview which is part of shared element transition between SignInActivity and CategorySelectionActivity.</li><li>The other non-shared views in the CategorySelectionActivity go through enter transition which is Slide-In from Right.</li><li>By the way, did you notice the shared avatar view actually passes through an arc</li><li>Toolbar in the CategorySelectionActivity fades in</li></ul><p><a href="https://github.com/android/topeka/blob/master/categories/src/main/res/values-v21/styles.xml"><strong>v21/styles.xml</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8ld5ILiMTs40J2Af3eIjA.png" /></figure><p><a href="https://github.com/android/topeka/blob/master/categories/src/main/res/transition-v21/category_enter.xml"><strong>transition-v21/category_enter.xml</strong></a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253CtransitionSet%252520xmlns%25253Aandroid%25253D%252522http%25253A%25252F%25252Fschemas.android.com%25252Fapk%25252Fres%25252Fandroid%252522%25253E%25250A%252520%252520%252520%252520%25253Cslide%252520android%25253AslideEdge%25253D%252522right%252522%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctargets%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AexcludeId%25253D%252522%252540android%25253Aid%25252FstatusBarBackground%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AexcludeId%25253D%252522%252540android%25253Aid%25252FnavigationBarBackground%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AexcludeId%25253D%252522%252540id%25252Ftoolbar_player%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253C%25252Ftargets%25253E%25250A%252520%252520%252520%252520%25253C%25252Fslide%25253E%25250A%252520%252520%252520%252520%25253Cfade%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctargets%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AtargetId%25253D%252522%252540id%25252Ftoolbar_player%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253C%25252Ftargets%25253E%25250A%252520%252520%252520%252520%25253C%25252Ffade%25253E%25250A%25253C%25252FtransitionSet%25253E&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253CtransitionSet%25252520xmlns%2525253Aandroid%2525253D%25252522http%2525253A%2525252F%2525252Fschemas.android.com%2525252Fapk%2525252Fres%2525252Fandroid%25252522%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253Cslide%25252520android%2525253AslideEdge%2525253D%25252522right%25252522%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctargets%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AexcludeId%2525253D%25252522%25252540android%2525253Aid%2525252FstatusBarBackground%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AexcludeId%2525253D%25252522%25252540android%2525253Aid%2525252FnavigationBarBackground%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AexcludeId%2525253D%25252522%25252540id%2525252Ftoolbar_player%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%2525252Ftargets%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253C%2525252Fslide%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253Cfade%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctargets%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AtargetId%2525253D%25252522%25252540id%2525252Ftoolbar_player%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%2525252Ftargets%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253C%2525252Ffade%2525253E%2525250A%2525253C%2525252FtransitionSet%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e6b666c13e0461706070f1972fd6cc4/href">https://medium.com/media/5e6b666c13e0461706070f1972fd6cc4/href</a></iframe><p><a href="https://github.com/android/topeka/blob/master/categories/src/main/res/transition-v21/category_exit.xml"><strong>transition-v21/category_exit.xml</strong></a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253CtransitionSet%252520xmlns%25253Aandroid%25253D%252522http%25253A%25252F%25252Fschemas.android.com%25252Fapk%25252Fres%25252Fandroid%252522%25253E%25250A%252520%252520%252520%252520%25253Cslide%252520android%25253AslideEdge%25253D%252522left%252522%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctargets%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AexcludeId%25253D%252522%252540android%25253Aid%25252FstatusBarBackground%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AexcludeId%25253D%252522%252540android%25253Aid%25252FnavigationBarBackground%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AexcludeId%25253D%252522%252540id%25252Ftoolbar_player%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253C%25252Ftargets%25253E%25250A%252520%252520%252520%252520%25253C%25252Fslide%25253E%25250A%252520%252520%252520%252520%25253Cfade%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctargets%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25253Ctarget%252520android%25253AtargetId%25253D%252522%252540id%25252Ftoolbar_player%252522%252520%25252F%25253E%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25253C%25252Ftargets%25253E%25250A%252520%252520%252520%252520%25253C%25252Ffade%25253E%25250A%25253C%25252FtransitionSet%25253E&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253CtransitionSet%25252520xmlns%2525253Aandroid%2525253D%25252522http%2525253A%2525252F%2525252Fschemas.android.com%2525252Fapk%2525252Fres%2525252Fandroid%25252522%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253Cslide%25252520android%2525253AslideEdge%2525253D%25252522left%25252522%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctargets%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AexcludeId%2525253D%25252522%25252540android%2525253Aid%2525252FstatusBarBackground%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AexcludeId%2525253D%25252522%25252540android%2525253Aid%2525252FnavigationBarBackground%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AexcludeId%2525253D%25252522%25252540id%2525252Ftoolbar_player%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%2525252Ftargets%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253C%2525252Fslide%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253Cfade%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctargets%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253Ctarget%25252520android%2525253AtargetId%2525253D%25252522%25252540id%2525252Ftoolbar_player%25252522%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525253C%2525252Ftargets%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253C%2525252Ffade%2525253E%2525250A%2525253C%2525252FtransitionSet%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c4c1f923f7f2ffcb664dc6ae06a4f51/href">https://medium.com/media/7c4c1f923f7f2ffcb664dc6ae06a4f51/href</a></iframe><p><a href="https://github.com/android/topeka/blob/master/categories/src/main/res/transition-v21/category_shared_enter.xml"><strong>transition-v21/category_shared_enter</strong></a><strong> : </strong>See the arcMotion transition</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25253CtransitionSet%252520xmlns%25253Aandroid%25253D%252522http%25253A%25252F%25252Fschemas.android.com%25252Fapk%25252Fres%25252Fandroid%252522%25253E%25250A%252520%252520%252520%252520%25253CchangeBounds%252520%25252F%25253E%25250A%252520%252520%252520%252520%25253CchangeTransform%252520%25252F%25253E%25250A%252520%252520%252520%252520%25253CarcMotion%252520android%25253AminimumHorizontalAngle%25253D%25252245%252522%252520%25252F%25253E%25250A%25253C%25252FtransitionSet%25253E&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dseti%26wt%3Dnone%26l%3Dhtmlmixed%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525253CtransitionSet%25252520xmlns%2525253Aandroid%2525253D%25252522http%2525253A%2525252F%2525252Fschemas.android.com%2525252Fapk%2525252Fres%2525252Fandroid%25252522%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253CchangeBounds%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253CchangeTransform%25252520%2525252F%2525253E%2525250A%25252520%25252520%25252520%25252520%2525253CarcMotion%25252520android%2525253AminimumHorizontalAngle%2525253D%2525252245%25252522%25252520%2525252F%2525253E%2525250A%2525253C%2525252FtransitionSet%2525253E&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bb09ea207aa84aefdfbf943bf51d563/href">https://medium.com/media/8bb09ea207aa84aefdfbf943bf51d563/href</a></iframe><p>This is how its invoked from the SignInFragment.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%28171%252C%2520184%252C%2520195%252C%25201%29%26t%3Dseti%26wt%3Dnone%26l%3Dtext%252Fx-kotlin%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252520%252540TargetApi%28Build.VERSION_CODES.LOLLIPOP%29%25250A%252520%252520%252520%252520private%252520fun%252520performSignInWithTransition%28v%25253A%252520View%25253F%252520%25253D%252520null%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520if%252520%28v%252520%25253D%25253D%252520null%252520%25257C%25257C%252520ApiLevelHelper.isLowerThan%28Build.VERSION_CODES.LOLLIPOP%29%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25252F%25252F%252520Don%2527t%252520run%252520a%252520transition%252520if%252520the%252520passed%252520view%252520is%252520null%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520activity%25253F.run%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520navigateToCategoryActivity%28%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520return%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%25250A%252520%252520%252520%252520%252520%252520%252520%252520if%252520%28ApiLevelHelper.isAtLeast%28Build.VERSION_CODES.LOLLIPOP%29%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520activity%25253F.run%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520window.sharedElementExitTransition.addListener%28object%252520%25253A%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520Transition.TransitionListener%252520by%252520TransitionListenerAdapter%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520override%252520fun%252520onTransitionEnd%28transition%25253A%252520Transition%29%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520finish%28%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%29%25250A%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520val%252520pairs%252520%25253D%252520TransitionHelper.createSafeTransitionParticipants%28this%25252C%252520true%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520Pair%28v%25252C%252520getString%28R.string.transition_avatar%29%29%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520val%252520options%252520%25253D%252520ActivityOptionsCompat.makeSceneTransitionAnimation%28this%25252C%252520%2Apairs%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520ActivityLaunchHelper.launchCategorySelection%28this%25252C%252520options%29%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%25250A%252520%252520%252520%252520%25257D&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%28171%25252C%252520184%25252C%252520195%25252C%2525201%29%26t%3Dseti%26wt%3Dnone%26l%3Dtext%25252Fx-kotlin%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252520%25252540TargetApi%28Build.VERSION_CODES.LOLLIPOP%29%2525250A%25252520%25252520%25252520%25252520private%25252520fun%25252520performSignInWithTransition%28v%2525253A%25252520View%2525253F%25252520%2525253D%25252520null%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520if%25252520%28v%25252520%2525253D%2525253D%25252520null%25252520%2525257C%2525257C%25252520ApiLevelHelper.isLowerThan%28Build.VERSION_CODES.LOLLIPOP%29%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525252F%2525252F%25252520Don%27t%25252520run%25252520a%25252520transition%25252520if%25252520the%25252520passed%25252520view%25252520is%25252520null%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520activity%2525253F.run%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520navigateToCategoryActivity%28%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520return%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520if%25252520%28ApiLevelHelper.isAtLeast%28Build.VERSION_CODES.LOLLIPOP%29%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520activity%2525253F.run%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520window.sharedElementExitTransition.addListener%28object%25252520%2525253A%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520Transition.TransitionListener%25252520by%25252520TransitionListenerAdapter%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520override%25252520fun%25252520onTransitionEnd%28transition%2525253A%25252520Transition%29%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520finish%28%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%29%2525250A%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520val%25252520pairs%25252520%2525253D%25252520TransitionHelper.createSafeTransitionParticipants%28this%2525252C%25252520true%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520Pair%28v%2525252C%25252520getString%28R.string.transition_avatar%29%29%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520val%25252520options%25252520%2525253D%25252520ActivityOptionsCompat.makeSceneTransitionAnimation%28this%2525252C%25252520%2Apairs%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520ActivityLaunchHelper.launchCategorySelection%28this%2525252C%25252520options%29%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%2525250A%25252520%25252520%25252520%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eebc17bfa863042ce700935d8e9a0db6/href">https://medium.com/media/eebc17bfa863042ce700935d8e9a0db6/href</a></iframe><ul><li>The id of the shared avatar Imageview is same in SignInFragment and CategorySelectionActivity and</li><li>while creating the pair in the above code we use the same string thats used in <strong>activity_category_selection.xml </strong>for the property <strong>android:transitionName </strong>as shown in the below xml snippet</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EpRC9tKdSg4GnAewkI2xOA.png" /></figure><p>That is it really that i wanted to share in this post. If you liked the article, please clap for it and don’t forget to share with other devs. I am going to continue and explore the animations in this app further and will continue to share my learnings.</p><p>You can follow me on twitter <a href="https://medium.com/u/1b7ecfd2b3e6">Smital Desai</a> for #android and #python content. Thank you for reading the post.</p><p>You can read the next part</p><p><a href="https://medium.com/@desaismital/topeka-transition-animations-2-10f9f1cf998">Topeka : Transition Animations [ 2]</a></p><p><strong>Resources:</strong></p><ul><li><a href="https://www.androiddesignpatterns.com/2014/12/activity-fragment-transitions-in-android-lollipop-part1.html">https://www.androiddesignpatterns.com/2014/12/activity-fragment-transitions-in-android-lollipop-part1.html</a></li><li><a href="https://developer.android.com/training/transitions">https://developer.android.com/training/transitions</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ebe542fd763" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Declarative Pipelines in Kotlin]]></title>
            <link>https://medium.com/gojekengineering/how-to-use-declarative-pipelines-in-kotlin-3bd4c44bf28d?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bd4c44bf28d</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Thu, 31 Jan 2019 03:53:15 GMT</pubDate>
            <atom:updated>2019-01-31T03:53:15.754Z</atom:updated>
            <content:encoded><![CDATA[<h4>Working on long, memory-intensive operations is stressful. Fret not, declarative pipelines are your friend.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DEEttjM6zlUHLxlgHhOUQ.jpeg" /><figcaption>In this example, the pipeline-based solution implemented in Kotlin is used to read the total bytes transferred from access logs in a memory-efficient manner.</figcaption></figure><blockquote>“How can we do this better?”</blockquote><p>This is a question we continuously ask ourselves at GOJEK. We’re always looking to hack faster, better solutions for the tasks we do. In this post, we explain how to construct declarative pipelines designed to deal with problems in parts.<br>This pattern is not new, and if you want more information, check out this article by <strong>Martin Fowler.</strong></p><p><a href="https://martinfowler.com/articles/collection-pipeline/">Collection Pipeline</a></p><blockquote>Collection pipelines are a programming pattern where you organise some computation as a sequence of operations which compose by taking a collection as output of one operation and feeding it into the next. (Common operations are filter, map, and reduce.) This pattern is common in functional programming, and also in object-oriented languages which have lambdas.</blockquote><p><strong>Now that you are up to speed, back to the story.</strong></p><p>If you have done any web development, you must be familiar with access logs on a server. If not, here is a snapshot of an access log file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mTIyl-2Yx7XmkbL3tMcYPQ.png" /></figure><p><strong>Each line in the file has the below format: </strong><br>IP address : date: time: HTTP method : End point : Response : Bytes Transferred.</p><p>Let’s say our task is to find the total number of bytes transferred during all the hits to all end points. This is a problem where declarative pipelines can be applied. We must remember that these access log files can be really large. Reading an entire file in memory to read bytes and aggregate them can put too much burden on RAM.</p><p><strong>In this case, we are using declarative pipelines in Kotlin</strong> to create memory-efficient, consumer-driven methods to process access log files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HyDeTXh1fxkIXWqTnanMSw.png" /></figure><p>Let’s see how we can build a pipeline which aids memory-efficient processing of this file. I highly recommend listening to <a href="https://fragmentedpodcast.com/tag/sequence/">this episode</a> of the Fragmented podcast to learn more about sequences, which form the foundation of the pipeline. I am also attaching <a href="https://medium.com/u/b85c7e530b1f">Kaushik Gopal</a>’s notes from this podcast episode which do a great job of explaining the concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cw40A-Eyd1MJqrExi1ZyEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_Up88lyaxv6Mjp73uTZKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oeaWJwghZqm-uLYQzH0X7Q.png" /></figure><p><strong>Here are the important takeaways: </strong><br>1. Sequences are evaluated lazily <br>2. Sequences are not useful without a terminating operation. Examples include sum / min / max.<br>3. Intermediate operations on sequences won’t result in temporary lists being created <strong>[This is where the memory saving happens]</strong></p><p>Based on these takeaways, a pipeline just needs two or more sequences to be chained together. To be more specific, we build a sequence from the first function and feed it as an input to the next function, resulting in an efficient data processing pipeline.</p><p><strong>Let’s look at individual functions forming a stage in the pipeline:</strong></p><p><strong>getLines() : </strong>This function doesn’t read the entire file. It just returns a sequence using file.bufferedReader().lineSequence(). We use yield(line) to feed that line to the next stage.</p><p><strong>getBytesColumn() :</strong> This function reads a single line at a time from getLines() function and gets only the last column [This is a sequence and not an intermediate list. So it’s cheap on memory].</p><p><strong>getBytes():</strong> If you look at the last three lines in the screenshot below, some log lines don’t have bytes at the last column. We skip those lines while getting bytes. [Still cheap on memory].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OTO77erR2hQ5uNfEC7LNA.png" /></figure><p>We are at the last stage of the pipeline and have the sequence of bytes. All that remains now is to compute the sum, ie the terminating operation. <br>This is the operation that drives even the first line that is read from the access log. Till this operation is invoked, not a single line is read from the log file.<br><strong>The entire pipeline is consumer-driven.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b7ad7c3a34dd3ead0036e83d42bc41e/href">https://medium.com/media/3b7ad7c3a34dd3ead0036e83d42bc41e/href</a></iframe><p>No matter how big the access log file is, you now have a way to deal with it in a memory efficient way. I could have used Fluent API to do all of this in a chain operation. However, a declarative format better communicates what we are trying to achieve at each stage. It also makes it easier to debug, especially if there are many stages involved in the pipeline.</p><p>I hope you enjoyed this post. We will dive deeper into sequences and generators in Kotlin in later posts. Until then, happy coding!</p><p>You don’t scale like GOJEK has (we process over 3 million orders a day! 🤯) without being innovative. As we grow into new markets in Southeast Asia, we’re on the lookout for sharp minds. If you fit the bill, visit <a href="http://bit.ly/2sSjSKk">gojek.jobs</a> and help us do better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*PdKKvtpvxTQcbMlDvIlFzQ.png" /><figcaption><a href="http://bit.ly/2sSjSKk">gojek.jobs</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bd4c44bf28d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gojekengineering/how-to-use-declarative-pipelines-in-kotlin-3bd4c44bf28d">How to Use Declarative Pipelines in Kotlin</a> was originally published in <a href="https://medium.com/gojekengineering">Gojek Product + Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strategy Pattern in Kotlin Using Functions]]></title>
            <link>https://medium.com/@desaismital/strategy-pattern-in-kotlin-using-functions-861957403c11?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/861957403c11</guid>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Mon, 14 Jan 2019 13:55:22 GMT</pubDate>
            <atom:updated>2019-01-14T13:55:22.992Z</atom:updated>
            <content:encoded><![CDATA[<p>Discuss how the functions being the first class citizens of the language can be used to simplify strategy pattern implementation.</p><p><strong>Strategy Pattern<br></strong>Provides means for encapsulating a set of algorithms, that can be used interchangeably, depending on the user’s needs.</p><p><strong>Let me summarise the case that we will be looking at</strong> <br>In an e-commerce site there are various customers, they create an order which contain items. The way we would like to demonstrate the use of strategy pattern is by a real requirement, where the final price charged to customer for an order can depend on a promotional strategy that we would like to offer to customer.</p><p>This example is taken from <a href="https://medium.com/u/a711f531c9b3">Luciano Ramalho ☂</a>’s book <a href="https://www.amazon.com/Fluent-Python-Concise-Effective-Programming/dp/1491946008"><strong><em>Fluent Python</em></strong></a></p><p>This book is one of the finest books on Python and I highly recommend reading this book should you consider Python Programming in your career.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd6ea16c5ce42137f4000803c1de6e24/href">https://medium.com/media/fd6ea16c5ce42137f4000803c1de6e24/href</a></iframe><p><strong>Lets look at the classes</strong><br>1. Customer class is pretty simple, its a data class <br>2. LineItem class captures the information regarding the Items<br>3. Order class has information regarding the Customer and his cart which represents list of LineItems.<br>4. LineItem class has method to calculate the price of line item based on quantity and price per quantity.<br>5. Order class has two methods, the first one is <strong>total()</strong> which finds the actual price and the other one is <strong>finalPrice()</strong> which computes price after promotional discount.</p><p>Now look at the Order class constructor , you see that we accept a parameter of type Promotion, which is an interface.</p><p>There are three promotional discount algorithms [ Strategies ] we have. <br>1. <strong>FidelityPromotion</strong>: 5% discount for customers with 1000 or more fidelity points<br>2. <strong>BulkPromotion</strong>: As the name suggests , <em>10% discount for each LineItem with 20 or more units<br>3. </em><strong>LargeOrderPromo: </strong><em>7% discount for orders with 10 or more distinct items</em></p><p>If you look at the implementation of these classes , its pretty straight forward. Have a some time glancing at these classes.</p><p>The main method , really test drives. It creates few customers with varying fidelity score, then it creates some carts for the customers. One cart is simple and its just to show the effect of FidelityPromotion. Other cart creates bulk and large orders respectively.</p><p>One interesting thing that we have done here, is we tried to find out what would have been the best promotional strategy for a given customer with specific fidelity score and a particular cart.</p><pre>fun <strong>findBestPromo</strong>(order: Order, promos: List&lt;Promotion&gt;): Sequence&lt;Pair&lt;String, Double&gt;&gt;?<br>{    <br>return promos.asSequence()<br>             .map { Pair(it.toString(),it.discount(order))}<br>             .sortedBy { it.second } <br>}</pre><p>This function gets the list of all available promos, then it finds out discount for a given order and returns a Pair to list name of the strategy used and the discount in that strategy. We sort the list of pairs using the discount which is the 2nd variable in the Pair.</p><p>Lets look at how to implement this using function rather than using classes for Promotion strategy.</p><p><strong>Changes to Promotion Interface and implementations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oU2_ghl04zZvVyZM0GhjaQ.png" /></figure><p>1.All the classes for Promotion are gone. <br>2. Interface Promotion is gone <br>3. Only methods remain as functions and each function of course gets unique name.</p><p><strong>Changes to Order Class</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzPZHO2O1wL44Ke2JeHnzw.png" /></figure><p><strong>Now Order class instead of receiving promo parameter of type Promotion, expects a function that takes Order as input and returns Double.</strong></p><p><strong>Changes to findBestPromo()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x0Ilum85zlIcejhxHKAhmA.png" /></figure><p><strong>Changes to main() method</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glI5MTFri3YS5vIGUKSSjg.png" /></figure><p>Here is the complete source code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b2fc7fc36f4cd03355d6369af4ffa8f/href">https://medium.com/media/4b2fc7fc36f4cd03355d6369af4ffa8f/href</a></iframe><p>I hope you enjoyed the article. Don’t forget to clap if you have :-)<br>I hope to explore further Kotlin and i will share as soon as i have something useful.</p><p>Please checkout my other articles and see if you like them. By the way two of them appeared in <strong>Kotlin Weekly</strong> news letter. so might be worth the read.</p><ul><li><a href="https://medium.com/@desaismital/declarative-pipelines-in-kotlin-b9e18e77f2c5">Declarative Pipelines in Kotlin</a></li><li><a href="https://medium.com/@desaismital/kotlin-coroutines-chain-of-responsibility-924a1ac95a9d">Kotlin Coroutines: Chain of Responsibility</a></li><li><a href="https://medium.com/@desaismital/understanding-suspending-functions-in-kotlin-3aae4bfd9991">Understanding suspending functions in Kotlin</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=861957403c11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Coroutines: Chain of Responsibility]]></title>
            <link>https://medium.com/@desaismital/kotlin-coroutines-chain-of-responsibility-924a1ac95a9d?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/924a1ac95a9d</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Fri, 11 Jan 2019 14:39:41 GMT</pubDate>
            <atom:updated>2019-01-11T14:39:41.839Z</atom:updated>
            <content:encoded><![CDATA[<p>How to implement chain of responsibility pattern using kotlin coroutines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*BbI4XZ13aUW_Tz_S-TRPnA.png" /></figure><p>kotlin has supports both object oriented programming and functional programming paradigms.<br>In this post we will look at how to make use of functional programming aspect of kotlin to implement <strong>Chain of Responsibility</strong> pattern.</p><p><strong>What is chain of Responsibility ? <br>Client can emmit different events and there are different handlers in the system which can handle only one type of event respectively.</strong></p><p>The basic idea is , there are different type of events, that flow through a chain of handlers as shown in the above figure. <strong>If handler-1 is able to handle the event, it gets consumed by it, but if handler-1 is not able to handle the event, it passes the event to handler-2 </strong>which is next in the chain and this continues through the chain till the event gets handled by one of the handlers in the chain and if no suitable handler found, event simply gets discarded.</p><p>If you would like to see , how its implemented in Java, please take a look at <a href="https://www.journaldev.com/1617/chain-of-responsibility-design-pattern-in-java">this post</a> linked below</p><p><a href="https://www.journaldev.com/1617/chain-of-responsibility-design-pattern-in-java">Chain of Responsibility Design Pattern in Java - JournalDev</a></p><p><strong>The key takeaways : </strong><br>1. Define an interface with abstract method that allows for an option to set next element in chain<br>2. Also interface should have abstract method to identify whether, the current handler can handle the event or not<br>3. All the participating handlers in the system implement the above interface<br>4. Then create concrete handlers and create a chain by calling setNext() on the previous handler object.</p><p><strong>Interface</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IiWBabiNvt9rr3AJKyIQQ.png" /></figure><p><strong>Handler-1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*flMQB024-Gd2mH0gF0sKdA.png" /></figure><p><strong>Handler-2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMn05MNqfiQI5_vnsW0IuQ.png" /></figure><p><strong>Chain</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lr-DoAHnkdNGtyr7TuBOsg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4e1R9IV9p4bvI17sOIE2ZQ.png" /></figure><p>Well now that you know, how to implement a chain of responsibility, lets see how we can make kotlin coroutines based chain.</p><p>Checkout the previous post to understand suspending functions in kotlin.</p><p><a href="https://medium.com/@desaismital/understanding-suspending-functions-in-kotlin-3aae4bfd9991">Understanding suspending functions in Kotlin</a></p><p>Now lets go into the details. Every handler is a generator and that generator accepts another handler as its input.</p><p>Again the example that we are showing here is , we are reading lines from <strong>access-log.txt and feeding it to our chain.</strong></p><p><strong>firstHandler ():</strong> handles lines starting with character “2” <br><strong>secondHandler ():</strong> handles lines starting with character “7”<br><strong>thirdHandler ():</strong> handles lines starting with character “8”</p><p>In this case Generator accepts a String and produces a String. Here we are assuming that our events are type String.</p><p>CanHandle() is a function that accepts a lambda, that determines if a particular handler is able to handle a particular event.</p><p>Now all that is remaining is creating a chain, line no 55 to 57 do exactly that.<br>If you have followed previous post , you already know that, a generator that is only created is really of no use. Its lazy :-)</p><p>Thats why on line 69, we start all the generators , which causes all of them to be suspended at yield() statements respectively for each.</p><p>Now all that is left is , read each line in file and feed it to our pipeline.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/052f43fdc10a09278df122fdc8f7c8ff/href">https://medium.com/media/052f43fdc10a09278df122fdc8f7c8ff/href</a></iframe><p>There is nothing wrong in following the same way as it was implemented in Java, this is just another take using coroutines in Kotlin. Its wonderful to explore such possibilities and its fun.</p><p>Thats it for the post. I hope you really like it and if you do, please don’t forget to clap for it. You can follow me on twitter <a href="https://medium.com/u/1b7ecfd2b3e6">Smital Desai</a>.</p><p>Read the previous posts here at <a href="https://medium.com/@desaismital">https://medium.com/@desaismital</a><br>Thank you so much for reading. Please don’t forget to let me know what do you think in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=924a1ac95a9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding suspending functions in Kotlin]]></title>
            <link>https://medium.com/@desaismital/understanding-suspending-functions-in-kotlin-3aae4bfd9991?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aae4bfd9991</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlindev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Wed, 09 Jan 2019 17:19:55 GMT</pubDate>
            <atom:updated>2019-01-13T13:34:32.912Z</atom:updated>
            <content:encoded><![CDATA[<p>What does it really mean ? when code gets suspended who gains the control ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*VnHYj6Or4aLTUGv9nGxjRQ.jpeg" /></figure><p>Frankly speaking when i heard of this term of suspending functions , it didn’t really resonate with me. I had questions such as <br><strong>1. What does it really mean for a function to be a suspending function ? </strong><br><strong>2. If it gets suspended , who gets the control ? </strong><br><strong>3. how does a suspended function gets resumed ? Who resumes it ?</strong></p><p>I came across this interesting post on stack overflow <a href="https://stackoverflow.com/questions/44214004/kotlin-alternative-to-pythons-coroutine-yield-and-send">https://stackoverflow.com/questions/44214004/kotlin-alternative-to-pythons-coroutine-yield-and-send</a></p><p>This code shows the usage of generator as shown. While the next snippet shows the implementation of ES6-style generator.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e23614d9c52c11cc5dd83cf45199f76d/href">https://medium.com/media/e23614d9c52c11cc5dd83cf45199f76d/href</a></iframe><p>As the comment tells this is an implementation of ES6-style generator. Basically ES6-style generator not only produces values but also allows other code interacting with it to pass the values to generator as well. Just the way as shown in the example above.</p><p><strong>While there is comment that …</strong><br>This code works just as well as its Python version, however it is not idiomatic for multitude of reasons ….(Read through stack overflow comment) <strong>I find thats this code really helps us understand what a suspending function is ?</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/165ab5c8089427f6d4ede25444bcb9c4/href">https://medium.com/media/165ab5c8089427f6d4ede25444bcb9c4/href</a></iframe><p>So lets turn our attention to what a suspending function is ?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e89f3675c16eabdd5fb21fecfc3d1f3b/href">https://medium.com/media/e89f3675c16eabdd5fb21fecfc3d1f3b/href</a></iframe><p>When you <strong>load the above code in Intellij</strong> , you will find that the <strong>yield()</strong> is a suspending function. <strong>The arrow with ~</strong> , in the left column points to the places in code where the code will be suspended because of a call to suspending function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzoURoKo7Lsj_dqkt10I0Q.png" /></figure><p>So lets try to address <strong>What is suspending function ? <br></strong>A suspending function is a function which instead of running to completion voluntarily releases control back to caller.</p><p>Lets focus on main() function now and see how this is true.<br>line 27 , really calls kotlincoro() function but<strong> instead of running to completion, what gets returned is a generator</strong>. <strong>Nothing interesting happens apart from this. Not a single line in the function kotlincoro() gets executed yet. Whaaaaaaaaat ? yes thats true.</strong></p><p>When g.next(“”) gets called on line 31, thats when the kotlincoro() function gets executed and with the call to<strong> yield(“hello”)</strong> it suspends and returns control back to main() function and this string <strong>“hello”</strong> gets assigned to variable <strong>val initdata</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rp49aMlFMNnvGo03WEIqkg.png" /></figure><p>Now since the control is in main function , we might wonder when is the rest of the code of the kotlincoro() gets executed ? Ie When does kotlincoro() resumes its execution [ Remember its suspended at yield(“Hello”) ]</p><p>The answer is it depends on the main() function. So nothing gets executed in kotlincoro() unless main() function calls g.next(“whats up) on line 35<br>Now the control goes back to kotlincoro() and the line 9 in the snippet collects the string “whats up” in variable <strong>val coroData</strong></p><p>Now the control is in kotlincoro() , when does the rest of the main() function gets executed ? it really depends if the kotlincoro() suspends again or not ? <br>Now in our case , kotlincoro() runs till line 16 and suspends on yield(“Bye”)</p><p>Main function receives this value in variable <strong>val data </strong>on line 35 and runs till line no 39 where we send another value “Howdy there ?” to kotlincoro() which is suspended on line 16 , which upon receiving the value , runs till completion and control again returns back to main.</p><p>So to recap answers to our questions</p><ol><li><strong>What does it really mean for a function to be a suspending function ?</strong>The function is said to be a suspending function, if instead of running to completion it relinquishes control back to driver.</li></ol><p><strong>2. If it gets suspended , who gets the control ?<br></strong>When a suspending function gets suspended, the driver gets control. The reason i am using the term driver instead of caller , is we are driving kotlincoro() function through many suspension points using g.next() <br>Remember when g = kotlincoro() gets executed , a generator gets created and nothing interesting happens , till we drive the generator using g.next()</p><p><strong>3.how does a suspended function gets resumed ? Who resumes it ?<br></strong>Again, as mentioned in the above answer, its the driver who resumes the execution of suspended function from previous suspension point.</p><p>Now if you have stuck with me this far, I really hope that , lets look at the output of the program</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FSHrH2jx-76oirEzVp6hSg.png" /></figure><p>If you give a careful thought , it might be important to notice that coroutines with the suspending functions need to be run under the guidance of driver. Otherwise its not really possible for them to proceed. Thats where event loops come into the picture.</p><p>I hope that , this has given you something to think more about coroutines.<br>With that i would like to thank you for reading this post.</p><p>In the next post, I will try to demonstrate , how to create an event loop and run multiple coroutines and sort of achieve Round-Robin schedular using generators and event loop.</p><p>You can also check out my other articles as well and see if you like them as well.</p><ul><li><a href="https://medium.com/@desaismital/kotlin-coroutines-chain-of-responsibility-924a1ac95a9d">Kotlin Coroutines: Chain of Responsibility</a></li><li><a href="https://medium.com/@desaismital/declarative-pipelines-in-kotlin-b9e18e77f2c5">Declarative Pipelines in Kotlin</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aae4bfd9991" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Declarative Pipelines in Kotlin]]></title>
            <link>https://medium.com/@desaismital/declarative-pipelines-in-kotlin-b9e18e77f2c5?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9e18e77f2c5</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Sat, 05 Jan 2019 04:43:45 GMT</pubDate>
            <atom:updated>2019-01-13T13:48:43.002Z</atom:updated>
            <content:encoded><![CDATA[<p>Attempt to demonstrate usefulness of generators in kotlin..</p><p>If you have done any kind of web development, you must have seen how the access logs on the server looks like. If not below is the snapshot of access-log file.</p><p><strong>Each in in the file has the below format </strong><br>Ip address : date: time: HTTP method : End point : Response : Bytes Transferred.</p><p>Now lets say that the task given is to find total number of bytes transferred during all the hits to all end points. We must remember the fact that these access-log files can be really large so reading an entire file in memory to read the bytes and then aggregating them to get the total count can put too much of burden on Ram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mTIyl-2Yx7XmkbL3tMcYPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HyDeTXh1fxkIXWqTnanMSw.png" /></figure><p>Now lets see how we can go about building a pipeline which is memory efficient during the processing of the file.<br>I would highly recommend this episode of fragmented podcast <br><a href="https://fragmentedpodcast.com/tag/sequence/">https://fragmentedpodcast.com/tag/sequence/</a> to get to know more about sequences which form the foundation of the pipeline.<br>I am attaching <a href="https://medium.com/u/b85c7e530b1f">Kaushik Gopal</a>’s notes from the podcast episode which are essential to understand and he has done a fantastic job in explaining it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cw40A-Eyd1MJqrExi1ZyEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_Up88lyaxv6Mjp73uTZKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oeaWJwghZqm-uLYQzH0X7Q.png" /></figure><p><strong>Here are the important takeaways </strong><br>1. Sequences are evaluated lazily <br>2. Sequences are not useful without a terminating operation. Examples sum / min / max <br>3. Intermediate operations on Sequences wont result in temporary lists being created <strong>[ This is where the memory saving comes ]</strong></p><p>With these two important takeaways pipeline is just chaining of two or more sequences.<br>To be more specific we build a sequence from first function and feed it as an input to the next function resulting into an efficient data processing pipeline.</p><p><strong>Lets look at individual functions forming a stage in pipeline.</strong><br><strong>getLines() : </strong>This function doesn’t read entire file but just returns a sequence using file.bufferedReader().lineSequence() and we use yield(line) to feed that line to the next stage.</p><p><strong>getBytesColumn() :</strong> This function reads a single line at a time from getLines() function and gets only the last column [ Remember this is sequence and not an intermediate list. so its cheap on memory ].</p><p><strong>getBytes():</strong> If you look at the screenshot below, some log lines don’t have bytes at the last column. look at last three lines. We skip those lines while getting bytes. [ Remember this is sequence and not an intermediate list. so its cheap on memory ].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OTO77erR2hQ5uNfEC7LNA.png" /></figure><p>Now since we are at the last stage of pipeline which has sequence of bytes , all that is remaining is we compute the sum. ie the terminating operation. <br>#2 point in our important takeaways while working with sequences.<br>You will be surprised but this is the operation that drivers even the first line that is read from access-log , till this operation is invoked , not a single line is read from the log file.<br>Basically the entire pipeline is consumer driven.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b7ad7c3a34dd3ead0036e83d42bc41e/href">https://medium.com/media/3b7ad7c3a34dd3ead0036e83d42bc41e/href</a></iframe><p>No matter how big the access-log file is , you now have a way to deal with it in memory efficient way.<br>Now i could have used fluent api to do all of these in chain operation but declarative way like this communicates the purpose about what we are trying to achieve at any stage and it becomes easier to reason about and debug especially if there are too many stages involved in the pipeline.</p><p>I hope you enjoyed the article. Don’t forget to clap if you have :-)<br>I hope to explore further on sequences and generators in Kotlin and i will share as soon as i have something useful.</p><p>Please checkout my other articles and see if you like them. By the way one of them appeared in <strong>Kotlin Weekly</strong> news letter.</p><ul><li><a href="https://medium.com/@desaismital/understanding-suspending-functions-in-kotlin-3aae4bfd9991">Understanding suspending functions in Kotlin</a></li><li><a href="https://medium.com/@desaismital/kotlin-coroutines-chain-of-responsibility-924a1ac95a9d">Kotlin Coroutines: Chain of Responsibility</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9e18e77f2c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responder — Part-9]]></title>
            <link>https://medium.com/@desaismital/responder-part-9-d3d7bb360a29?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3d7bb360a29</guid>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Sat, 27 Oct 2018 12:28:59 GMT</pubDate>
            <atom:updated>2018-10-27T12:28:59.864Z</atom:updated>
            <content:encoded><![CDATA[<h3>Responder — Part-9</h3><p>If you just started following the series , its good to look at previous posts to get up to speed.</p><ol><li><a href="https://medium.com/@desaismital/responder-9e6f6457633d">Setup: Part 1</a></li><li><a href="https://medium.com/@desaismital/responder-part-2-8c45733f4fd1">Responder: Part 2</a></li><li><a href="https://medium.com/@desaismital/responder-part-3-8dddd377ccc1">Responder: Part 3</a></li><li><a href="https://medium.com/@desaismital/responder-part-4-342db5f284c1">Responder: Part 4</a></li><li><a href="https://medium.com/@desaismital/responder-part-5-3881a3273e1b">Responder: Part 5</a></li><li><a href="https://medium.com/@desaismital/responder-part-6-a504970591f0">Responder: Part 6</a></li><li><a href="https://medium.com/@desaismital/responder-part-7-3a095f7a9f9d">Responder: Part 7</a></li><li><a href="https://medium.com/@desaismital/responder-part-8-28aef4aab81c">Responder: Part 8</a></li></ol><pre>git checkout 671499bb43a2ab3fdf780cc5d392c7025bbcfc9f1</pre><p>As we know that Responder plans first class support to GraphQL, we see this dependency getting added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwo9z6sjcIxQ7vXTrxUQCA.png" /></figure><p>why ? cause this is the one which powers GraphQL support for following web frameworks. Take a look at their <a href="https://github.com/graphql-python/graphql-server-core">repo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9KgWcOtdG5qEBGGl-t_3rg.png" /></figure><p>Then we see that , we allow <strong>add_route </strong>method in api.py to accept <strong>graphiql=True / False</strong> , at present its unused but there is already a comment to support <a href="https://graphql.github.io/swapi-graphql/">graphiql</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0niFrya2WJQ8eXkbV7Yfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jyc5CRW4QxQGVmkcslM0PA.png" /></figure><p>Now lets look at how do we make use of the <strong>graphql-server-core</strong> package</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*38EsXwV700k9rzI327l0Bw.png" /></figure><p>Apart from this , there are some minor changes done to hardcoded <strong>autoencoding = False</strong> option in <strong>Jinja2</strong> support</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ad_i-gQc9XIwqKi6aj6SSg.png" /></figure><p>And few changes done to Request class from models.py , pretty self explanatory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMcPdSzxo8LGCiYIXBuFpQ.png" /></figure><p>Thats it really there is to this commit , as the commit message says <strong>“Working Order” . </strong>I really hope you are enjoying the series just as me and so much learning. I will see you in the next post. Till then happy learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3d7bb360a29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responder — Part-8]]></title>
            <link>https://medium.com/@desaismital/responder-part-8-28aef4aab81c?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/28aef4aab81c</guid>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Wed, 24 Oct 2018 14:33:03 GMT</pubDate>
            <atom:updated>2018-10-24T14:33:03.322Z</atom:updated>
            <content:encoded><![CDATA[<h3>Responder — Part-8</h3><p>If you just started following the series , its good to look at previous posts to get up to speed.</p><ol><li><a href="https://medium.com/@desaismital/responder-9e6f6457633d">Setup: Part 1</a></li><li><a href="https://medium.com/@desaismital/responder-part-2-8c45733f4fd1">Responder: Part 2</a></li><li><a href="https://medium.com/@desaismital/responder-part-3-8dddd377ccc1">Responder: Part 3</a></li><li><a href="https://medium.com/@desaismital/responder-part-4-342db5f284c1">Responder: Part 4</a></li><li><a href="https://medium.com/@desaismital/responder-part-5-3881a3273e1b">Responder: Part 5</a></li><li><a href="https://medium.com/@desaismital/responder-part-6-a504970591f0">Responder: Part 6</a></li><li><a href="https://medium.com/@desaismital/responder-part-7-3a095f7a9f9d">Responder: Part 7</a></li></ol><pre>git checkout 749a7efdef1770177b211a05aa2451e752638de1</pre><p>So this commit is all about supporting templates. So what are templating engines, lets look at the information present on <a href="https://www.fullstackpython.com/template-engines.html">full stack python</a></p><h3>Template Engines</h3><p>Template engines take in tokenized strings and produce rendered strings with values in place of the tokens as output. Templates are typically used as an intermediate format written by developers to programmatically produce one or more desired output formats, commonly HTML, XML or PDF.</p><p>Well what are the commonly seen templating engines in Python. This content is taken from <a href="https://www.fullstackpython.com/template-engines.html">full stack python</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1C0cDoJZ7COYkWE8l3aC9Q.png" /></figure><h3>Other Python template engine implementations</h3><p>There are numerous Python template engine implementations that range from weekend hacks to actively developed mature libraries. These template engines are listed alphabetically:</p><ul><li><a href="https://chameleon.readthedocs.io/en/latest/">Chameleon</a> is an HTML and XML template engine that supports both <a href="https://www.fullstackpython.com/python-2-or-3.html">Python 2 and 3</a>.</li><li><a href="https://pythonhosted.org/Cheetah/">Cheetah</a></li><li><a href="http://docs.diazo.org/en/latest/">Diazo</a></li><li><a href="https://pypi.org/project/evoque/">evoque</a></li><li><a href="https://genshi.edgewall.org/">Genshi</a></li><li><a href="https://github.com/breily/juno">Juno</a></li><li><a href="https://pythonhosted.org/Myghty/whatsitdo.html">Myghty</a></li><li><a href="https://pypi.org/project/pyratemp/0.3.2">pyratemp</a></li><li><a href="https://github.com/defunkt/pystache">pystache</a></li></ul><p>Now the question comes which templating engine is supported by Responder ? — <strong>Jinja2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60TDRvoGRDfHsBNJ6lT6Ew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z62Z0mPKe57595ESwK4IEw.png" /></figure><p>In app.py, we see the template method added.</p><p>Based on the doc: <a href="http://jinja.pocoo.org/docs/2.10/api/#basics">http://jinja.pocoo.org/docs/2.10/api/#basics</a> , we see that we need to create environment , which requires a loader for which we use a FilesystemLoader and autoescape flag which is set to True by default which is a sane choice based on the doc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Ti49obt1LrqJIvHMuGq7w.png" /></figure><p>If you want to know more about Auto-Escaping vs Manual Escaping ….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lb9DeZ-vT9tckPryFhxBhg.png" /></figure><p>Okies now as far as how to use the templating , its pretty simple</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IdRhLs7EWkjynzel_5RZw.png" /></figure><p>Thats it for this post , i really hope you are enjoying the series just as me and so much learning. I will see you in the next post. Till then happy learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28aef4aab81c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responder — Part-7]]></title>
            <link>https://medium.com/@desaismital/responder-part-7-3a095f7a9f9d?source=rss-e1c9d9b2149a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a095f7a9f9d</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Smital Desai]]></dc:creator>
            <pubDate>Tue, 23 Oct 2018 14:02:00 GMT</pubDate>
            <atom:updated>2018-10-23T14:02:00.834Z</atom:updated>
            <content:encoded><![CDATA[<h3>Responder — Part-7</h3><p>If you just started following the series , its good to look at previous posts to get up to speed.</p><ol><li><a href="https://medium.com/@desaismital/responder-9e6f6457633d">Setup: Part 1</a></li><li><a href="https://medium.com/@desaismital/responder-part-2-8c45733f4fd1">Responder: Part 2</a></li><li><a href="https://medium.com/@desaismital/responder-part-3-8dddd377ccc1">Responder: Part 3</a></li><li><a href="https://medium.com/@desaismital/responder-part-4-342db5f284c1">Responder: Part 4</a></li><li><a href="https://medium.com/@desaismital/responder-part-5-3881a3273e1b">Responder: Part 5</a></li><li><a href="https://medium.com/@desaismital/responder-part-6-a504970591f0">Responder: Part 6</a></li></ol><pre>git checkout 90eecdaa848b166ebcacedf0c8b49b0a2d65c36b</pre><p>Mount other WSGI apps.</p><p>To be fair when i looked at for the first time i was not really sure about what does it mean to mount other WSGI app. So i decided to look at documentation before diving into changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xb71O1VCJWNo9uQTPNcPrg.png" /></figure><p>So lets look at the changes , we imported <strong>DispatchMiddleware class</strong> from werkzeug. Lets see what does it really do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJXx2LoruGebcInrDpdvkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EoHYGcOmXFNjdhJg6EvDRw.png" /></figure><p>So what we see is class DispatcherMiddleware needs to arguments as shown in above screenshot.</p><ol><li>Main app</li><li>Mount point Dictionary { path : corresponding wsgi app }</li></ol><p>Okies so we need to store the default wsgi app we wish to create and then add other WSGI apps to it using the DispatcherMiddleware class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wlH0DZUhUelIK_eUze_zA.png" /></figure><p>Now</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SL1xaWj_YBMyviVRJBeBtg.png" /></figure><p>Here comes the final function that ties all the things together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LzUTaQ0R4ZNE8drGR1E2jg.png" /></figure><p>So with every new WSGI app that needs to be mounted on separate path, all we do is we just update the self.apps dictionary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xb71O1VCJWNo9uQTPNcPrg.png" /></figure><pre>So this is how the contents of self.apps will look after requesting to mount multiple WSGI apps.</pre><pre>{ <br>   “/”       : self._wsgi,<br>   “/flask”  : flask,<br>   “/pyramid”: pyramid<br>} </pre><p>Thats it for this post , i really hope you are enjoying the series just as me and so much learning.</p><p>I will see you in the next post. Till then happy learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a095f7a9f9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>