handle activeSubscriptionInfoList returning null

This commit is contained in:
tibbi 2020-05-13 15:34:45 +02:00
parent 64bb563ef6
commit 98a7095324
2 changed files with 5 additions and 3 deletions

View File

@ -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<Int, String>()
subscriptionIdToSimId[-1] = "?"
SubscriptionManager.from(this).activeSubscriptionInfoList.forEachIndexed { index, subscriptionInfo ->
SubscriptionManager.from(this).activeSubscriptionInfoList?.forEachIndexed { index, subscriptionInfo ->
subscriptionIdToSimId[subscriptionInfo.subscriptionId] = "${index + 1}"
}

View File

@ -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<ThreadItem
itemClick: (Any) -> 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)