Android MVP Part 2
Android MVP Tutorial |
If you are not clear with Basic of MVP Pattern, Please read first part of MVP.
Lets start . Make a new Project .
activity_login.xml :
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:padding="30dp" android:layout_height="match_parent"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Submit" /> </LinearLayout>
To achieve MVP Pattern, we need 2 interface and 1 class and 1 Activity .
- Login Activity
- LoginView -> (Interface )
- LoginPresenter -> (Interface )
- LoginPresenterImplemetation -> ( class)
- Login Activity implements LoginView .
- LoginPresenterImplemetation implements LoginPresenter
LoginActivity
public class LoginActivity extends AppCompatActivity implements LoginView {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_login);}}
LoginView
package com.stacklearning.androidmvp.login;
/**
* Created by jaspreet on 23/2/18.
*/
public interface LoginView {
}
LoginPresenter
package com.stacklearning.androidmvp.login;
/**
* Created by jaspreet on 23/2/18.
*/
public interface LoginPresenter {
}
LoginPresenterImplemetation
package com.stacklearning.androidmvp.login;/*** Created by jaspreet on 23/2/18.*/public class LoginPresenterImplementation implements LoginPresenter {}
Take a look at Screen shot Below :
DOWNLOAD CODE
In the third part we will show you how to make login with MVP pattern .
if you are not cleared with Basics of MVP, I recommend you to read First part of MVP Tutorial .
0 comments:
Post a Comment