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
View keybase.md

Keybase proof

I hereby claim:

  • I am aimanbaharum on github.
  • I am aimanb (https://keybase.io/aimanb) on keybase.
  • I have a public key ASDtpjMJiw5mo9c3Ng0Ojv6lF3JhSWtYDAvWMjz-eeBphQo

To claim this, I am signing this object:

View BasePresenter.java
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);
View LoginActivity.java
package com.myapp.ui.home;
public class LoginActivity extends BaseActivity implements LoginContract.LoginView {
// field declaration
private LoginPresenter presenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
@aimanbaharum
aimanbaharum / LoginRepositoryImpl.java
Created Aug 23, 2017
Implementation for LoginRepository
View LoginRepositoryImpl.java
package com.myapp.core.data.repository.impl;
public class LoginRepositoryImpl implements Repository<Login> {
private DatabaseRealm databaseRealm;
public LoginRepositoryImpl(DatabaseRealm databaseRealm) {
this.databaseRealm = databaseRealm;
}
@aimanbaharum
aimanbaharum / Repository.java
Created Aug 23, 2017
Repository interface base class
View Repository.java
public interface Repository<T> {
T find(String guid);
List<T> findAll();
void add(T item);
void add(List<T> items);
@aimanbaharum
aimanbaharum / RemoteView.java
Created Aug 23, 2017
Generic view base class
View RemoteView.java
public interface RemoteView {
void showProgress();
void hideProgress();
void showUnauthorizedError();
void showEmpty();
View LoginPresenter.java
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,
View LoginContract.java
package com.myapp.core.mvp.home.login;
public interface LoginContract {
interface ViewAction{
void onUserLogin(@NonNull Login login);
}
interface LoginView extends RemoteView {
void onLoginSuccess();
View AppAPI.java
package com.myapp.core.data.network;
interface AppAPI {
// other API interface
//POST Login user
@POST("user/login")
Call<LoginResponse> loginUser(@Body Login login);
View APIManager.java
package com.myapp.core.data.network;
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.