aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/cgeoimages.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2011-09-26 11:52:44 +0200
committerSamuel Tardieu <sam@rfc1149.net>2011-09-26 11:52:44 +0200
commit78fccfda0f8719e292103adbbed30e87c44721e1 (patch)
tree9b5e86e225ee366d03b87e0d8b87b8780e78ff07 /main/src/cgeo/geocaching/cgeoimages.java
parent2019e29040b01947b4ab8a5ab83754f171f390ca (diff)
downloadcgeo-78fccfda0f8719e292103adbbed30e87c44721e1.zip
cgeo-78fccfda0f8719e292103adbbed30e87c44721e1.tar.gz
cgeo-78fccfda0f8719e292103adbbed30e87c44721e1.tar.bz2
Use symbolic "what" names in message
Diffstat (limited to 'main/src/cgeo/geocaching/cgeoimages.java')
-rw-r--r--main/src/cgeo/geocaching/cgeoimages.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/main/src/cgeo/geocaching/cgeoimages.java b/main/src/cgeo/geocaching/cgeoimages.java
index c1a6bee..5b4720a 100644
--- a/main/src/cgeo/geocaching/cgeoimages.java
+++ b/main/src/cgeo/geocaching/cgeoimages.java
@@ -48,6 +48,9 @@ public class cgeoimages extends AbstractActivity {
private int countDone = 0;
private String load_process_string;
+ private final static int IMG_LOAD_SUCCESS = 0;
+ private final static int IMG_LOAD_FAILURE = 1;
+
private Handler loadImagesHandler = new Handler() {
@Override
@@ -108,15 +111,15 @@ public class cgeoimages extends AbstractActivity {
@Override
public void run() {
- BitmapDrawable image = null;
try {
cgHtmlImg imgGetter = new cgHtmlImg(cgeoimages.this, geocode, true, offline, false, save);
- image = imgGetter.getDrawable(img.url);
- Message message = handler.obtainMessage(0, image);
+ final BitmapDrawable image = imgGetter.getDrawable(img.url);
+ Message message = handler.obtainMessage(IMG_LOAD_SUCCESS, image);
handler.sendMessage(message);
} catch (Exception e) {
Log.e(cgSettings.tag, "cgeoimages.onCreate.onClick.run: " + e.toString());
+ handler.sendMessage(handler.obtainMessage(IMG_LOAD_FAILURE));
}
}
@@ -254,12 +257,11 @@ public class cgeoimages extends AbstractActivity {
@Override
public void handleMessage(Message message) {
- final BitmapDrawable image = (BitmapDrawable) message.obj;
- if (image != null) {
- ImageView image_view = null;
- image_view = (ImageView) inflater.inflate(R.layout.image_item, null);
+ if (message.what == IMG_LOAD_SUCCESS) {
+ final BitmapDrawable image = (BitmapDrawable) message.obj;
+ final ImageView image_view = (ImageView) inflater.inflate(R.layout.image_item, null);
- Rect bounds = image.getBounds();
+ final Rect bounds = image.getBounds();
image_view.setImageResource(R.drawable.image_not_loaded);
image_view.setClickable(true);