Created
August 23, 2017 16:09
-
-
Save aemxn/a998a97a0b4c562d0a8c2b437719a173 to your computer and use it in GitHub Desktop.
Login activity ui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myapp.ui.home; | |
public class LoginActivity extends BaseActivity implements LoginContract.LoginView { | |
// field declaration | |
private LoginPresenter presenter; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// other instantiation | |
PreferenceService preferenceService = new PreferenceServiceImpl(this); | |
NetworkManager networkManager = new NetworkManager(this); | |
DatabaseRealm databaseRealm = new DatabaseRealm(); | |
Repository<Login> loginRepository = new LoginRepositoryImpl(databaseRealm); | |
presenter = new LoginPresenter(APIManager.getInstance(), preferenceService, | |
networkManager, loginRepository); | |
presenter.attachView(this); | |
} | |
@OnClick(R.id.login_btn) | |
public void onLoginClicked() { | |
presenter.onUserLogin(mobileNoEditText.getText().toString(), passwordEditText.getText().toString()); | |
} | |
@Override | |
public void showProgress() { | |
} | |
@Override | |
public void hideProgress() { | |
} | |
@Override | |
public void showUnauthorizedError() { | |
} | |
@Override | |
public void showEmpty() { | |
} | |
@Override | |
public void showError(String errorMessage) { | |
} | |
@Override | |
public void showMessageLayout(boolean show) { | |
} | |
@Override | |
public void onLoginSuccess() { | |
Toast.makeText(this, "Login success. TODO Redir to Homepage", Toast.LENGTH_LONG).show(); | |
} | |
@Override | |
public void onLoginFailed(String message) { | |
Toast.makeText(this, "Login failed: " + message, Toast.LENGTH_LONG).show(); | |
} | |
@Override | |
protected void onDestroy() { | |
presenter.detachView(this); | |
super.onDestroy(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment