Update the bitmap factory and the location request. Fixed #53

This commit is contained in:
Tommaso Berlose
2020-05-05 01:32:51 +02:00
parent bea0803c3a
commit 4feb72381d
45 changed files with 56 additions and 40 deletions

View File

@ -7,6 +7,7 @@ import android.util.Log
import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.drawToBitmap
import com.google.firebase.crashlytics.FirebaseCrashlytics
import java.lang.Exception
@ -19,10 +20,11 @@ object BitmapHelper {
view.measure(measuredWidth, measuredHeight)
return try {
Log.d("ciao", "bitmap ${view.measuredWidth}, ${view.measuredHeight} - draw = ${draw}")
val btm = Bitmap.createBitmap(
view.measuredWidth,
view.measuredHeight,
Bitmap.Config.ARGB_8888
if (draw) Bitmap.Config.ARGB_8888 else Bitmap.Config.ALPHA_8
)
if (draw) {
//Bind a canvas to it
@ -35,7 +37,7 @@ object BitmapHelper {
btm
} catch (ex: Exception) {
FirebaseCrashlytics.getInstance().recordException(ex)
Bitmap.createBitmap(5, 5, Bitmap.Config.ARGB_8888)
Bitmap.createBitmap(5, 5, Bitmap.Config.ALPHA_8)
}
}

View File

@ -24,7 +24,7 @@ object WeatherHelper {
val networkApi = WeatherNetworkApi(context)
if (Preferences.customLocationAdd != "") {
networkApi.updateWeather()
} else if (context.checkGrantedPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
} else if (context.checkGrantedPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION)) {
LocationServices.getFusedLocationProviderClient(context).lastLocation.addOnCompleteListener { task ->
if (task.isSuccessful) {
val location = task.result