From 871d9d7a73f07c392e615c4957fe6585fe8a516a Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 15 May 2018 09:18:04 +0200 Subject: [PATCH] add a fallback if getLaunchIntent returns null --- .../calendar/helpers/MyWidgetListProvider.kt | 5 +++-- .../calendar/helpers/MyWidgetMonthlyProvider.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt index ee2f21a88..2e2903d86 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt @@ -9,6 +9,7 @@ import android.content.Intent import android.net.Uri import android.widget.RemoteViews import com.simplemobiletools.calendar.R +import com.simplemobiletools.calendar.activities.SplashActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.launchNewEventIntent import com.simplemobiletools.calendar.services.WidgetService @@ -50,7 +51,7 @@ class MyWidgetListProvider : AppWidgetProvider() { views.setRemoteAdapter(R.id.widget_event_list, this) } - val startActivityIntent = context.getLaunchIntent() + val startActivityIntent = context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java) val startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT) views.setPendingIntentTemplate(R.id.widget_event_list, startActivityPendingIntent) views.setEmptyView(R.id.widget_event_list, R.id.widget_event_list_empty) @@ -79,7 +80,7 @@ class MyWidgetListProvider : AppWidgetProvider() { } private fun launchDayActivity(context: Context) { - context.getLaunchIntent().apply { + (context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply { putExtra(DAY_CODE, Formatter.getDayCodeFromDateTime(DateTime())) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(this) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt index 05529164d..672b39dfa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt @@ -10,6 +10,7 @@ import android.content.res.Resources import android.view.View import android.widget.RemoteViews import com.simplemobiletools.calendar.R +import com.simplemobiletools.calendar.activities.SplashActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.launchNewEventIntent import com.simplemobiletools.calendar.interfaces.MonthlyCalendar @@ -45,7 +46,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { } private fun setupAppOpenIntent(context: Context, views: RemoteViews, id: Int, dayCode: String) { - context.getLaunchIntent().apply { + (context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply { putExtra(DAY_CODE, dayCode) putExtra(OPEN_MONTH, true) val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode.substring(0, 6)), this, 0) @@ -54,7 +55,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { } private fun setupDayOpenIntent(context: Context, views: RemoteViews, id: Int, dayCode: String) { - context.getLaunchIntent().apply { + (context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply { putExtra(DAY_CODE, dayCode) val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode), this, 0) views.setOnClickPendingIntent(id, pendingIntent)