本文整理汇总了Java中com.trello.rxlifecycle.ActivityLifecycleProvider类的典型用法代码示例。如果您正苦于以下问题:Java ActivityLifecycleProvider类的具体用法?Java ActivityLifecycleProvider怎么用?Java ActivityLifecycleProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActivityLifecycleProvider类属于com.trello.rxlifecycle包,在下文中一共展示了ActivityLifecycleProvider类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VoicePresenter
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
@Inject
VoicePresenter(VoiceMainApi voiceMainApi, MoHoSharedPreferences mSharedPreferences, ActivityLifecycleProvider activityLifecycleProvider) {
this.voiceMainApi = voiceMainApi;
this.mSharedPreferences = mSharedPreferences;
this.mActivityLifecycleProvider = activityLifecycleProvider;
mPath = FileUtil.getAppFilePath(FileUtil.DIR_FRAME);
}
示例2: checkDataUpdate
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
public void checkDataUpdate() {
umi.showLoading();
newIds_card.clear();
allIds_card.clear();
//cards
Observable<List<String>> now_cardIdList = Observable.just(DBHelper.with(mContext).getAll(DBHelper.TABLE_NAME_Card, "id"));
Observable<List<CardIndex>> newestCardIndex = RetrofitProvider.getInstance()
.create(CardService.class)
.getCardIdList();
Observable.combineLatest(now_cardIdList, newestCardIndex, (nowIdList, newestIdList) -> {
if (nowIdList == null || newestIdList == null) {
return false;
}
for (CardIndex cardIndex : newestIdList) {
allIds_card.add(String.valueOf(cardIndex.id));
allIds_card.add(String.valueOf(cardIndex.evolution_id));
if (!nowIdList.contains(String.valueOf(cardIndex.id))) {
newIds_card.add(String.valueOf(cardIndex.id));
}
if (!nowIdList.contains(String.valueOf(cardIndex.evolution_id))) {
newIds_card.add(String.valueOf(cardIndex.evolution_id));
}
}
return true;
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(((ActivityLifecycleProvider) mContext).bindToLifecycle())
.subscribe(aBoolean -> {
if (aBoolean) {
checkData();
}
}, throwable -> upToDate.set(true));
}
示例3: ActivityModule
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
public ActivityModule(ActivityLifecycleProvider activityLifecycleProvider) {
this.activityLifecycleProvider = activityLifecycleProvider;
}
示例4: getActivityLifecycleProvider
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
@Provides
@ActivityScope
ActivityLifecycleProvider getActivityLifecycleProvider() {
return this.activityLifecycleProvider;
}
示例5: onTranSwitchChanged
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
private void onTranSwitchChanged(boolean check){
/*if (!(mContext instanceof CardDetailActivity)){
return;
}*/
tran.set(check);
if (check){
if (stringsToTranslate.size() > 0){
// umi.showLoading();
Observable<Map<String, String>> translation = RetrofitProvider.getInstance()
.create(TranslationService.class)
.getTranslations(stringsToTranslate)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(((ActivityLifecycleProvider) mContext).bindToLifecycle());
translation.subscribe(stringStringMap -> {
translationMap.putAll(stringStringMap);
// stringsToTranslate.clear();
translateTheCard();
umi.dismissLoading();
Observable.create(subscriber -> {
for (String key : stringStringMap.keySet()) {
stringsToTranslate.remove(key);
ContentValues contentValues = new ContentValues();
contentValues.put("origin", key);
contentValues.put("translate", stringStringMap.get(key));
DBHelper.with(mContext).insertData(DBHelper.TABLE_NAME_Translation, contentValues);
}
subscriber.onNext(true);
subscriber.onCompleted();
}).subscribeOn(Schedulers.io())
.compose(((ActivityLifecycleProvider) mContext).bindToLifecycle())
.subscribe(b -> {
// do nothing
});
}, ExceptionHandler::handleException);
}else {
translateTheCard();
}
}else {
card.set(originCard);
cardTitle.set("[" + Utils.emptyLessString(mContext, card.get().getTitle()) + "]");
}
}
示例6: checkData
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
private void checkData() {
total = newIds_card.size();
// check truth version
RetrofitProvider.getInstance().create(InfoService.class)
.getGameInfo()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.compose(((ActivityLifecycleProvider) mContext).bindToLifecycle())
.subscribe(info -> {
boolean update = false;
if (info != null) {
String nowTruthVersion = umi.spRead(SharedHelper.KEY_TruthVersion);
if (!nowTruthVersion.equals(info.getTruth_version())) {
// truth version differs, update manifest.db
update = true;
} else {
info.setTruth_version("");
}
}
if (total > 0) {
update = true;
}
if (update){
umi.dismissLoading();
haveUpdate.set(true);
android.databinding.Observable.OnPropertyChangedCallback agreeCallBack = new android.databinding.Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(android.databinding.Observable observable, int i) {
if (agree.get()) {
agree.set(false);
solved = 0;
boolean isUpdateManifest = info != null && !TextUtils.isEmpty(info.getTruth_version());
isShowProgress.set(true);
total = allIds_card.size();
if (newIds_card.size() > 0 || isUpdateManifest) {
upDateDB(isUpdateManifest, isUpdateManifest ? info.getTruth_version() : null);
}
agree.removeOnPropertyChangedCallback(this);
}
}
};
agree.addOnPropertyChangedCallback(agreeCallBack);
}else {
upToDate.set(true);
}
}, ExceptionHandler::handleException);
}
示例7: with
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
public static SubscriberBuilder with(ActivityLifecycleProvider provider){
return new SubscriberBuilder(provider);
}
示例8: SubscriberBuilder
import com.trello.rxlifecycle.ActivityLifecycleProvider; //导入依赖的package包/类
public SubscriberBuilder(ActivityLifecycleProvider provider){
this.mActLifecycleProvider = provider;
}