Optimize clear #451
This commit is contained in:
parent
72cb059caa
commit
46e811b928
|
@ -0,0 +1,19 @@
|
|||
package com.tungsten.fcl.ui;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.tungsten.fcllibrary.component.dialog.FCLDialog;
|
||||
import com.tungsten.fcllibrary.component.view.FCLProgressBar;
|
||||
|
||||
public class ProgressDialog extends FCLDialog {
|
||||
public ProgressDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
FCLProgressBar progressBar = new FCLProgressBar(context);
|
||||
setContentView(progressBar);
|
||||
show();
|
||||
}
|
||||
}
|
|
@ -7,16 +7,19 @@ import android.widget.ScrollView;
|
|||
|
||||
import com.tungsten.fcl.R;
|
||||
import com.tungsten.fcl.setting.Profile;
|
||||
import com.tungsten.fcl.ui.ProgressDialog;
|
||||
import com.tungsten.fcl.ui.UIManager;
|
||||
import com.tungsten.fcl.ui.version.Versions;
|
||||
import com.tungsten.fcl.util.RequestCodes;
|
||||
import com.tungsten.fclauncher.utils.FCLPath;
|
||||
import com.tungsten.fclcore.fakefx.beans.property.BooleanProperty;
|
||||
import com.tungsten.fclcore.fakefx.beans.property.SimpleBooleanProperty;
|
||||
import com.tungsten.fclcore.task.Schedulers;
|
||||
import com.tungsten.fclcore.task.Task;
|
||||
import com.tungsten.fclcore.util.io.FileUtils;
|
||||
import com.tungsten.fcllibrary.browser.FileBrowser;
|
||||
import com.tungsten.fcllibrary.browser.options.LibMode;
|
||||
import com.tungsten.fcllibrary.component.dialog.FCLAlertDialog;
|
||||
import com.tungsten.fcllibrary.component.theme.ThemeEngine;
|
||||
import com.tungsten.fcllibrary.component.ui.FCLCommonPage;
|
||||
import com.tungsten.fcllibrary.component.view.FCLImageButton;
|
||||
|
@ -122,11 +125,35 @@ public class ManagePage extends FCLCommonPage implements ManageUI.VersionLoadabl
|
|||
}
|
||||
|
||||
private void clearLibraries() {
|
||||
FileUtils.deleteDirectoryQuietly(new File(getProfile().getRepository().getBaseDirectory(), "libraries"));
|
||||
FCLAlertDialog.Builder builder = new FCLAlertDialog.Builder(getContext());
|
||||
builder.setAlertLevel(FCLAlertDialog.AlertLevel.ALERT);
|
||||
builder.setMessage(String.format(getContext().getString(R.string.version_manage_remove_confirm), "libraries"));
|
||||
builder.setPositiveButton(() -> {
|
||||
ProgressDialog progress = new ProgressDialog(getContext());
|
||||
Task.runAsync(() -> {
|
||||
FileUtils.deleteDirectoryQuietly(new File(getProfile().getRepository().getBaseDirectory(), "libraries"));
|
||||
}).whenComplete(Schedulers.androidUIThread(), (e) -> {
|
||||
progress.dismiss();
|
||||
}).start();
|
||||
});
|
||||
builder.setNegativeButton(null);
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void clearJunkFiles() {
|
||||
Versions.cleanVersion(getProfile(), getVersion());
|
||||
FCLAlertDialog.Builder builder = new FCLAlertDialog.Builder(getContext());
|
||||
builder.setAlertLevel(FCLAlertDialog.AlertLevel.ALERT);
|
||||
builder.setMessage(String.format(getContext().getString(R.string.version_manage_remove_confirm), "logs"));
|
||||
builder.setPositiveButton(() -> {
|
||||
ProgressDialog progress = new ProgressDialog(getContext());
|
||||
Task.runAsync(() -> {
|
||||
Versions.cleanVersion(getProfile(), getVersion());
|
||||
}).whenComplete(Schedulers.androidUIThread(), (e) -> {
|
||||
progress.dismiss();
|
||||
}).start();
|
||||
});
|
||||
builder.setNegativeButton(null);
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void updateGame() {
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.tungsten.fcl.setting.Accounts;
|
|||
import com.tungsten.fcl.setting.Profile;
|
||||
import com.tungsten.fcl.setting.Profiles;
|
||||
import com.tungsten.fcl.ui.PageManager;
|
||||
import com.tungsten.fcl.ui.ProgressDialog;
|
||||
import com.tungsten.fcl.ui.TaskDialog;
|
||||
import com.tungsten.fcl.ui.account.CreateAccountDialog;
|
||||
import com.tungsten.fcl.ui.download.DownloadPageManager;
|
||||
|
@ -102,7 +103,14 @@ public class Versions {
|
|||
FCLAlertDialog.Builder builder = new FCLAlertDialog.Builder(context);
|
||||
builder.setAlertLevel(FCLAlertDialog.AlertLevel.ALERT);
|
||||
builder.setMessage(message);
|
||||
builder.setPositiveButton(() -> Task.runAsync(() -> profile.getRepository().removeVersionFromDisk(version)).start());
|
||||
builder.setPositiveButton(() -> {
|
||||
ProgressDialog progress = new ProgressDialog(context);
|
||||
Task.runAsync(() -> {
|
||||
profile.getRepository().removeVersionFromDisk(version);
|
||||
}).whenComplete(Schedulers.androidUIThread(), (e) -> {
|
||||
progress.dismiss();
|
||||
}).start();
|
||||
});
|
||||
builder.setNegativeButton(null);
|
||||
builder.create().show();
|
||||
}
|
||||
|
@ -113,17 +121,23 @@ public class Versions {
|
|||
reject.accept(context.getString(R.string.install_new_game_malformed));
|
||||
return;
|
||||
}
|
||||
if (profile.getRepository().renameVersion(version, newName)) {
|
||||
resolve.run();
|
||||
profile.getRepository().refreshVersionsAsync()
|
||||
.thenRunAsync(Schedulers.androidUIThread(), () -> {
|
||||
if (profile.getRepository().hasVersion(newName)) {
|
||||
profile.setSelectedVersion(newName);
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
reject.accept(context.getString(R.string.version_manage_rename_fail));
|
||||
}
|
||||
ProgressDialog progress = new ProgressDialog(context);
|
||||
Task.supplyAsync(() -> profile.getRepository().renameVersion(version, newName))
|
||||
.thenComposeAsync(Schedulers.androidUIThread(), result -> {
|
||||
progress.dismiss();
|
||||
if (result) {
|
||||
resolve.run();
|
||||
profile.getRepository().refreshVersionsAsync()
|
||||
.thenRunAsync(Schedulers.androidUIThread(), () -> {
|
||||
if (profile.getRepository().hasVersion(newName)) {
|
||||
profile.setSelectedVersion(newName);
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
reject.accept(context.getString(R.string.version_manage_rename_fail));
|
||||
}
|
||||
return null;
|
||||
}).start();
|
||||
});
|
||||
dialog.show();
|
||||
return dialog.getFuture();
|
||||
|
@ -138,9 +152,11 @@ public class Versions {
|
|||
DuplicateVersionDialog dialog = new DuplicateVersionDialog(context, profile, version, (res, resolve, reject) -> {
|
||||
String newVersionName = (String) res.get(0);
|
||||
boolean copySaves = (boolean) res.get(1);
|
||||
ProgressDialog progress = new ProgressDialog(context);
|
||||
Task.runAsync(() -> profile.getRepository().duplicateVersion(version, newVersionName, copySaves))
|
||||
.thenComposeAsync(profile.getRepository().refreshVersionsAsync())
|
||||
.whenComplete(Schedulers.androidUIThread(), (result, exception) -> {
|
||||
progress.dismiss();
|
||||
if (exception == null) {
|
||||
resolve.run();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue