-
Notifications
You must be signed in to change notification settings - Fork 605
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
12 changed files
with
341 additions
and
95 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
41 changes: 41 additions & 0 deletions
41
app/src/main/java/json/chao/com/wanandroid/contract/main/UsageDialogContract.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,41 @@ | ||
package json.chao.com.wanandroid.contract.main; | ||
|
||
import java.util.List; | ||
|
||
import json.chao.com.wanandroid.base.presenter.AbstractPresenter; | ||
import json.chao.com.wanandroid.base.view.BaseView; | ||
import json.chao.com.wanandroid.core.bean.BaseResponse; | ||
import json.chao.com.wanandroid.core.bean.main.search.UsefulSiteData; | ||
|
||
|
||
/** | ||
* @author quchao | ||
* @date 2018/4/2 | ||
*/ | ||
|
||
public interface UsageDialogContract { | ||
|
||
interface View extends BaseView { | ||
|
||
/** | ||
* Show useful sites | ||
* | ||
* @param usefulSitesResponse BaseResponse<List<UsefulSiteData>> | ||
*/ | ||
void showUsefulSites(BaseResponse<List<UsefulSiteData>> usefulSitesResponse); | ||
|
||
/** | ||
* Show useful sites data fail | ||
*/ | ||
void showUsefulSitesDataFail(); | ||
} | ||
|
||
interface Presenter extends AbstractPresenter<UsageDialogContract.View> { | ||
|
||
/** | ||
* 常用网站 | ||
*/ | ||
void getUsefulSites(); | ||
} | ||
|
||
} |
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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/json/chao/com/wanandroid/presenter/main/UsageDialogPresenter.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,45 @@ | ||
package json.chao.com.wanandroid.presenter.main; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
import json.chao.com.wanandroid.base.presenter.BasePresenter; | ||
import json.chao.com.wanandroid.contract.main.UsageDialogContract; | ||
import json.chao.com.wanandroid.core.DataManager; | ||
import json.chao.com.wanandroid.core.bean.BaseResponse; | ||
import json.chao.com.wanandroid.core.bean.main.search.UsefulSiteData; | ||
import json.chao.com.wanandroid.utils.RxUtils; | ||
import json.chao.com.wanandroid.widget.BaseObserver; | ||
|
||
/** | ||
* @author quchao | ||
* @date 2018/4/2 | ||
*/ | ||
|
||
public class UsageDialogPresenter extends BasePresenter<UsageDialogContract.View> implements UsageDialogContract.Presenter { | ||
|
||
DataManager mDataManager; | ||
|
||
@Inject | ||
UsageDialogPresenter(DataManager dataManager) { | ||
mDataManager = dataManager; | ||
} | ||
|
||
@Override | ||
public void getUsefulSites() { | ||
addSubscribe(mDataManager.getUsefulSites() | ||
.compose(RxUtils.rxSchedulerHelper()) | ||
.subscribeWith(new BaseObserver<BaseResponse<List<UsefulSiteData>>>(mView) { | ||
@Override | ||
public void onNext(BaseResponse<List<UsefulSiteData>> usefulSitesResponse) { | ||
if (usefulSitesResponse.getErrorCode() == BaseResponse.SUCCESS) { | ||
mView.showUsefulSites(usefulSitesResponse); | ||
} else { | ||
mView.showUsefulSitesDataFail(); | ||
} | ||
} | ||
})); | ||
} | ||
|
||
} |
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
Oops, something went wrong.