mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 16:16:04 -04:00
Clean up a bit
This commit is contained in:
parent
0a67b1f629
commit
e93e83ceed
@ -2,8 +2,6 @@ package net.kdt.pojavlaunch.multirt;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
@ -26,23 +24,13 @@ public class MultiRTConfigDialog {
|
|||||||
dialogView.setLayoutManager(linearLayoutManager);
|
dialogView.setLayoutManager(linearLayoutManager);
|
||||||
dialogView.setAdapter(new RTRecyclerViewAdapter(this));
|
dialogView.setAdapter(new RTRecyclerViewAdapter(this));
|
||||||
builder.setView(dialogView);
|
builder.setView(dialogView);
|
||||||
builder.setPositiveButton(R.string.multirt_config_add, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.multirt_config_add, (dialog, which) -> openRuntimeSelector(ctx,MULTIRT_PICK_RUNTIME));
|
||||||
@Override
|
builder.setNegativeButton(R.string.mcn_exit_call, (dialog, which) -> dialog.cancel());
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
/* Initialte import */
|
|
||||||
openRuntimeSelector(ctx,MULTIRT_PICK_RUNTIME);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(R.string.mcn_exit_call, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog = builder.create();
|
dialog = builder.create();
|
||||||
}
|
}
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
dialogView.getAdapter().notifyDataSetChanged();
|
RecyclerView.Adapter adapter = dialogView.getAdapter();
|
||||||
|
if(adapter != null)dialogView.getAdapter().notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
public static void openRuntimeSelector(Activity ctx, int code) {
|
public static void openRuntimeSelector(Activity ctx, int code) {
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package net.kdt.pojavlaunch.multirt;
|
package net.kdt.pojavlaunch.multirt;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import net.kdt.pojavlaunch.PojavLoginActivity;
|
|
||||||
import net.kdt.pojavlaunch.R;
|
import net.kdt.pojavlaunch.R;
|
||||||
import net.kdt.pojavlaunch.Tools;
|
import net.kdt.pojavlaunch.Tools;
|
||||||
import net.kdt.pojavlaunch.utils.JREUtils;
|
import net.kdt.pojavlaunch.utils.JREUtils;
|
||||||
@ -27,7 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MultiRTUtils {
|
public class MultiRTUtils {
|
||||||
public static HashMap<String,Runtime> cache = new HashMap();
|
public static HashMap<String,Runtime> cache = new HashMap<>();
|
||||||
public static class Runtime {
|
public static class Runtime {
|
||||||
public Runtime(String name) {
|
public Runtime(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -40,7 +37,7 @@ public class MultiRTUtils {
|
|||||||
public static interface ProgressReporterThingy {
|
public static interface ProgressReporterThingy {
|
||||||
void reportStringProgress(int resid, Object ... stuff);
|
void reportStringProgress(int resid, Object ... stuff);
|
||||||
}
|
}
|
||||||
private static File runtimeFolder = new File(Tools.MULTIRT_HOME);
|
private static final File runtimeFolder = new File(Tools.MULTIRT_HOME);
|
||||||
private static final String JAVA_VERSION_str = "JAVA_VERSION=\"";
|
private static final String JAVA_VERSION_str = "JAVA_VERSION=\"";
|
||||||
private static final String OS_ARCH_str = "OS_ARCH=\"";
|
private static final String OS_ARCH_str = "OS_ARCH=\"";
|
||||||
public static List<Runtime> getRuntimes() {
|
public static List<Runtime> getRuntimes() {
|
||||||
@ -53,7 +50,7 @@ public class MultiRTUtils {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
public static Runtime installRuntimeNamed(InputStream runtimeInputStream, String name, ProgressReporterThingy thingy) throws IOException {
|
public static void installRuntimeNamed(InputStream runtimeInputStream, String name, ProgressReporterThingy thingy) throws IOException {
|
||||||
File dest = new File(runtimeFolder,"/"+name);
|
File dest = new File(runtimeFolder,"/"+name);
|
||||||
File tmp = new File(dest,"temporary");
|
File tmp = new File(dest,"temporary");
|
||||||
if(dest.exists()) FileUtils.deleteDirectory(dest);
|
if(dest.exists()) FileUtils.deleteDirectory(dest);
|
||||||
@ -65,7 +62,7 @@ public class MultiRTUtils {
|
|||||||
runtimeInputStream.close();
|
runtimeInputStream.close();
|
||||||
uncompressTarXZ(tmp,dest,thingy);
|
uncompressTarXZ(tmp,dest,thingy);
|
||||||
tmp.delete();
|
tmp.delete();
|
||||||
return read(name);
|
read(name);
|
||||||
}
|
}
|
||||||
private static void __installRuntimeNamed__NoRM(InputStream runtimeInputStream, File dest, ProgressReporterThingy thingy) throws IOException {
|
private static void __installRuntimeNamed__NoRM(InputStream runtimeInputStream, File dest, ProgressReporterThingy thingy) throws IOException {
|
||||||
File tmp = new File(dest,"temporary");
|
File tmp = new File(dest,"temporary");
|
||||||
@ -135,12 +132,11 @@ public class MultiRTUtils {
|
|||||||
cache.remove(name);
|
cache.remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static boolean setRuntimeNamed(Context ctx, String name) throws IOException {
|
public static void setRuntimeNamed(Context ctx, String name) throws IOException {
|
||||||
File dest = new File(runtimeFolder,"/"+name);
|
File dest = new File(runtimeFolder,"/"+name);
|
||||||
if(!dest.exists()) return false;
|
if(!dest.exists()) return;
|
||||||
Tools.DIR_HOME_JRE = dest.getAbsolutePath();
|
Tools.DIR_HOME_JRE = dest.getAbsolutePath();
|
||||||
JREUtils.relocateLibPath(ctx);
|
JREUtils.relocateLibPath(ctx);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
private static Runtime read(String name) {
|
private static Runtime read(String name) {
|
||||||
if(cache.containsKey(name)) return cache.get(name);
|
if(cache.containsKey(name)) return cache.get(name);
|
||||||
@ -201,7 +197,7 @@ public class MultiRTUtils {
|
|||||||
try {
|
try {
|
||||||
// 40 small files per second
|
// 40 small files per second
|
||||||
Thread.sleep(25);
|
Thread.sleep(25);
|
||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException ignored) {}
|
||||||
}
|
}
|
||||||
final String tarEntryName = tarEntry.getName();
|
final String tarEntryName = tarEntry.getName();
|
||||||
// publishProgress(null, "Unpacking " + tarEntry.getName());
|
// publishProgress(null, "Unpacking " + tarEntry.getName());
|
||||||
|
@ -8,7 +8,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -21,22 +20,22 @@ import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RTRecyclerViewAdapter extends RecyclerView.Adapter {
|
public class RTRecyclerViewAdapter extends RecyclerView.Adapter<RTRecyclerViewAdapter.RTViewHolder> {
|
||||||
MultiRTConfigDialog dialog;
|
MultiRTConfigDialog dialog;
|
||||||
public RTRecyclerViewAdapter(MultiRTConfigDialog dialog) {
|
public RTRecyclerViewAdapter(MultiRTConfigDialog dialog) {
|
||||||
this.dialog = dialog;
|
this.dialog = dialog;
|
||||||
}
|
}
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RTViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View recyclableView = LayoutInflater.from(parent.getContext()).inflate(R.layout.multirt_recyclable_view,parent,false);
|
View recyclableView = LayoutInflater.from(parent.getContext()).inflate(R.layout.multirt_recyclable_view,parent,false);
|
||||||
return new RTViewHolder(recyclableView);
|
return new RTViewHolder(recyclableView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RTViewHolder holder, int position) {
|
||||||
final List<MultiRTUtils.Runtime> runtimes = MultiRTUtils.getRuntimes();
|
final List<MultiRTUtils.Runtime> runtimes = MultiRTUtils.getRuntimes();
|
||||||
((RTViewHolder)holder).bindRuntime(runtimes.get(position),position);
|
holder.bindRuntime(runtimes.get(position),position);
|
||||||
}
|
}
|
||||||
public boolean isDefaultRuntime(MultiRTUtils.Runtime rt) {
|
public boolean isDefaultRuntime(MultiRTUtils.Runtime rt) {
|
||||||
return LauncherPreferences.PREF_DEFAULT_RUNTIME.equals(rt.name);
|
return LauncherPreferences.PREF_DEFAULT_RUNTIME.equals(rt.name);
|
||||||
@ -88,7 +87,7 @@ public class RTRecyclerViewAdapter extends RecyclerView.Adapter {
|
|||||||
if (currentRuntime != null) {
|
if (currentRuntime != null) {
|
||||||
final ProgressDialog barrier = new ProgressDialog(ctx);
|
final ProgressDialog barrier = new ProgressDialog(ctx);
|
||||||
barrier.setMessage(ctx.getString(R.string.global_waiting));
|
barrier.setMessage(ctx.getString(R.string.global_waiting));
|
||||||
barrier.setProgressStyle(barrier.STYLE_SPINNER);
|
barrier.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||||
barrier.setCancelable(false);
|
barrier.setCancelable(false);
|
||||||
barrier.show();
|
barrier.show();
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user