Fixations

This commit is contained in:
artdeell 2022-03-20 13:42:16 +03:00
parent 8685b4969c
commit 68b10bcc89
3 changed files with 23 additions and 33 deletions

View File

@ -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<String,String> lReleaseMaps = (Map<String,String>)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<String,String> releaseTable = (Map<String,String>)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

View File

@ -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) {

View File

@ -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<String, MinecraftProfile> 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<String> 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) {