<?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 Dan Nesfeder on Medium]]></title>
        <description><![CDATA[Stories by Dan Nesfeder on Medium]]></description>
        <link>https://medium.com/@daniel.nesfeder?source=rss-d38215941cf4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rbE77OaAyQPO7EsJj3crQg.jpeg</url>
            <title>Stories by Dan Nesfeder on Medium</title>
            <link>https://medium.com/@daniel.nesfeder?source=rss-d38215941cf4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 14:12:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@daniel.nesfeder/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[Android: Compose UI Screenshot Testing with Firebase Test Lab and CircleCI]]></title>
            <link>https://medium.com/@daniel.nesfeder/android-compose-ui-screenshot-testing-with-firebase-test-lab-and-circleci-a4a7165cf3e4?source=rss-d38215941cf4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4a7165cf3e4</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[compose]]></category>
            <dc:creator><![CDATA[Dan Nesfeder]]></dc:creator>
            <pubDate>Tue, 04 Jan 2022 20:51:47 GMT</pubDate>
            <atom:updated>2022-01-04T20:53:56.833Z</atom:updated>
            <content:encoded><![CDATA[<h3>Before we begin!</h3><p>Huge shoutout and thanks to Mark Allison for <a href="https://blog.stylingandroid.com/compose-ui-snapshot-testing/">this blog post</a>. Please take a moment to read over how this screenshot test code is working — he does a great job of explaining everything you need to know about the testing itself.</p><p>The main goal of this post is to run a test using <a href="https://gist.github.com/nesfeder/fd02ef960e51f9be6c191570ecb9282f">ScreenshotComparator</a> with CircleCI and Firebase Test Lab. You can add this class to your project after you&#39;ve finished reading his post. I&#39;ve also included a gist with the code below.</p><h3>CircleCI Account</h3><p>We will need a CircleCI account to run our tests. In this post, we will be using CircleCI with Github. To sign up, follow these <a href="https://circleci.com/integrations/github/">instructions</a>. CircleCI has free tier <a href="https://circleci.com/pricing/">pricing</a> that will let us run our builds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*uLkSUuRupFyXh3sYle5QAA.png" /></figure><p>Using CircleCI, you can link an existing Github project that uses Compose. For this post, I created a project using the Empty Compose Activity and pushed it to my Github account.</p><h3>Firebase Test Lab</h3><p>Next, we need to setup and add Firebase to our project. I followed <a href="https://firebase.google.com/docs/android/setup#console">option 1</a> instructions to setup via the Firebase Console. You can create a project in your console by clicking on “Add Project”.</p><p>These instructions include adding the Firebase plugin to our Android project + the app/google-services.json you downloaded from the console setup process.</p><p>Project-level build.gradle should look something like:</p><pre>buildscript {<br>    ext {<br>        compose_version = &#39;1.0.5&#39;<br>    }<br>    repositories {<br>        <strong>google()</strong><br>        mavenCentral()<br>    }<br>    dependencies {<br>        classpath &quot;com.android.tools.build:gradle:7.0.4&quot;<br>        classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31&quot;<br>        <strong>classpath &quot;com.google.gms:google-services:4.3.10&quot;</strong><br>    }<br>}</pre><p>App-level build.gradle should look something like:</p><pre>plugins {<br>    id &#39;com.android.application&#39;<br>    id &#39;kotlin-android&#39;<br>    <strong>id &#39;com.google.gms.google-services&#39;</strong><br>    ...<br>}</pre><pre>android {<br>    ...<br>}</pre><pre>dependencies {<br>    implementation &#39;androidx.core:core-ktx:1.7.0&#39;<br>    implementation &#39;androidx.appcompat:appcompat:1.4.0&#39;<br>    implementation &#39;com.google.android.material:material:1.4.0&#39;<br>    implementation &quot;androidx.compose.ui:ui:$compose_version&quot;<br>    implementation &quot;androidx.compose.material:material:$compose_version&quot;<br>    implementation &quot;androidx.compose.ui:ui-tooling-preview:$compose_version&quot;<br>    implementation &#39;androidx.lifecycle:lifecycle-runtime-ktx:2.4.0&#39;<br>    implementation &#39;androidx.activity:activity-compose:1.4.0&#39;<br>    <br>    <strong>implementation platform(&#39;com.google.firebase:firebase-bom:29.0.3&#39;)</strong><br>    ...<br>}</pre><p>Sync your project and push it to Github to trigger a CircleCI build (if you’d like, this is more of sanity check that everything is working okay so far).</p><h3>Add screenshot test</h3><p>Like I mentioned above, make sure you’ve added app/src/androidTest/ScreenshotComparator.kt from Mark&#39;s blog post. Here is a gist of the one I ended up using for my project (I made some modifications to make it very clear where the image is placed the first time you run a test):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8feef30fce5f152fc67c3bd143c49b7e/href">https://medium.com/media/8feef30fce5f152fc67c3bd143c49b7e/href</a></iframe><p>With that added, we can write a test for the simple Greeting Composable in the MainActivity (this is generated from Empty Compose Project template):</p><pre>import androidx.compose.ui.test.junit4.createAndroidComposeRule<br>import androidx.compose.ui.test.onRoot<br>import org.junit.BeforeClass<br>import org.junit.Rule<br>import org.junit.Test</pre><pre>class GreetingTest {</pre><pre>    @get:Rule<br>    val composeTestRule = createAndroidComposeRule&lt;MainActivity&gt;()</pre><pre>    companion object {<br>        private const val TEST_TAG_NAME = &quot;Greeting&quot;</pre><pre>        @BeforeClass<br>        @JvmStatic<br>        fun clearExistingImagesBeforeStart() {<br>            clearExistingImages(TEST_TAG_NAME)<br>        }<br>    }</pre><pre>    @Test<br>    fun givenAndroidTextPassed_helloAndroidIsRendered() {<br>        composeTestRule.setContent {<br>            Greeting(&quot;Android&quot;)<br>        }</pre><pre>        <strong>assertScreenshotMatchesGolden(<br>          TEST_TAG_NAME, <br>          &quot;hello_android&quot;, <br>          composeTestRule.onRoot()<br>        )</strong><br>    }<br>}</pre><p>When you run this the first time, it will fail. And that’s because we don’t have a “golden file” in our androidTest/assets just as Mark outlined. Use the Android Studio Device File Explorer to locate the .png we generated. For our test, running on a Pixel 3, this will be called hello_android_238_52.png for the given device density.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6mp5Sue7xhY3Wb2pNB5ig.png" /></figure><p>Run the test again after the PNG has been added to /assets and it should pass ✅.</p><h3>Configure CircleCI</h3><p>Now let’s get this test running on a Pixel 3 in Firebase Test Lab.</p><p><strong>NOTE</strong>: It’s important here that the device you ran your screenshot test on locally matches the one you run in Firebase Test Lab. For this post, I used a Pixel 3 emulator. This ensures matching screen density and the PNGs match correctly.</p><h4>Project Environment Variables</h4><p>We need to add two project environment variables that will be used in our CircleCI config.yml to authenticate and use gcloud commands.</p><p>If you don’t know how to add environment variables, check out this <a href="https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project">link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*HvjG8X6vhVYgcm8tPGWPHQ.png" /></figure><p>First, is our Firebase project ID that was generated when we setup the project. You can find that right under your project name in the Firebase console (see below). It’s also in your google-services.json under project_info &gt; project_id. Add this environment variable as GOOGLE_PROJECT_ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*pkjkgde-eFL_V-txhdP7xw.png" /></figure><p>Second, we need to generate a gcloud-service-key.json. This is in the Google Cloud Platform console <a href="https://console.cloud.google.com/">https://console.cloud.google.com/</a>.</p><ol><li>Make sure your project is selected if you have multiple Cloud projects</li><li>Go to IAM &amp; Admin &gt; Service Accounts</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*8qGf4OMISvZKLynMBJTBig.png" /></figure><p>3. You should see an account already there for Firebase Admin SDK Service Agent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bTLDzNHt5Ja0jBwyEvmVQ.png" /></figure><p>Click the “snowman” on the right and Manage keys</p><p>4. Click Add Key &gt; Create New Key &gt; and use JSON recommended format</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2kVTjwGMKG6IlCBtuHhAZQ.png" /></figure><p>Save the .json file and then copy it to the environment variable GCLOUD_SERVICE_KEY.</p><p><strong>NOTE</strong>: Make sure you have a billing account linked to your Google Cloud project — I was running into an issue where it was required to run commands (even if we are within the free tier).</p><h4>Add and push config.yml</h4><p>Using the 2.0 CircleCI Android orb (see docs <a href="https://circleci.com/developer/orbs/orb/circleci/android?utm_source=google&amp;utm_medium=sem&amp;utm_campaign=sem-google-dg--uscan-en-dsa-maxConv-auth-brand&amp;utm_term=g_-_c__dsa_&amp;utm_content=&amp;gclid=Cj0KCQiA_c-OBhDFARIsAIFg3exNMhhD_L4jvwmdVn296wXH63Aa_1YL0maBfeL6CjpR3aZxcv77qOYaAj9mEALw_wcB">here</a>) we can create an android-test job that authorizes the gcloud CLI and then runs the firebase test:</p><pre>version: 2.1<br><br>orbs:<br>  android: circleci/android@2.0<br><br>jobs:<br>  android-test:<br>    executor:<br>      name: android/android-machine<br>      resource-class: xlarge<br>      tag: 2021.10.1<br>    steps:<br>      - checkout<br>      - android/restore-gradle-cache<br>      - android/restore-build-cache<br>      - run:<br>          name: Build debug APK<br>          command: |<br>            ./gradlew :app:assembleDebug<br>            ./gradlew :app:assembleDebugAndroidTest<br><strong>      - run:<br>          name: Store Google Service Account<br>          command: echo $GCLOUD_SERVICE_KEY &gt; ${HOME}/gcloud-service-key.json<br>      - run:<br>          name: Authorize gcloud and set config defaults<br>          command: |<br>            sudo gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json<br>            sudo gcloud --quiet config set project ${GOOGLE_PROJECT_ID}<br>      - run:<br>          name: Test with Firebase Test Lab (Pixel 3 API 30)<br>          command: &gt;<br>            sudo gcloud firebase test android run \<br>              --type instrumentation \<br>              --app app/build/outputs/apk/debug/app-debug.apk \<br>              --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \<br>              --device model=Pixel3,version=30,locale=en,orientation=portrait  \</strong></pre><pre>workflows:<br>  build-and-test:<br>    jobs:<br>      - android-test</pre><p>And that should be it! Once you push this config, go and check that everything is running okay and passing in CircleCI and Firebase Test Lab. Please ask any questions below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4a7165cf3e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Fragment Testing: FragmentScenario]]></title>
            <link>https://medium.com/@daniel.nesfeder/android-fragment-testing-fragmentscenario-b8079b6e09fa?source=rss-d38215941cf4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8079b6e09fa</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[architecture-components]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[fragments]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Dan Nesfeder]]></dc:creator>
            <pubDate>Mon, 21 Jan 2019 21:22:58 GMT</pubDate>
            <atom:updated>2019-01-21T21:22:58.204Z</atom:updated>
            <content:encoded><![CDATA[<p>Back in November, Google held their <a href="https://developer.android.com/dev-summit/">Android Dev Summit</a> in Mountain View. Although I did not attend, I tried to watch as many sessions as possible — they were all recorded and posted to this <a href="https://www.youtube.com/playlist?list=PLWz5rJ2EKKc8WFYCR9esqGGY0vOZm2l6e">YouTube playlist</a>.</p><p>One talk which really stood out to me was Ian Lake’s <a href="https://www.youtube.com/watch?v=2k8x8V77CrU&amp;index=53&amp;list=PLWz5rJ2EKKc8WFYCR9esqGGY0vOZm2l6e&amp;t=2079s">Single Activity: Why, When, and How</a>. I highly encourage you to give it a watch. It focused mainly on the new <a href="https://developer.android.com/topic/libraries/architecture/navigation/">Navigation Architecture Component</a> announced at I/O.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLWz5rJ2EKKc8WFYCR9esqGGY0vOZm2l6e%26start%3D2079&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2k8x8V77CrU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2k8x8V77CrU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8fcf4c4d3cf993980f1245236be57b3/href">https://medium.com/media/b8fcf4c4d3cf993980f1245236be57b3/href</a></iframe><p>In the talk, Ian touched on a lot of great features of the new component including a new way to test a givenFragment — FragmentScenario. The general gist being a FragmentScenario will launch a Fragment in an empty Activity, handling the boilerplate code that would be needed to do this with a library like <a href="https://developer.android.com/training/testing/espresso/">espresso</a>. This means we can write concise and isolated tests for ourFragments.</p><h4>Adding the dependencies:</h4><p>In your app build.gradle:</p><pre>implementation &#39;androidx.fragment:fragment:1.1.0-alpha03&#39;</pre><pre>debugImplementation &#39;androidx.fragment:fragment-testing:1.1.0-alpha03&#39;</pre><h4>Test view is displayed:</h4><p>A simple example is checking a View is displayed on when the Fragment is launched. I created a SplashFragment that is shown while asking for permissions.</p><pre>@Test<br>fun testSplashImageIsDisplayed() {<br>  <strong><em>launchFragmentInContainer</em>&lt;SplashFragment&gt;()</strong><br><br>  onView(withId(R.id.<em>splashImageView</em>)).check(matches(isDisplayed()))<br>}</pre><p>launchFragmentInContainer is the main code to look at here. When you run the test on a device, you can see this takes care of creating the empty Activity and adding the SplashFragment.</p><h4>Text arguments are displayed:</h4><p>You are able to take the tests even further — like adding custom arguments and adjusting the state of the Fragment:</p><pre>val displayText = &quot;Hello world!&quot;<br>val args = Bundle().<em>apply </em><strong>{<br>  </strong>putString(<em>DISPLAY_TEXT</em>, displayText)<br><strong>}</strong></pre><pre>val scenario = <em>launchFragmentInContainer</em>&lt;DisplayTextFragment&gt;(<strong>args</strong>)<br><strong>scenario.moveToState(Lifecycle.State.RESUMED)</strong></pre><pre>// TODO Verify text is displayed in correct view</pre><p>As the navigation architecture component becomes more popular, I’m excited to see how Android UI testing will continue to evolve. Please reach out with questions or comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8079b6e09fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android: How to set up custom Day/Night themes in your app]]></title>
            <link>https://medium.com/@daniel.nesfeder/android-how-to-set-up-custom-day-night-themes-in-your-app-2e5b8ac83277?source=rss-d38215941cf4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e5b8ac83277</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Dan Nesfeder]]></dc:creator>
            <pubDate>Wed, 25 Apr 2018 01:07:55 GMT</pubDate>
            <atom:updated>2018-04-25T01:07:55.778Z</atom:updated>
            <content:encoded><![CDATA[<p>The Android SDK offers powerful tools that enable you to set custom themes for your application UI. In this quick tutorial, we are going to take a look at how to use AppCompatDelegate#setDefaultNightMode() to switch between colors specific to day / night styles.</p><p>To demonstrate how to switch between day and night modes, we can create a simple test activity with a FloatingActionButton to toggle the modes:</p><pre>FloatingActionButton fabRefresh = findViewById(R.id.<em>fab_refresh_theme</em>);<br>fabRefresh.setOnClickListener(new View.OnClickListener() {<br>  @Override<br>  public void onClick(View view) {<br>    int currentNightMode = <strong>getCurrentNightMode()</strong>;<br>    <strong>alternateNightMode</strong>(currentNightMode);<br>  }<br>});</pre><p>To get the current night mode with getCurrentNightMode(), we can get the current Configuration from our Activity:</p><pre>private int getCurrentNightMode() {<br>  return getResources().getConfiguration().uiMode<br>    &amp; Configuration.<em>UI_MODE_NIGHT_MASK</em>;<br>}</pre><p>Alternating between day / night modes isn’t a completely straightforward process. After getting the current mode, we can run logic to get the opposite mode:</p><pre>private void alternateNightMode(int currentNightMode) {<br>  int newNightMode;<br>  if (currentNightMode == Configuration.<em>UI_MODE_NIGHT_YES</em>) {<br>    newNightMode = AppCompatDelegate.<em>MODE_NIGHT_NO</em>;<br>  } else {<br>    newNightMode = AppCompatDelegate.<em>MODE_NIGHT_YES</em>;<br>  }<br>  <strong>saveNightModeToPreferences</strong>(newNightMode);<br>  <strong>recreate()</strong>;<br>}</pre><p>The part that isn’t straightforward here is the last two lines of alternateNightMode(). In order for the new mode to take effect, we need to recreate our Activity and set the new mode before we set our layout xml. In this example, we are saving the new mode to SharedPreferences and then setting it using AppCompatDelegate#setDefaultNightMode() in our Activity#onCreate():</p><pre>@Override<br>protected void onCreate(Bundle savedInstanceState) {<br>  super.onCreate(savedInstanceState);<br>  <strong>initNightMode</strong>();<br>  setContentView(R.layout.<em>activity_day_night</em>);<br><br>  ...<br>}<br><br>private void <strong>initNightMode</strong>() {<br>  int nightMode = retrieveNightModeFromPreferences();<br>  AppCompatDelegate.<em>setDefaultNightMode</em>(nightMode);<br>}</pre><p>Now that we are successfully toggling night mode, how do we update our app style or color based on which mode is enabled? Android has a resource file qualifier that makes it simple to set up different colors specific to night mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*Vk_BSudQU2BZrAbFjggoJg.png" /></figure><p>As you can see, we have two colors.xml files, but one has (night), denoting that these colors will be used when night mode is enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plCOeCNwnaPhYZrqp0Tj6w.png" /></figure><p>The end product should look something like this — check out <a href="https://github.com/danesfeder/day-night-example">the code</a> used for this tutorial and give it a try in your own application. Thanks for checking out this post!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*oH82qOtfn28G6N1simoo_w.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e5b8ac83277" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Animations with Lottie]]></title>
            <link>https://medium.com/@daniel.nesfeder/android-animations-with-lottie-d4aa5a5f237?source=rss-d38215941cf4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4aa5a5f237</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[animation-and-design]]></category>
            <category><![CDATA[airbnb-design]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[lottie]]></category>
            <dc:creator><![CDATA[Dan Nesfeder]]></dc:creator>
            <pubDate>Wed, 30 Aug 2017 03:08:12 GMT</pubDate>
            <atom:updated>2017-08-30T03:17:47.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*1nqw5nBX6EWfWrDANvC3Ng.png" /></figure><p>Airbnb’s <a href="https://airbnb.design/introducing-lottie/">Lottie animation framework</a> uses animation data exported as JSON files from an open-source After Effects extension called <a href="https://github.com/bodymovin/bodymovin">Bodymovin</a>.</p><p>This quick tutorial will show you how to add a simple Lottie animation to your Android application.</p><p>To get started, head over to lottiefiles.com and download this animation JSON file: <a href="https://www.lottiefiles.com/433-checked-done">https://www.lottiefiles.com/433-checked-done</a>. We are going to use this green check to indicate we have clicked on an item in a RecyclerView.</p><p>Let’s then create a new project in Android Studio with the “Empty Activity” template (Min API 21). I’ve named the MainActivty, LottieActivity for the sake of this example.</p><p>First thing we can do is add the checked_done_.json to our assets directory (path: app/src/main/assets) — you will need to create this directory in your new project.</p><p>We can then compile the Lottie / RecyclerView dependencies in our build.gradle (Module: app) file and sync the project:</p><pre>dependencies {  <br>  <strong>compile &#39;com.airbnb.android:lottie:2.2.0&#39;</strong><br>  compile &#39;com.android.support:recyclerview-v7:25.3.1&#39;<br>}</pre><p>To set up a simple RecyclerView, you can follow the Android developer docs for creating lists and cards: <a href="https://developer.android.com/training/material/lists-cards.html">https://developer.android.com/training/material/lists-cards.html</a></p><p>The XML layout file used for our ViewHolders and containing the LottieAnimationView looks like this:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;RelativeLayout   xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    android:orientation=&quot;horizontal&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;wrap_content&quot;&gt;<br><br>    &lt;TextView<br>        android:id=&quot;@+id/listText&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:layout_marginStart=&quot;16sp&quot;<br>        android:textSize=&quot;18sp&quot;<br>        android:textStyle=&quot;bold&quot;<br>        android:textColor=&quot;@color/colorPrimary&quot;<br>        android:layout_centerVertical=&quot;true&quot;<br>        tools:text=&quot;Example List Text&quot;/&gt;<br><br>    <strong>&lt;com.airbnb.lottie.LottieAnimationView<br>        android:id=&quot;@+id/lottieAnimationView&quot;<br>        android:layout_width=&quot;56dp&quot;<br>        android:layout_height=&quot;56dp&quot;<br>        android:layout_marginEnd=&quot;16dp&quot;<br>        android:layout_alignParentEnd=&quot;true&quot;<br>        app:lottie_fileName=&quot;checked_done.json&quot;/&gt;</strong><br><br>&lt;/RelativeLayout&gt;</pre><p>And all of the Lottie animation logic is going to be in the RecyclerView.ViewHolder:</p><pre>class ListViewHolder extends RecyclerView.ViewHolder {<br><br>    TextView listText;<br>    private LottieAnimationView animationView;<br><br>    ListViewHolder(View itemView) {<br>        super(itemView);<br><br>        listText = (TextView) itemView.findViewById(R.id.<em>listText</em>);<br>        animationView = (LottieAnimationView) itemView.findViewById(R.id.<em>lottieAnimationView</em>);<br><br>        itemView.setOnClickListener(new View.OnClickListener() {<br>            @Override<br>            public void onClick(View view) {<br>                startCheckAnimation();<br>            }<br>        });<br>    }<br><br>    private void startCheckAnimation() {<br>        ValueAnimator animator = ValueAnimator.<em>ofFloat</em>(0f, 1f).setDuration(500);<br>        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {<br>            @Override<br>            public void onAnimationUpdate(ValueAnimator valueAnimator) {<br>                animationView.setProgress((Float) valueAnimator.getAnimatedValue());<br>            }<br>        });<br><br>        if (animationView.getProgress() == 0f) {<br>            animator.start();<br>        } else {<br>            animationView.setProgress(0f);<br>        }<br>    }<br>}</pre><p>Using a ValueAnimator, we can set the progress of the LottieAnimationView. The animation we picked works nicely because, when set to a progress 0f, it shows a grey circle to indicate “unselected.”</p><p>Once we have everything set up, it should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*WDWYTcO7TVhGeamp__6C4w.gif" /><figcaption>*Gif Frame Rate Slowed*</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4aa5a5f237" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>