<?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 Umang Burman on Medium]]></title>
        <description><![CDATA[Stories by Umang Burman on Medium]]></description>
        <link>https://medium.com/@umang.burman.micro?source=rss-ea54a40df7bd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*keN4YsklKJ1X5MCX0wOViw.png</url>
            <title>Stories by Umang Burman on Medium</title>
            <link>https://medium.com/@umang.burman.micro?source=rss-ea54a40df7bd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 12:34:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@umang.burman.micro/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android’s Room in Kotlin ft. MVVM Architecture and Coroutines]]></title>
            <link>https://medium.com/@umang.burman.micro/androids-room-in-kotlin-ft-mvvm-architecture-and-coroutines-4d4116e0f70f?source=rss-ea54a40df7bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d4116e0f70f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[room]]></category>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Umang Burman]]></dc:creator>
            <pubDate>Tue, 09 Jun 2020 19:10:04 GMT</pubDate>
            <atom:updated>2023-03-11T16:24:40.864Z</atom:updated>
            <content:encoded><![CDATA[<p>Kotlin + MVVM + Room + Coroutines = :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGMV3F6rMv-_v6s7MPRemw.jpeg" /><figcaption>Room + ViewModel + LiveData = MVVM</figcaption></figure><p>If you’re looking for an explanation on Room implementation on Android using Kotlin and one of it’s Coroutine feature with MVVM architecture, then this one is for you.</p><p>Let’s see what I have in store for you.</p><ol><li>What is Room, Kotlin, MVVM, Coroutines?</li><li>Advantages of Room over SQLite?</li><li>Important Annotation in Room.</li><li>Step-by-Step Simple Insert and Read Example</li><li>Conclusion</li></ol><p>So let’s get started.</p><h3><strong>What is Room, Kotlin, MVVM, Coroutines?</strong></h3><h4><strong>ROOM</strong></h4><p><strong>a. Room Database: </strong>Database layer on top of SQLite database that takes care of mundane tasks that you used to handle with an SQLiteOpenHelper. Database holder that serves as an access point to the underlying SQLite database. The Room database uses the DAO to issue queries to the SQLite database.</p><p><strong>b. Entity: </strong>When working with Architecture Components, this is an annotated class that describes a database table.</p><p><strong>c. SQLite database:</strong> On the device, data is stored in an SQLite database. For simplicity, additional storage options, such as a web server, are omitted. The Room persistence library creates and maintains this database for you.</p><p><strong>d. DAO:</strong> Data access object. A mapping of SQL queries to functions. You used to have to define these painstakingly in your SQLiteOpenHelper class. When you use a DAO, you call the methods, and Room takes care of the rest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*sFafRQ6cw3c3-LNki86DUw.png" /><figcaption>Room Architecture</figcaption></figure><h4>Kotlin</h4><p>Kotlin is an open-source, statically-typed programming language that supports both object-oriented and functional programming. Kotlin provides similar syntax and concepts from other languages, including C#, Java, and Scala, among many others. Kotlin does not aim to be unique — instead, it draws inspiration from decades of language development. It exists in variants that target the JVM (Kotlin/JVM), JavaScript (Kotlin/JS), and native code (Kotlin/Native).</p><h4>MVVM</h4><p>a. <strong>ViewModel:</strong> Provides data to the UI. Acts as a communication center between the Repository and the UI. Hides where the data originates from the UI. ViewModel instances survive configuration changes.</p><p><strong>b. LiveData:</strong> A data holder class that can be observed. Always holds/caches latest version of data. Notifies its observers when the data has changed. LiveData is lifecycle aware. UI components just observe relevant data and don’t stop or resume observation. LiveData automatically manages all of this since it’s aware of the relevant lifecycle status changes while observing.</p><p>c. <strong>Repository:</strong> A class that you create, for example using the WordRepository class. You use the Repository for managing multiple data sources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*lr_s-SM-64OuvxhyGmQ2Gw.png" /><figcaption>MVVM with ROOM</figcaption></figure><h4>Coroutines</h4><p><strong>Coroutines</strong> are a great new feature of <strong>Kotlin</strong> which allow you to write asynchronous code in a sequential fashion. … However, like RxJava, <strong>coroutines</strong> have a number of little subtleties that you end up learning for yourself during development time, or tricks that you pick up from others.</p><h3>Advantages of Room over SQLite?</h3><ul><li>In case of SQLite, There is no compile time verification of raw SQLite queries. But in Room there is SQL validation at compile time.</li><li>As your schema changes, you need to update the affected SQL queries manually. Room solves this problem.</li><li>You need to use lots of boilerplate code to convert between SQL queries and Java data objects. But, Room maps our database objects to Java Object without boilerplate code.</li><li>Room is built to work with LiveData and RxJava for data observation, while SQLite does not.</li></ul><h3>Important Annotations in Room.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*usV410Egk7ZXDaIJ8AKtmA.png" /><figcaption>Important annotations used in Room</figcaption></figure><h3>Step By Step Simple Insert and Read Example.</h3><p>Please refer to the be low Repository for Step-by-Step Implementation:</p><p>Click on the <a href="https://github.com/umangburman/MVVM-Room-Kotlin-Example">GitHub Repository of Room using Kotlin and MVVM</a></p><h3>Conclusion</h3><p>Hopefully this guide introduced you to a lesser known yet useful form of Android application data storage called <strong><em>ROOM </em></strong>with <strong><em>Kotlin</em></strong> and <strong><em>MVVM</em></strong>.</p><p>If you want to see a simplest example of MVVM in Kotlin with Retrofit, <a href="https://github.com/umangburman/MVVM-Room-Kotlin-Example">HERE IT IS</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d4116e0f70f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android’s MVVM Architecture in Kotlin ft. Retrofit]]></title>
            <link>https://medium.com/@umang.burman.micro/androids-mvvm-architecture-in-kotlin-ft-retrofit-6acc22cabfc6?source=rss-ea54a40df7bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/6acc22cabfc6</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[retrofit2]]></category>
            <category><![CDATA[example]]></category>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Umang Burman]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 18:14:11 GMT</pubDate>
            <atom:updated>2020-06-04T18:14:11.096Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uAPrx7f5vln3u3Ky6PTd5A.png" /><figcaption>Graphical Representation of MVVM Architecture</figcaption></figure><p>This example will demonstrate the working of MVVM using Live data and Retrofit in Kotlin. Just follow the steps and you will be able to try out the same in your Android Studio as well.</p><p>So Let’s Get Started:</p><ol><li>What is MVVM, LiveData, ViewModel, Model, Repository?</li><li>Implementation Step-by-Step</li><li>Conclusion</li></ol><h4><strong>1. What is MVVM, LiveData, ViewModel, Model, Repository?</strong></h4><p><strong>Answer: </strong>Let’s see what are the important concepts in MVVM.<br><strong>MVVM: Model-View-ViewModel (</strong>i.e<strong> MVVM)</strong> is a template of a client application architecture, proposed by <strong>John Gossman</strong> as an alternative to MVC and MVP patterns when using Data Binding technology. Its concept is to separate data presentation logic from business logic by moving it into particular class for a clear distinction.</p><p><strong>LiveData: </strong><a href="https://developer.android.com/reference/androidx/lifecycle/LiveData">LiveData</a> is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state.</p><p>Advantages of Using LiveData:</p><p><strong>Ensures your UI matches your data state: </strong>LiveData follows the observer pattern. LiveData notifies <a href="https://developer.android.com/reference/androidx/lifecycle/Observer">Observer</a> objects when the lifecycle state changes. You can consolidate your code to update the UI in these Observer objects. Instead of updating the UI every time the app data changes, your observer can update the UI every time there&#39;s a change.</p><p><strong>No memory leaks:</strong> Observers are bound to <a href="https://developer.android.com/reference/androidx/lifecycle/Lifecycle">Lifecycle</a> objects and clean up after themselves when their associated lifecycle is destroyed.</p><p><strong>No crashes due to stopped activities:</strong> If the observer&#39;s lifecycle is inactive, such as in the case of an activity in the back stack, then it doesn’t receive any LiveData events.</p><p><strong>No more manual lifecycle handling:</strong> UI components just observe relevant data and don’t stop or resume observation. LiveData automatically manages all of this since it’s aware of the relevant lifecycle status changes while observing.</p><p><strong>Always up to date data:</strong> If a lifecycle becomes inactive, it receives the latest data upon becoming active again. For example, an activity that was in the background receives the latest data right after it returns to the foreground.</p><p><strong>Proper configuration changes:</strong> If an activity or fragment is recreated due to a configuration change, like device rotation, it immediately receives the latest available data.</p><p><strong>Sharing resources:</strong> You can extend a <a href="https://developer.android.com/reference/androidx/lifecycle/LiveData">LiveData</a> object using the singleton pattern to wrap system services so that they can be shared in your app. The LiveData object connects to the system service once, and then any observer that needs the resource can just watch the LiveData object. For more information, see <a href="https://developer.android.com/topic/libraries/architecture/livedata#extend_livedata">Extend LiveData</a>.</p><p><strong>ViewModel: </strong>The <a href="https://developer.android.com/reference/androidx/lifecycle/ViewModel">ViewModel</a> class is designed to store and manage UI-related data in a lifecycle conscious way. The <a href="https://developer.android.com/reference/androidx/lifecycle/ViewModel">ViewModel</a> class allows data to survive configuration changes such as screen rotations.</p><p><strong>Model: </strong><a href="https://developer.android.com/reference/kotlin/androidx/compose/Model#">Model</a> can be applied to a class which represents your application’s data model, and will cause instances of the class to become observable, such that a read of a property of an instance of this class during the invocation of a composable function will cause that component to be “subscribed” to mutations of that instance. Composable functions which directly or indirectly read properties of the model class, the composables will be recomposed whenever any properties of the the model are written to.</p><p><strong>Repository: Repository</strong> modules handle data operations. They provide a clean API so that the rest of the app can retrieve this data easily. They know where to get the data from and what API calls to make when data is updated. You can consider repositories to be mediators between different data sources, such as persistent models, web services, and caches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*-yY0l4XD3kLcZz0rO1sfRA.png" /><figcaption>MVVM Flow Control</figcaption></figure><h4>2. Implementation Step-by-Step?</h4><p>As said before, this example uses MVVM with Retrofit using Kotlin. Let’s dive into the steps of doing it.</p><p>Please refer to the below Repository for Step-by-Step Implementation:</p><p><a href="https://github.com/umangburman/MVVM-Kotlin-Example">umangburman/MVVM-Kotlin-Example</a></p><h3>Conclusion</h3><p>Hopefully this guide introduced you to a better and useful form of Android application’s architectural component called MVVM in Kotlin.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6acc22cabfc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigation Drawer with Navigation Component]]></title>
            <link>https://medium.com/@umang.burman.micro/navigation-drawer-with-navigation-component-4f032bfdeae6?source=rss-ea54a40df7bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f032bfdeae6</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[navigation-arch-component]]></category>
            <category><![CDATA[navigation-drawer]]></category>
            <category><![CDATA[navigationview]]></category>
            <dc:creator><![CDATA[Umang Burman]]></dc:creator>
            <pubDate>Sun, 04 Nov 2018 12:55:59 GMT</pubDate>
            <atom:updated>2020-09-02T14:13:47.706Z</atom:updated>
            <content:encoded><![CDATA[<h3>Navigation Drawer with Navigation Components</h3><p>This is an example of <strong>Navigation Drawer with Navigation Architecture Component</strong> in Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YIQHQmS_wneHSl3Ur055OA.png" /><figcaption><a href="https://cdn-images-1.medium.com/max/2000/1*YIQHQmS_wneHSl3Ur055OA.png">Source</a></figcaption></figure><p>This is an example of <strong>Navigation Drawer with Navigation Architecture Component</strong> in Android. The Navigation Architecture Component Part of Android Jetpack.</p><p>The Navigation Architecture Component simplifies the implementation of navigation in an Android app.</p><p>This section begins by providing the guiding principles of navigation as implemented by the Navigation Architecture Component. The principles are followed by Implementing navigation with the Navigation Architecture Component providing the fundamental tasks to implement the Navigation Architecture Component in your app. Finally, you can use it in our legacy Navigation Drawer, depending on your needs for your app:</p><p>So Let’s Get Started:</p><ol><li>Principles of Navigation.</li><li>What is Androidx?</li><li>What is destination, actions and NavHostFragment.</li><li>Implementation Step-by-Step.</li><li>Conclusion.</li></ol><h3>Principles of Navigation</h3><p><strong>Answer:</strong> The goal of any in-app navigation should be to provide a consistent and predictable experience to users. To meet this goal, the Navigation Architecture Component helps you build an app that adheres to each of the navigation principles below:</p><p><strong>a.</strong> The app should have a fixed starting destination.</p><p><strong>b.</strong> A stack is used to represent the “navigation state” of an app.</p><p><strong>c.</strong> The Up button never exits your app.</p><p><strong>d.</strong> Up and Back are equivalent within your app’s task</p><p><strong>e.</strong> Deep linking to a destination or navigating to the same destination should yield the same stack.</p><h3>What is Androidx?</h3><p><strong>Answer:</strong> AndroidX is the open-source project that the Android team uses to develop, test, package, version and release libraries within Jetpack.</p><p>AndroidX is a major improvement to the original Android Support Library. Like the Support Library, AndroidX ships separately from the Android OS and provides backwards-compatibility across Android releases. AndroidX fully replaces the Support Library by providing feature parity and new libraries. In addition AndroidX includes the following features:</p><p><strong>a.</strong> All packages in AndroidX live in a consistent namespace starting with the string androidx. The Support Library packages have been mapped into corresponding androidx.* packages. For a full mapping of all the old classes and build artifacts to the new ones, see the Package Refactoring page.</p><p><strong>b.</strong> Unlike the Support Library, AndroidX packages are separately maintained and updated. The androidx packages use strict Semantic Versioning starting with version 1.0.0. You can update AndroidX libraries in your project independently.</p><p><strong>c.</strong> All new Support Library development will occur in the AndroidX library. This includes maintenance of the original Support Library artifacts and introduction of new Jetpack components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*PisajvOBX73GVgEljhwmkA.png" /><figcaption>Easy Way To Convert Your App To Androidx</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02u9Ps3J3d52_TqSPPT_NQ.png" /><figcaption>Changes From Previous Version</figcaption></figure><h3>What is destination, actions and NavHostFragment</h3><p><strong>Answer:</strong> <strong>1. Destination</strong>: A destination is any place you can navigate to in your app. While destinations are usually Fragments representing specific screens, the Navigation Architecture Component supports other destination types:</p><ul><li>Activities</li><li>Navigation graphs and subgraphs — when the destination is a graph or subgraph, you navigate to the starting destination of that graph or subgraph</li><li>Custom destination types</li></ul><p><strong>2. Actions</strong>: In addition to destinations, a navigation graph has connections between destinations called actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SA4BCOQeAo5JvGmEK3mq9A.png" /><figcaption>Destinations and Actions</figcaption></figure><p>In the above image, the visual representation of a navigation graph for a sample app containing 6 destinations connected by 5 actions.</p><p><strong>3. NavHostFragment</strong>: NavHostFragment provides an area within your layout for self-contained navigation to occur.</p><p>NavHostFragment is intended to be used as the content area within a layout resource defining your app’s chrome around it, e.g.:</p><pre>&lt;androidx.drawerlayout.widget.DrawerLayout<br>        xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>        xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;&gt;<br>  <br>    &lt;fragment<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;match_parent&quot;<br>            android:id=&quot;@+id/my_nav_host_fragment&quot;<br>            android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;<br>            app:navGraph=&quot;@xml/nav_sample&quot;<br>            app:defaultNavHost=&quot;true&quot; /&gt;<br>  <br>    &lt;com.google.android.material.navigation.NavigationView<br>        android:id=&quot;@+id/navigationView&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        android:layout_gravity=&quot;start&quot;<br>        android:fitsSystemWindows=&quot;true&quot;<br>        app:headerLayout=&quot;@layout/header_layout&quot;<br>        app:menu=&quot;@menu/drawer_menu&quot; /&gt;<br>  <br>&lt;/androidx.drawerlayout.widget.DrawerLayout&gt;</pre><p>Each NavHostFragment has a NavController that defines valid navigation within the navigation host. This includes the navigation graph as well as navigation state such as current location and back stack that will be saved and restored along with the NavHostFragment itself.</p><p>NavHostFragments register their navigation controller at the root of their view subtree such that any descendant can obtain the controller instance through the Navigation helper class’s methods such as Navigation.findNavController(View). View event listener implementations such as View.OnClickListener within navigation destination fragments can use these helpers to navigate based on user interaction without creating a tight coupling to the navigation host.</p><h3>Implementation Step-By-Step</h3><p>Please refer to the be low Repository for Step-by-Step Implementation:</p><p>Click on the <a href="https://github.com/umangburman/Navigation-Drawer-With-Navigation-Component">GitHub Repository of NavDrawer with NavComponent</a></p><h3>Conclusion</h3><p>Hopefully this guide should have helped you in making your Navigation Drawer much more easier as it eliminated the legacy <strong>Fragment Manager</strong> and <strong>Fragment Transaction</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f032bfdeae6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Login Example using Efficient Dagger2 — Android Injector]]></title>
            <link>https://medium.com/@umang.burman.micro/login-example-using-efficient-dagger2-android-injector-a7b878a3f4f3?source=rss-ea54a40df7bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7b878a3f4f3</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[dagger-2]]></category>
            <category><![CDATA[dagger-android]]></category>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Umang Burman]]></dc:creator>
            <pubDate>Sun, 23 Sep 2018 20:35:22 GMT</pubDate>
            <atom:updated>2018-09-23T20:39:44.940Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUO6p081GzWyKgWZQrhE5g.png" /><figcaption>The Efficient Dagger 2.10+ Approach</figcaption></figure><p>This is a very simple <strong>Login Example of Dagger2 — An Efficient Approach</strong> in Android. It takes the input from the UI, uses Dagger2 and displays back on the UI efficiently.</p><p>This example is for those beginners who want to learn this efficient approach a.k.a <strong>Android Injector</strong>. One of the primary advantages of Dagger 2 over most other dependency injection frameworks is that its strictly generated implementation (no reflection) means that it can be used in Android applications. However, there are still some considerations to be made when using Dagger within Android applications.</p><p>So Let’s Get Started:</p><ol><li>What is Dependency Injection (Efficient)?</li><li>What are ComponentInjector, AndroidInjector and other components?</li><li>How does it work?</li><li>Implementation Step-by-Step</li><li>Conclusion</li></ol><h3>What is Dependency Injection (Efficient)?</h3><p><strong>Answer:</strong> Dependency Injection in build upon the concept of Inversion of Control. Which says that a class should get its dependencies from outside. In simple words, no class should instantiate another class but should get the instances from a configuration class.</p><p>If a java class creates an instance of another class via the new operator, then it cannot be used and tested independently from that class and is called a hard dependency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*N29Z9F-flmRn-vK5MrCbdw.jpeg" /><figcaption>Before and After Applying DI</figcaption></figure><h3>What are ComponentInjector, AndroidInjector and other components?</h3><p><strong>Answer:</strong> One of the central difficulties of writing an Android application using Dagger is that many Android framework classes are instantiated by the OS itself, like Activity and Fragment, but Dagger works best if it can create all the injected objects. Instead, you have to perform members injection in a lifecycle method.</p><p>This has a few problems:</p><ol><li>Copy-pasting code makes it hard to refactor later on. As more and more developers copy-paste that block, fewer will know what it actually does.</li><li>More fundamentally, it requires the type requesting injection (FrombulationActivity) to know about its injector. Even if this is done through interfaces instead of concrete types, it breaks a core principle of dependency injection: a class shouldn’t know anything about how it is injected.</li></ol><p>To overcome these, Dagger has introduced <strong>dagger.android</strong> from <strong>version — 2.10</strong> onwards. The classes in dagger.android offer one approach to simplify this pattern.</p><ol><li><strong>AndroidInjectionModule:</strong> Contains bindings to ensure the usability of dagger.android framework classes. This module should be installed in the component that is used to inject the Application class.</li><li><strong>ContributesAndroidInjector:</strong> Generates an AndroidInjector for the return type of this method. The injector is implemented with a Subcomponent and will be a child of the Module’s component. This annotation must be applied to an abstract method in a Module that returns a concrete Android framework type (e.g. FooActivity, BarFragment, MyService, etc). The method should have no parameters.</li><li><strong>HasActivityInjector:</strong> Provides an AndroidInjector of Activitys.</li><li><strong>DispatchingAndroidInjector:</strong> Performs members-injection on instances of core Android types (e.g. Activity, Fragment) that are constructed by the Android framework and not by Dagger. This class relies on an injected mapping from each concrete class to an AndroidInjector.Factory for an AndroidInjector of that class. Each concrete class must have its own entry in the map, even if it extends another class which is already present in the map. Calls Object.getClass() on the instance in order to find the appropriate AndroidInjector.Factory.</li><li><strong>AndroidInjection:</strong> Injects core Android types.</li></ol><h3>How does it work?</h3><p><strong>Answer:</strong> AndroidInjection.inject() gets a DispatchingAndroidInjector from the Application and passes your activity to inject(Activity). The DispatchingAndroidInjector looks up the AndroidInjector.Factory for your activity’s class (which is YourActivitySubcomponent.Builder), creates the AndroidInjector (which is YourActivitySubcomponent), and passes your activity to inject(YourActivity).</p><h3>Implementation Step-by-Step</h3><p>Please refer to the be low Repository for Step-by-Step Implementation:</p><p>Click on the <a href="https://github.com/umangburman/Dagger2-Android-Efficient-Approach">GitHub Repository of Dagger2 Android Efficient Approach</a></p><h3>Conclusion</h3><p>Hopefully this guide introduced you to a lesser known yet useful form of Android application dependency injection known as <strong>Dagger2 — Efficient Approach</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7b878a3f4f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Login Example with MVVM, DataBinding With LiveData]]></title>
            <link>https://medium.com/@umang.burman.micro/login-example-with-mvvm-databinding-with-livedata-81319048afb0?source=rss-ea54a40df7bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/81319048afb0</guid>
            <category><![CDATA[android-data-binding]]></category>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[livedata]]></category>
            <dc:creator><![CDATA[Umang Burman]]></dc:creator>
            <pubDate>Sat, 15 Sep 2018 19:12:11 GMT</pubDate>
            <atom:updated>2018-09-15T19:12:11.169Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MR6Z5qtDwldp3g3F1C8peQ.jpeg" /><figcaption>Coding Is Life</figcaption></figure><p>This is a very simple <strong>Login Example</strong> using <strong>MVVM pattern and DataBinding and LiveData</strong> in Android. It takes input from the UI using DataBinding <strong>“@=”</strong>, stores it in LiveData and displays back on the UI.</p><p>This example is for those who want to learn the easiest way to get data from UI. This is useful in many ways such as Saving Development Time, Code Reusability, Validations etc. No wonder it is being used all over Android Community.</p><p>So let’s get started on using these technologies together in a single application:</p><ol><li>What is MVVM?</li><li>What is DataBinding?</li><li>What is LiveData?</li><li>Implementation Step-by-Step</li><li>Conclusion</li></ol><h3>What is MVVM?</h3><p><strong>Answer:</strong> MVVM is a design pattern for organizing GUI applications that has become popular on Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*2s3WIc38SlfnAy6bpKyU3Q.png" /><figcaption>MVVM Architecture</figcaption></figure><p>This concept will introduce you to the main 3 components of MVVM, the View, Model, and ViewModel.</p><p>The Model View ViewModel (MVVM) is an architectural pattern used in software engineering that originated from Microsoft which is specialized in the Presentation Model design pattern. It is based on the Model-view-controller pattern (MVC), and is targeted at modern UI development platforms (WPF and Silverlight) in which there is a UX developer who has different requirements than a more “traditional” developer. MVVM is a way of creating client applications that leverages core features of the WPF platform, allows for simple unit testing of application functionality, and helps developers and designers work together with less technical difficulties.</p><p><strong>View:</strong> A View is defined in XAML and should not have any logic in the code-behind. It binds to the view-model by only using data binding.</p><p><strong>Model:</strong> A Model is responsible for exposing data in a way that is easily consumable by WPF. It must implement INotifyPropertyChanged and/or INotifyCollectionChanged as appropriate.</p><p><strong>ViewModel:</strong> A ViewModel is a model for a view in the application or we can say as abstraction of the view. It exposes data relevant to the view and exposes the behaviors for the views, usually with Commands.</p><p><strong>Model:</strong></p><ul><li>Definition, roles and responsibilities.</li><li>What should go in your model layer and what shouldn’t.</li><li>Benefits of model isolation and how it affects testing.</li></ul><p><strong>View:</strong></p><ul><li>Definition, roles and responsibilities.</li><li>How it interacts with the ViewModel.</li></ul><p><strong>ViewModel:</strong></p><ul><li>Definition, roles and responsibilities.</li><li>How it supports the View, by providing actions and observable state.</li><li>Interactions with the Model.</li><li>Isolation from the View.</li></ul><h3>What is DataBinding?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*YSYMWgA__8cyBIfNcKWc_Q.png" /><figcaption>DataBinding Usage</figcaption></figure><p><strong>Answer:</strong> The Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically and many more.</p><h3>What is LiveData?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*6wLhG2AYbh5p0pYuGWN46Q.png" /><figcaption>LiveData Usage</figcaption></figure><p><strong>Answer:</strong> LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state.</p><p>Using LiveData provides the following advantages:</p><p><strong>Ensures your UI matches your data state:</strong> LiveData follows the observer pattern. LiveData notifies Observer objects when the lifecycle state changes. You can consolidate your code to update the UI in these Observer objects. Instead of updating the UI every time the app data changes, your observer can update the UI every time there’s a change.</p><p><strong>No memory leaks:</strong> Observers are bound to Lifecycle objects and clean up after themselves when their associated lifecycle is destroyed.</p><p><strong>No crashes due to stopped activities:</strong> If the observer’s lifecycle is inactive, such as in the case of an activity in the back stack, then it doesn’t receive any LiveData events.</p><p><strong>No more manual lifecycle handling:</strong> UI components just observe relevant data and don’t stop or resume observation. LiveData automatically manages all of this since it’s aware of the relevant lifecycle status changes while observing.</p><p><strong>Always up to date data:</strong> If a lifecycle becomes inactive, it receives the latest data upon becoming active again. For example, an activity that was in the background receives the latest data right after it returns to the foreground.</p><p><strong>Proper configuration changes:</strong> If an activity or fragment is recreated due to a configuration change, like device rotation, it immediately receives the latest available data.</p><p><strong>Sharing resources:</strong> You can extend a LiveData object using the singleton pattern to wrap system services so that they can be shared in your app. The LiveData object connects to the system service once, and then any observer that needs the resource can just watch the LiveData object. For more information, see Extend LiveData.</p><h3>Implementation Step-By-Step</h3><p>Please refer to the be low Repository for Step-by-Step Implementation:</p><p>Click on the <a href="https://github.com/umangburman/MVVMDataBindingWithLiveData">GitHub Repository of DataBinding, LiveData, MVVM Android</a></p><h3>Conclusion</h3><p>Hopefully this guide should have helped you in making your tasks really easier in terms of many things, such as: eliminating <strong>findViewById(…)</strong> and many more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81319048afb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Room Persistence Library: A Login Example with LiveData]]></title>
            <link>https://medium.com/@umang.burman.micro/android-room-persistence-library-a-login-example-with-livedata-b6019fe23b0?source=rss-ea54a40df7bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6019fe23b0</guid>
            <category><![CDATA[room]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Umang Burman]]></dc:creator>
            <pubDate>Sun, 09 Sep 2018 11:24:04 GMT</pubDate>
            <atom:updated>2018-09-09T11:24:04.706Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*en_uXo-3AUp1hph8SCrZtg.png" /><figcaption>ROOM: One of the Important Android Architecture Component. <a href="https://developer.android.com/topic/libraries/architecture/room">Source</a></figcaption></figure><h3>Login Example using Room Database Android</h3><p>This is a very simple <strong>Login Example of Room Database with LiveData</strong> in Android. It takes the input from the UI, stores it in Room Database and displays back on the UI.</p><p>This example is for those beginners who want to learn <strong>Room Database</strong> for Android. Room Database is usually used to populate a large number of data from the database into a RecyclerView.</p><p>This example follows the recommended Architecture Components pattern.</p><p>So Let’s Get Started:</p><ol><li>What are the recommended Architecture Components?</li><li>What is Room Database?</li><li>Important Annotation or Components.</li><li>Implementation Step-by-Step</li><li>Conclusion</li></ol><h3>1. What are the recommended Architecture Components?</h3><p><strong>Answer:</strong> To introduce the terminology, here is a short introduction to the Architecture Components and how they work together. Note that this codelab focuses on a subset of the components, namely LiveData, ViewModel and Room. Each component is explained more as you use it. This diagram shows a basic form of this architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*4_teAVWTzaL5gTkEHu7gxw.png" /><figcaption>Usually Apps must be implemented this way.</figcaption></figure><p><strong>Entity:</strong> When working with Architecture Components, this is an annotated class that describes a database table.</p><p><strong>SQLite database:</strong> On the device, data is stored in an SQLite database. For simplicity, additional storage options, such as a web server, are omitted. The Room persistence library creates and maintains this database for you.</p><p><strong>DAO:</strong> Data access object. A mapping of SQL queries to functions. You used to have to define these painstakingly in your SQLiteOpenHelper class. When you use a DAO, you call the methods, and Room takes care of the rest.</p><p><strong>Room database:</strong> Database layer on top of SQLite database that takes care of mundane tasks that you used to handle with an SQLiteOpenHelper. Database holder that serves as an access point to the underlying SQLite database. The Room database uses the DAO to issue queries to the SQLite database.</p><p><strong>Repository:</strong> A class that you create, for example using the WordRepository class. You use the Repository for managing multiple data sources.</p><p><strong>ViewModel:</strong> Provides data to the UI. Acts as a communication center between the Repository and the UI. Hides where the data originates from the UI. ViewModel instances survive configuration changes.</p><p><strong>LiveData:</strong> A data holder class that can be observed. Always holds/caches latest version of data. Notifies its observers when the data has changed. LiveData is lifecycle aware. UI components just observe relevant data and don’t stop or resume observation. LiveData automatically manages all of this since it’s aware of the relevant lifecycle status changes while observing.</p><h3>2. What is Room Database?</h3><p><strong>Answer:</strong> The Room persistence library provides an abstraction layer over SQLite to allow for more robust database access while harnessing the full power of SQLite.</p><p>The library helps you create a cache of your app’s data on a device that’s running your app. This cache, which serves as your app’s single source of truth, allows users to view a consistent copy of key information within your app, regardless of whether users have an internet connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*uCxeyc0QZKbqW4uPWYp0zw.png" /><figcaption>Anatomy of Room Database</figcaption></figure><h3>Important Annotation or Components</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*usV410Egk7ZXDaIJ8AKtmA.png" /><figcaption>Basic Important annotations used in Room</figcaption></figure><h3>Implementation Step-By-Step</h3><p>Please refer to the be low Repository for Step-by-Step Implementation:</p><p>Click on the <a href="https://github.com/umangburman/Room-Login-Example">GitHub Repository of Room</a></p><h3>Conclusion</h3><p>Hopefully this guide introduced you to a lesser known yet useful form of Android application data storage called <strong><em>ROOM</em></strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6019fe23b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>