Skip to content

Instantly share code, notes, and snippets.

public interface LoginMvpView extends MvpView {
void openMainActivity();
void onLoginButtonClick();
}
public class LoginActivity extends BaseActivity implements LoginMvpView {
LoginPresenter loginPresenter;
EditText editTextEmail, editTextPassword;
Button button;
public static Intent getStartIntent(Context context) {
Intent intent = new Intent(context, LoginActivity.class);
public interface LoginMvpPresenter<V extends LoginMvpView> extends MvpPresenter<V> {
void startLogin(String emailId);
}
public class LoginPresenter<V extends LoginMvpView> extends BasePresenter<V> implements LoginMvpPresenter<V> {
public LoginPresenter(DataManager dataManager) {
super(dataManager);
}
@Override
public void startLogin(String emailId) {
getDataManager().saveEmailId(emailId);
getDataManager().setLoggedIn();
public class MainActivity extends BaseActivity implements MainMvpView {
TextView textViewShow;
Button buttonLogout;
MainPresenter mainPresenter;
public static Intent getStartIntent(Context context) {
Intent intent = new Intent(context, MainActivity.class);
return intent;
}
public interface MainMvpPresenter<V extends MainMvpView> extends MvpPresenter<V> {
String getEmailId();
void setUserLoggedOut();
}
public interface MainMvpView extends MvpView {
void openSplashActivity();
}
public class MainPresenter<V extends MainMvpView> extends BasePresenter<V> implements MainMvpPresenter<V> {
public MainPresenter(DataManager dataManager) {
super(dataManager);
}
@Override
public String getEmailId() {
return getDataManager().getEmailId();
}
public class CommonUtils {
public static boolean isEmailValid(String email) {
Pattern pattern;
Matcher matcher;
final String EMAIL_PATTERN =
"^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email);
public class MvpApp extends Application {
DataManager dataManager;
@Override
public void onCreate() {
super.onCreate();
SharedPrefsHelper sharedPrefsHelper = new SharedPrefsHelper(getApplicationContext());
dataManager = new DataManager(sharedPrefsHelper);