com.jess.arms.mvp.IView Java Examples

The following examples show how to use com.jess.arms.mvp.IView. 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: RxUtils.java    From TikTok with Apache License 2.0 6 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulers(final IView view) {
    return new ObservableTransformer<T, T>() {
        @Override
        public Observable<T> apply(Observable<T> observable) {
            return observable.subscribeOn(Schedulers.io())
                    .doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(@NonNull Disposable disposable) throws Exception {
                            view.showLoading();//显示进度条
                        }
                    })
                    .subscribeOn(AndroidSchedulers.mainThread())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doFinally(new Action() {
                        @Override
                        public void run() {
                            view.hideLoading();//隐藏进度条
                        }
                    }).compose(RxLifecycleUtils.bindToLifecycle(view));
        }
    };
}
 
Example #2
Source File: RxUtil.java    From lifecycle-component with Apache License 2.0 6 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulers(final IView view) {
    return new ObservableTransformer<T, T>() {
        @Override
        public Observable<T> apply(Observable<T> observable) {
            return observable.subscribeOn(Schedulers.io())
                    .doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(@NonNull Disposable disposable) throws Exception {
                            view.showLoading();//显示进度条
                        }
                    })
                    .subscribeOn(AndroidSchedulers.mainThread())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doFinally(new Action() {
                        @Override
                        public void run() {
                            view.hideLoading();//隐藏进度条
                        }
                    }).compose(RxLifecycleUtils.bindToLifecycle(view));
        }
    };
}
 
Example #3
Source File: RxUtil.java    From Hands-Chopping with Apache License 2.0 6 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulers(final IView view) {
    return new ObservableTransformer<T, T>() {
        @Override
        public Observable<T> apply(Observable<T> observable) {
            return observable.subscribeOn(Schedulers.io())
                    .doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(@NonNull Disposable disposable) throws Exception {
                            view.showLoading();//显示进度条
                        }
                    })
                    .subscribeOn(AndroidSchedulers.mainThread())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doFinally(new Action() {
                        @Override
                        public void run() {
                            view.hideLoading();//隐藏进度条
                        }
                    }).compose(RxLifecycleUtils.bindToLifecycle(view));
        }
    };
}
 
Example #4
Source File: RxUtils.java    From Hands-Chopping with Apache License 2.0 6 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulers(final IView view) {
    return new ObservableTransformer<T, T>() {
        @Override
        public Observable<T> apply(Observable<T> observable) {
            return observable.subscribeOn(Schedulers.io())
                    .doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(@NonNull Disposable disposable) throws Exception {
                            view.showLoading();//显示进度条
                        }
                    })
                    .subscribeOn(AndroidSchedulers.mainThread())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doFinally(new Action() {
                        @Override
                        public void run() {
                            view.hideLoading();//隐藏进度条
                        }
                    }).compose(RxLifecycleUtils.bindToLifecycle(view));
        }
    };
}
 
Example #5
Source File: RxUtils.java    From AndroidBase with Apache License 2.0 6 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulers(final IView view) {
    return new ObservableTransformer<T, T>() {
        @Override
        public ObservableSource<T> apply(Observable<T> observable) {
            return observable.doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(Disposable disposable) throws Exception {
                            view.showLoading();//显示进度条
                        }
                    })
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doAfterTerminate(new Action() {
                        @Override
                        public void run() throws Exception {
                            view.hideLoading();//隐藏进度条
                        }
                    }).compose(RxUtils.<T>bindToLifecycle(view));
        }
    };
}
 
Example #6
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 #7
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 #8
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 #9
Source File: RxUtils.java    From Aurora with Apache License 2.0 6 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulers(final IView view,final boolean isLoadMore) {
    return new ObservableTransformer<T, T>() {
        @Override
        public Observable<T> apply(Observable<T> observable) {
            return observable.subscribeOn(Schedulers.io())
                    .doOnSubscribe(new Consumer<Disposable>() {
                        @Override
                        public void accept(@NonNull Disposable disposable) throws Exception {
                            if (!isLoadMore){
                                view.showLoading();
                            }
                        }
                    })
                    .subscribeOn(AndroidSchedulers.mainThread())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doAfterTerminate(new Action() {
                        @Override
                        public void run() {
                            view.hideLoading();//隐藏进度条
                        }
                    }).compose(RxLifecycleUtils.bindToLifecycle(view));
        }
    };
}
 
Example #10
Source File: RxUtils.java    From Aurora with Apache License 2.0 6 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulersWithLifeCycle(IView view) {
    return new ObservableTransformer<T, T>() {
        @Override
        public Observable<T> apply(Observable<T> observable) {
            return observable.subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doAfterTerminate(new Action() {
                        @Override
                        public void run() {
                            view.hideLoading();//隐藏进度条
                        }
                    })
                    .compose(RxLifecycleUtils.bindToLifecycle(view));
        }
    };
}
 
Example #11
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 #12
Source File: RxUtils.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
public static <T> LifecycleTransformer<T> bindToLifecycle(IView 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");
    }

}
 
Example #13
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 #14
Source File: RxLifecycleUtils.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定 Activity/Fragment 的生命周期
 *
 * @param view
 * @param <T>
 * @return
 */
public static <T> LifecycleTransformer<T> bindToLifecycle(@NonNull IView view) {
    Preconditions.checkNotNull(view, "view == null");
    if (view instanceof Lifecycleable) {
        return bindToLifecycle((Lifecycleable) view);
    } else {
        throw new IllegalArgumentException("view isn't Lifecycleable");
    }
}
 
Example #15
Source File: RxLifecycleUtils.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定 Fragment 的指定生命周期
 *
 * @param view
 * @param event
 * @param <T>
 * @return
 */
public static <T> LifecycleTransformer<T> bindUntilEvent(@NonNull final IView view,
                                                         final FragmentEvent event) {
    Preconditions.checkNotNull(view, "view == null");
    if (view instanceof FragmentLifecycleable) {
        return bindUntilEvent((FragmentLifecycleable) view, event);
    } else {
        throw new IllegalArgumentException("view isn't FragmentLifecycleable");
    }
}
 
Example #16
Source File: RxLifecycleUtils.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定 Activity 的指定生命周期
 *
 * @param view
 * @param event
 * @param <T>
 * @return
 */
public static <T> LifecycleTransformer<T> bindUntilEvent(@NonNull final IView view,
                                                         final ActivityEvent event) {
    Preconditions.checkNotNull(view, "view == null");
    if (view instanceof ActivityLifecycleable) {
        return bindUntilEvent((ActivityLifecycleable) view, event);
    } else {
        throw new IllegalArgumentException("view isn't ActivityLifecycleable");
    }
}
 
Example #17
Source File: RxUtils.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
public static <T> ObservableTransformer<T, T> applySchedulers(final IView view) {
    return observable -> observable.subscribeOn(Schedulers.io())
            .doOnSubscribe(disposable -> {
                view.showLoading();//显示进度条
            })
            .subscribeOn(AndroidSchedulers.mainThread())
            .observeOn(AndroidSchedulers.mainThread())
            .doFinally(() -> {
                view.hideLoading();//隐藏进度条
            }).compose(RxLifecycleUtils.bindToLifecycle(view));
}
 
Example #18
Source File: RxLifecycleUtils.java    From Aurora with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定 Activity/Fragment 的生命周期
 *
 * @param view
 * @param <T>
 * @return
 */
public static <T> LifecycleTransformer<T> bindToLifecycle(@NonNull IView view) {
    Preconditions.checkNotNull(view, "view == null");
    if (view instanceof Lifecycleable) {
        return bindToLifecycle((Lifecycleable) view);
    } else {
        throw new IllegalArgumentException("view isn't Lifecycleable");
    }
}
 
Example #19
Source File: RxLifecycleUtils.java    From Aurora with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定 Fragment 的指定生命周期
 *
 * @param view
 * @param event
 * @param <T>
 * @return
 */
public static <T> LifecycleTransformer<T> bindUntilEvent(@NonNull final IView view,
                                                         final FragmentEvent event) {
    Preconditions.checkNotNull(view, "view == null");
    if (view instanceof FragmentLifecycleable) {
        return bindUntilEvent((FragmentLifecycleable) view, event);
    } else {
        throw new IllegalArgumentException("view isn't FragmentLifecycleable");
    }
}
 
Example #20
Source File: RxLifecycleUtils.java    From Aurora with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定 Activity 的指定生命周期
 *
 * @param view
 * @param event
 * @param <T>
 * @return
 */
public static <T> LifecycleTransformer<T> bindUntilEvent(@NonNull final IView view,
                                                         final ActivityEvent event) {
    Preconditions.checkNotNull(view, "view == null");
    if (view instanceof ActivityLifecycleable) {
        return bindUntilEvent((ActivityLifecycleable) view, event);
    } else {
        throw new IllegalArgumentException("view isn't ActivityLifecycleable");
    }
}
 
Example #21
Source File: RxUtils.java    From MVPArms with Apache License 2.0 2 votes vote down vote up
/**
 * 此方法已废弃
 *
 * @param view
 * @param <T>
 * @return
 * @see RxLifecycleUtils 此类可以实现 {@link RxLifecycle} 的所有功能, 使用方法和之前一致
 * @deprecated Use {@link RxLifecycleUtils#bindToLifecycle(IView)} instead
 */
@Deprecated
public static <T> LifecycleTransformer<T> bindToLifecycle(IView view) {
    return RxLifecycleUtils.bindToLifecycle(view);
}
 
Example #22
Source File: RxUtils.java    From Aurora with Apache License 2.0 2 votes vote down vote up
public static <T> LifecycleTransformer<T> bindToLifecycle(IView view) {
    return RxLifecycleUtils.bindToLifecycle(view);

}
 
Example #23
Source File: RxUtils.java    From Hands-Chopping with Apache License 2.0 2 votes vote down vote up
/**
 * 此方法已废弃
 *
 * @param view
 * @param <T>
 * @return
 * @see RxLifecycleUtils 此类可以实现 {@link RxLifecycle} 的所有功能, 使用方法和之前一致
 * @deprecated Use {@link RxLifecycleUtils#bindToLifecycle(IView)} instead
 */
@Deprecated
public static <T> LifecycleTransformer<T> bindToLifecycle(IView view) {
    return RxLifecycleUtils.bindToLifecycle(view);
}
 
Example #24
Source File: RxUtils.java    From TikTok with Apache License 2.0 2 votes vote down vote up
/**
 * 此方法已废弃
 *
 * @param view
 * @param <T>
 * @return
 * @see RxLifecycleUtils 此类可以实现 {@link RxLifecycle} 的所有功能, 使用方法和之前一致
 * @deprecated Use {@link RxLifecycleUtils#bindToLifecycle(IView)} instead
 */
@Deprecated
public static <T> LifecycleTransformer<T> bindToLifecycle(IView view) {
    return RxLifecycleUtils.bindToLifecycle(view);
}