use of de.robv.android.xposed.installer.util.RunnableWithParam in project XposedInstaller by rovo89.
the class StatusInstallerFragment method showActionDialog.
private void showActionDialog(final Context context, final String title, final FrameworkZips.Type type) {
final int ACTION_FLASH = 0;
final int ACTION_FLASH_RECOVERY = 1;
final int ACTION_SAVE = 2;
final int ACTION_DELETE = 3;
boolean isDownloaded = FrameworkZips.hasLocal(title, type);
int itemCount = isDownloaded ? 3 : 2;
String[] texts = new String[itemCount];
int[] ids = new int[itemCount];
int i = 0;
texts[i] = context.getString(type.text_flash);
ids[i++] = ACTION_FLASH;
texts[i] = context.getString(type.text_flash_recovery);
ids[i++] = ACTION_FLASH_RECOVERY;
if (FrameworkZips.hasLocal(title, type)) {
texts[i] = context.getString(R.string.framework_delete);
ids[i++] = ACTION_DELETE;
}
new MaterialDialog.Builder(context).title(title).items(texts).itemsIds(ids).itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
final int action = itemView.getId();
// Handle delete simple actions.
if (action == ACTION_DELETE) {
FrameworkZips.delete(context, title, type);
LOCAL_ZIP_LOADER.triggerReload(true);
return;
}
// Handle actions that need a download first.
RunnableWithParam<File> runAfterDownload = null;
if (action == ACTION_FLASH) {
runAfterDownload = new RunnableWithParam<File>() {
@Override
public void run(File file) {
flash(context, new FlashDirectly(file, type, title, false));
}
};
} else if (action == ACTION_FLASH_RECOVERY) {
runAfterDownload = new RunnableWithParam<File>() {
@Override
public void run(File file) {
flash(context, new FlashRecoveryAuto(file, type, title));
}
};
} else if (action == ACTION_SAVE) {
runAfterDownload = new RunnableWithParam<File>() {
@Override
public void run(File file) {
saveTo(context, file);
}
};
}
LocalFrameworkZip local = FrameworkZips.getLocal(title, type);
if (local != null) {
runAfterDownload.run(local.path);
} else {
download(context, title, type, runAfterDownload);
}
}
}).show();
}
Aggregations