Revision | 092657133f24dd545ca6d991bd12a281d98f9ac5 (tree) |
---|---|
Zeit | 2018-08-03 14:26:14 |
Autor | HMML <hmml3939@gmai...> |
Commiter | HMML |
Handle exception on setting null weather icon image.
@@ -7,8 +7,8 @@ android { | ||
7 | 7 | applicationId "cloud.hmml.mmw" |
8 | 8 | minSdkVersion 17 |
9 | 9 | targetSdkVersion 27 |
10 | - versionCode 8 | |
11 | - versionName '0.4.4' | |
10 | + versionCode 9 | |
11 | + versionName '0.4.5' | |
12 | 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
13 | 13 | |
14 | 14 | } |
@@ -59,10 +59,10 @@ public class WeatherDispWidget extends AppWidgetProvider { | ||
59 | 59 | |
60 | 60 | if (conf.loadWeatherIdent(1) != null) { |
61 | 61 | Bitmap icon = theme.getIconBitmap(conf.loadWeatherIdent(1)); |
62 | - if (metrics.widthPixels < icon.getWidth()) { | |
62 | + if (icon != null && metrics.widthPixels < icon.getWidth()) { | |
63 | 63 | // resize if icon is bigger than twice to avoid memory limit exception... |
64 | 64 | views.setImageViewBitmap(R.id.weather_image_today, |
65 | - Bitmap.createScaledBitmap(icon, metrics.widthPixels/2, metrics.widthPixels * icon.getHeight() / icon.getWidth() / 2, true)); | |
65 | + Bitmap.createScaledBitmap(icon, metrics.widthPixels / 2, metrics.widthPixels * icon.getHeight() / icon.getWidth() / 2, true)); | |
66 | 66 | } else { |
67 | 67 | views.setImageViewBitmap(R.id.weather_image_today, icon); |
68 | 68 | } |
@@ -82,9 +82,9 @@ public class WeatherDispWidget extends AppWidgetProvider { | ||
82 | 82 | |
83 | 83 | if (conf.loadWeatherIdent(2) != null) { |
84 | 84 | Bitmap icon = theme.getIconBitmap(conf.loadWeatherIdent(2)); |
85 | - if (metrics.widthPixels < icon.getWidth()) { | |
85 | + if (icon != null && metrics.widthPixels < icon.getWidth()) { | |
86 | 86 | views.setImageViewBitmap(R.id.weather_image_tomorrow, |
87 | - Bitmap.createScaledBitmap(icon, metrics.widthPixels/2, metrics.widthPixels * icon.getHeight() / icon.getWidth() / 2, true)); | |
87 | + Bitmap.createScaledBitmap(icon, metrics.widthPixels / 2, metrics.widthPixels * icon.getHeight() / icon.getWidth() / 2, true)); | |
88 | 88 | } else { |
89 | 89 | views.setImageViewBitmap(R.id.weather_image_tomorrow, icon); |
90 | 90 | } |