Add workers

This commit is contained in:
Tommaso Berlose
2020-05-06 20:58:32 +02:00
parent 2e684e0902
commit 7076311e94
11 changed files with 237 additions and 46 deletions

View File

@ -20,15 +20,12 @@ object BitmapHelper {
view.measure(measuredWidth, measuredHeight)
return try {
if (draw) {
Log.d("ciao", "bitmap ${view.measuredWidth}, ${view.measuredHeight}")
}
val btm = Bitmap.createBitmap(
view.measuredWidth,
view.measuredHeight,
if (true || draw) Bitmap.Config.ARGB_8888 else Bitmap.Config.ALPHA_8
if (draw) Bitmap.Config.ARGB_8888 else Bitmap.Config.ALPHA_8
)
if (true || draw) {
if (draw) {
//Bind a canvas to it
val canvas = Canvas(btm)
// draw the view on the canvas

View File

@ -125,8 +125,7 @@ object CalendarHelper {
eventRepository.resetNextEventData()
}
UpdatesWorker.setUpdates(context)
Log.d("ciao", "force update? 7")
UpdatesReceiver.setUpdates(context)
MainWidget.updateWidget(context)
EventBus.getDefault().post(MainActivity.UpdateUiMessageEvent())

View File

@ -1,5 +1,6 @@
package com.tommasoberlose.anotherwidget.helpers
import android.appwidget.AppWidgetManager
import android.content.ComponentName
import android.content.ContentUris
import android.content.Context
@ -11,12 +12,23 @@ import android.provider.CalendarContract
import android.provider.CalendarContract.Events
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.models.Event
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
import java.util.*
object IntentHelper {
fun getGoogleMapsIntentFromAddress(context: Context, address:String): Intent {
fun getWidgetUpdateIntent(context: Context): Intent {
val widgetManager = AppWidgetManager.getInstance(context)
val widgetComponent = ComponentName(context, MainWidget::class.java)
val widgetIds = widgetManager.getAppWidgetIds(widgetComponent)
return Intent(context, MainWidget::class.java).apply {
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds)
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
}
}
fun getGoogleMapsIntentFromAddress(context: Context, address: String): Intent {
val gmmIntentUri: Uri = Uri.parse("geo:0,0?q=$address")
val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri)
mapIntent.`package` = "com.google.android.apps.maps"