-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
133 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
62 changes: 62 additions & 0 deletions
62
...ain/java/com/arellomobile/mvp/sample/github/mvp/presenters/RepositoryWidgetPresenter.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.arellomobile.mvp.sample.github.mvp.presenters; | ||
|
||
import java.util.List; | ||
|
||
import android.util.Log; | ||
|
||
import com.arellomobile.mvp.InjectViewState; | ||
import com.arellomobile.mvp.MvpPresenter; | ||
import com.arellomobile.mvp.sample.github.mvp.models.Repository; | ||
import com.arellomobile.mvp.sample.github.mvp.views.RepositoryView; | ||
|
||
/** | ||
* Date: 27.01.2016 | ||
* Time: 21:12 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
@InjectViewState | ||
public class RepositoryWidgetPresenter extends MvpPresenter<RepositoryView> { | ||
private boolean mIsInitialized = false; | ||
private Repository mRepository; | ||
private List<Integer> mInProgress; | ||
private List<Integer> mLikedIds; | ||
|
||
public RepositoryWidgetPresenter() { | ||
super(); | ||
|
||
Log.i("***-***", "Create new presenter"); | ||
} | ||
|
||
public void setRepository(Repository repository) { | ||
if (mIsInitialized) { | ||
return; | ||
} | ||
mIsInitialized = true; | ||
|
||
mRepository = repository; | ||
|
||
getViewState().showRepository(repository); | ||
|
||
updateLikes(mInProgress, mLikedIds); | ||
} | ||
|
||
public void updateLikes(List<Integer> inProgress, List<Integer> likedIds) { | ||
mInProgress = inProgress; | ||
mLikedIds = likedIds; | ||
|
||
if (mRepository == null || mInProgress == null || mLikedIds == null) { | ||
return; | ||
} | ||
|
||
boolean isInProgress = inProgress.contains(mRepository.getId()); | ||
boolean isLiked = likedIds.contains(mRepository.getId()); | ||
|
||
getViewState().updateLike(isInProgress, isLiked); | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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