add a fallback if getLaunchIntent returns null
This commit is contained in:
parent
82c1bb4934
commit
871d9d7a73
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue