Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Jan 23, 2020
1 parent ce4dc56 commit dc2c2d1
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ public void onSuccess(ArrayList<String> strings) {
if (TextUtils.isEmpty(path)) {
selectRestoreFolder();
} else {
Restore.INSTANCE.restore(MainActivity.this, Uri.parse(path));
restore(Uri.parse(path));
recreate();
}
} else {
Expand All @@ -685,6 +685,20 @@ public void onSuccess(ArrayList<String> strings) {

}

private void restore(Uri uri) {
Single.create((SingleOnSubscribe<Boolean>) e -> {
Restore.INSTANCE.restore(this, uri);
e.onSuccess(true);
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new MySingleObserver<Boolean>() {
@Override
public void onSuccess(Boolean t) {
recreate();
}
});
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void selectRestoreFolder() {
try {
Expand Down Expand Up @@ -816,8 +830,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (uri == null) return;
getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
preferences.edit().putString("backupPath", uri.toString()).apply();
Restore.INSTANCE.restore(this, uri);
recreate();
restore(uri);
}
break;
}
Expand Down

0 comments on commit dc2c2d1

Please sign in to comment.