Update bitmap generator
This commit is contained in:
@ -15,11 +15,13 @@ object BitmapHelper {
|
||||
|
||||
fun getBitmapFromView(view: View, width: Int? = null, height: Int? = null, draw: Boolean = true): Bitmap {
|
||||
//Define a bitmap with the same size as the view
|
||||
val measuredWidth = View.MeasureSpec.makeMeasureSpec(width ?: view.width, if (width != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.UNSPECIFIED)
|
||||
val measuredWidth = View.MeasureSpec.makeMeasureSpec(width ?: view.width, if (width != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.AT_MOST)
|
||||
val measuredHeight = View.MeasureSpec.makeMeasureSpec(height ?: view.height, if (height != null) View.MeasureSpec.EXACTLY else View.MeasureSpec.UNSPECIFIED)
|
||||
view.measure(measuredWidth, measuredHeight)
|
||||
|
||||
if (draw) {
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("initialWidth", width ?: -1)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("initialHeight", height ?: -1)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredWidth", view.measuredWidth)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredWidth_spec", measuredWidth)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("measuredHeight", view.measuredHeight)
|
||||
|
@ -3,6 +3,7 @@ package com.tommasoberlose.anotherwidget.helpers
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
|
||||
object WidgetHelper {
|
||||
class WidgetSizeProvider(
|
||||
@ -16,6 +17,8 @@ object WidgetHelper {
|
||||
val height = getWidgetHeight(isPortrait, widgetId)
|
||||
val widthInPx = context.dip(width)
|
||||
val heightInPx = context.dip(height)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("widthInPx", widthInPx)
|
||||
FirebaseCrashlytics.getInstance().setCustomKey("heightInPx", heightInPx)
|
||||
return widthInPx to heightInPx
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user