Refactor[gen]: other minor refactors

This commit is contained in:
artdeell 2023-10-01 11:58:16 +03:00
parent 1151e7fcd2
commit d8ed111b10
7 changed files with 20 additions and 52 deletions

View File

@ -307,7 +307,7 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
if(view != null){ if(view != null){
Bitmap bitmap = mSelectecAccount.getSkinFace(); Bitmap bitmap = mSelectecAccount.getSkinFace();
if(bitmap != null) { if(bitmap != null) {
mHeadDrawable = new BitmapDrawable(bitmap); mHeadDrawable = new BitmapDrawable(getResources(), bitmap);
mHeadDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); mHeadDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
view.setCompoundDrawables(mHeadDrawable, null, null, null); view.setCompoundDrawables(mHeadDrawable, null, null, null);

View File

@ -39,7 +39,6 @@ import fr.spse.extended_view.ExtendedTextView;
*/ */
public class mcVersionSpinner extends ExtendedTextView { public class mcVersionSpinner extends ExtendedTextView {
private static final int VERSION_SPINNER_PROFILE_CREATE = 0; private static final int VERSION_SPINNER_PROFILE_CREATE = 0;
private static final int VERSION_SPINNER_PROFILE_CREATE_MODDED = 1;
public mcVersionSpinner(@NonNull Context context) { public mcVersionSpinner(@NonNull Context context) {
super(context); super(context);
init(); init();
@ -133,11 +132,10 @@ public class mcVersionSpinner extends ExtendedTextView {
} }
private void performExtraAction(ProfileAdapterExtra extra) { private void performExtraAction(ProfileAdapterExtra extra) {
switch (extra.id) { //Replace with switch-case if you want to add more extra actions
case VERSION_SPINNER_PROFILE_CREATE: if (extra.id == VERSION_SPINNER_PROFILE_CREATE) {
Tools.swapFragment((FragmentActivity) getContext(), ProfileTypeSelectFragment.class, Tools.swapFragment((FragmentActivity) getContext(), ProfileTypeSelectFragment.class,
ProfileTypeSelectFragment.TAG, true, null); ProfileTypeSelectFragment.TAG, true, null);
break;
} }
} }

View File

@ -28,6 +28,9 @@ public class CustomControls {
} }
// Generate default control // Generate default control
// Here for historical reasons
// Just admire it idk
@SuppressWarnings("unused")
public CustomControls(Context ctx) { public CustomControls(Context ctx) {
this(); this();
this.mControlDataList.add(new ControlData(ControlData.getSpecialButtons()[0])); // Keyboard this.mControlDataList.add(new ControlData(ControlData.getSpecialButtons()[0])); // Keyboard

View File

@ -1,8 +0,0 @@
package net.kdt.pojavlaunch.modloaders;
import org.json.JSONException;
import org.json.JSONObject;
public interface FabricMetaReader {
boolean processMetadata(JSONObject jsonObject) throws JSONException;
}

View File

@ -1,6 +1,5 @@
package net.kdt.pojavlaunch.modloaders.modpacks.api; package net.kdt.pojavlaunch.modloaders.modpacks.api;
import android.content.Context;
import android.util.Log; import android.util.Log;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
@ -232,11 +231,10 @@ public class CurseforgeApi implements ModpackApi{
if(manifest.minecraft == null) return false; if(manifest.minecraft == null) return false;
if(manifest.minecraft.version == null) return false; if(manifest.minecraft.version == null) return false;
if(manifest.minecraft.modLoaders == null) return false; if(manifest.minecraft.modLoaders == null) return false;
if(manifest.minecraft.modLoaders.length < 1) return false; return manifest.minecraft.modLoaders.length >= 1;
return true;
} }
class CurseforgeSearchResult extends SearchResult { static class CurseforgeSearchResult extends SearchResult {
int previousOffset; int previousOffset;
} }
} }

View File

@ -204,7 +204,7 @@ public class AsyncMinecraftDownloader {
try { try {
if(assets != null) if(assets != null)
downloadAssets(assets, verInfo.assets, assets.mapToResources ? new File(Tools.OBSOLETE_RESOURCES_PATH) : new File(Tools.ASSETS_PATH)); downloadAssets(assets, assets.mapToResources ? new File(Tools.OBSOLETE_RESOURCES_PATH) : new File(Tools.ASSETS_PATH));
} catch (Exception e) { } catch (Exception e) {
Log.e("AsyncMcDownloader", e.toString(), e); Log.e("AsyncMcDownloader", e.toString(), e);
ProgressKeeper.submitProgress(ProgressLayout.DOWNLOAD_MINECRAFT, -1, -1); ProgressKeeper.submitProgress(ProgressLayout.DOWNLOAD_MINECRAFT, -1, -1);
@ -221,7 +221,7 @@ public class AsyncMinecraftDownloader {
(int) Math.max((float)curr/max*100,0), R.string.mcl_launch_downloading_progress, destination.getName(), curr/BYTE_TO_MB, max/BYTE_TO_MB)); (int) Math.max((float)curr/max*100,0), R.string.mcl_launch_downloading_progress, destination.getName(), curr/BYTE_TO_MB, max/BYTE_TO_MB));
} }
public void downloadAssets(final JAssets assets, String assetsVersion, final File outputDir) { public void downloadAssets(final JAssets assets, final File outputDir) {
LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(); LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
final ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 500, TimeUnit.MILLISECONDS, workQueue); final ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 500, TimeUnit.MILLISECONDS, workQueue);

View File

@ -3,12 +3,15 @@ package org.lwjgl.glfw;
import net.kdt.pojavlaunch.*; import net.kdt.pojavlaunch.*;
import android.content.*; import android.content.*;
import android.view.Choreographer; import android.view.Choreographer;
import androidx.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import dalvik.annotation.optimization.CriticalNative; import dalvik.annotation.optimization.CriticalNative;
public class CallbackBridge { public class CallbackBridge {
public static Choreographer sChoreographer = Choreographer.getInstance(); public static final Choreographer sChoreographer = Choreographer.getInstance();
private static boolean isGrabbing = false; private static boolean isGrabbing = false;
private static final ArrayList<GrabListener> grabListeners = new ArrayList<>(); private static final ArrayList<GrabListener> grabListeners = new ArrayList<>();
@ -41,21 +44,11 @@ public class CallbackBridge {
public static void sendKeycode(int keycode, char keychar, int scancode, int modifiers, boolean isDown) { public static void sendKeycode(int keycode, char keychar, int scancode, int modifiers, boolean isDown) {
// TODO CHECK: This may cause input issue, not receive input! // TODO CHECK: This may cause input issue, not receive input!
/*
if (!nativeSendCharMods((int) keychar, modifiers) || !nativeSendChar(keychar)) {
nativeSendKey(keycode, 0, isDown ? 1 : 0, modifiers);
}
*/
//nativeSendKeycode(keycode, keychar, scancode, isDown ? 1 : 0, modifiers);
if(keycode != 0) nativeSendKey(keycode,scancode,isDown ? 1 : 0, modifiers); if(keycode != 0) nativeSendKey(keycode,scancode,isDown ? 1 : 0, modifiers);
//else nativeSendKey(32,scancode,isDown ? 1 : 0, modifiers);
if(isDown && keychar != '\u0000') { if(isDown && keychar != '\u0000') {
nativeSendCharMods(keychar,modifiers); nativeSendCharMods(keychar,modifiers);
nativeSendChar(keychar); nativeSendChar(keychar);
} }
//throw new IllegalStateException("Tracing call");
// sendData(JRE_TYPE_KEYCODE_CONTROL, keycode, Character.toString(keychar), Boolean.toString(isDown), modifiers);
} }
public static void sendChar(char keychar, int modifiers){ public static void sendChar(char keychar, int modifiers){
@ -108,7 +101,8 @@ public class CallbackBridge {
} }
// Called from JRE side // Called from JRE side
public static String accessAndroidClipboard(int type, String copy) { @SuppressWarnings("unused")
public static @Nullable String accessAndroidClipboard(int type, String copy) {
switch (type) { switch (type) {
case CLIPBOARD_COPY: case CLIPBOARD_COPY:
MainActivity.GLOBAL_CLIPBOARD.setPrimaryClip(ClipData.newPlainText("Copy", copy)); MainActivity.GLOBAL_CLIPBOARD.setPrimaryClip(ClipData.newPlainText("Copy", copy));
@ -127,24 +121,6 @@ public class CallbackBridge {
default: return null; default: return null;
} }
} }
/*
private static String currData;
public static void sendData(int type, Object... dataArr) {
currData = "";
for (int i = 0; i < dataArr.length; i++) {
if (dataArr[i] instanceof Integer) {
currData += Integer.toString((int) dataArr[i]);
} else if (dataArr[i] instanceof String) {
currData += (String) dataArr[i];
} else {
currData += dataArr[i].toString();
}
currData += (i + 1 < dataArr.length ? ":" : "");
}
nativeSendData(true, type, currData);
}
private static native void nativeSendData(boolean isAndroid, int type, String data);
*/
public static int getCurrentMods() { public static int getCurrentMods() {
@ -183,10 +159,11 @@ public class CallbackBridge {
case LwjglGlfwKeycode.GLFW_KEY_NUM_LOCK: case LwjglGlfwKeycode.GLFW_KEY_NUM_LOCK:
CallbackBridge.holdingNumlock = isDown; CallbackBridge.holdingNumlock = isDown;
return;
} }
} }
//Called from JRE side
@SuppressWarnings("unused")
private static void onGrabStateChanged(final boolean grabbing) { private static void onGrabStateChanged(final boolean grabbing) {
isGrabbing = grabbing; isGrabbing = grabbing;
sChoreographer.postFrameCallbackDelayed((time) -> { sChoreographer.postFrameCallbackDelayed((time) -> {