Skip to content

Instantly share code, notes, and snippets.

aiman aimanbaharum

Block or report user

Report or block aimanbaharum

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am aimanbaharum on github.
  • I am aimanb ( on keybase.
  • I have a public key ASDtpjMJiw5mo9c3Ng0Ojv6lF3JhSWtYDAvWMjz-eeBphQo

To claim this, I am signing this object:

public abstract class BasePresenter<V extends RemoteView> {
private WeakReference<V> view = null;
public final void attachView(V view) {
if (view == null) throw new NullPointerException("View must not be null");
if(this.view != null) detachView(this.view.get());
this.view = new WeakReference<V>(view);
package com.myapp.ui.home;
public class LoginActivity extends BaseActivity implements LoginContract.LoginView {
// field declaration
private LoginPresenter presenter;
protected void onCreate(Bundle savedInstanceState) {
aimanbaharum /
Created Aug 23, 2017
Implementation for LoginRepository
public class LoginRepositoryImpl implements Repository<Login> {
private DatabaseRealm databaseRealm;
public LoginRepositoryImpl(DatabaseRealm databaseRealm) {
this.databaseRealm = databaseRealm;
aimanbaharum /
Created Aug 23, 2017
Repository interface base class
public interface Repository<T> {
T find(String guid);
List<T> findAll();
void add(T item);
void add(List<T> items);
aimanbaharum /
Created Aug 23, 2017
Generic view base class
public interface RemoteView {
void showProgress();
void hideProgress();
void showUnauthorizedError();
void showEmpty();
package com.myapp.core.mvp.home.login;
public class LoginPresenter extends BasePresenter<LoginContract.LoginView> implements LoginContract.ViewAction {
private APIManager apiManager;
private PreferenceService preference;
private INetworkManager networkManager;
private Repository<Login> eventRepository;
public LoginPresenter(APIManager apiManager, PreferenceService preference,
package com.myapp.core.mvp.home.login;
public interface LoginContract {
interface ViewAction{
void onUserLogin(@NonNull Login login);
interface LoginView extends RemoteView {
void onLoginSuccess();
interface AppAPI {
// other API interface
//POST Login user
Call<LoginResponse> loginUser(@Body Login login);
public class APIManager {
private static APIManager sInstance;
private final AppAPI mApi;
public static APIManager getInstance() {
if (sInstance == null) {
You can’t perform that action at this time.