catch exceptions at filling the widget

This commit is contained in:
tibbi 2018-12-18 09:55:28 +01:00
parent f7e126d69e
commit 81276cb878
2 changed files with 11 additions and 9 deletions

View file

@ -78,7 +78,7 @@ dependencies {
//implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' //implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
//implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.1-fork' //implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.1-fork'
implementation 'com.github.tibbi:subsampling-scale-image-view:4.0.0' implementation 'com.github.tibbi:subsampling-scale-image-view:fcb724fb0a'
// implementation 'com.github.chrisbanes:PhotoView:2.3.0' // implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.github.tibbi:PhotoView:2.3.0-fork' implementation 'com.github.tibbi:PhotoView:2.3.0-fork'

View file

@ -52,14 +52,16 @@ class MyWidgetProvider : AppWidgetProvider() {
val height = appWidgetOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT) val height = appWidgetOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT)
val widgetSize = (Math.max(width, height) * density).toInt() val widgetSize = (Math.max(width, height) * density).toInt()
try {
val image = Glide.with(context) val image = Glide.with(context)
.asBitmap() .asBitmap()
.load(path) .load(path)
.apply(options) .apply(options)
.submit(widgetSize, widgetSize) .submit(widgetSize, widgetSize)
.get() .get()
views.setImageViewBitmap(R.id.widget_imageview, image) views.setImageViewBitmap(R.id.widget_imageview, image)
} catch (e: Exception) {
}
setupAppOpenIntent(context, views, R.id.widget_holder, it) setupAppOpenIntent(context, views, R.id.widget_holder, it)
appWidgetManager.updateAppWidget(it.widgetId, views) appWidgetManager.updateAppWidget(it.widgetId, views)