fix some minor crashes

This commit is contained in:
Phillip Thelen 2020-07-30 13:06:35 +02:00
parent fb4ab4203d
commit 205a23bb2d
5 changed files with 19 additions and 6 deletions

View file

@ -10,12 +10,12 @@
<FrameLayout
android:id="@+id/image_view_wrapper"
android:layout_width="65dp"
android:layout_height="74dp"
android:layout_height="65dp"
android:layout_gravity="center">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center"
app:actualImageScaleType="fitCenter"/>
</FrameLayout>

View file

@ -12,6 +12,7 @@ import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.UnsupportedEncodingException
import java.lang.IllegalStateException
import java.math.BigInteger
import java.security.*
import java.util.*
@ -188,6 +189,8 @@ constructor(ctx: Context, var sharedPreferences: SharedPreferences, var keyStore
null
} catch (e: GeneralSecurityException) {
null
} catch (e: IllegalStateException) {
null
}
}

View file

@ -5,6 +5,7 @@ import android.content.Intent
import com.habitrpg.android.habitica.HabiticaBaseApplication
import com.habitrpg.android.habitica.proxy.CrashlyticsProxy
import org.solovyev.android.checkout.*
import java.lang.NullPointerException
import java.util.*
import javax.annotation.Nonnull
@ -92,7 +93,11 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
private fun loadInventory(type: String, skus: List<String>, callback: Inventory.Callback) {
val request = Inventory.Request.create().loadAllPurchases().loadSkus(type, skus)
if (request != null) {
inventory?.load(request, callback)
try {
inventory?.load(request, callback)
} catch (e: NullPointerException) {
return
}
}
}

View file

@ -19,14 +19,16 @@ class HabiticaFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
userComponent?.inject(this)
pushNotificationManager.displayNotification(remoteMessage)
if (this::pushNotificationManager.isInitialized) {
pushNotificationManager.displayNotification(remoteMessage)
}
}
override fun onNewToken(s: String) {
super.onNewToken(s)
userComponent?.inject(this)
val refreshedToken = FirebaseInstanceId.getInstance().token
if (refreshedToken != null) {
if (refreshedToken != null && this::pushNotificationManager.isInitialized) {
pushNotificationManager.refreshedToken = refreshedToken
}
}

View file

@ -291,6 +291,9 @@ open class TaskRecyclerViewFragment : BaseFragment(), androidx.swiperefreshlayou
protected fun showBrokenChallengeDialog(task: Task) {
context?.let {
if (!task.isValid) {
return
}
taskRepository.getTasksForChallenge(task.challengeID).subscribe(Consumer { tasks ->
val taskCount = tasks.size
val dialog = HabiticaAlertDialog(it)