<?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 Ajay on Medium]]></title>
        <description><![CDATA[Stories by Ajay on Medium]]></description>
        <link>https://medium.com/@ajay_46839?source=rss-ef77d8e59706------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3XW-M5-nBwertQl1AoiSqg.jpeg</url>
            <title>Stories by Ajay on Medium</title>
            <link>https://medium.com/@ajay_46839?source=rss-ef77d8e59706------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:57:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajay_46839/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[What is a RecyclerView and How it works internally?]]></title>
            <link>https://medium.com/tilicholabs/what-is-a-recyclerview-and-how-it-works-internally-2a1fa60399a3?source=rss-ef77d8e59706------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a1fa60399a3</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[recyclerview-in-android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Ajay]]></dc:creator>
            <pubDate>Fri, 18 Feb 2022 03:31:09 GMT</pubDate>
            <atom:updated>2022-02-21T04:24:54.967Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*P1ubv05jBhr0nNi9.png" /></figure><p>Wonder how identical horizontal/vertical list views populate in Android like how WhatsApp shows the chats/contacts list? Well, it can all be done using RecyclerView. <strong>RecyclerView is the </strong><strong>ViewGroup that contains the views corresponding to your data</strong>.</p><p>RecyclerView itself is a view added to the parent layout that holds another(card/item) layout using an adapter. Each element in the list is defined by a ViewHolder object.</p><p>RecyclerView is made by improving the efficiency of <a href="https://developer.android.com/reference/android/widget/GridView">GridView</a> and <a href="https://developer.android.com/reference/android/widget/ListView">ListView</a>. As from the name <strong>RecyclerView,</strong> it recycles the views which are out of visibility.</p><h3>Components of RecyclerView</h3><h4>Adapter</h4><p>An Adapter acts as a bridge between an AdapterView and the underlying data for that view. <strong>The adapter provides access to the data items</strong>. The Adapter is also responsible for making a View for each item in the data set.<br>Our Adapter class should extend <a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter"><strong><em>Recycler.Adapter</em></strong></a> class and override below methods for the recycler view to work</p><ul><li>onCreateViewHolder<em> </em>method prepares appropriate views for the individual data in the list.</li><li>onBindViewHolder<em> </em>method takes individual item position and holder as parameters and every visible item is filled with correct values.</li><li><em>getItemCount </em>method returns the size of the input array</li></ul><p>Every time when the user scrolls a recycler view, <em>onBindViewHolder </em>is called with the visible position and fills the layout accordingly.</p><h4>ViewHolder</h4><p>ViewHolder is a helper class for drawing the UI for individual items in the list.<br>It extends <em>RecyclerView.ViewHolder </em>class. All the UI bindings happen in this class.</p><h4>LayoutManager</h4><p>A <em>LayoutManager</em> is responsible for measuring and positioning item views within a <em>RecyclerView</em> as well as determining the policy for when to recycle item views that are no longer visible to the user.</p><p>Generally, LinearLayoutManger is used as LayoutManager for RecyclerView. We can determine the horizontal/vertical scrolling by assigning the specific LinearLayoutManager constants like LinearLayoutManager.HORIZONTAL ,LinearLayoutManager.VERTICAL , etc.</p><h3>How it works internally?</h3><p>As from the name “RecyclerView”, we know that this view recycles the views attached to it. But how does the recycling of views work? Let’s see.</p><p>Let’s say we have a list of 50 objects which are needed to be populated through RecyclerView. We will be giving all the 50 objects to the Adapter and it prepares the view based on the object. But, we can see only 5 cards at one time from a normal screen device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*sATTGbP7UNL4RoQntJY3Uw.png" /></figure><p>Here, I<strong>tem-1</strong> to<strong> Item-5</strong> are the ones that are visible on the screen. Item 6is the one that will be loaded next on the screen when we scroll up.</p><p>All the items here have their own instance of ViewHolder and the ViewHolder here is helpful for caching the specific item’s view.</p><p>So, how recycling works here?</p><ul><li><strong>Item 1</strong> to <strong>Item 5</strong> are initially loaded on the screen and <strong>Item 6</strong> is which needs to be visible when the user scrolls up which is called as <strong>Waiting view</strong>.</li><li>When the user scrolls up <strong>Item 6 </strong>is visible and <strong>Item 1</strong> goes under the top of the screen, disappears and flushes out. <strong>Item 1</strong> is now called <strong>Dirty View</strong>. <br>These steps are executed simultaneously.</li><li>When the user again scrolls down <strong>Item 6</strong> gets out of visibility and flushes out and <strong>Item 1 </strong>is loaded gets onto the screen.</li></ul><p>This happens on every scroll by the user and the view visibility changes based on the currently visible items on the screen.</p><blockquote><em>ScrapView is the view in RecyclerView which was once visible and now is not visible on the phone’s screen to the user.</em></blockquote><blockquote><em>The views which we take from scrap view collection and then after re-bound happens by the recyclerView adapter before it is drawn to the screen are called dirty views.</em></blockquote><h3>Reuse issues with RecyclerView</h3><p>There will be few reuse issue when we are dealing with RecyclerView as it reuses the other view. So, make sure that we need to clean the views on <em>onBindViewHolder </em>method.</p><p><strong>Example:</strong> Let’s take a ImageView which we need to load an image from URL using <a href="https://github.com/bumptech/glide">Glide</a>. As Glide is a image loading and caching library. <br>When same ImageView is used by two or three elements, previously loaded image is populated(due to caching) on the newly loaded ImageView. This raises an reuse issue.</p><p>To avoid this set ImageView to null or set any default image in onBindViewHolder method and then populate the image from URL once it is ready.</p><h3><strong>Conclusion</strong></h3><p>RecyclerView got improved using ViewHolder and recycling of views. We can have multiple ViewHolders for the same RecyclerView. We can specify the respective ViewHolder based on the element type.</p><h3>References</h3><ul><li><a href="https://blog.mindorks.com/how-does-recyclerview-work-internally">https://blog.mindorks.com/how-does-recyclerview-work-internally</a></li><li>Image- <a href="https://www.raywenderlich.com/">https://www.raywenderlich.com/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a1fa60399a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tilicholabs/what-is-a-recyclerview-and-how-it-works-internally-2a1fa60399a3">What is a RecyclerView and How it works internally?</a> was originally published in <a href="https://medium.com/tilicholabs">Tilicho Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android development with various languages]]></title>
            <link>https://medium.com/tilicholabs/android-development-with-various-languages-c350f302d9bf?source=rss-ef77d8e59706------2</link>
            <guid isPermaLink="false">https://medium.com/p/c350f302d9bf</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Ajay]]></dc:creator>
            <pubDate>Fri, 17 Dec 2021 10:38:40 GMT</pubDate>
            <atom:updated>2021-12-23T09:59:18.482Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*JEOpUCPLjcIOcC9P.jpg" /></figure><p>If I’m not wrong, most of us can think of only Java and Kotlin as languages when asked about Android app development, but it’s not true!</p><p>In this article, we will discuss all the languages that one can use for Android app development.</p><h3>Languages</h3><h4><a href="https://developer.android.com/studio/write/java8-support"><strong>Java</strong></a></h4><p>Java was the official programming language for Android development(replaced by Kotlin). Most of the apps in the Google play store were developed in Java.<br> <br><strong>Pros:<br>- </strong>It has the largest online community. <br>- As most of us are familiar with Java, we can easily pick the topics and learn.<br><strong>Cons:<br>- </strong>Java has many complex topics like <a href="https://www.javatpoint.com/inheritance-in-java">Inheritance</a>, Null pointer exceptions, <a href="http://tutorials.jenkov.com/java-concurrency/index.html">Concurrency</a>, etc which might make it difficult for beginners to use for development.<br> <br>It is recommended for a beginner to learn something easier and then return to Java.</p><h4><a href="https://developer.android.com/kotlin"><strong>Kotlin</strong></a></h4><p>Kotlin is the official programming language for Android Development declared by Google in 2019. It is a cross-platform language and can be used as an alternative to Java for Android development.<br> <br><strong>Pros:<br>- </strong>It uses lambda functions for any in-built operations which reduce boilerplate code and handle Null pointer exceptions using safe calls.<br><strong>-</strong> Kotlin can run on JVM.<strong> <br>- </strong>Kotlin can be recommended for beginners as it is the simplest<br><strong>Cons:<br>-</strong> It is the less familiar language for the college pass-outs compared to Java and people who are from different streams e.g. Python/Web</p><h4><a href="https://developer.android.com/studio/projects/add-native-code"><strong>C++</strong></a></h4><p>Android App development can be done using C++ using <a href="https://developer.android.com/ndk/guides">Android NDK</a>. An Android app cannot be created totally with C++ but we can create libraries that can be used in the app.<br> <br><strong>Pros:<br>-</strong> As C++ has vectors it is quicker while executing complex problems, like large array operations, dealing with large numbers<br><strong>Cons:<br>- </strong>It is more difficult to set up C++ for Android and also leads to a lot of bugs due to more complexity due to context switching from Java/Kotlin to C++.</p><h4><a href="https://dotnet.microsoft.com/en-us/apps/xamarin"><strong>C#</strong></a></h4><p>We can develop Android apps using C# as well as using <a href="https://dotnet.microsoft.com/en-us/apps/xamarin">Xamarin</a>. It has similar features as Java. Initially, C# is used to develop the Windows Application using the .NET framework. <br> <br><strong>Pros:<br>-</strong> With Xamarin, we can use the same code and develop apps on multiple platforms — Windows, iOS, tvOS, etc.<br><strong>Cons:<br>-</strong> Less community support<br><strong>-</strong> Large app sizes<br><strong>-</strong> Premium IDE(Visual studio) to access advanced developer features.</p><h4><a href="https://reactnative.dev/"><strong>JavaScript</strong></a></h4><p>JavaScript is used as the programming language for Android app development using <a href="https://reactnative.dev/">React Native</a> framework. React Native was launched by Facebook in 2015. Like Xamarin, React Native can ship iOS app as well with the same code.<br> <br><strong>Pros:<br>-</strong> Single code for multiple platforms<br><strong>-</strong> More community support<br><strong>-</strong> Live and Hot reload<br><strong>Cons:<br>-</strong> Need to customize layouts for a richer native feel.<br><strong>-</strong> Difficult to debug the code</p><h4><a href="https://dart.dev/"><strong>Dart</strong></a></h4><p>Dart is used as the programming language for Android app development using the <a href="https://flutter.dev/">Flutter</a> framework. Flutter was launched by Google in 2017. It is a trending technology in app development where we can also ship an iOS app and Web app with the same code.<br> <br><strong>Pros:<br>-</strong> Single code for multiple platforms<br><strong>-</strong> Live and Hot reload<br><strong>Cons: <br>-</strong> Less community support<br><strong>-</strong> Large app sizes</p><h4><a href="https://kivy.org/"><strong>Python</strong></a></h4><p>Android development in Python is possible because of the open-source Python library <a href="https://kivy.org/">Kivy</a>. Its initial release is in 2011 and got stable in 2019.<br> <br><strong>Pros:<br>-</strong> Single code for multiple platforms<br><strong>-</strong> Well-documented APIs <br><strong>-</strong> Design innovative user interfaces with multi-touch functionalities. <strong><br>Cons:<br>-</strong> It has a less online community. <br><strong>-</strong> It has more performance issues, is painful to run on Android <br><strong>-</strong> It is still under development.</p><h3>Recommendation</h3><p>It is better to go with Java/Kotlin as they have more online community support and are somewhat easy to develop compared to other languages.</p><p>But if you/your organization is in need of a cross-platform solution to save time and costs — go for either React Native, Flutter or Xamarin</p><h3>References</h3><p><a href="https://www.geeksforgeeks.org/top-programming-languages-for-android-app-development/">https://www.geeksforgeeks.org/top-programming-languages-for-android-app-development/</a></p><p><strong>Thanks for reading!</strong></p><p>Happy Coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c350f302d9bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tilicholabs/android-development-with-various-languages-c350f302d9bf">Android development with various languages</a> was originally published in <a href="https://medium.com/tilicholabs">Tilicho Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get server time in Android]]></title>
            <link>https://medium.com/tilicholabs/get-server-time-in-android-5723b5fb4f44?source=rss-ef77d8e59706------2</link>
            <guid isPermaLink="false">https://medium.com/p/5723b5fb4f44</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[firebaserealtimedatabase]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ajay]]></dc:creator>
            <pubDate>Tue, 23 Mar 2021 04:08:46 GMT</pubDate>
            <atom:updated>2021-03-23T04:08:46.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*5k2_oyr53gbzmKSg.png" /></figure><p>As Mobile app developers, At some point of time, we may deal with time calculation for calculating the time intervals or sending the time stamp in request to the backend, etc….</p><p>In Android, there is a possibility to alter the device time.<br>In such a case, when we request the device time we would get an invalid time from the device. This may lead to bugs in our app.</p><blockquote>For example, let’s take a very popular Indian food delivery app called Swiggy. The restaurants delivering would have a closing time and the user should be restricted from placing an order after any such time. Let’s say, we are using the System time to check whether the restaurant is closed or not and the user has changes his/her mobile time then they can actually place an order which could be a major flaw in the functioning of the app.</blockquote><p>To avoid such a flaw we should try not to use the System time that we get from the device. Instead, we should fetch the current time from any trusted server which follows the common time.</p><p>In this blog, I will be showing how we can fetch the server time from Firebase. This is a very efficient and trusted way of getting the current time.</p><p>Firstly, we have to integrate our app with Firebase by following <a href="https://firebase.google.com/docs/android/setup">this</a> documentation.<br>After the integration, add the following dependency to get access to the Firebase DB :</p><blockquote>implementation ‘com.google.firebase:firebase-database:19.6.0’</blockquote><p>After adding this dependency, we should be able to access the FirebaseDatabase class.</p><p>Add the following code to get the server time offset :</p><pre>fun getServerTime() {<br>    var serverOffset: Long<br>    FirebaseDatabase.getInstance().goOffline()<br>    FirebaseDatabase.getInstance().goOnline()<br>    val ref = FirebaseDatabase.getInstance().getReference(&quot;.info/serverTimeOffset&quot;)<br><br>    ref.addListenerForSingleValueEvent(object : ValueEventListener {<br>        override fun onCancelled(error: DatabaseError) {<br><br>        }<br><br>        override fun onDataChange(snapshot: DataSnapshot) {<br>            if (snapshot != null) {<br>                serverOffset = (snapshot.<em>value </em>as Long).toLong()<br>            }<br><br>        }<br><br>    })<br>}</pre><p>Using this function, we will get the server offset which is the difference between device time and server time.</p><p>Now to get the real-time we need to add this offset to the current system(device) time.</p><pre>val serverTime = (Date().<em>time </em>+ serverOffset)</pre><p>This function should be called at the start of our app and use the server offset wherever needed in the app.</p><p>In this way, we can get the real-time that cannot be updated by the user.</p><p>Now, there’s another case that we would need to handle if the user changes the time when the app is in the background without being killed.</p><p>For this, we need to add a broadcast receiver in our Application class to check whether the device time has changed or not like so :</p><pre>val intentFilter = IntentFilter()<br>intentFilter.addAction(Intent.<em>ACTION_TIME_CHANGED</em>)<br>registerReceiver(timeChangedBroadcastReceiver, intentFilter)</pre><p>Now if the local time is changed, the broadcast receiver would get a callback informing the device time has been changed. At this point, we can call the <strong>getServerTime()</strong> function so that we get the new offset and this offset can be used in the app.</p><p>That’s it. It’s this simple to make sure we avoid major issues with Time related functionalities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5723b5fb4f44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tilicholabs/get-server-time-in-android-5723b5fb4f44">Get server time in Android</a> was originally published in <a href="https://medium.com/tilicholabs">Tilicho Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paypal Checkout Integration in Android]]></title>
            <link>https://medium.com/tilicholabs/paypal-checkout-integration-in-android-d9cd39233893?source=rss-ef77d8e59706------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9cd39233893</guid>
            <category><![CDATA[paypal]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ajay]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 09:20:55 GMT</pubDate>
            <atom:updated>2021-03-16T09:20:55.236Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*6raMtsBn6LTQCyUFXvyh4w.jpeg" /></figure><p>Integrating Paypal in Android is quite complex because of the lack of proper documentation and also limited community support.</p><p>Recently when my team and I were trying to integrate the Paypal payment method in one of our projects we were following <a href="https://developer.paypal.com/docs/limited-release/native-checkout/android/"><strong><em>this</em></strong></a> documentation. In our use-case, the order will be created from the backend and the <strong>order_id</strong> is shared with the mobile client. Using this <strong>order_id</strong>, we need to checkout via Paypal and make the payment.</p><p>If you don’t have a backend for creating order_id you can go with <a href="https://github.com/paypal/PayPal-Android-SDK"><strong><em>Paypal SDK</em></strong></a> or try with <a href="https://developers.braintreepayments.com/guides/paypal/overview/android/v2"><strong><em>Braintree Paypal SDK</em></strong></a>.</p><p>We had followed all the steps mentioned in the documentation. We were using the native implementation with <strong>isWebView</strong> set to true</p><p>We added a redirect URI scheme as mentioned in the documentation that would be used while redirecting back to our app after the payment is completed or canceled.</p><p>The scheme should be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*gab6wvkRGmHu4QRbSPDpig.png" /></figure><blockquote>Make sure that your activity launchMode should be singleTop. <br>You need to define the merchant redirect URL as <strong>checkoutConfig.<em>merchantRedirectUrl </em>= “yourappnamepaypal://paypalxo”</strong></blockquote><p>Now, Paypal payment will redirect to your app after the payment is successful or canceled.</p><blockquote><em>After we are redirected to our app we would receive an intent which would be like so :</em><br><strong><em>yourappnamepaypal://paypalxo?token=9WH********61B&amp;PayerID=VJW*******5EC&amp;intent=sale&amp;opType=payment&amp;return_uri=</em></strong></blockquote><p>You will get this intent in <strong><em>OnNewIntent(intent: Intent). </em></strong>You need to capture this intent from the above function.</p><p>Here comes the real nightmare which we faced while capturing the payment from the frontend. We have tried using the callback listeners which actually didn’t work for payment successful or canceled.</p><p>So, We tried capturing the payments from the backend using the <strong>order_id. </strong>Paypal provides <strong>v2 API’s</strong> for capturing and authorizing the payments.</p><p>Here is the link for the Paypal v2 API’s documentation for capturing and authorizing the payments.</p><p><a href="https://developer.paypal.com/docs/api/orders/v2/"><strong><em>https://developer.paypal.com/docs/api/orders/v2/</em></strong></a></p><blockquote>Note: Make sure that you integrate these Order Capturing API’s in backend only. We should not keep the Paypal token in the frontend as the token may be misused.</blockquote><p>After capturing the payment from the backend, the response should be propagated to the mobile client informing if the order was captured successfully or not and then on the mobile client we have to update the UI based on this response.</p><p>That’s it, Paypal Checkout integration in Android is completed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*6Nss8-35ufR_F6LvxFEzbQ.gif" /></figure><p>Follow our <a href="https://medium.com/tilicholabs">Blog</a>, Like us on <a href="https://www.facebook.com/tilicholabs/">Facebook</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9cd39233893" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tilicholabs/paypal-checkout-integration-in-android-d9cd39233893">Paypal Checkout Integration in Android</a> was originally published in <a href="https://medium.com/tilicholabs">Tilicho Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>