<?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 Himanshu Srivastava on Medium]]></title>
        <description><![CDATA[Stories by Himanshu Srivastava on Medium]]></description>
        <link>https://medium.com/@manasshrivu?source=rss-177e584908df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jULl-U-moiZTJ0Ue.</url>
            <title>Stories by Himanshu Srivastava on Medium</title>
            <link>https://medium.com/@manasshrivu?source=rss-177e584908df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 00:52:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manasshrivu/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[Introduction to Android]]></title>
            <link>https://medium.com/@manasshrivu/introduction-to-android-9d10722c8683?source=rss-177e584908df------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d10722c8683</guid>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Himanshu Srivastava]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 07:10:03 GMT</pubDate>
            <atom:updated>2020-02-02T07:10:03.439Z</atom:updated>
            <content:encoded><![CDATA[<p>Android is an operating system which is built on the top of Linux Kernel. It was primarily designed to build touch screen mobile devices like smart phones.</p><p>Initially developed by Android Inc., which was bought by Google in 2005. Android was unveiled in 2007, with the first Android device launched in September 2008. The current stable version is <strong>Android 10</strong>, released on September 3, 2019. The core Android source code is known as <strong>Android Open Source Project (AOSP)</strong>, which is primarily licensed under the Apache License.</p><h3><strong>Android Architecture</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*eKr8QVCOOiTHuYyWOyJWXw.png" /></figure><p>Android operating system is stack of software components which is divided in four layers and five sections.</p><p><strong>Linux kernel : </strong>It provides a level of abstraction between the device hardware and it contains all the essential hardware drivers like camera, keypad, display etc. Also, the kernel handles all the things that Linux is really good at such as networking and a vast array of device drivers.</p><p><strong>Libraries : </strong>On top of Linux kernel there is a set of libraries including open-source Web browser engine WebKit, well known library libc, database which is a useful repository for storage and sharing of application data, libraries to play and record audio and video, SSL libraries responsible for Internet security etc.</p><p><strong>Android Libraries : </strong>This category encompasses libraries that are specific to Android development. Libraries in this category include the application framework libraries in addition to those that facilitate user interface building, graphics drawing and database access.</p><p><strong>Android Runtime : </strong>This section provides a key component called <strong>Dalvik Virtual Machine</strong> which is a kind of Java Virtual Machine specially designed and optimized for Android.The Dalvik VM makes use of Linux core features like memory management and multi-threading. The <strong>Dalvik VM</strong> enables every Android application to run in its own process, with its own instance of the <strong>Dalvik virtual machine.</strong></p><p>The Android runtime also provides a set of core libraries which enable Android application developers to write Android applications using standard programming languages like Java, Kotlin.</p><p><strong>Application Framework : </strong>The Application Framework layer provides many higher-level services to applications in the form of classes. Application developers are allowed to make use of these services in their applications.</p><p>It provides the following services.</p><p><strong>Activity Manager</strong> − Controls all aspects of the application lifecycle and activity stack.</p><p><strong>Content Providers</strong> − Allows applications to publish and share data with other applications.</p><p><strong>Resource Manager</strong> − Provides access to non-code embedded resources such as strings, color settings and user interface layouts.</p><p><strong>Notifications Manager</strong> − Allows applications to display alerts and notifications to the user.</p><p><strong>View System</strong> − An extensible set of views used to create application user interfaces.</p><p><strong>Application</strong> : Android Applications at the top layer. You will write your application to be installed on this layer only. Examples of such applications are Contacts Books, Browser, Games etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d10722c8683" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jetpack — Life Cycle]]></title>
            <link>https://medium.com/@manasshrivu/jetpack-life-cycle-e8dcecfe7abe?source=rss-177e584908df------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8dcecfe7abe</guid>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[lifecycle]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Himanshu Srivastava]]></dc:creator>
            <pubDate>Fri, 01 Nov 2019 11:10:35 GMT</pubDate>
            <atom:updated>2019-11-01T11:10:35.118Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jetpack — Life Cycle</h3><p>Life cycle is a term, every one does know about. Life cycle is associated to every thing in this world, whether it is living, non living even in computer programming also, life cycle is associated to every variable, function, program etc.</p><p>Like Every other thing, components like Activity, Fragments do have Life cycle associated with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*hTg-4KCddAwfVr_45bOEWQ.png" /><figcaption>Life cycle of an Activity</figcaption></figure><p>In conventional way, we use these life cycle call backs to perform specific actions when activity state changes. But this can make code maintenance harder.</p><p>So, Android came with a new idea to manage these Life cycle aware components. They came up with Life cycle framework in jetpack. And this really removed the overhead of overloading our Activity/Fragment with a lot of code.</p><p>To use Jetpack — LifeCycle in Android. Put this line inside dependencies in build.gradle file</p><pre>def lifecycle_version = &quot;2.1.0&quot;<br>implementation &quot;androidx.lifecycle:lifecycle-runtime:$lifecycle_version&quot;</pre><p>There are three things.</p><p><strong>1 . Life Cycle — </strong>Life Cycle is class which holds the information about the Life cycle of the Associated component. It maintains two enumerations <strong>Event</strong> and <strong>State</strong></p><p><strong>Event : </strong>Life cycle events are dispatched from Framework and Life cycle class. These events are mapped to callback events of the Associated components.</p><p><strong>State : </strong>This<strong> </strong>enumeration keeps the track of current state of the associated component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*u2XNtRkCpIpgz_HGbe_7cQ.jpeg" /></figure><p><strong>2 . Life Cycle Owner — </strong>This is an interface, it has a single method. getLifeCycle(). This methods must be implemented by the class implementing this interface. If we want to manage the life cycle of the entire application then we have to use <a href="https://developer.android.com/reference/androidx/lifecycle/ProcessLifecycleOwner.html"><strong>ProcessLifeCycleOwner</strong></a>.</p><p><strong>3 . Life Cycle Observer — </strong>This<strong> </strong>class<strong> </strong>work seamlessly with Lifecycle Owner. this class can contain code for the every different states of the associated component that we have written in Life cycle callbacks within our Activity/Fragment.</p><pre>class MyLifecycleObserver : LifecycleObserver{<br><br>    private val TAG = &quot;MyLifecycleObserver&quot;<br><br>    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)<br>    fun created(){<br>        Log.d(TAG, &quot;Created called&quot;)<br>    }<br><br><br>    @OnLifecycleEvent(Lifecycle.Event.ON_START)<br>    fun started(){<br>        Log.d(TAG, &quot;Started called&quot;)<br>    }<br><br>    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)<br>    fun resumed(){<br>        Log.d(TAG, &quot;Resume Called&quot;)<br>    }<br><br>    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)<br>    fun paused(){<br>        Log.d(TAG, &quot;Pause called&quot;)<br>    }<br><br>    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)<br>    fun stopped(){<br>        Log.d(TAG, &quot;Stop Called&quot;)<br>    }<br><br>    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)<br>    fun destroyed(){<br>        Log.d(TAG, &quot;Destroy Called&quot;)<br>    }<br>}</pre><p>To add this observer in Lifecycle(Can be directly accessed in AppCompatActivity) add these lines in onCreate() of Activity class. But this works only if You want to use Default Life cycle owner.</p><pre>lifeCycleObserver = MyLifecycleObserver()<br>lifecycle.addObserver(lifeCycleObserver)</pre><p>If you want to go for custom Life cycle owner then you have to use <strong>LifecycleRegistry </strong>and if Activity state changes you have to mark state as current state using <strong>lifeCycleRegistry.markState()</strong>.</p><pre>class MyLifeCycleOwner : LifecycleOwner{<br><br>    private val TAG = &quot;MyLifeCycleOwner&quot;<br><br>    private lateinit var lifeCycleRegistry : LifecycleRegistry<br><br>    constructor() {<br>        this.lifeCycleRegistry = LifecycleRegistry(this)<br>    }<br><br>    override fun getLifecycle(): Lifecycle {<br>            return lifeCycleRegistry<br>    }<br><br>    fun markState(state : Lifecycle.State){<br>        lifeCycleRegistry.markState(state)<br>    }<br><br>}</pre><p>and Activity will look like below</p><pre>class MainActivity : AppCompatActivity() {<br><br>    private lateinit var lifeCycleObserver : MyLifecycleObserver<br>    private lateinit var lifeCycleOwner: MyLifeCycleOwner<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br><br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.<em>activity_main</em>)<br><br>        lifeCycleObserver = MyLifecycleObserver()<br>        lifeCycleOwner = MyLifeCycleOwner()<br>        lifeCycleOwner.markState(Lifecycle.State.CREATED)<br>        lifeCycleOwner.<em>lifecycle</em>.addObserver(lifeCycleObserver)<br><br>    }<br><br>    override fun onRestart() {<br>        super.onRestart()<br>        lifeCycleOwner.markState(Lifecycle.State.STARTED)<br>    }<br><br><br>    override fun onResume() {<br>        super.onResume()<br>        lifeCycleOwner.markState(Lifecycle.State.RESUMED)<br>    }<br><br>}</pre><p>You can refer this sample project on <a href="https://github.com/mansuu/lifecycle---jetpack">git hub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8dcecfe7abe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Navigation Component]]></title>
            <link>https://medium.com/@manasshrivu/android-navigation-component-73905bafe714?source=rss-177e584908df------2</link>
            <guid isPermaLink="false">https://medium.com/p/73905bafe714</guid>
            <category><![CDATA[navigation-architecture]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[navigation]]></category>
            <dc:creator><![CDATA[Himanshu Srivastava]]></dc:creator>
            <pubDate>Sat, 12 Oct 2019 13:27:50 GMT</pubDate>
            <atom:updated>2019-10-12T13:27:50.304Z</atom:updated>
            <content:encoded><![CDATA[<p>Navigation is a very basic and one of the most important things in an Application. It allows users to navigate across, into and back out from different content areas of an Application. Android Jetpack library helps to implement <strong>Navigation Component</strong> within App.</p><p>It contains three things</p><p><strong>1 . Navigation Graph : </strong>It is a xml file which contains different content areas called destinations.</p><p><strong>2 . Navigation Host :</strong> This is an Empty container called <strong>NavHost</strong>, It displays the destinations from <strong>Navigation Graph</strong>.</p><p><strong>3 . Navigation Controller :</strong> It is an object which manages the navigation between the destinations called <strong>NavController</strong>.</p><p><strong>Getting Started : </strong>To support Jetpack <strong>Navigation Component</strong> in your app, you must have Android studio 3.3 or higher. To get started with this open your app level gradle file add following lines in dependencies</p><pre>dependencies {<br>    def nav_version = &quot;2.1.0&quot;<br>    implementation &quot;androidx.navigation:navigation-      fragment:$nav_version&quot;<br>    implementation &quot;androidx.navigation:navigation-ui:$nav_version&quot;<br>}</pre><p>To create a Navigation graph right click on <strong>res folder -&gt; New -&gt; Android Resource Directory. </strong>Select navigation as resource type and type the name of the folder what ever you want and click OK. Now, right click on <strong>“navigation folder created” -&gt; New -&gt; Navigation resource file,</strong> type the name of the file(let say nav_graph) and click OK. Now, Android studio opens the <strong>nav_graph.xml</strong> file in Navigation Editor. Here we can create our destinations just click <strong>plus</strong> icon like below.</p><p>Click the plus icon and select the layout file for destination or just select place holder destination(You can add your layout file later).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zotvuh6tUaCDqdstk8ysBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mELqdap-E10h62rsJpAv9Q.png" /></figure><p>Arrows between destinations are action paths from one destination to next. this nav_graph.xml file showing just action path, you have to write logic for navigation in your activity/fragment on click events or the events you want to navigate on. You can see the <strong>nav_graph.xml</strong> in text format(Just click on Text tab available beside design tab), when a new new destination is created, an entry is created.</p><pre>&lt;fragment<br>    android:id=&quot;@+id/fragmentTwo&quot;<br>    android:name=&quot;com.example.navigationcomponent.fragments.FragmentTwo&quot;<br>    android:label=&quot;fragment_fragment_two&quot;<br>    tools:layout=&quot;@layout/fragment_fragment_two&quot; &gt;<br>&lt;/fragment&gt;</pre><p>To create an action just select the first destination move cursor to round button appearing on the right side of the destination press control and connect to next destination. On creating an action an entry gets created inside fragment tag like below</p><pre>&lt;action<br>    android:id=&quot;@+id/action_fragmentOne_to_fragmentTwo&quot;<br>    app:destination=&quot;@id/fragmentTwo&quot; /&gt;</pre><p>Now We can move to <strong>Nav_Host </strong>part. A Navigation Host is an Empty container that hosts the different content areas(destinations). The layout file for this Navigation Host looks like this.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    tools:context=&quot;.activities.HomeActivity&quot;&gt;<br><br>    &lt;fragment<br>        android:id=&quot;@+id/frag_nav_host&quot;<br>        android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;<br>        app:defaultNavHost=&quot;true&quot;<br>        app:navGraph=&quot;@navigation/nav_graph&quot;<br>        app:layout_constraintTop_toTopOf=&quot;parent&quot;<br>        app:layout_constraintLeft_toLeftOf=&quot;parent&quot;<br>        app:layout_constraintRight_toRightOf=&quot;parent&quot;<br>        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>        tools:layout_editor_absoluteX=&quot;match_parent&quot;<br>        tools:layout_editor_absoluteY=&quot;match_parent&quot; /&gt;<br>&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;</pre><p><strong>&lt;fragment/&gt;</strong> tag is used to host the destination.</p><p>App automatically navigates to first destination when launched. To navigate from one destination to another there is a navigation controller called <strong>NavController, </strong>it is an object the manages the navigation. Below is the navigation logic to go from first destination to second. In below code, id given is the action id defined in <strong>nav_graph.xml</strong> file.</p><pre>Navigation.<em>findNavController</em>(v).navigate(R.id.<em>action_fragmentOne_to_fragmentTwo</em>);</pre><p>In your Host Activity file write below code in onCreate() method.</p><pre>Navigation.<em>findNavController</em>(this,R.id.<em>frag_nav_host</em>).navigateUp();</pre><p>For more, you can refer this project available on GitHub.</p><p><a href="https://github.com/mansuu/Android-Navigation-Component">https://github.com/mansuu/Android-Navigation-Component</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73905bafe714" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Your Hands on MVVM using Data Binding]]></title>
            <link>https://medium.com/@manasshrivu/get-your-hands-on-mvvm-using-data-binding-91d8b4b0f6c7?source=rss-177e584908df------2</link>
            <guid isPermaLink="false">https://medium.com/p/91d8b4b0f6c7</guid>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mvvm-databinding]]></category>
            <dc:creator><![CDATA[Himanshu Srivastava]]></dc:creator>
            <pubDate>Thu, 03 Oct 2019 17:48:17 GMT</pubDate>
            <atom:updated>2019-10-03T17:48:17.199Z</atom:updated>
            <content:encoded><![CDATA[<p>I think everyone is familiar with MVVM. This is a Design pattern came after MVC. There are various articles you can find over internet about this.</p><p>MVVM means Model View View-Model. Model is a class that prepares data to be represented on the view. View is your activity class where you populate your view to show data to the user. and the most important thing in this Design pattern is View-Model class. This class is a bridge between Model and View that connects these classes.</p><p>Now, We can directly jump into code. I have created a simple sign up app to explain the topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*VFR2ou7WiT5fdzFGK6Xd2w.png" /><figcaption>Project Structure</figcaption></figure><p>1 . First go to app level build.gradle file and add the following in android tag</p><pre>dataBinding{<br>    enabled = true<br>}</pre><p>and in the dependencies add below line</p><pre>implementation &#39;android.arch.lifecycle:extensions:1.1.1&#39;</pre><p>2 . Define your Model class</p><pre>package com.example.mvvmdemojava.models;<br><br>public class User {<br>    private String userEmail;<br>    private String userPassword;<br>    private String userName;<br>    private String confirmPassword;<br><br>    public String getUserEmail() {<br>        return userEmail;<br>    }<br><br>    public void setUserEmail(String userEmail) {<br>        this.userEmail = userEmail;<br>    }<br><br>    public String getUserPassword() {<br>        return userPassword;<br>    }<br><br>    public void setUserPassword(String userPassword) {<br>        this.userPassword = userPassword;<br>    }<br><br>    public String getUserName() {<br>        return userName;<br>    }<br><br>    public void setUserName(String userName) {<br>        this.userName = userName;<br>    }<br><br>    public String getConfirmPassword() {<br>        return confirmPassword;<br>    }<br><br>    public void setConfirmPassword(String confirmPassword) {<br>        this.confirmPassword = confirmPassword;<br>    }<br><br>    public User(String userEmail, String userPassword, String userName) {<br>        this.userEmail = userEmail;<br>        this.userPassword = userPassword;<br>        this.userName = userName;<br>    }<br>}</pre><p>3 . In MVVM design pattern, there are three classes Model, View And View-Model. Let’s go to our View Model class. This class acts as observer and observable both. It observes Model class and observed by View class that’s how View-Model works. It is extending BaseObservable class like below</p><pre>package com.example.mvvmdemojava.viewmodels;<br><br>import androidx.databinding.BaseObservable;<br>import androidx.databinding.Bindable;<br>import androidx.databinding.library.baseAdapters.BR;<br><br>import com.example.mvvmdemojava.models.User;<br>import com.example.mvvmdemojava.supportingFiles.AppConstants;<br>import com.example.mvvmdemojava.supportingFiles.Util;<br><br>public class SignUpViewModel extends BaseObservable {<br>    private User user;<br>    @Bindable<br>    private String toastMessage = null;<br><br>    public SignUpViewModel() {<br>        this.user = new User(&quot;&quot;,&quot;&quot;, &quot;&quot;);<br>    }<br><br>    public String getToastMessage() {<br>        return toastMessage;<br>    }<br><br>    public void setToastMessage(String toastMessage) {<br>        this.toastMessage = toastMessage;<br>        notifyPropertyChanged(BR.<em>toastMessage</em>);<br><br>    }<br>    public void setUserName(String userName){<br>        user.setUserName(userName);<br>        notifyPropertyChanged(BR.<em>userName</em>);<br>    }<br>    @Bindable<br>    public String getUserName(){<br>        return user.getUserName();<br>    }<br>    public void setUserEmail(String userEmail){<br>        user.setUserEmail(userEmail);<br>        notifyPropertyChanged(BR.<em>userEmail</em>);<br>    }<br>    @Bindable<br>    public String getUserEmail(){<br>        return user.getUserEmail();<br>    }<br><br>    public void setUserPassword(String userPassword){<br>        user.setUserPassword(userPassword);<br>        notifyPropertyChanged(BR.<em>userPassword</em>);<br>    }<br>    @Bindable<br>    public String getUserPassword(){<br>        return user.getUserPassword();<br>    }<br><br>    public void setConfirmPassword(String confirmPassword){<br>        user.setConfirmPassword(confirmPassword);<br>        notifyPropertyChanged(BR.<em>confirmPassword</em>);<br>    }<br>    @Bindable<br>    public String getConfirmPassword(){<br>        return user.getConfirmPassword();<br>    }<br>    public void onLoginClicked(){<br>        if(user.getUserName() == null){<br>            setToastMessage(AppConstants.<em>ALL_FIELDS_MANDATORY</em>);<br>            return;<br>        }<br>        else if(user.getUserEmail() == null){<br>            setToastMessage(AppConstants.<em>ALL_FIELDS_MANDATORY</em>);<br>            return;<br>        }<br>        else if(user.getUserPassword() == null){<br>            setToastMessage(AppConstants.<em>ALL_FIELDS_MANDATORY</em>);<br>            return;<br>        }<br>        else if(user.getConfirmPassword() == null){<br>            setToastMessage(AppConstants.<em>ALL_FIELDS_MANDATORY</em>);<br>            return;<br>        }<br>        if (Util.<em>getInstance</em>().areSame(getUserPassword(),getConfirmPassword())){<br>            if (!Util.<em>getInstance</em>().isEmailValid(getUserEmail())){<br>                setToastMessage(AppConstants.<em>INVALID_EMAIL</em>);<br>            }<br>            else{<br>                setToastMessage(AppConstants.<em>ACCOUNT_CREATED_SUCCESSFULLY</em>);<br>            }<br>        }<br>        else{<br>            setToastMessage(AppConstants.<em>PASSWORD_DONOT_MATCH</em>);<br>        }<br><br><br>    }<br><br>}</pre><p>4 . Define the layout file. in layout file &lt;layout&gt;&lt;/layout&gt; tag is used on the top and &lt;data/&gt; tag is used to bind data directly in the xml, to bind data directly in the xml @={variableName} is used.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:bind=&quot;http://schemas.android.com/tools&quot;&gt;<br><br>    &lt;data&gt;<br><br>        &lt;variable<br>            name=&quot;viewModel&quot;<br>            type=&quot;com.example.mvvmdemojava.viewmodels.SignUpViewModel&quot; /&gt;<br>    &lt;/data&gt;<br><br><br>    &lt;ScrollView<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;match_parent&quot;&gt;<br><br>        &lt;LinearLayout<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_gravity=&quot;center&quot;<br>            android:layout_margin=&quot;8dp&quot;<br>            android:orientation=&quot;vertical&quot;&gt;<br>            &lt;EditText<br>                android:layout_width=&quot;match_parent&quot;<br>                android:hint=&quot;@string/full_name&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                android:text=&quot;@={viewModel.userName}&quot;<br>                /&gt;<br>            &lt;EditText<br>                android:id=&quot;@+id/inEmail&quot;<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                android:hint=&quot;@string/email&quot;<br>                android:inputType=&quot;textEmailAddress&quot;<br>                android:padding=&quot;8dp&quot;<br>                android:text=&quot;@={viewModel.userEmail}&quot;<br>                android:autofillHints=&quot;&quot; /&gt;<br><br><br>            &lt;EditText<br>                android:id=&quot;@+id/inPassword&quot;<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                android:hint=&quot;@string/password&quot;<br>                android:inputType=&quot;textPassword&quot;<br>                android:padding=&quot;8dp&quot;<br>                android:text=&quot;@={viewModel.userPassword}&quot; /&gt;<br>            &lt;EditText<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                android:hint=&quot;@string/confirm_password&quot;<br>                android:text=&quot;@={viewModel.confirmPassword}&quot;<br>                /&gt;<br><br><br>            &lt;Button<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                android:layout_marginTop=&quot;8dp&quot;<br>                android:onClick=&quot;@{()-&gt; viewModel.onLoginClicked()}&quot;<br>                android:text=&quot;@string/create_account&quot;<br>                android:textAllCaps=&quot;true&quot;<br>                android:textColor=&quot;@color/colorAccent&quot;<br>                bind:toastMessage=&quot;@{viewModel.toastMessage}&quot; /&gt;<br><br><br>        &lt;/LinearLayout&gt;<br><br>    &lt;/ScrollView&gt;<br><br>&lt;/layout&gt;</pre><p>5 . Now, our Activity class comes in. To use ViewModel as a connecting wire between view and Model write these lines in onCreate() method</p><pre>@Override<br>protected void onCreate(Bundle savedInstanceState) {<br>    super.onCreate(savedInstanceState);<br>    ActivitySignupBinding signupBinding = DataBindingUtil.<em>setContentView</em>(this, R.layout.<em>activity_signup</em>);<br>    signupBinding.setViewModel(new SignUpViewModel());<br>    signupBinding.executePendingBindings();<br>}</pre><p>I have defined a function runMe to show toast messages if something happens</p><pre>@BindingAdapter(&quot;toastMessage&quot;)<br>public static void runMe(View view,String toastMessage){<br>    if(toastMessage == null || toastMessage.isEmpty()){<br>        return;<br>    }<br>    Toast.<em>makeText</em>(view.getContext(), toastMessage, Toast.<em>LENGTH_LONG</em>).show();<br>}</pre><p>Here BindingAdapter annotation is used, this annotation works as a setter called from ViewModel class to show toast message to the user.</p><p>You can find the code on GitHub.</p><p><a href="https://github.com/mansuu/MVVMDemo">https://github.com/mansuu/MVVMDemo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91d8b4b0f6c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I started hating ios Framework]]></title>
            <link>https://medium.com/@manasshrivu/why-i-started-hating-ios-framework-78be87b401da?source=rss-177e584908df------2</link>
            <guid isPermaLink="false">https://medium.com/p/78be87b401da</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Himanshu Srivastava]]></dc:creator>
            <pubDate>Wed, 08 Nov 2017 19:57:40 GMT</pubDate>
            <atom:updated>2017-11-08T19:57:40.313Z</atom:updated>
            <content:encoded><![CDATA[<p>I am sorry ios developers. But yes, I don’t like this Framework.</p><p>I am an Android developer and I am developing android apps for more than 2.5 years. I really enjoy developing Android apps and implementing it’s new features. Things are pretty easy and very straight forward in this very cool Framework. As a developer You don’t need to put very very extras efforts even for tedious things.</p><p>Four months back, my manager approached me and said We have to develop an ios app for our customers. As I am a mobile developer and I am always very open to learn new things. I said Why not? We must do it. Question was how and how much time it will take? We decided to publish our app module by module and I was given 45 days to complete it’s very first module including setup Mac machine for ios development.</p><p>After few days I started working on first module and before starting I was sure that things will be very similar to Android.<br>After a week</p><p><em>What the fuck! </em><br><em> It’s nothing like what was expected.</em></p><p>The very first problem I faced in managing widgets and their constraints in storyboards. I took a lot of hours to design a simple <strong>ViewController.</strong></p><p>Customization is not really easy task in ios. I used to bang my head on keyboard to customize things as per my requirements.</p><p>Most of the things what I needed in my project like Customized SegmentedControl, horizontal smooth progress view without timer and many more, I had to rely on pods.</p><p>Some methods can be called only from some standard methods. They won’t work if You call them from some other methods.</p><p>And the worst part is working with <strong>UIcollectionView. </strong>I am still stuck with this thing.<br>Everywhere it gives me run time warnings for constraint violation, I really don’t know why? What I have done wrong? I tested every scenario in my xib file, but warnings are still there.<br> Using AutoLayout in UICollectionView was a really tedious task for me at least.<br>And I am still fighting with inserting new rows to the bottom of my UICollectionView, because it makes my screen blank just before inserting new cells and after adding them, it scrolls my UIcollectionView to top.</p><p>Now it’s fourth month and still first module to go live.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78be87b401da" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>