From 98a70953244e702bfc276f64ad6006cf12367d8e Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 13 May 2020 15:34:45 +0200 Subject: [PATCH] handle activeSubscriptionInfoList returning null --- .../smsmessenger/activities/ThreadActivity.kt | 4 ++-- .../simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index 479d531e..cd545422 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -274,7 +274,7 @@ class ThreadActivity : SimpleActivity() { @SuppressLint("MissingPermission") private fun setupSIMSelector() { - val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList + val availableSIMs = SubscriptionManager.from(this).activeSubscriptionInfoList ?: return if (availableSIMs.size > 1) { availableSIMs.forEachIndexed { index, subscriptionInfo -> var label = subscriptionInfo.displayName.toString() @@ -376,7 +376,7 @@ class ThreadActivity : SimpleActivity() { val subscriptionIdToSimId = HashMap() subscriptionIdToSimId[-1] = "?" - SubscriptionManager.from(this).activeSubscriptionInfoList.forEachIndexed { index, subscriptionInfo -> + SubscriptionManager.from(this).activeSubscriptionInfoList?.forEachIndexed { index, subscriptionInfo -> subscriptionIdToSimId[subscriptionInfo.subscriptionId] = "${index + 1}" } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt index 7eb239b1..0f5a6531 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.smsmessenger.adapters +import android.annotation.SuppressLint import android.content.Intent import android.graphics.drawable.Drawable import android.net.Uri @@ -43,7 +44,8 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt() - private val hasMultipleSIMCards = SubscriptionManager.from(activity).activeSubscriptionInfoList.size > 1 + @SuppressLint("MissingPermission") + private val hasMultipleSIMCards = SubscriptionManager.from(activity).activeSubscriptionInfoList?.size ?: 0 > 1 init { setupDragListener(true)