<?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 Mohit Rajput on Medium]]></title>
        <description><![CDATA[Stories by Mohit Rajput on Medium]]></description>
        <link>https://medium.com/@mohitrajput987?source=rss-49a9fa9ed7ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oVcQMHLLrQHjTyA2.</url>
            <title>Stories by Mohit Rajput on Medium</title>
            <link>https://medium.com/@mohitrajput987?source=rss-49a9fa9ed7ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:10:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohitrajput987/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[From Material 2 to Material You: Everything New in Material 3 for Android Developers]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@mohitrajput987/from-material-2-to-material-you-everything-new-in-material-3-for-android-developers-58de8055fe94?source=rss-49a9fa9ed7ce------2"><img src="https://cdn-images-1.medium.com/max/1000/0*ePyM9s42VCcbMgf_.png" width="1000"></a></p><p class="medium-feed-snippet">What is Material 3?</p><p class="medium-feed-link"><a href="https://medium.com/@mohitrajput987/from-material-2-to-material-you-everything-new-in-material-3-for-android-developers-58de8055fe94?source=rss-49a9fa9ed7ce------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@mohitrajput987/from-material-2-to-material-you-everything-new-in-material-3-for-android-developers-58de8055fe94?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/58de8055fe94</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[material-design]]></category>
            <category><![CDATA[graphic-design]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 10:40:54 GMT</pubDate>
            <atom:updated>2025-11-15T10:40:54.018Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Avoid Unnecessary Recomposition]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@mohitrajput987/avoid-unnecessary-recomposition-a2b8755da2bb?source=rss-49a9fa9ed7ce------2"><img src="https://cdn-images-1.medium.com/max/1536/1*kDVczVa2-6xUC79XBSbtzA.png" width="1536"></a></p><p class="medium-feed-snippet">While writing code in Jetpack Compose, developers often make mistakes that lead to unnecessary recomposition, resulting in bad performance.</p><p class="medium-feed-link"><a href="https://medium.com/@mohitrajput987/avoid-unnecessary-recomposition-a2b8755da2bb?source=rss-49a9fa9ed7ce------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@mohitrajput987/avoid-unnecessary-recomposition-a2b8755da2bb?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2b8755da2bb</guid>
            <category><![CDATA[recomposition]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 05:38:01 GMT</pubDate>
            <atom:updated>2025-10-30T05:38:01.574Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Debugging Recompositions in Jetpack Compose]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@mohitrajput987/debugging-recompositions-in-jetpack-compose-b780e4e41a41?source=rss-49a9fa9ed7ce------2"><img src="https://cdn-images-1.medium.com/max/1536/1*70B8tNT-7IR18-h1aBlbHg.png" width="1536"></a></p><p class="medium-feed-snippet">If you&#x2019;ve ever wondered, &#x201C;Why is my composable recomposing so many times?&#x201D;&#x200A;&#x2014;&#x200A;you&#x2019;re not alone &#x1F605;</p><p class="medium-feed-link"><a href="https://medium.com/@mohitrajput987/debugging-recompositions-in-jetpack-compose-b780e4e41a41?source=rss-49a9fa9ed7ce------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@mohitrajput987/debugging-recompositions-in-jetpack-compose-b780e4e41a41?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/b780e4e41a41</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 12:50:06 GMT</pubDate>
            <atom:updated>2025-10-28T12:50:06.010Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Android 15 (API Level 35) Target SDK Deadline: What’s New, What’s Critical, and How to Prepare]]></title>
            <link>https://medium.com/@mohitrajput987/android-15-api-level-35-target-sdk-deadline-whats-new-what-s-critical-and-how-to-prepare-d394c441aa4e?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/d394c441aa4e</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[google-play-store]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Tue, 05 Aug 2025 12:49:31 GMT</pubDate>
            <atom:updated>2025-08-05T12:49:31.402Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKdJY-PkU6Pnrj3xlcNX2w.png" /></figure><h3>🚀 Introduction</h3><p>As Google continues to tighten Play Store policies and elevate the Android experience, developers must adapt to new system behaviors. With <strong>API Level 35 (Android 15)</strong> rolling out, apps must meet <strong>targetSdkVersion requirements</strong> to remain compliant and performant. In this blog, we’ll explore what’s changed, why it matters, and how to migrate smoothly before the Play Console deadline.</p><h3>📊 Deadline Highlights</h3><p><strong>Google Play Deadline:</strong></p><ul><li><strong>New apps</strong> must target <strong>API 35</strong> by <strong>August 2025</strong>.</li><li><strong>Updates to existing apps</strong> must also comply with this requirement by the same deadline.</li><li><strong>Extensions</strong> are possible via a form for critical use cases, but <strong>Play Store visibility will be restricted</strong> otherwise.</li></ul><h3>🔄 Major Changes in API 35</h3><h4>1. Foreground Service Restrictions</h4><ul><li>New foreground service types enforced.</li><li>Misuse will lead to runtime exceptions.</li><li>Introduce WorkManager or JobScheduler as alternatives.</li></ul><h4>2. Background Activity Launch Restrictions</h4><ul><li>Apps can no longer launch activities from the background without explicit user interaction.</li><li>Use notifications or full-screen intents for high-priority tasks.</li></ul><h4>3. String Formatting Changes</h4><ul><li>String.format() now throws exceptions for format mismatches in more strict scenarios.</li><li>Important for apps localizing to multiple languages.</li></ul><h4>4. Improved Privacy Sandbox</h4><ul><li>Includes UI consistency, ad tracking limitations, and changes to permission flow.</li></ul><h4>5. More Strict Permissions and Scoped Storage Rules</h4><ul><li>Enhanced enforcement of scoped storage and granular media permissions.</li></ul><h4>6. Predictive Back Support (Optional but recommended)</h4><ul><li>Integrate animations and navigation transitions using OnBackInvokedCallback APIs.</li></ul><h3>🔧 Migration Checklist</h3><ul><li>Update targetSdkVersion to 35 in build.gradle</li><li>Test foreground services behavior thoroughly</li><li>Validate background activity use cases</li><li>Review all string formatting logic</li><li>Verify new permissions are requested only when needed</li><li>Enable predictive back support where suitable</li></ul><h3>✅ Best Practices</h3><ul><li><strong>Use Jetpack Libraries:</strong> Most are already API 35-ready</li><li><strong>Feature flags:</strong> Gradually toggle features to test Android 15-specific behavior</li><li><strong>Compose &amp; Material3:</strong> Move to Jetpack Compose and Material3 to avoid layout inconsistencies</li><li><strong>Crashlytics + Firebase Test Lab:</strong> Monitor real-device crashes after the upgrade</li></ul><h3>⚠️ Common Pitfalls to Avoid</h3><ul><li>Calling startActivity() from services or background receivers</li><li>Missing new foreground service types in your manifest</li><li>Forgetting to request updated permissions (e.g. READ_MEDIA_IMAGES instead of READ_EXTERNAL_STORAGE)</li></ul><h3>⏳ Tools &amp; Resources</h3><ul><li><a href="https://developer.android.com/about/versions/15/behavior-changes-all">Official API 35 Behavior Changes</a></li><li><a href="https://developer.android.com/guide/components/foreground-services#types">Foreground Service Types</a></li><li><a href="https://developer.android.com/about/versions/15/behavior-changes-15#permissions">Permission Changes</a></li></ul><h3>🌍 Final Thoughts</h3><p>Migrating to API 35 is not just about compliance, but an opportunity to deliver better performance, security, and user experience. Don’t wait for the deadline — start testing your app today and share your learnings with the community.</p><h3>📣 Spread the Word</h3><p>If this blog helped you, share it with fellow devs and let’s raise awareness about API 35 changes.</p><p>Want a checklist or migration script? DM me on <a href="https://www.linkedin.com/in/mohitrajput987/">LinkedIn</a> or leave a comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d394c441aa4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Kotlin Coroutines in Android: A Practical Guide]]></title>
            <link>https://medium.com/@mohitrajput987/mastering-kotlin-coroutines-in-android-a-practical-guide-4fa497b92d88?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fa497b92d88</guid>
            <category><![CDATA[coroutines-in-kotlin]]></category>
            <category><![CDATA[coroutine]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Sun, 04 May 2025 18:11:57 GMT</pubDate>
            <atom:updated>2025-05-04T18:11:57.838Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern Android development is all about writing <strong>clean, efficient, and asynchronous code</strong> — and Kotlin Coroutines have become the go-to tool for that. If you’re tired of callback hell and want to write <strong>non-blocking, readable code</strong>, coroutines are your best friend.</p><p>In this post, we’ll cover:</p><ul><li>✅ What are Coroutines?</li><li>🔁 Coroutine vs Thread</li><li>🧭 Coroutine Scope</li><li>🚀 launch vs async</li><li>🔄 withContext</li><li>⚠️ Exception handling</li><li>📱 Real-world Android examples</li></ul><h3>🌱 What is a Coroutine?</h3><p>A <strong>coroutine</strong> is a <strong>lightweight thread</strong> that can be suspended and resumed. It allows you to perform long-running tasks like network calls or database operations <strong>without blocking the main thread</strong>.</p><p><strong>Coroutine = Co + routine,</strong> i.e., it’s the cooperation among routines(functions).</p><p>Think of it as a function that can <strong>pause</strong> mid-way and <strong>resume</strong> later, keeping your UI responsive. Coroutine is a framework that is built on traditional thread for ease of work.</p><pre>GlobalScope.launch {<br>    val data = fetchDataFromNetwork()<br>    updateUI(data)<br>}</pre><h3>🧵 Coroutine vs Thread</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBaX3cKwBOhvUQJegMuuRQ.png" /></figure><p>Coroutines <strong>don’t create new threads</strong> — they efficiently use existing ones via dispatchers.</p><h3>🧭 Coroutine Scope</h3><p>A <strong>CoroutineScope</strong> defines the lifecycle of a coroutine. If the scope is canceled, so are all its coroutines.</p><h3>Common scopes:</h3><ul><li>GlobalScope: Application-wide (⚠️ Avoid in Android)</li><li>lifecycleScope: Tied to Activity/Fragment</li><li>viewModelScope: Tied to ViewModel lifecycle</li></ul><pre>viewModelScope.launch(Dispatchers.IO) {<br>    val user = userRepository.getUser()<br>    _userState.value = user<br>}</pre><h3>🚀 launch vs async</h3><p>Both start coroutines, but differ in intent:</p><h3>🔹 launch: fire-and-forget</h3><ul><li>Doesn’t return a result</li><li>Ideal for background tasks</li></ul><pre>launch {<br>    saveDataToDb()<br>}</pre><h3>🔹 async: returns a Deferred</h3><ul><li>Used when you need a result</li></ul><pre>val deferred = async {<br>    fetchDataFromApi()<br>}<br>val result = deferred.await()</pre><p>You can call functions concurrently using async. Here is the example:</p><pre>class UserViewModel : ViewModel() {<br><br>private val _userInfo = MutableLiveData&lt;String&gt;()<br>    val userInfo: LiveData&lt;String&gt; get() = _userInfo<br>    fun loadUserData() {<br>        viewModelScope.launch {<br>            val userDeferred = async { fetchUser() }<br>            val settingsDeferred = async { fetchUserSettings() }<br>            try {<br>                val user = userDeferred.await()<br>                val settings = settingsDeferred.await()<br>                _userInfo.value = &quot;User: $user, Settings: $settings&quot;<br>            } catch (e: Exception) {<br>                _userInfo.value = &quot;Error: ${e.message}&quot;<br>            }<br>        }<br>    }<br>    // Simulated suspending functions<br>    private suspend fun fetchUser(): String {<br>        delay(1000) // Simulate network/API delay<br>        return &quot;Alice&quot;<br>    }<br>    private suspend fun fetchUserSettings(): String {<br>        delay(1200) // Simulate network/API delay<br>        return &quot;Dark Mode&quot;<br>    }<br>}</pre><h3>🔄 withContext: for switching threads</h3><p>Switch coroutine execution to a different dispatcher.</p><pre>withContext(Dispatchers.IO) {<br>    val data = fetchData()<br>    withContext(Dispatchers.Main) {<br>        updateUI(data)<br>    }<br>}</pre><blockquote><em>✅ Use </em><em>withContext for sequential tasks. Prefer it over </em><em>async/await when there&#39;s no concurrency benefit.</em></blockquote><h3>⚠️ Exception Handling in Coroutines</h3><h3>✅ Use try-catch inside coroutine blocks</h3><pre>viewModelScope.launch(Dispatchers.IO) {<br>    try {<br>        val result = repository.getData()<br>        _dataLiveData.postValue(result)<br>    } catch (e: Exception) {<br>        _errorLiveData.postValue(&quot;Something went wrong&quot;)<br>    }<br>}</pre><h3>✅ Use CoroutineExceptionHandler for top-level coroutines</h3><pre>val exceptionHandler = CoroutineExceptionHandler { _, exception -&gt;<br>    Log.e(&quot;CoroutineError&quot;, &quot;Caught $exception&quot;)<br>}<br><br>viewModelScope.launch(Dispatchers.IO + exceptionHandler) {<br>    throw RuntimeException(&quot;Oops!&quot;)<br>}</pre><h3>📱 Real-world Example (Network + DB)</h3><pre>viewModelScope.launch(Dispatchers.Main) {<br>    try {<br>        val user = withContext(Dispatchers.IO) {<br>            val networkUser = apiService.fetchUser()<br>            userDao.insertUser(networkUser)<br>            networkUser<br>        }<br>        _userLiveData.postValue(user)<br>    } catch (e: Exception) {<br>        _errorLiveData.postValue(&quot;Failed to load user&quot;)<br>    }<br>}</pre><h3>🧼 Best Practices</h3><ul><li>Always use viewModelScope or lifecycleScope, not GlobalScope</li><li>Use Dispatchers.IO for heavy I/O tasks (network, DB)</li><li>Use withContext for sequential switching</li><li>Catch exceptions explicitly</li><li>Avoid blocking calls like Thread.sleep() inside coroutines</li></ul><h3>📚 Final Thoughts</h3><p>Kotlin Coroutines are <strong>powerful, concise</strong>, and align beautifully with <strong>modern Android architecture</strong>. Once you embrace them, you’ll write faster, cleaner, and more maintainable asynchronous code.</p><p>✍️ <em>Enjoyed this post?</em> Drop a ❤️, share it with your Android dev circle, or follow me for more practical guides.</p><p>Got questions or want advanced coroutine topics like Flow, SupervisorJob? Let me know in the comments! I will cover that in the next blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fa497b92d88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New Android Studio Logcat]]></title>
            <link>https://medium.com/@mohitrajput987/new-android-studio-logcat-20ccf2dfb5ac?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/20ccf2dfb5ac</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[intelij-idea]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Mon, 04 Sep 2023 11:16:23 GMT</pubDate>
            <atom:updated>2023-09-04T11:16:23.893Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*eSLYB8kvZzQeC_ZE.png" /></figure><p>The Android Studio Dolphin 🐬 update brought an exciting revamp to the logcat feature, but with great power comes the challenge of mastering log filtering. Many developers have found themselves swimming in a sea of logs. Fear not! Dive into this blog for a handy cheat sheet that’ll have you effortlessly surfacing the logs you need with a grin 😃.</p><h3>Filter Fields</h3><ul><li><strong>package:mine</strong> — Displays the logs of package names of currently open project.</li><li><strong>package:com.example</strong> — Displays the logs of package name specified i.e. com.example in given example.</li><li><strong>is:crash</strong> — Displays the logs related to crashes.</li><li><strong>is:stacktrace</strong> — Displays the logs of full stack trace.</li><li><strong>is:firebase</strong> — Displays the logs related to firebase.</li><li><strong>tag:AppName</strong> — Displays the logs matching log tag AppName.</li><li><strong>message:AppName</strong> — Displays the logs matching log tag AppName. If the sentence has spaces, separate the words with the slash \ sign.</li><li><strong>level:DEBUG</strong> — Displays the logs matching log level DEBUG. Other valid values are: VERBOSE, WARNING, INFO, ERROR and FATAL.</li><li><strong>age:1m</strong> — Displays the logs with a timestamp of the last 1 minute. There are following supported time units:</li><li>s — seconds</li><li>m — minutes</li><li>h — hours</li><li>d — days</li></ul><h3>Match Operators</h3><ul><li><strong>Regex</strong> — Append ~ after any field. E.g. tag~:Activity displays logs which contain log tag &quot;Activity&quot;.</li><li><strong>Exact match</strong> — Append = after any field. E.g. tag=:Activity displays logs which exactly has log tag &quot;Activity&quot;.</li><li><strong>Negation</strong> — It works like NOT operator. Prepend - to the field name. E.g. -tag:Activity displays logs which don&#39;t have the log tag &quot;Activity&quot;.</li><li><strong>Logical Operators</strong> — AND(&amp;) and OR(|) signs are supported in logs. E.g. package:mine &amp; (tag:AppName | message:This\is\sample).</li><li><strong>Space</strong> — Space is an implicit AND logical operator. E.g. package:mine tag:AppName message:Sample will evaluated as package:mine &amp; tag:AppName &amp; message:Sample .</li></ul><p>That is all about it. Before we sign off, remember that the world of Android development is full of hidden gems and ingenious tricks. Given options work till latest Android Studio G. If you’ve got some secret logcat filtering sorcery up your sleeve, don’t be shy — share it in the comments! Happy coding, and may your lines of code always compile with a sprinkle of developer magic ✨😇.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20ccf2dfb5ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authenticator in Retrofit Android]]></title>
            <link>https://medium.com/@mohitrajput987/authenticator-in-retrofit-android-6c0df3dcd500?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c0df3dcd500</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[retrofit]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Sat, 15 Apr 2023 17:51:50 GMT</pubDate>
            <atom:updated>2023-05-07T15:02:23.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*hjIkgF9ZilCAYqoT.jpeg" /></figure><p>There is a general use case in any application: the authentication token expires, and you need to refresh it internally. After refreshing the token, the API call should be executed again, and UI should be updated. Let’s understand this scenario by an example:</p><ul><li>You are building a social network application that has various functionalities, i.e. new feeds, a friend requests list, sending a friend request, seeing comments on a post, etc.</li><li>After login, you provide the user an authentication token(i.e. JWT token). This token has an expiry time of 30 mins(which could be configurable on the server side). This token should be passed in the header of each API call.</li><li>When you go to the friend requests list screen, you get 401 Unauthorized which means you need to refresh the token.</li><li>You need to update the token and make the call to the friend requests list API again and show the list in UI.</li></ul><p>The naive way of handling this is, on each API call, to make a check of the 401 status code and call the refresh token API again. After calling the API, make the call to the required API again. This code needs to be written everywhere(i.e. in each API call callback).</p><p>Does Android(more specifically, OkHttp or Retrofit) have any way to handle this scenario using a standard code?<br>The answer is <em>YES!!!</em> We have a way of handling this scenario by Retrofit using Authenticator.</p><p>You can achieve this functionality using simple steps which are described below:</p><h3>1. Method to fetch updated token</h3><p>Declare a method in the retrofit interface to fetch the updated token from the server, as shown below:</p><pre>interface UserApiService {<br>    companion object {<br>        private const val REQUEST_REFRESH_TOKEN = &quot;/oauth/token&quot;<br>    }<br><br>    @FormUrlEncoded<br>    @POST(REQUEST_REFRESH_TOKEN)<br>    fun getAuthenticationToken(@FieldMap params: HashMap&lt;String, String&gt;): retrofit2.Call&lt;AuthTokenResponse&gt;<br><br>    ...<br>}</pre><h3>2. Create an Authenticator class</h3><p>Implemented okhttp3.Authenticator interface and override authenticate() method as shown below:</p><pre>class TokenAuthenticator : Authenticator {<br>    override fun authenticate(route: Route?, response: Response): Request? {<br>        // This is a synchronous call<br>        val updatedToken = getUpdatedToken()<br>        return response.request().newBuilder()<br>                .header(ApiClient.HEADER_AUTHORIZATION, updatedToken)<br>                .build()<br>    }<br><br>    private fun getUpdatedToken(): String {<br>        val requestParams = HashMap&lt;String, String&gt;()<br>        ...<br><br>        val authTokenResponse = ApiClient.userApiService.getAuthenticationToken(requestParams).execute().body()!!<br><br>        val newToken = &quot;${authTokenResponse.tokenType} ${authTokenResponse.accessToken}&quot;<br>        SharedPreferenceUtils.saveString(Constants.PreferenceKeys.USER_ACCESS_TOKEN, newToken)<br>        return newToken<br>    }<br>}</pre><p>The authenticate() method is called when the server returns 401 Unauthorized. For calling ApiClient.userApiService.getAuthenticationToken(), we&#39;re using execute() to make it a synchronous call.</p><h3>3. Prepare OkHttp client</h3><p>Now set this TokenAuthenticator in OkHttpClient as shown below:</p><pre>OkHttpClient.Builder()<br>                .connectTimeout(TIMEOUT_IN_SECONDS.toLong(), TimeUnit.SECONDS)<br>                .readTimeout(TIMEOUT_IN_SECONDS.toLong(), TimeUnit.SECONDS)<br>                .authenticator(TokenAuthenticator())`<br>                .addInterceptor(MyInterceptor())</pre><p><em>That is it!!! 😁</em></p><h3>Token Management Logic</h3><p>When I wrote this article <a href="https://dev.to/mohitrajput987/refresh-authentication-token-in-retrofit-without-modifying-any-call-1ogb">here</a>, many developers asked me about refresh handling logic. Especially handling of parallel APIs i.e. when you call multiple APIs at a screen and all return 401, then the refresh token shouldn’t happen again and again. So I am sharing the code below which handles all such cases:</p><pre>package one.projectname.sdk.network<br><br>import kotlinx.coroutines.delay<br>import kotlinx.coroutines.runBlocking<br>import okhttp3.Authenticator<br>import okhttp3.Request<br>import okhttp3.Response<br>import okhttp3.Route<br><br>/**<br> * Created by Mohit Rajput on 09/03/21.<br> */<br>class TokenAuthenticator(<br>    private val tokenManager: TokenManager<br>) : Authenticator {<br><br>    override fun authenticate(route: Route?, response: Response): Request {<br>        synchronized(this) {<br>            val sessionData = if (isRefreshNeeded(response)) {<br>                runBlocking { getUpdatedSessionData() }<br>            } else {<br>                getExistingSessionData()<br>            }<br><br>            return response.request.newBuilder()<br>                .header(HeaderKeys.SESSION_ID, sessionData.sessionId)<br>                .header(HeaderKeys.REFRESH_ID, sessionData.refreshId)<br>                .build()<br>        }<br>    }<br><br>    private fun isRefreshNeeded(response: Response): Boolean {<br>        val oldSessionId = response.request.header(HeaderKeys.SESSION_ID)<br>        val oldRefreshId = response.request.header(HeaderKeys.REFRESH_ID)<br><br>        val updatedSessionId = tokenManager.getSessionId()<br>        val updatedRefreshId = tokenManager.getRefreshId()<br><br>        return (oldSessionId == updatedSessionId &amp;&amp; oldRefreshId == updatedRefreshId)<br>    }<br><br>    private fun getExistingSessionData(): ApiResponse.SessionData {<br>        val updatedSessionId = tokenManager.getSessionId()<br>        val updatedRefreshId = tokenManager.getRefreshId()<br>        return ApiResponse.SessionData(<br>            sessionId = updatedSessionId,<br>            refreshId = updatedRefreshId<br>        )<br>    }<br><br>    private suspend fun getUpdatedSessionData(): ApiResponse.SessionData {<br>        val refreshTokenRequest =<br>            ApiResponse.RefreshSessionRequest(tokenManager.getRefreshId())<br>        return when (val result =<br>            getResult { userApiService().refreshSession(refreshTokenRequest) }) {<br>            is ApiResult.Success -&gt; {<br>                val sessionData = result.data.data<br>                tokenManager.saveSessionId(sessionData.sessionId)<br>                tokenManager.saveRefreshId(sessionData.refreshId)<br>                delay(50)<br>                sessionData<br>            }<br>            is ApiResult.Error -&gt; {<br>                MySdk.instance().mySdkListeners?.onSessionExpired()<br>                return ApiResponse.SessionData()<br>            }<br>        }<br>    }<br><br>    private class CustomNetworkStateChecker : NetworkStateChecker {<br>        override fun isNetworkAvailable() = true<br>    }<br><br>    private fun userApiService(): UserApiService {<br>        val retrofit = RetrofitHelper.provideRetrofit(<br>            RetrofitHelper.provideOkHttpClient(CustomNetworkStateChecker(), tokenManager)<br>        )<br>        return retrofit.create(UserApiService::class.java)<br>    }<br>}</pre><p>You should give me a treat for sharing this code. 😜</p><h3>Conclusion</h3><p>Now, whenever you make an API call, i.e. friend requests list API call and get 401, the retrofit will call API to refresh the token and make the same request, i.e. friend requests list call again.<br>You do not need to handle anything on the view layer for this.</p><p>Thanks for reading this article. I hope you liked it and understood the solution easily. For any doubts or suggestions, feel free to comment.<br>If you’re new to Kotlin, you can read my previous blog <a href="https://dev.to/mohitrajput987/features-you-will-love-about-kotlin-h8o">Features You Will Love About Kotlin</a> which will give you an understanding of this beautiful language.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c0df3dcd500" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Splash Screen API from Android]]></title>
            <link>https://medium.com/@mohitrajput987/splash-screen-api-from-android-f922ed0dd515?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/f922ed0dd515</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[splash-screen]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Thu, 09 Feb 2023 18:18:03 GMT</pubDate>
            <atom:updated>2023-02-09T18:18:03.448Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Splash Screen API from Android" src="https://cdn-images-1.medium.com/max/1000/0*tVELgsxA0ROAz6TJ.png" /></figure><p>Billions of Android apps are there in the play store. Most of the apps have one thing in common, Splash Screen. Android 12 brought us the official splash screen support. Previously, we had to add a custom implementation i.e. there was no uniform way to implement it. You can also implement this feature in lower versions(minimum SDK 23) with a support library.</p><h3>Definition of the splash screen</h3><p>When your app is not in memory or its process is not active, it takes time to open. It takes time to load the first frame of your app. Till then even if you implement an activity as splash, you will see a plain white screen for some time. It’s better to show some graphical assets i.e. app logo, animation, background color, etc. to users instead of showing a white screen. This graphic is called <strong>Splash Screen</strong>.</p><p>An example of splash screen animation from Android’s official document:</p><figure><img alt="Gmail’s splash screen API demo" src="https://cdn-images-1.medium.com/max/640/0*Ncxv4eRQ-Yyem7GG.gif" /><figcaption>Splash API Example of Gmail</figcaption></figure><p>The splash screen will be shown in the following scenarios:</p><ol><li><a href="https://developer.android.com/topic/performance/vitals/launch-time#cold"><strong>Cold Start</strong></a>- A cold start refers to an app’s starting from scratch. Cold start happens in cases such as your app’s being launched for the first time since the device booted or the system killed the app.</li><li><a href="https://developer.android.com/topic/performance/vitals/launch-time#warm"><strong>Warm Start</strong></a> happens when the user backs out from the app or when the system evicts your app from memory, then the user re-launches the app.</li></ol><h3>Implementation of Splash Screen API</h3><p>Let’s do some coding together.</p><h3>Step 1:</h3><p>Add the following gradle dependency in your app level build.gradle file:</p><pre>implementation &quot;androidx.core:core-splashscreen:1.0.0-beta01&quot;</pre><p>Make sure compileSdkVersion of your app is 31 or above.</p><p>Now sync gradle.</p><h3>Step 2:</h3><p>Create a splash theme in values/themes.xml. Also, it&#39;s night mode counterpart if you are supporting night mode i.e. in values-night/themes.xml. The splash theme would look as follows:</p><pre>&lt;style name=&quot;Theme.MySplash&quot; parent=&quot;Theme.SplashScreen&quot;&gt;<br>        &lt;item name=&quot;windowSplashScreenBackground&quot;&gt;@color/purple_500&lt;/item&gt;<br>        &lt;item name=&quot;windowSplashScreenAnimatedIcon&quot;&gt;@drawable/splash_animation&lt;/item&gt;<br>        &lt;item name=&quot;postSplashScreenTheme&quot;&gt;@style/AppTheme&lt;/item&gt;<br>        &lt;item name=&quot;windowSplashScreenAnimationDuration&quot;&gt;2000&lt;/item&gt;<br>    &lt;/style&gt;</pre><p>where,</p><ul><li>windowSplashScreenBackground- is the background color of your splash screen.</li><li>windowSplashScreenAnimatedIcon- is the icon resource to display at the center of the splash screen. This could be a normal drawable icon or animated drawable or an animated vector drawable.</li><li>windowSplashScreenAnimationDuration- Duration(in milliseconds) of centre icon animation if it is animated resource. Keep in mind that, animation here will only work in Android 12 or above.</li><li>postSplashScreenTheme- This is your app theme which will be applied after the completion of the splash screen.</li></ul><h3>Step 3:</h3><p>Add this theme in AndroidManifest.xml file. Your manifest will look as follows:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    package=&quot;com.otb.splashdemo&quot;&gt;<br><br>    &lt;application<br>        android:allowBackup=&quot;true&quot;<br>        android:icon=&quot;@mipmap/ic_launcher&quot;<br>        android:label=&quot;@string/app_name&quot;<br>        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;<br>        android:supportsRtl=&quot;true&quot;<br>        android:theme=&quot;@style/Theme.MySplash&quot;&gt;<br>        &lt;activity<br>            android:name=&quot;.MainActivity&quot;<br>            android:exported=&quot;true&quot;&gt;<br>            &lt;intent-filter&gt;<br>                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br><br>                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>            &lt;/intent-filter&gt;<br>        &lt;/activity&gt;<br>    &lt;/application&gt;<br><br>&lt;/manifest&gt;</pre><p>see android:theme=&quot;@style/Theme.MySplash&quot; property.</p><h3>Step 4</h3><p>Inside the launcher activity, call the activity’s installSplashScreen() extension function before setContentView(). Below is an example:</p><pre>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        installSplashScreen()<br>        setContentView(R.layout.activity_main)<br>    }<br>}</pre><p>😃 That’s it!!! Really simple steps right?</p><h3>Advanced Steps</h3><p>Now, what if you want to keep the splash screen till loading some data from a local or remote data source? Then you can follow some advanced steps:</p><h3>Step 5</h3><p>To keep the splash screen even after the app came in process, you need to use a pre-draw listener. Modify your activity as follows:</p><pre>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        installSplashScreen()<br>        setContentView(R.layout.activity_main)<br>        setupPreDrawListener()<br>    }<br><br>    /**<br>     * Use this method only if you want to keep splash screen for longer than cold start time.<br>     * Manage `isReady` flag according to your logic.<br>     */<br>    private fun setupPreDrawListener() {<br>        // Set up an OnPreDrawListener to the root view.<br>        val content: View = findViewById(android.R.id.content)<br>        content.viewTreeObserver.addOnPreDrawListener(<br>            object : ViewTreeObserver.OnPreDrawListener {<br>                override fun onPreDraw(): Boolean {<br>                    // Check if the initial data is ready.<br>                    val isReady = true<br>                    return if (isReady) {<br>                        // The content is ready; start drawing.<br>                        content.viewTreeObserver.removeOnPreDrawListener(this)<br>                        true<br>                    } else {<br>                        // The content is not ready; suspend.<br>                        false<br>                    }<br>                }<br>            }<br>        )<br>    }<br>}</pre><h3>Step 6</h3><p>If you want to exit the splash screen with some animation, you can do this using the extension field splashScreen. This will work only for Android 12. Use the below method to create a custom exit animation:</p><pre>private fun exitWithSlideUp(){<br>        splashScreen.setOnExitAnimationListener { splashScreenView -&gt;<br>            // Create your custom animation.<br>            val slideUp = ObjectAnimator.ofFloat(<br>                splashScreenView,<br>                View.TRANSLATION_Y,<br>                0f,<br>                -splashScreenView.height.toFloat()<br>            )<br>            slideUp.interpolator = AnticipateInterpolator()<br>            slideUp.duration = 200L<br><br>            // Call SplashScreenView.remove at the end of your custom animation.<br>            slideUp.doOnEnd { splashScreenView.remove() }<br><br>            // Run your animation.<br>            slideUp.start()<br>        }<br>    }</pre><p>For the ease of my readers, I have created <a href="https://github.com/mohitrajput987/splash-api-demo">Splash Demo GitHub Repo</a> where you can see an example implementation of splash screen API.</p><h3>Conclusion</h3><p>The first impression is the last impression. If a user sees a blank screen upon launching the app, it will create a bad impact. To provide a better user experience, the splash screen is a very useful API. To read more about the splash screen, you can read the <a href="https://developer.android.com/guide/topics/ui/splash-screen">official document</a>.<br>Blog’s banner credit goes to <a href="https://wajahatkarim.com/2019/12/revisited-a-guide-on-splash-screen-in-android-in-2020/">Wajahat Karim</a>. Originally posted on my <a href="https://dev.to/mohitrajput987/new-splash-screen-api-from-android-4m3n">dev.to</a> account.<br>Thanks for reading my blog. 😇😇😇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f922ed0dd515" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event Bus Pattern in Android Using Kotlin Flows]]></title>
            <link>https://medium.com/@mohitrajput987/event-bus-pattern-in-android-using-kotlin-flows-1fe0c6ca08c8?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fe0c6ca08c8</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[flow]]></category>
            <category><![CDATA[eventbus]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Sun, 25 Dec 2022 11:37:52 GMT</pubDate>
            <atom:updated>2022-12-25T11:37:52.212Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*1vns5OUQRymBKu7H.png" /></figure><p>The event bus design pattern is very popular and advantageous in programming. The publishers trigger events and subscribers can listen to those events from anywhere. It reduces unnecessary coupling. With the arrival of observers and other frameworks, this design pattern is in less use nowadays. To achieve broadcasting of events in Android, we already had the following options:</p><ul><li>RxBus</li><li>Local Broadcast</li><li>Third parties i.e. green robot etc.</li></ul><p>While Kotlin is gaining popularity, language is providing so many cutting-edge frameworks. Flow is one of them. Kotlin released a stable version of StateFlow and SharedFlow with the language’s 1.4 release. We can achieve the EventBus design pattern using SharedFlow and leverage the benefits of language and framework.</p><h3>Implementation</h3><p>You can achieve an event bus using shared flow using the following easy steps:</p><h3>Step 1:</h3><p>Create a generic event bus class as follows:</p><pre>object EventBus {<br>  private val _events = MutableSharedFlow&lt;Any&gt;()<br>  val events = _events.asSharedFlow()<br><br>  suspend fun publish(event: Any) {<br>    _events.emit(event)<br>  }<br><br>  suspend inline fun &lt;reified T&gt; subscribe(crossinline onEvent: (T) -&gt; Unit) {<br>    events.filterIsInstance&lt;T&gt;()<br>      .collectLatest { event -&gt;<br>        coroutineContext.ensureActive()<br>        onEvent(event)<br>      }<br>  }<br>}</pre><p>Here, the publish method posts an event passed as a parameter. Subscribe method collects those events. It does some utility work i.e. filtering correct event, ensuring coroutine context is active or not then providing events on the onEvent() method. Moreover, you can collect public events shared flow variable to apply custom logic if needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/0*TMf-Zmo7lfbiZcrM.png" /><figcaption>Flow of an Event Bus</figcaption></figure><h3>Step 2:</h3><p>Create an event class as follows:</p><pre>data class LoginEvent(<br>  val userId: String,<br>  val userName: String<br>)</pre><p>Ideally, your event classes would be data classes as in any event, you would require some data. But it could be any kind of class.</p><h3>Step 3:</h3><p>Now use those methods to publish and subscribe to events. Creating a separate class would be preferred as per module or feature. One example is as follows:</p><pre>class LoginEventHandler {<br>  suspend fun postLoginEvent(loginEvent: LoginEvent) {<br>    EventBus.publish(loginEvent)<br>  } <br><br><br>  fun subscribeLoginEvent(lifecycleOwner: LifecycleOwner) {<br>    lifecycleOwner.lifecycleScope.launch {<br>      EventBus.subscribe&lt;LoginEvent&gt; { loginEvent -&gt;<br>        Log.d(&quot;LoginEventHandler&quot;, &quot;${loginEvent.userName} logged-in successfully&quot;)<br>      }<br>    }<br>  }<br>}</pre><p>And that’s it!!! 🥳🥳🥳</p><h3>Conclusion</h3><p>Event bus has been a debatable topic among developers. 😑</p><p>Some say it should not be followed because it could act as a single point of failure. Sometimes, it could be hard to debug what is the source of the event.<br>However, it is widely accepted and useful for many use cases i.e. updating UI on internet connectivity changes, refreshing UI on login once login popup dismisses i.e. in e-commerce apps, etc. In my opinion, don’t be too dependent on it. Use it as minimally as possible. Your opinion and approaches are welcome in the comments. 😊</p><p>You can check more blogs at <a href="https://dev.to/mohitrajput987">https://dev.to/mohitrajput987</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fe0c6ca08c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RecyclerView pagination scroll listener in Android]]></title>
            <link>https://medium.com/@mohitrajput987/recyclerview-pagination-scroll-listener-in-android-98e14ce911b?source=rss-49a9fa9ed7ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/98e14ce911b</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mohit Rajput]]></dc:creator>
            <pubDate>Mon, 28 Nov 2022 17:40:03 GMT</pubDate>
            <atom:updated>2022-11-28T17:40:03.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvCK78nhOYZyYELrC8R-Uw.png" /></figure><h3>What is pagination</h3><p>Loading a list of items in batches instead of loading all items in a single go is called pagination. When you open the Gmail web app, you see 50 emails by default on a single page. To see the 51st mail, you have to click on the next page button.</p><h3>Why pagination</h3><p>Consider in your Gmail account, there are about one thousand plus emails. Loading all a thousand emails at once will have the following drawbacks:</p><ul><li>Database read operation will be very costly. So you will get a list with a great amount of latency.</li><li>After fetching the list, rendering a large number of items in a single go can slow down GUI.</li></ul><h3>Ways to use pagination</h3><p>In Android, there are two ways to implement pagination:</p><ol><li>Using jetpack’s paging library. You can see the detailed implementation of the paging library using MVVM in my other blog <a href="https://dev.to/mohitrajput987/android-app-with-mvvm-room-paging-koin-coroutine-live-data-gom">Paging with MVVM and coroutines</a>.</li><li>Using our own implementation of RecyclerView scroll listener.</li></ol><h3>Simple scroll listener</h3><p>This article focuses on our own implementation. There are many ways to implement logic inside the scroll listener of RecyclerView. I have created a generic implementation of scroll listener which you can simply copy-paste into your code:</p><pre>/**<br> * Created by Mohit Rajput on 20/03/22.<br> * Used for the load more functionality.<br> */<br>abstract class PaginationScrollListener(private val layoutManager: LinearLayoutManager) :<br>    RecyclerView.OnScrollListener() {<br><br>    override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {<br>        super.onScrolled(recyclerView, dx, dy)<br>        val visibleItemCount: Int = layoutManager.childCount<br>        val totalItemCount: Int = layoutManager.itemCount<br>        val firstVisibleItemPosition: Int = layoutManager.findFirstVisibleItemPosition()<br>        if (!isLoading() &amp;&amp; !isLastPage()) {<br>            if (visibleItemCount + firstVisibleItemPosition &gt;= totalItemCount<br>                &amp;&amp; firstVisibleItemPosition &gt;= 0<br>            ) {<br>                loadMoreItems()<br>            }<br>        }<br>    }<br><br>    protected abstract fun loadMoreItems()<br>    abstract fun isLastPage(): Boolean<br>    abstract fun isLoading(): Boolean<br>}</pre><p>Here is an example usage of this scroll listener:</p><pre>private var isLoadingEmails = false<br>private val viewModel by viewModels&lt;EmailsViewModel&gt;()<br><br>private fun addScrollListener() {<br>        recyclerView.addOnScrollListener(object :<br>            PaginationScrollListener(recyclerView.layoutManager as LinearLayoutManager) {<br>            override fun loadMoreItems() {<br>                viewModel.fetchEmails()<br>            }<br><br>            override fun isLastPage() = viewModel.isAllEmailLoaded<br><br>            override fun isLoading() = isLoadingEmails<br>        })<br>    }</pre><h3>Explanation</h3><ul><li>When you start loading the list, set isLoadingEmails value to true. Once loaded, set it to false. This can be managed by view state triggered through live data or state flow.</li><li>viewModel.isAllEmailLoaded value depends on API call implementation. If your API provides the total count of list items, you can simply implement it as isAllEmailLoaded = currentList.size == totalListItems.</li><li>This implementation is for LinearLayoutManager only. I will provide an efficient code for GridLayoutManager soon.</li></ul><h3>Conclusion</h3><p>Load more or pagination is a widespread concept that almost every app uses. We write the code of the scroll listener again and again. So I created a small generic class that structures the load more so that it can be reused easily. If loading is in progress, it will not make a loading call simultaneously. <br>Thanks for the reading. 😊😊😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98e14ce911b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>