me.jessyan.rxerrorhandler.core.RxErrorHandler Java Examples

The following examples show how to use me.jessyan.rxerrorhandler.core.RxErrorHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PermissionUtil.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
/**
     * 请求获取手机状态的权限
     */
    public static void readPhonestate(final RequestPermission requestPermission, RxPermissions rxPermissions, IView view, RxErrorHandler errorHandler) {
//先确保是否已经申请过权限
        boolean isPermissionsGranted =
                rxPermissions
                        .isGranted(Manifest.permission.READ_PHONE_STATE);

        if (isPermissionsGranted) {//已经申请过,直接执行操作
            requestPermission.onRequestPermissionSuccess();
        } else {//没有申请过,则申请
            rxPermissions
                    .request(Manifest.permission.READ_PHONE_STATE)
                    .compose(RxUtils.<Boolean>bindToLifecycle(view))
                    .subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
                        @Override
                        public void onNext(Boolean granted) {
                            if (granted) {
                                Timber.tag(TAG).d("request SEND_SMS success");
                                requestPermission.onRequestPermissionSuccess();
                            } else {
                                Timber.tag(TAG).e("request permissons failure");
                            }
                        }
                    });
        }
    }
 
Example #2
Source File: PermissionUtil.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
/**
     * 请求打电话权限
     */
    public static void callPhone(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
//先确保是否已经申请过权限
        boolean isPermissionsGranted =
                rxPermissions
                        .isGranted(Manifest.permission.CALL_PHONE);

        if (isPermissionsGranted) {//已经申请过,直接执行操作
            requestPermission.onRequestPermissionSuccess();
        } else {//没有申请过,则申请
            rxPermissions
                    .request(Manifest.permission.CALL_PHONE)
                    .compose(RxUtils.<Boolean>bindToLifecycle(view))
                    .subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
                        @Override
                        public void onNext(Boolean granted) {
                            if (granted) {
                                Timber.tag(TAG).d("request SEND_SMS success");
                                requestPermission.onRequestPermissionSuccess();
                            } else {
                                view.showMessage("request permissons failure");
                            }
                        }
                    });
        }
    }
 
Example #3
Source File: PermissionUtil.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
/**
     * 请求发送短信权限
     */
    public static void sendSms(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
//先确保是否已经申请过权限
        boolean isPermissionsGranted =
                rxPermissions
                        .isGranted(Manifest.permission.SEND_SMS);

        if (isPermissionsGranted) {//已经申请过,直接执行操作
            requestPermission.onRequestPermissionSuccess();
        } else {//没有申请过,则申请
            rxPermissions
                    .request(Manifest.permission.SEND_SMS)
                    .compose(RxUtils.<Boolean>bindToLifecycle(view))
                    .subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
                        @Override
                        public void onNext(Boolean granted) {
                            if (granted) {
                                Timber.tag(TAG).d("request SEND_SMS success");
                                requestPermission.onRequestPermissionSuccess();
                            } else {
                                view.showMessage("request permissons failure");
                            }
                        }
                    });
        }
    }
 
Example #4
Source File: PermissionUtil.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
/**
 * 请求外部存储的权限
 */
public static void externalStorage(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
    //先确保是否已经申请过摄像头,和写入外部存储的权限
    boolean isPermissionsGranted =
            rxPermissions
                    .isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE);

    if (isPermissionsGranted) {//已经申请过,直接执行操作
        requestPermission.onRequestPermissionSuccess();
    } else {//没有申请过,则申请
        rxPermissions
                .request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .compose(RxUtils.<Boolean>bindToLifecycle(view))
                .subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
                    @Override
                    public void onNext(Boolean granted) {
                        if (granted) {
                            Timber.tag(TAG).d("request WRITE_EXTERNAL_STORAGE and CAMERA success");
                            requestPermission.onRequestPermissionSuccess();
                        } else {
                            view.showMessage("request permissons failure");
                        }
                    }
                });
    }
}
 
Example #5
Source File: MainPresenter.java    From LQRBiliBlili with MIT License 5 votes vote down vote up
@Inject
public MainPresenter(MainContract.Model model, MainContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #6
Source File: PermissionUtil.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
/**
 * 请求摄像头权限
 */
public static void launchCamera(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView view, RxErrorHandler errorHandler) {
    //先确保是否已经申请过摄像头,和写入外部存储的权限
    boolean isPermissionsGranted =
            rxPermissions
                    .isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE) &&
                    rxPermissions
                            .isGranted(Manifest.permission.CAMERA);

    if (isPermissionsGranted) {//已经申请过,直接执行操作
        requestPermission.onRequestPermissionSuccess();
    } else {//没有申请过,则申请
        rxPermissions
                .request(Manifest.permission.WRITE_EXTERNAL_STORAGE
                        , Manifest.permission.CAMERA)
                .compose(RxUtils.<Boolean>bindToLifecycle(view))
                .subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
                    @Override
                    public void onNext(Boolean granted) {
                        if (granted) {
                            Timber.tag(TAG).d("request WRITE_EXTERNAL_STORAGE and CAMERA success");
                            requestPermission.onRequestPermissionSuccess();
                        } else {
                            view.showMessage("request permissons failure");
                        }
                    }
                });
    }
}
 
Example #7
Source File: ClientModule.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
/**
 * 提供处理 RxJava 错误的管理器
 *
 * @param application {@link Application}
 * @param listener    {@link ResponseErrorListener}
 * @return {@link RxErrorHandler}
 */
@Singleton
@Provides
static RxErrorHandler proRxErrorHandler(Application application, ResponseErrorListener listener) {
    return RxErrorHandler
            .builder()
            .with(application)
            .responseErrorListener(listener)
            .build();
}
 
Example #8
Source File: ClientModule.java    From MVVMArms with Apache License 2.0 5 votes vote down vote up
@Singleton
@Provides
RxErrorHandler provideRxErrorHandler(ResponseErrorListener listener) {
    return RxErrorHandler
            .builder()
            .with(mApplication)
            .responseErrorListener(listener)
            .build();
}
 
Example #9
Source File: VideoDetailPresenter.java    From LQRBiliBlili with MIT License 5 votes vote down vote up
@Inject
public VideoDetailPresenter(VideoDetailContract.Model model, VideoDetailContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
    RetrofitUrlManager.getInstance().putDomain("video_detail_summary", Api.VIDEO_DETAIL_SUMMARY_BASE_URL);
    RetrofitUrlManager.getInstance().putDomain("video_detail_reply", Api.VIDEO_DETAIL_REPLY_BASE_URL);
}
 
Example #10
Source File: MainCategoryPresenter.java    From LQRBiliBlili with MIT License 5 votes vote down vote up
@Inject
public MainCategoryPresenter(MainCategoryContract.Model model, MainCategoryContract.View rootView, RxErrorHandler handler, Application application, ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    mErrorHandler = handler;
    mApplication = application;
    mImageLoader = imageLoader;
    mAppManager = appManager;
}
 
Example #11
Source File: RecommendPresenter.java    From LQRBiliBlili with MIT License 5 votes vote down vote up
@Inject
public RecommendPresenter(RecommendContract.Model model, RecommendContract.View rootView, RxErrorHandler errorHandler, Application application, ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    mErrorHandler = errorHandler;
    mApplication = application;
    mImageLoader = imageLoader;
    mAppManager = appManager;
}
 
Example #12
Source File: LivePresenter.java    From LQRBiliBlili with MIT License 5 votes vote down vote up
@Inject
public LivePresenter(LiveContract.Model model, LiveContract.View rootView, RxErrorHandler errorHandler, Application application, ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    mErrorHandler = errorHandler;
    mApplication = application;
    mImageLoader = imageLoader;
    mAppManager = appManager;
}
 
Example #13
Source File: AuthorDetailPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public AuthorDetailPresenter(AuthorDetailContract.Model model, AuthorDetailContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #14
Source File: VideoDetailPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public VideoDetailPresenter(VideoDetailContract.Model model, VideoDetailContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #15
Source File: VideoListActivityPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public VideoListActivityPresenter(VideoListActivityContract.Model model, VideoListActivityContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #16
Source File: SplashPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public SplashPresenter(SplashContract.Model model, SplashContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #17
Source File: HotPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public HotPresenter(HotContract.Model model, HotContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #18
Source File: CategoryPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public CategoryPresenter(CategoryContract.Model model, CategoryContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #19
Source File: AttentionPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public AttentionPresenter(AttentionContract.Model model, AttentionContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #20
Source File: HistoryPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public HistoryPresenter(HistoryContract.Model model, HistoryContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #21
Source File: VideoPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public VideoPresenter(VideoContract.Model model, VideoContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #22
Source File: SearchPresenter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Inject
public SearchPresenter(SearchContract.Model model, SearchContract.View rootView
        , RxErrorHandler handler, Application application
        , ImageLoader imageLoader, AppManager appManager) {
    super(model, rootView);
    this.mErrorHandler = handler;
    this.mApplication = application;
    this.mImageLoader = imageLoader;
    this.mAppManager = appManager;
}
 
Example #23
Source File: ClientModule.java    From Aurora with Apache License 2.0 5 votes vote down vote up
/**
 * 提供处理 RxJava 错误的管理器
 *
 * @return
 */
@Singleton
@Provides
RxErrorHandler proRxErrorHandler(Application application, ResponseErrorListener listener) {
    return RxErrorHandler
            .builder()
            .with(application)
            .responseErrorListener(listener)
            .build();
}
 
Example #24
Source File: PermissionUtil.java    From Aurora with Apache License 2.0 4 votes vote down vote up
/**
 * 请求外部存储的权限
 */
public static void externalStorage(RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
    requestPermission(requestPermission, rxPermissions, errorHandler, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
 
Example #25
Source File: PermissionUtil.java    From Aurora with Apache License 2.0 4 votes vote down vote up
/**
 * 请求发送短信权限
 */
public static void sendSms(RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
    requestPermission(requestPermission, rxPermissions, errorHandler, Manifest.permission.SEND_SMS);
}
 
Example #26
Source File: PermissionUtil.java    From Aurora with Apache License 2.0 4 votes vote down vote up
/**
 * 请求打电话权限
 */
public static void callPhone(RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
    requestPermission(requestPermission, rxPermissions, errorHandler, Manifest.permission.CALL_PHONE);
}
 
Example #27
Source File: PermissionUtil.java    From Aurora with Apache License 2.0 4 votes vote down vote up
/**
 * 请求获取手机状态的权限
 */
public static void readPhonestate(RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
    requestPermission(requestPermission, rxPermissions, errorHandler, Manifest.permission.READ_PHONE_STATE);
}
 
Example #28
Source File: PermissionUtil.java    From MVPArms with Apache License 2.0 4 votes vote down vote up
/**
 * 请求获取手机状态的权限
 */
public static void readPhonestate(RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
    requestPermission(requestPermission, rxPermissions, errorHandler, Manifest.permission.READ_PHONE_STATE);
}
 
Example #29
Source File: PermissionUtil.java    From MVPArms with Apache License 2.0 4 votes vote down vote up
/**
 * 请求打电话权限
 */
public static void callPhone(RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
    requestPermission(requestPermission, rxPermissions, errorHandler, Manifest.permission.CALL_PHONE);
}
 
Example #30
Source File: PermissionUtil.java    From MVPArms with Apache License 2.0 4 votes vote down vote up
/**
 * 请求发送短信权限
 */
public static void sendSms(RequestPermission requestPermission, RxPermissions rxPermissions, RxErrorHandler errorHandler) {
    requestPermission(requestPermission, rxPermissions, errorHandler, Manifest.permission.SEND_SMS);
}