<?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 Iman Dolatkia on Medium]]></title>
        <description><![CDATA[Stories by Iman Dolatkia on Medium]]></description>
        <link>https://medium.com/@iman.dolatkia?source=rss-d4de3b385dde------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*v4H9siNFupmSXNSUl9m3-Q.jpeg</url>
            <title>Stories by Iman Dolatkia on Medium</title>
            <link>https://medium.com/@iman.dolatkia?source=rss-d4de3b385dde------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:41:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iman.dolatkia/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[Baselines For Multiple Build Variants (For Android Lint)]]></title>
            <link>https://medium.com/@iman.dolatkia/baselines-for-multiple-build-variants-for-android-lint-9b8931e40aa4?source=rss-d4de3b385dde------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b8931e40aa4</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[linter]]></category>
            <category><![CDATA[baseline]]></category>
            <category><![CDATA[lint]]></category>
            <dc:creator><![CDATA[Iman Dolatkia]]></dc:creator>
            <pubDate>Thu, 28 Oct 2021 20:39:31 GMT</pubDate>
            <atom:updated>2021-10-28T20:39:52.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gmey2gc__Y5S_MRIU5PQJg.jpeg" /><figcaption><a href="https://github.com/imandolatkia/baselines-for-multiple-build-variants">github link</a></figcaption></figure><p>check in <a href="https://github.com/imandolatkia/baselines-for-multiple-build-variants">github link</a></p><h3>What is android lint?</h3><p>Lint easy learning: <a href="https://medium.com/swlh/what-is-android-lint-17fa0d87abb2">https://medium.com/swlh/what-is-android-lint-17fa0d87abb2</a></p><p>Lint official google doc: <a href="https://developer.android.com/studio/write/lint">https://developer.android.com/studio/write/lint</a></p><h3>What is Baseline?</h3><p>According to google doc: You can take a snapshot of your project’s current set of warnings, and then use the snapshot as a baseline for future inspection runs so that only new issues are reported. The baseline snapshot lets you start using lint to fail the build without having to go back and address all existing issues first. To create a baseline snapshot, modify your project’s build.gradle file as follows.</p><pre>android {<br>    lintOptions {<br>        baseline file(&quot;lint-baseline.xml&quot;)<br>    }<br>}</pre><h3>Now, what is the problem?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/0*MTFbtoFabgNmPPtZ.gif" /></figure><p>If you have multiple build variants in your app and have specific codes for them, you can’t create a separate baseline for them. Because, according to the google doc, you can define only one baseline in the project. It means that every time you change build variants, you may see a new lint error that is not in the baseline.</p><h3>So, how solve the problem?</h3><p>check in <a href="https://github.com/imandolatkia/baselines-for-multiple-build-variants">github link</a></p><p>1- add the following function to your app-level build.gradle file:</p><pre>def getPath() {<br>    Gradle gradle = getGradle()<br>    String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()<br>    Pattern pattern<br>    String path<br>    String fileName = &quot;lint-baseline&quot;</pre><pre>    if (tskReqStr.contains(&quot;assemble&quot;))<br>        pattern = Pattern.compile(&quot;assemble(\\w+)(Release|Debug)&quot;)<br>    else if (tskReqStr.contains(&quot;generate&quot;))<br>        pattern = Pattern.compile(&quot;generate(\\w+)(Release|Debug)&quot;)<br>    else if (tskReqStr.contains(&quot;lint&quot;))<br>        pattern = Pattern.compile(&quot;lint(\\w+)(Release|Debug)&quot;)</pre><pre>    if(pattern != null) {<br>        Matcher matcher = pattern.matcher(tskReqStr)</pre><pre>        if (matcher.find()) {<br>            path = matcher.group(1).toLowerCase() + matcher.group(2).toLowerCase()<br>            return &quot;lint-baselines/${path}-${fileName}.xml&quot;<br>        } else {<br>            return &quot;lint-baselines/${fileName}.xml&quot;<br>        }<br>    }<br>    return &quot;lint-baselines/${fileName}.xml&quot;<br>}</pre><p>this function creates a specific path for each build variants. you can customize the file name by changing the “fileName” variable.</p><p>2- add the following line to lintOption scop of your app-level build.gradle file:</p><pre>lintOptions {<br>        ...<br>        // Use (or create) a baseline file for issues that should not be reported<br>        baseline file(&quot;${getPath()}&quot;)<br>        ...<br>    }</pre><p>3- run linter for each of build varients.</p><p>for example type the following command in the terminal tab of Android studio in the root of project:</p><p>gradlew app:lintMyAppRelease</p><p>app = your module name</p><p>MyAppRelease = your build varient</p><p>4- Done</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*OhZ8cBIFtw4JPR9H.gif" /></figure><h3>Github link:</h3><p><a href="https://github.com/imandolatkia/baselines-for-multiple-build-variants">https://github.com/imandolatkia/baselines-for-multiple-build-variants</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b8931e40aa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create endless fullScreen cardViewPager in Android]]></title>
            <link>https://medium.com/@iman.dolatkia/how-to-create-endless-fullscreen-cardviewpager-in-android-4011161a359b?source=rss-d4de3b385dde------2</link>
            <guid isPermaLink="false">https://medium.com/p/4011161a359b</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[viewpager2]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[endless]]></category>
            <dc:creator><![CDATA[Iman Dolatkia]]></dc:creator>
            <pubDate>Thu, 28 Oct 2021 20:24:24 GMT</pubDate>
            <atom:updated>2021-10-28T20:27:55.322Z</atom:updated>
            <content:encoded><![CDATA[<p>I have published an android library on GitHub. With this library, you can display application products pages with endless horizontal cards.<br><a href="https://github.com/imandolatkia/FullScreenCardViewPager_Android">https://github.com/imandolatkia/FullScreenCardViewPager_Android</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/0*fwfAdtLJtJECiQlP.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/0*QtotBwBTtg1ny1A0.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/0*_moaq68CFY0Prim4.gif" /><figcaption><a href="https://github.com/imandolatkia/FullScreenCardViewPager_Android">endless fullScreen cardViewPager in Android</a></figcaption></figure><h4><a href="https://raw.githubusercontent.com/imandolatkia/FullScreenCardViewPager_Android/master/apk/FullScreenCardViewPager.apk">Download sample APK File 📥</a></h4><h3>Features</h3><ul><li>Scale cards on scroll up.</li><li>Endless (from server or database).</li><li>Show loading card.</li><li>Floating actionbar.</li><li>Save position when fragments are changed or onConfigurationChanged() called.</li><li>Lock horizontal scroll after card expanded.</li><li>Push side cards on card scale.</li><li>Support RTL.</li><li>Support java and kotlin projects.</li><li>Easy to use (3 tiny steps).</li><li>Support API &gt; 16.</li></ul><h3>How to install?</h3><p>Add the following line to the app-level build.gradle file, in dependencies scope:</p><pre>dependencies {<br>    ...<br>    // add this line:<br>    implementation &quot;com.dolatkia:full-screen-card-viewpager:1.0.0&quot;<br>}</pre><h3>How to use it in 3 steps?</h3><p>Our library is based on RecyclerView, we need a RecyclerView.Adapter for each card. So let&#39;s start:</p><h4>Step 1</h4><p>Add FullScreenCardViewPager to your Fragment/Activity layout xml file:</p><pre>&lt;com.dolatkia.horizontallycardslibrary.FullScreenCardViewPager<br>        android:id=&quot;@+id/fullScreenCardViewPager&quot;<br>        android:background=&quot;@color/cards_background&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot; /&gt;</pre><h4>Step 2</h4><p>Create adapter class that extends fromFullScreenCardViewPagerAdapter and override 3 abstract methods:</p><pre>class MyFullScreenCardViewPagerAdapter(private val activity: Activity) :<br>    FullScreenCardViewPagerAdapter(activity) {<br>    <br>    // list of products that you should fill it yourself<br>    private val productsList = arrayListOf&lt;Product&gt;()</pre><pre>    // you should create your own RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; for each card with the given position<br>    //data in this adapter will save<br>    override fun getCardRecyclerViewAdapter(position: Int): RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {<br>        return InnerRecyclerAdapter(activity, position, productsList[position])<br>    }</pre><pre>    // return number of cards (except loading card, loading card will add with the library)<br>    override fun getCardsCount(): Int {<br>        return productsList.size<br>    }</pre><pre>    // return View.OnClickListener to call when close button clicked<br>    override fun getOnCloseClickListener(position: Int, context: Context): View.OnClickListener {<br>        return View.OnClickListener { activity.onBackPressed() }<br>    }    <br>}</pre><p>productsList = list of products that you should fill it yourself, each product is for one card.<br>InnerRecyclerAdapter = is your custom RecyclerView.Adapter to display in each card. for more details see sample app.</p><h4>Step 3</h4><p>Set adapter created in step 2 for FullScreenCardViewPager created in step 1.</p><pre>// set customize adapter to fullScreenCardViewPager<br>// 0 = start position<br>// adapter = your customize adapter (for more details see sample app)<br>adapter = MyFullScreenCardViewPagerAdapter(this)<br>binding.fullScreenCardViewPager.setAdapter(adapter, 0)</pre><h4>All done :)</h4><h3>Some other settings and customization:</h3><h4>Action bar:</h4><p>If you need actionbars for cards override these two methods in your adapter:</p><pre>// create and return actionbar view<br>override fun onCreateActionBarCustomView(): View {<br>  return ItemActionbarBinding.inflate(activity.layoutInflater).root<br>}</pre><pre>// update actionbar view with relevant data<br>override fun onBindActionBarCustomView(position: Int, customView: View) {<br>  (&quot;Beautiful Chair &quot; + (position + 1).toString()).also {<br>    ItemActionbarBinding.bind(customView).title.text = it<br>  }<br>}</pre><h4>Endless cards:</h4><p>override these two methods in your adapter:</p><pre>override fun hasMoreData(): Boolean {<br>  return true<br>  // return true if you have endless cards and your data is incomplete,<br>  // return false if you don&#39;t have endless cards or you get all data or <br>}</pre><pre>// load data (from server or db) in this method and add it to the adapter<br>// you should  manage your load data sequence yourself<br>override fun loadData() {<br>  Handler(Looper.getMainLooper()).postDelayed(<br>    {<br>      addFakeItems()<br>     // call this method when new data is ready<br>      dataLoaded()<br>    },<br>    1000 // value in milliseconds<br>  )<br>}</pre><h4>Save positions:</h4><p>To save cards position and inner card scroll position when fragments are changed or onConfigurationChange() called (land&lt;-&gt;portrate), Just create customize FullScreenCardViewPagerAdapter instance in onCreate() method of the fragment to avoid recreate it. for more information see the sample app. <a href="https://github.com/imandolatkia/FullScreenCardViewPager_Android#more-demo">Demo</a></p><h4>RTL (Right To Left) scroll:</h4><p>call setRTL() method of fullScreenCardViewPager ,before set it&#39;s adapter</p><pre>binding.fullScreenCardViewPager.setRTL()<br>// setAdapter() after setRtl()<br>binding.fullScreenCardViewPager.setAdapter(adapter, 0)</pre><p>setRTL() doesn&#39;t work properly on API 28, contact me for the solution.</p><h4>Customize UI:</h4><p>To customize UI override these methods in your adapter:</p><pre>// customize distance from top to enter actionbar<br>open fun getActionBarStartAnimationOffsetThreshold(<br>  recyclerView: RecyclerView,<br>  customActionBarView: View?<br>  ): Int {<br>  return PresentationUtils.convertDpToPixel(50, recyclerView.context)<br>}</pre><pre>// customize cards background-color<br>open fun getCardsColor(position: Int, context: Context): Int {<br>  return Color.parseColor(&quot;#ffffff&quot;)<br>}</pre><pre>// customize cards top-radius <br>open fun getCardRadius(context: Context): Int {<br>  return PresentationUtils.convertDpToPixel(15, context)<br>}</pre><pre>// customize close icon<br>open fun getCloseResId(position: Int, context: Context): Int {<br>  return R.drawable.ic_close<br>}</pre><pre>// customize close color<br>open fun getCloseColor(position: Int, context: Context): Int {<br>  return Color.parseColor(&quot;#444444&quot;)<br>}</pre><h3>Github Link:</h3><p><a href="https://github.com/imandolatkia/FullScreenCardViewPager_Android">FullScreenCardViewPager_Android</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o0R_4-D3yF1capeJ" /><figcaption><a href="https://github.com/imandolatkia/FullScreenCardViewPager_Android">FullScreenCardViewPager_Android</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4011161a359b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Animated Theme Manager]]></title>
            <link>https://medium.com/@iman.dolatkia/android-animated-theme-manager-4c9770add6af?source=rss-d4de3b385dde------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c9770add6af</guid>
            <category><![CDATA[ripple]]></category>
            <category><![CDATA[themes]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Iman Dolatkia]]></dc:creator>
            <pubDate>Tue, 31 Aug 2021 09:36:17 GMT</pubDate>
            <atom:updated>2021-08-31T09:36:17.631Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="themes ripple animation" src="https://cdn-images-1.medium.com/max/227/1*55ird6pFEoyHdKOmkaKIUA.gif" /><figcaption>ripple animation for change theme</figcaption></figure><p>Sometimes your android apps may need to have multiple themes. The standard way is to use android styles and for this approach, you should define some themes in style.xml as below:</p><pre>&lt;style name=&quot;AppThemeLight&quot; parent=&quot;Theme.AppCompat.Light&quot;&gt;<br>    &lt;!-- Customize your theme here. --&gt;<br>    &lt;item name=&quot;android:windowAnimationStyle&quot;&gt;@style/WindowAnimationTransition&lt;/item&gt;<br>&lt;/style&gt;<br>&lt;style name=&quot;AppThemeDark&quot; parent=&quot;Theme.AppCompat&quot;&gt;<br>    &lt;!-- Customize your theme here. --&gt;<br>    &lt;item name=&quot;android:windowAnimationStyle&quot;&gt;@style/WindowAnimationTransition&lt;/item&gt;<br>&lt;/style&gt;<br>&lt;!-- This will set the fade in animation on all your activities by default --&gt;<br>&lt;style name=&quot;WindowAnimationTransition&quot;&gt;<br>    &lt;item name=&quot;android:windowEnterAnimation&quot;&gt;@android:anim/fade_in&lt;/item&gt;<br>    &lt;item name=&quot;android:windowExitAnimation&quot;&gt;@android:anim/fade_out&lt;/item&gt;<br>&lt;/style&gt;</pre><p>And change themes in code with this:</p><pre>setTheme(someSettings.get(PREFFERED_THEME) ? R.style.AppThemeLight : R.style.AppThemeDark);</pre><p>But to apply it you should restart the app because setTheme() needs to be called before activity setContentView().<br>To avoid restarting the app you should save the selected theme ID in some prefs when the user clicked on it and call Activity.this.recreate(), and call setTheme() before activity setContentView() according to saved data in prefs, Something like this:</p><pre>@Override<br>protected void onCreate(Bundle savedInstanceState) {<br><br>    // MUST do this before super call or setContentView(...)<br>    // pick which theme DAY or NIGHT from settings<br>    setTheme(someSettings.get(PREFFERED_THEME) ? R.style.AppThemeLight : R.style.AppThemeDark);<br><br>    super.onCreate(savedInstanceState);<br>}<br><br>// Somewhere in your activity where the button switches the theme<br>btn.setOnClickListener(new View.OnClickListener() {<br>    @Override<br>    public void onClick(View v) {<br><br>        // decide which theme to use DAY or NIGHT and save it<br>        someSettings.save(PREFFERED_THEME, isDay());<br><br>        Activity.this.recreate();<br>    }<br>});</pre><p>You can find more details here: <a href="https://stackoverflow.com/questions/30174042/how-to-switch-themes-night-mode-without-restarting-the-activity">https://stackoverflow.com/questions/30174042/how-to-switch-themes-night-mode-without-restarting-the-activity</a></p><h3>What is the problem with this approach?</h3><p><strong>setTheme()</strong> before <strong>super.onCreate(savedInstanceState)</strong> in GKA answer is the perfect approach and works well, thanks to GKA.</p><p>But it creates new instances for all resources again, including activities, fragments, and recycler views that may be heavy work and cause to loss of some saved data like local variables.</p><p>According to google document: <a href="https://developer.android.com/reference/android/app/Activity#recreate()">https://developer.android.com/reference/android/app/Activity#recreate()</a></p><blockquote><em>Cause this Activity to be recreated with a new instance. This results in essentially the same flow as when the Activity is created due to a configuration change — the current instance will go through its lifecycle to onDestroy() and a new instance then created after it.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*L28Jdo7B1uJ5k_b_MqWjZA.gif" /></figure><h3><strong>So, what is my approach?</strong></h3><p>In my approach, you can change the theme programmatically with code (Java or Kotlin), in this approach you don’t need to recreate all resources, and also you can use custom animation like ripple.</p><h3>Let’s start to make ripple animation for changing themes, without recreating resources:</h3><p>I published my approach as a public library here:</p><p><a href="https://github.com/imandolatkia/Android-Animated-Theme-Manager">https://github.com/imandolatkia/Android-Animated-Theme-Manager</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qiu9CwckObqD-AOQUP2H7A.jpeg" /><figcaption><a href="https://github.com/imandolatkia/Android-Animated-Theme-Manager">https://github.com/imandolatkia/Android-Animated-Theme-Manager</a></figcaption></figure><h4>How to install?</h4><p>Add the following line to app-level build.gradle file, in dependencies scope:</p><pre>dependencies {<br>    ...<br>    implementation &quot;io.github.imandolatkia:animatedThemeManager:1.1.2&quot;<br>}</pre><h4>How to use?</h4><p><em>If you use java check here: </em><a href="https://github.com/imandolatkia/Android-Animated-Theme-Manager"><em>java document</em></a></p><p>1- Create an abstract class that inherits from AppTheme. In this class create abstract methods to return related color for all UI element that you want to change them on each theme. For example, if you want to change the background color, text colors and icon colors in your firstActivity, do the following:</p><pre>interface MyAppTheme : AppTheme {<br>    fun firstActivityBackgroundColor(context: Context): Int<br>    fun firstActivityTextColor(context: Context): Int<br>    fun firstActivityIconColor(context: Context): Int<br>    // any other methods for other elements<br>}</pre><p>2- For each theme that you want in your app, create a class that extends from the class that was created in step 1 (MyAppTheme), and implement methods with related colors or resources, for example, if you want to have 3 themes, you should create 3 class and implement methods:</p><pre>class LightTheme : MyAppTheme {</pre><pre>    override fun id(): Int { // set unique iD for each theme <br>        return 0<br>    }</pre><pre>    override fun firstActivityBackgroundColor(context: Context): Int {<br>        return ContextCompat.getColor(context, R.color.background_light)<br>    }</pre><pre>    override fun firstActivityTextColor(context: Context): Int {<br>        return ContextCompat.getColor(context, R.color.text_light)<br>    }<br>    <br>     override fun firstActivityIconColor(context: Context): Int {<br>        return ContextCompat.getColor(context, R.color.icon_light)<br>    }<br>    <br>    ...<br>}</pre><pre>class NightTheme : MyAppTheme {...}<br>class PinkTheme : MyAppTheme {...}</pre><p>3- Extend your activity from ThemeActivity:</p><pre>MainActivity : ThemeActivity() {<br>...<br>}</pre><p>4- Implement ThemeActivity’s 2 abstract methods:</p><pre>// to sync ui with selected theme<br>override fun syncTheme(appTheme: AppTheme) {<br>    // change ui colors with new appThem here</pre><pre>    val myAppTheme = appTheme as MyAppTheme<br>    // set background color<br>    binder.root.setBackgroundColor(myAppTheme.firstActivityBackgroundColor(this))</pre><pre>    //set text color<br>    binder.text.setTextColor(myAppTheme.activityTextColor(this))<br>        <br>    // set icons color<br>    binder.share.setColorFilter(myAppTheme.firstActivityIconColor(this))<br>    binder.gift.setColorFilter(myAppTheme.firstActivityIconColor(this))        <br>    ...<br>}</pre><pre>// to get the start theme<br>override fun getStartTheme(): AppTheme {<br>    return LightTheme()<br>}</pre><p>5- Change theme with the ThemeManager.instance.changeTheme() method:</p><pre>// set change theme click listener<br>binder.lightButton.setOnClickListener {<br>  ThemeManager.instance.changeTheme(LightTheme(), it)<br>}</pre><p>The first argument is the selected theme.<br>The second argument is the view that animation starts from the center of it.</p><p>Done</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*qebyvEb_ue5bKG_PiJnJNw.gif" /></figure><h3>How to use in multi fragments app?</h3><p>Repeat all previous 5 steps, and then:</p><p>6- Extend your fragments from ThemeFragment:</p><pre>MyFragment : ThemeFragment() {<br>...<br>}</pre><p>7- Implement ThemeFragment syncTheme abstract methods:</p><pre>// to sync ui with selected theme<br>override fun syncTheme(appTheme: AppTheme) {<br>    // change ui colors with new appThem here<br>    ...<br>}</pre><h3>Some other settings and customization:</h3><h4>✔️ reverse animation</h4><p>If you want to use the reverse animation, call reverseChangeTheme() instead of changeTheme():</p><pre>binder.lightButton.setOnClickListener {<br>        ThemeManager.instance.reverseChangeTheme(LightTheme(), it)<br>   }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*nHJWqZqu7u9I5YP7.gif" /></figure><h4>✔️ change animation duration</h4><p>If you want to change the animation duration, add your desired duration in milliseconds as the third argument of ThemeManager.instance.changeTheme(). The default value is 600:</p><pre>binder.lightButton.setOnClickListener {<br>        ThemeManager.instance.changeTheme(LightTheme(), it, 800)<br>   }</pre><h4>✔️ change animation center position</h4><p>If you want to start animation somewhere other than the view that clicked, send a Coordinate object instead of a View in ThemeManager.instance.changeTheme()</p><pre>binder.lightButton.setOnClickListener {<br>          binder.nightButton.setOnClickListener {<br>            ThemeManager.instance.changeTheme(NightTheme(), Coordinate(10, 20)<br>        }<br>   }</pre><p>witch the Coordinate is:</p><pre>Coordinate(var x: Int, var y: Int)</pre><h4>✔️ observe changes of themes yourself</h4><p>If you want to observe changes of themes and do some custom action, you can use theme Livedata in any fragment or activity:</p><pre>ThemeManager.instance.getCurrentLiveTheme().observe(this) {<br>        Toast.makeText(this, &quot;on Theme changed to ${it.id()}&quot;, Toast.LENGTH_SHORT).show()<br>    }</pre><h4>✔️ set animation listener</h4><p>If you want to set an animation listener, use setThemeAnimationListener() method in your activity</p><pre>setThemeAnimationListener(MyThemeAnimationListener(this))</pre><p>witch the MyThemeAnimationListener is:</p><pre>class MyThemeAnimationListener(var context: Context) : ThemeAnimationListener{<br>        override fun onAnimationStart(animation: Animator) {<br>           Toast.makeText(context, &quot;onAnimationStart&quot;, Toast.LENGTH_SHORT).show()<br>        }</pre><pre>        override fun onAnimationEnd(animation: Animator) {<br>            Toast.makeText(context, &quot;onAnimationEnd&quot;, Toast.LENGTH_SHORT).show()<br>        }</pre><pre>        override fun onAnimationCancel(animation: Animator) {<br>            Toast.makeText(context, &quot;onAnimationCancel&quot;, Toast.LENGTH_SHORT).show()<br>        }</pre><pre>        override fun onAnimationRepeat(animation: Animator) {<br>            Toast.makeText(context, &quot;onAnimationRepeat&quot;, Toast.LENGTH_SHORT).show()<br>        }<br>    }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c9770add6af" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>