avoid crash when font does not load, sending crashlytics log though

od
Laurent 6 years ago
parent aff2bacae6
commit 2d77f1ff89
  1. 11
      app/src/main/java/net/pokeranalytics/android/ui/graph/GraphExtensions.kt

@ -1,8 +1,10 @@
package net.pokeranalytics.android.ui.graph
import android.content.Context
import android.content.res.Resources
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import com.crashlytics.android.Crashlytics
import com.github.mikephil.charting.charts.BarChart
import com.github.mikephil.charting.charts.BarLineChartBase
import com.github.mikephil.charting.components.XAxis
@ -32,7 +34,14 @@ fun BarLineChartBase<*>.setStyle(
this.xAxis.isGranularityEnabled = true
this.xAxis.granularity = 1.0f
this.xAxis.textColor = ContextCompat.getColor(context, R.color.chart_default)
this.xAxis.typeface = ResourcesCompat.getFont(context, R.font.roboto_medium)
try {
val font = ResourcesCompat.getFont(context, R.font.roboto_medium)
this.xAxis.typeface = font
} catch (e: Resources.NotFoundException) {
Crashlytics.log(e.message)
}
this.xAxis.labelCount = 4
this.xAxis.textSize = 12f
this.xAxis.isEnabled = true

Loading…
Cancel
Save