mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 14:51:51 -04:00
Fix[code]: clearer meanings for some stuff and remove hardcoded -1, -1 for ProgressKeeper
This commit is contained in:
parent
e6af83b2e2
commit
f1ee8f0177
@ -18,12 +18,12 @@ public class DownloadMirror {
|
||||
public static final int DOWNLOAD_CLASS_METADATA = 1;
|
||||
public static final int DOWNLOAD_CLASS_ASSETS = 2;
|
||||
|
||||
private static final String URL_PROTOCOL_TAIL = "://";
|
||||
private static final String[] MIRROR_BMCLAPI = {
|
||||
"https://bmclapi2.bangbang93.com/maven",
|
||||
"https://bmclapi2.bangbang93.com",
|
||||
"https://bmclapi2.bangbang93.com/assets"
|
||||
};
|
||||
|
||||
private static final String[] MIRROR_MCBBS = {
|
||||
"https://download.mcbbs.net/maven",
|
||||
"https://download.mcbbs.net",
|
||||
@ -91,15 +91,14 @@ public class DownloadMirror {
|
||||
}
|
||||
|
||||
private static int getBaseUrlTail(String wholeUrl) throws MalformedURLException{
|
||||
int protocolNameEnd = wholeUrl.indexOf("://");
|
||||
int protocolNameEnd = wholeUrl.indexOf(URL_PROTOCOL_TAIL);
|
||||
if(protocolNameEnd == -1)
|
||||
throw new MalformedURLException("No protocol, or non path-based URL");
|
||||
protocolNameEnd += 3;
|
||||
protocolNameEnd += URL_PROTOCOL_TAIL.length();
|
||||
int hostnameEnd = wholeUrl.indexOf('/', protocolNameEnd);
|
||||
if(protocolNameEnd >= wholeUrl.length() || hostnameEnd == protocolNameEnd)
|
||||
throw new MalformedURLException("No hostname");
|
||||
if(hostnameEnd == -1) hostnameEnd = wholeUrl.length();
|
||||
System.out.println(protocolNameEnd +" "+ hostnameEnd);
|
||||
return hostnameEnd;
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,6 @@ public class LauncherPreferenceJavaFragment extends LauncherPreferenceFragment {
|
||||
if(data != null) Tools.installRuntimeFromUri(getContext(), data);
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle b, String str) {
|
||||
int ramAllocation = LauncherPreferences.PREF_RAM_ALLOCATION;
|
||||
|
@ -92,7 +92,7 @@ public class AsyncMinecraftDownloader {
|
||||
|
||||
// THIS one function need the activity in the case of an error
|
||||
if(activity != null && !JRE17Util.installNewJreIfNeeded(activity, verInfo)){
|
||||
ProgressKeeper.submitProgress(ProgressLayout.DOWNLOAD_MINECRAFT, -1, -1);
|
||||
ProgressLayout.clearProgress(ProgressLayout.DOWNLOAD_MINECRAFT);
|
||||
throw new DownloaderException();
|
||||
}
|
||||
|
||||
@ -188,11 +188,11 @@ public class AsyncMinecraftDownloader {
|
||||
}
|
||||
}
|
||||
} catch (DownloaderException e) {
|
||||
ProgressKeeper.submitProgress(ProgressLayout.DOWNLOAD_MINECRAFT, -1, -1);
|
||||
ProgressLayout.clearProgress(ProgressLayout.DOWNLOAD_MINECRAFT);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
Log.e("AsyncMcDownloader", e.toString(),e );
|
||||
ProgressKeeper.submitProgress(ProgressLayout.DOWNLOAD_MINECRAFT, -1, -1);
|
||||
ProgressLayout.clearProgress(ProgressLayout.DOWNLOAD_MINECRAFT);
|
||||
throw new DownloaderException(e);
|
||||
}
|
||||
|
||||
@ -211,10 +211,10 @@ public class AsyncMinecraftDownloader {
|
||||
downloadAssets(assets, assets.mapToResources ? new File(Tools.OBSOLETE_RESOURCES_PATH) : new File(Tools.ASSETS_PATH));
|
||||
} catch (Exception e) {
|
||||
Log.e("AsyncMcDownloader", e.toString(), e);
|
||||
ProgressKeeper.submitProgress(ProgressLayout.DOWNLOAD_MINECRAFT, -1, -1);
|
||||
ProgressLayout.clearProgress(ProgressLayout.DOWNLOAD_MINECRAFT);
|
||||
throw new DownloaderException(e);
|
||||
}
|
||||
ProgressKeeper.submitProgress(ProgressLayout.DOWNLOAD_MINECRAFT, -1, -1);
|
||||
ProgressLayout.clearProgress(ProgressLayout.DOWNLOAD_MINECRAFT);
|
||||
}
|
||||
|
||||
public void verifyAndDownloadMainJar(String url, String sha1, File destination) throws Exception{
|
||||
|
Loading…
x
Reference in New Issue
Block a user