diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java index 6da7fa414..943c3b7c4 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java @@ -116,11 +116,10 @@ public abstract class BaseLauncherActivity extends BaseActivity { if (verJsonFile.exists()) { mTask.onPostExecute(null); } else { - new AlertDialog.Builder(this) - .setTitle(R.string.global_error) - .setMessage(R.string.mcl_launch_error_localmode) - .setPositiveButton(android.R.string.ok, null) - .show(); + Tools.dialogOnUiThread(this, + getString(R.string.global_error), + getString(R.string.mcl_launch_error_localmode) + ); } }else { mTask.execute(getVersionId(prof.lastVersionId)); @@ -131,16 +130,11 @@ public abstract class BaseLauncherActivity extends BaseActivity { } public static String getVersionId(String input) { - Map lReleaseMaps = (Map)ExtraCore.getValue(ExtraConstants.RELEASE_TABLE); - if(lReleaseMaps == null || lReleaseMaps.isEmpty()) return input; - switch(input) { - case "latest-release": - return lReleaseMaps.get("release"); - case "latest-snapshot": - return lReleaseMaps.get("snapshot"); - default: - return input; - } + Map releaseTable = (Map)ExtraCore.getValue(ExtraConstants.RELEASE_TABLE); + if(releaseTable == null || releaseTable.isEmpty()) return input; + if("latest-release".equals(input)) return releaseTable.get("release"); + if("latest-snapshot".equals(input)) return releaseTable.get("snapshot"); + return input; } @Override diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java index 6bef51a9b..1f59c41cb 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java @@ -192,7 +192,7 @@ public class PojavLauncherActivity extends BaseLauncherActivity setupBasicList(this); //mAvailableVersions; - ProfileAdapter profileAdapter = new ProfileAdapter(this); + ProfileAdapter profileAdapter = new ProfileAdapter(this, true); ProfileEditor profileEditor = new ProfileEditor(this,(name, isNew, deleting)->{ LauncherProfiles.update(); if(isNew) { diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java index c641654e9..bef5f4683 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileAdapter.java @@ -1,11 +1,7 @@ package net.kdt.pojavlaunch.profiles; import android.content.Context; -import android.database.DataSetObserver; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.util.Base64; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -28,23 +24,23 @@ import java.util.Map; public class ProfileAdapter extends BaseAdapter { Map profiles; public static final String CREATE_PROFILE_MAGIC = "___extra____profile-create"; - static final MinecraftProfile DUMMY = new MinecraftProfile(); - static MinecraftProfile CREATE_PROFILE; + final MinecraftProfile dummy = new MinecraftProfile(); + private MinecraftProfile createProfile; List profileList; - public ProfileAdapter(Context context) { + public ProfileAdapter(Context context, boolean enableCreateButton) { ProfileIconCache.initDefault(context); LauncherProfiles.update(); profiles = new HashMap<>(LauncherProfiles.mainProfileJson.profiles); - if(CREATE_PROFILE == null) { - CREATE_PROFILE = new MinecraftProfile(); - CREATE_PROFILE.name = "Create new profile"; - CREATE_PROFILE.lastVersionId = ""; + if(enableCreateButton) { + createProfile = new MinecraftProfile(); + createProfile.name = "Create new profile"; + createProfile.lastVersionId = ""; } profileList = new ArrayList<>(Arrays.asList(profiles.keySet().toArray(new String[0]))); - profileList.add(ProfileAdapter.CREATE_PROFILE_MAGIC); - profiles.put(CREATE_PROFILE_MAGIC, CREATE_PROFILE); - - + if(enableCreateButton) { + profileList.add(ProfileAdapter.CREATE_PROFILE_MAGIC); + profiles.put(CREATE_PROFILE_MAGIC, createProfile); + } } /* * Gets how much profiles are loaded in the adapter right now @@ -91,7 +87,7 @@ public class ProfileAdapter extends BaseAdapter { profiles = new HashMap<>(LauncherProfiles.mainProfileJson.profiles); profileList = new ArrayList<>(Arrays.asList(profiles.keySet().toArray(new String[0]))); profileList.add(ProfileAdapter.CREATE_PROFILE_MAGIC); - profiles.put(CREATE_PROFILE_MAGIC, CREATE_PROFILE); + profiles.put(CREATE_PROFILE_MAGIC, createProfile); super.notifyDataSetChanged(); } @@ -104,7 +100,7 @@ public class ProfileAdapter extends BaseAdapter { } public void setViewProfile(View v, String nm) { MinecraftProfile minecraftProfile = profiles.get(nm); - if(minecraftProfile == null) minecraftProfile = DUMMY; + if(minecraftProfile == null) minecraftProfile = dummy; Bitmap cachedIcon = ProfileIconCache.getCachedIcon(nm); ImageView iconView = v.findViewById(R.id.vprof_icon_view); if(cachedIcon == null) {