Skip to content

Commit

Permalink
Merge pull request #3 from Ne1c/dev
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
Nikolay Kucheriaviy authored Aug 29, 2016
2 parents 3e2ce53 + 18bcba9 commit b3c6973
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions rainbowmvp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 9
targetSdkVersion 24
versionCode 3
versionName "1.2"
versionCode 4
versionName "1.2.1"
}
buildTypes {
release {
Expand Down
4 changes: 2 additions & 2 deletions rainbowmvp/src/main/java/com/ne1c/rainbowmvp/ViewState.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* FINISH - use in end of work any operation
* SUCCESS - use for show result of any operation
* ERROR - use for show error of any operation
* EMPTY - use for default state if not necessary show any information
* NOTHING - use for default state if not necessary show any information
*/
public enum ViewState {
START, IN_PROGRESS, FINISH, SUCCESS, ERROR, EMPTY
START, IN_PROGRESS, FINISH, SUCCESS, ERROR, NOTHING
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@

package com.ne1c.rainbowmvp.base;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.ne1c.rainbowmvp.ViewState;
import com.ne1c.rainbowmvp.ViewStateListener;

public abstract class BasePresenter<V> {
private V mView;

private ViewState mLastState = ViewState.EMPTY;
private ViewState mLastState = ViewState.NOTHING;
private ViewStateListener mViewStateListener;

public void bindView(V view) {
public void bindView(@NonNull V view) {
mView = view;

if (mViewStateListener != null) {
Expand All @@ -41,22 +44,15 @@ public void onDestroy() {
removeViewStateListener();
}

@Nullable
public V getView() {
return mView;
}

public void setViewState(ViewState state) {
mLastState = state;

if (mViewStateListener != null) {
mViewStateListener.stateChanged(state);
}
}

public void setViewState(ViewState state, boolean callListener) {
mLastState = state;

if (callListener && mViewStateListener != null) {
if (mViewStateListener != null && mView != null) {
mViewStateListener.stateChanged(state);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void call(ArrayList<RepoModel> repoModels) {
if (getView() != null) {
getView().showRepos(repoModels);
getView().hideProgress();
setViewState(ViewState.EMPTY);
setViewState(ViewState.NOTHING);
}
}
}, new Action1<Throwable>() {
Expand All @@ -80,7 +80,7 @@ public void call(Throwable throwable) {
getView().showError(R.string.something_happened);
getView().hideProgress();

setViewState(ViewState.EMPTY);
setViewState(ViewState.NOTHING);
}
}
});
Expand Down

0 comments on commit b3c6973

Please sign in to comment.