Bugfixes
This commit is contained in:
@ -10,6 +10,7 @@ import com.tommasoberlose.anotherwidget.db.EventRepository
|
||||
import com.tommasoberlose.anotherwidget.models.Event
|
||||
import com.tommasoberlose.anotherwidget.global.Preferences
|
||||
import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver
|
||||
import com.tommasoberlose.anotherwidget.services.UpdatesWorker
|
||||
import com.tommasoberlose.anotherwidget.ui.activities.MainActivity
|
||||
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
|
||||
import com.tommasoberlose.anotherwidget.utils.checkGrantedPermission
|
||||
@ -124,7 +125,8 @@ object CalendarHelper {
|
||||
eventRepository.resetNextEventData()
|
||||
}
|
||||
|
||||
UpdatesReceiver.setUpdates(context)
|
||||
UpdatesWorker.setUpdates(context)
|
||||
Log.d("ciao", "force update? 7")
|
||||
MainWidget.updateWidget(context)
|
||||
|
||||
EventBus.getDefault().post(MainActivity.UpdateUiMessageEvent())
|
||||
|
@ -2,6 +2,8 @@ package com.tommasoberlose.anotherwidget.helpers
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.kwabenaberko.openweathermaplib.constants.Units
|
||||
import com.kwabenaberko.openweathermaplib.implementation.OpenWeatherMapHelper
|
||||
@ -24,7 +26,7 @@ object WeatherHelper {
|
||||
val networkApi = WeatherNetworkApi(context)
|
||||
if (Preferences.customLocationAdd != "") {
|
||||
networkApi.updateWeather()
|
||||
} else if (context.checkGrantedPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION)) {
|
||||
} else if (context.checkGrantedPermission(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
LocationServices.getFusedLocationProviderClient(context).lastLocation.addOnCompleteListener { task ->
|
||||
if (task.isSuccessful) {
|
||||
val location = task.result
|
||||
|
@ -39,4 +39,13 @@ object WidgetHelper {
|
||||
private fun Context.dip(value: Int): Int = (value * resources.displayMetrics.density).toInt()
|
||||
|
||||
}
|
||||
|
||||
fun Pair<Int, Int>.reduceDimensionWithMaxWidth(width: Int): Pair<Int, Int> {
|
||||
return if (first < width) {
|
||||
this
|
||||
} else {
|
||||
val factor = width / first
|
||||
width to second * factor
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user