io.reactivex.observers.ResourceObserver Java Examples
The following examples show how to use
io.reactivex.observers.ResourceObserver.
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: PermPresenter.java From AppOpsX with MIT License | 6 votes |
void setMode(final OpEntryInfo info) { Helper.setMode(context, appInfo.packageName, info) .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(new ResourceObserver<OpsResult>() { @Override public void onNext(OpsResult value) { } @Override public void onError(Throwable e) { mView.updateItem(info); } @Override public void onComplete() { } }); }
Example #2
Source File: VerticalTabActivity.java From FlowHelper with Apache License 2.0 | 5 votes |
@SuppressLint("CheckResult") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vertical_tab); mTabFlowLayout = findViewById(R.id.tabflow); mRecyclerView = findViewById(R.id.recyclerview); mManager = new LinearLayoutManager(this); mRecyclerView.setLayoutManager(mManager); HttpCreate.getServer().getNaviData() .compose(RxUtils.<BaseResponse<List<NaviBean>>>rxScheduers()) .subscribeWith(new ResourceObserver<BaseResponse<List<NaviBean>>>() { @Override public void onNext(BaseResponse<List<NaviBean>> listBaseResponse) { handleData(listBaseResponse); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); }
Example #3
Source File: SearchHandler.java From AppOpsX with MIT License | 5 votes |
void handleWord(final String text) { if (TextUtils.isEmpty(text)) { mAdapter.clear(); return; } search(text) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new ResourceObserver<List<AppInfo>>() { @Override protected void onStart() { super.onStart(); } @Override public void onNext(List<AppInfo> value) { mAdapter.kw = text; mAdapter.showItems(value); if (!value.isEmpty()) { recyclerView.scrollToPosition(0); } } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); }
Example #4
Source File: PermGroupPresenter.java From AppOpsX with MIT License | 5 votes |
void changeMode(final int groupPosition, final int childPosition, final PermissionChildItem info) { info.opEntryInfo.changeStatus(); Helper.setMode(context, info.appInfo.packageName, info.opEntryInfo) .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(new ResourceObserver<OpsResult>() { @Override public void onNext(OpsResult value) { mView.changeTitle(groupPosition, childPosition, info.opEntryInfo.isAllowed()); } @Override public void onError(Throwable e) { try { info.opEntryInfo.changeStatus(); mView.refreshItem(groupPosition, childPosition); } catch (Exception e2) { e2.printStackTrace(); } } @Override public void onComplete() { } }); }
Example #5
Source File: ConfigPresenter.java From AppOpsX with MIT License | 5 votes |
void restoreOps(final RestoreModel model) { final int size = model.preAppInfos.size(); final AtomicInteger progress = new AtomicInteger(); mView.showProgress(true, size); Observable.fromIterable(model.preAppInfos) .flatMap(new Function<PreAppInfo, ObservableSource<OpsResult>>() { @Override public ObservableSource<OpsResult> apply(@NonNull PreAppInfo appInfo) throws Exception { return Helper.setModes(context, appInfo.getPackageName(), AppOpsManager.MODE_IGNORED, appInfo.getOps()); } }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new ResourceObserver<OpsResult>() { @Override public void onNext(@NonNull OpsResult opsResult) { mView.setProgress(progress.incrementAndGet()); } @Override public void onError(@NonNull Throwable e) { progress.incrementAndGet(); } @Override public void onComplete() { mView.showProgress(false, 0); Toast.makeText(context, "恢复成功", Toast.LENGTH_LONG).show(); } }); }
Example #6
Source File: PermPresenter.java From AppOpsX with MIT License | 4 votes |
void load() { observable = Helper.getAppPermission(context, appInfo.packageName, PreferenceManager.getDefaultSharedPreferences(context) .getBoolean("key_show_no_prems", false)); observable.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new ResourceObserver<List<OpEntryInfo>>() { @Override protected void onStart() { super.onStart(); } @Override public void onNext(List<OpEntryInfo> opEntryInfos) { if (opEntryInfos != null && !opEntryInfos.isEmpty()) { if (autoDisabled) { if (sortByMode) { reSortByModePerms(opEntryInfos); } else { mView.showProgress(false); mView.showPerms(opEntryInfos); } } else { autoDisable(); } } else { mView.showError(context.getString(R.string.no_perms)); } loadSuccess = true; } @Override public void onError(Throwable e) { mView.showError(getHandleError(e)); loadSuccess = false; } @Override public void onComplete() { } }); }
Example #7
Source File: MainActivity.java From AppOpsX with MIT License | 4 votes |
private void loadData(final boolean isFirst) { boolean showSysApp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getBoolean("show_sysapp", false); Helper.getInstalledApps(getApplicationContext(), showSysApp) .map(Helper.getSortComparator(getApplicationContext())).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new ResourceObserver<List<AppInfo>>() { @Override protected void onStart() { super.onStart(); if(isFirst){ mProgressBar.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.GONE); } } @Override public void onNext(List<AppInfo> value) { adapter.showItems(value); mSearchHandler.setBaseData(new ArrayList<>(value)); invalidateOptionsMenu(); } @Override public void onError(Throwable e) { e.printStackTrace(); mSwipeRefreshLayout.setRefreshing(false); Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); invalidateOptionsMenu(); } @Override public void onComplete() { mProgressBar.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); mSwipeRefreshLayout.setRefreshing(false); if (isFirst) { mSwipeRefreshLayout.setEnabled(true); } invalidateOptionsMenu(); } }); loadUsers(); }