本文整理汇总了Java中com.trello.rxlifecycle2.components.support.RxFragment类的典型用法代码示例。如果您正苦于以下问题:Java RxFragment类的具体用法?Java RxFragment怎么用?Java RxFragment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxFragment类属于com.trello.rxlifecycle2.components.support包,在下文中一共展示了RxFragment类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestList
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public void requestList(String cacheName , int id,boolean update){
if (update) page = 1;
mModel.getListData("/tnfs/api/list",cacheName,page,id,update)
.subscribeOn(Schedulers.io())
.retryWhen(new RetryWithDelay(3, 2))//遇到错误时重试,第一个参数为重试几次,第二个参数为重试的间隔
.doOnSubscribe(disposable ->mRootView.showLoading())//显示上拉刷新的进度条
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(()->mRootView.hideLoading())
.compose(((RxFragment) mRootView).bindUntilEvent(FragmentEvent.DESTROY))//使用RXlifecycle,使subscription和activity一起销毁
.subscribe(new SuccessSubscriber<NewsListEntity>(mErrorHandler) {
@Override
public void onSuccess(NewsListEntity entity) {
page++;
mRootView.loadListData(entity.getTngou(),true);
}
@Override
public void onError(Throwable e) {
super.onError(e);
mRootView.loadListData(null,false);
}
});
}
示例2: CCDownloadTask
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public CCDownloadTask(RxFragment fragment, String taskKey, String sourceUrl, String savePath, String saveName, int priority, long fileSize, long downloadedSize) {
super(fragment);
this.taskKey = taskKey;
this.sourceUrl = sourceUrl;
this.savePath = savePath;
this.saveName = saveName;
this.priority = priority;
this.downloadStatus = CCDownloadStatus.WAIT;
this.fileSize = fileSize;
this.downloadedSize = downloadedSize;
}
示例3: setupFragments
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
private void setupFragments() {
lastShowFragment = 0;
CollectionFragment collectionFragment = new CollectionFragment();
NewFragment newFragment = new NewFragment();
FeaturedFragment featuredFragment = new FeaturedFragment();
RandomFragment randomFragment = new RandomFragment();
mRxFragments = new RxFragment[]{collectionFragment, newFragment, featuredFragment, randomFragment};
mFragmentManager.beginTransaction()
.add(R.id.container, collectionFragment)
.show(collectionFragment)
.commitAllowingStateLoss();
}
示例4: bindToLifeCycle
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public static LifecycleProvider bindToLifeCycle(IView view) {
if (view instanceof RxAppCompatActivity) {
return (LifecycleProvider<ActivityEvent>) view;
} else if (view instanceof RxFragment) {
return (LifecycleProvider<Fragment>) view;
} else {
throw new IllegalArgumentException("Unable find fragment or activity properly");
}
}
示例5: bindToLifecycle
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public static <T> LifecycleTransformer<T> bindToLifecycle(IView view) {
if (view instanceof RxAppCompatActivity) {
return ((RxAppCompatActivity) view).bindToLifecycle();
} else if (view instanceof RxFragment) {
return ((RxFragment) view).bindToLifecycle();
} else {
throw new IllegalArgumentException("view isn't activity or fragment");
}
}
示例6: CCBaseDownloadTask
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public CCBaseDownloadTask(RxFragment fragment) {
this.netLifecycleComposer = fragment.bindUntilEvent(FragmentEvent.DESTROY);
initTaskStamp();
}
示例7: CCDownloadTask2
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public CCDownloadTask2(RxFragment fragment, String taskKey, String sourceUrl, String savePath, String saveName, int priority, long fileSize, long downloadedSize) {
super(sourceUrl, savePath, saveName, priority, null, fileSize);
this.taskKey = taskKey;
this.downloadStatus = CCDownloadStatus.WAIT;
this.downloadedSize = downloadedSize;
}
示例8: SlotListAdapter
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public SlotListAdapter(ArrayList<SlotRoomViewModel> items, ListType type, RxFragment fragment) {
this.items = items;
this.type = type;
this.fragment = fragment;
}
示例9: fragmentLifecycle
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public static <T> ObservableTransformer<T, T> fragmentLifecycle(RxFragment fragment) {
return observable ->
observable.compose(fragment.bindUntilEvent(FragmentEvent.DESTROY));
}
示例10: fragmentLifecycleF
import com.trello.rxlifecycle2.components.support.RxFragment; //导入依赖的package包/类
public static <T> FlowableTransformer<T, T> fragmentLifecycleF(RxFragment fragment) {
return flowable ->
flowable.compose(fragment.bindUntilEvent(FragmentEvent.DESTROY));
}