Skip to content

Commit cb04f4b

Browse files
committed
fix(NotificationDownloadListener): Crash on no-installer forge versions
Fixes #282
1 parent 63ef7de commit cb04f4b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/modloaders/modpacks/api/NotificationDownloadListener.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@
1414

1515
public class NotificationDownloadListener implements ModloaderDownloadListener {
1616
private final Context mContext;
17+
private final Intent mIntent;
1718
private final ModLoader mModLoader;
1819

1920
public NotificationDownloadListener(Context context, ModLoader modLoader) {
2021
mModLoader = modLoader;
2122
mContext = context.getApplicationContext();
23+
mIntent = new Intent(mContext, LauncherActivity.class);
2224
}
2325

2426
@Override
2527
public void onDownloadFinished(File downloadedFile) {
2628
if(mModLoader.requiresGuiInstallation()) {
2729
ModloaderInstallTracker.saveModLoader(mContext, mModLoader, downloadedFile);
28-
Intent mainActivityIntent = new Intent(mContext, LauncherActivity.class);
29-
sendIntentNotification(mainActivityIntent, R.string.modpack_install_notification_success);
30+
sendIntentNotification(R.string.modpack_install_notification_success);
3031
}
3132
}
3233

@@ -40,11 +41,11 @@ public void onDownloadError(Exception e) {
4041
Tools.showErrorRemote(mContext, R.string.modpack_install_modloader_download_failed, e);
4142
}
4243

43-
private void sendIntentNotification(Intent intent, int localeString) {
44+
private void sendIntentNotification(int localeString) {
4445
Tools.runOnUiThread(() -> NotificationUtils.sendBasicNotification(mContext,
4546
R.string.modpack_install_notification_title,
4647
localeString,
47-
intent,
48+
mIntent,
4849
NotificationUtils.PENDINGINTENT_CODE_DOWNLOAD_SERVICE,
4950
NotificationUtils.NOTIFICATION_ID_DOWNLOAD_LISTENER
5051
));
@@ -54,7 +55,7 @@ private void sendEmptyNotification(int localeString) {
5455
Tools.runOnUiThread(()->NotificationUtils.sendBasicNotification(mContext,
5556
R.string.modpack_install_notification_title,
5657
localeString,
57-
null,
58+
mIntent,
5859
NotificationUtils.PENDINGINTENT_CODE_DOWNLOAD_SERVICE,
5960
NotificationUtils.NOTIFICATION_ID_DOWNLOAD_LISTENER
6061
));

0 commit comments

Comments
 (0)