Surrounds crash with try/catch block

blinds
Laurent 5 years ago
parent 6325daf4c3
commit eb86679fa7
  1. 8
      app/src/main/java/net/pokeranalytics/android/ui/fragment/SubscriptionFragment.kt

@ -1,5 +1,6 @@
package net.pokeranalytics.android.ui.fragment package net.pokeranalytics.android.ui.fragment
import android.content.res.Resources
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
@ -118,6 +119,8 @@ class SubscriptionFragment : BaseFragment(), SkuDetailsResponseListener, Purchas
if (indexOfLastSpace >= 0) { if (indexOfLastSpace >= 0) {
try { // can crash for unknown reasons
val end = upgradeString.chars().count().toInt() val end = upgradeString.chars().count().toInt()
val lightTypeFace = ResourcesCompat.getFont(requireContext(), R.font.roboto_light) val lightTypeFace = ResourcesCompat.getFont(requireContext(), R.font.roboto_light)
val boldTypeFace = ResourcesCompat.getFont(requireContext(), R.font.roboto_bold) val boldTypeFace = ResourcesCompat.getFont(requireContext(), R.font.roboto_bold)
@ -126,6 +129,11 @@ class SubscriptionFragment : BaseFragment(), SkuDetailsResponseListener, Purchas
ssb.setSpan(TypefaceSpan(lightTypeFace), 0, indexOfLastSpace, Spanned.SPAN_EXCLUSIVE_INCLUSIVE) ssb.setSpan(TypefaceSpan(lightTypeFace), 0, indexOfLastSpace, Spanned.SPAN_EXCLUSIVE_INCLUSIVE)
ssb.setSpan(TypefaceSpan(boldTypeFace), indexOfLastSpace, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE) ssb.setSpan(TypefaceSpan(boldTypeFace), indexOfLastSpace, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE)
} }
} catch (e: Resources.NotFoundException) {
CrashLogging.log(e.message ?: "ResourcesCompat.getFont crashes somehow")
}
} }
title.text = ssb title.text = ssb

Loading…
Cancel
Save