本文整理汇总了Java中com.jess.arms.base.BaseActivity类的典型用法代码示例。如果您正苦于以下问题:Java BaseActivity类的具体用法?Java BaseActivity怎么用?Java BaseActivity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseActivity类属于com.jess.arms.base包,在下文中一共展示了BaseActivity类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNewsDetail
import com.jess.arms.base.BaseActivity; //导入依赖的package包/类
public void getNewsDetail(int id){
mModel.getNewsDetail(id).subscribeOn(Schedulers.io())
.retryWhen(new RetryWithDelay(3,2))
.doOnSubscribe(disposable -> {
mRootView.showLoading();
}).subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(()-> {
mRootView.hideLoading();
}).compose(((BaseActivity)mRootView).<NewsDetailEntity>bindToLifecycle())
.subscribe(new ErrorHandleSubscriber<NewsDetailEntity>(mErrorHandler) {
@Override
public void onNext(NewsDetailEntity entity) {
mRootView.loadData(entity);
}
});
}
示例2: requestImageDetail
import com.jess.arms.base.BaseActivity; //导入依赖的package包/类
public void requestImageDetail(int id){
mModel.getImageDetail(id)
.subscribeOn(Schedulers.io())
.retryWhen(new RetryWithDelay(3, 2))//遇到错误时重试,第一个参数为重试几次,第二个参数为重试的间隔
.doOnSubscribe(disposable -> {
mRootView.showLoading();//显示上拉刷新的进度条
}).subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(()-> {
mRootView.hideLoading();//隐藏上拉刷新的进度条
})
.compose(((BaseActivity) mRootView).<ImageDetailEntity>bindToLifecycle())//使用RXlifecycle,使subscription和activity一起销毁
.subscribe(new ErrorHandleSubscriber<ImageDetailEntity>(mErrorHandler) {
@Override
public void onNext(ImageDetailEntity entity) {
mRootView.setImageDetail(entity);
}
});
}
示例3: bindToLifecycle
import com.jess.arms.base.BaseActivity; //导入依赖的package包/类
public static <T> LifecycleTransformer<T> bindToLifecycle(BaseView view) {
if (view instanceof BaseActivity) {
return ((BaseActivity) view).<T>bindToLifecycle();
} else if (view instanceof BaseFragment) {
return ((BaseFragment) view).<T>bindToLifecycle();
} else {
throw new IllegalArgumentException("view isn't activity or fragment");
}
}