From a47b9f23ee847d208d1408c3ca32f8a56cdeecd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Jans=C3=B8n=20Engvik?= Date: Sun, 13 Jan 2013 19:23:05 +0100 Subject: [PATCH] Fixed loading of thumbnails. --- res/layout/event_list_row.xml | 26 ++++++++++++++----- src/com/studentersamfundet/app/Event.java | 8 +----- .../app/JSONParserProgram.java | 1 + .../app/network/ImageLoader.java | 13 +++++++++- .../app/ui/lists/EventListActivity.java | 1 + 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/res/layout/event_list_row.xml b/res/layout/event_list_row.xml index 93ba490..2e9d90a 100644 --- a/res/layout/event_list_row.xml +++ b/res/layout/event_list_row.xml @@ -6,23 +6,35 @@ android:paddingTop="3px" android:paddingBottom="3px"> - + android:padding="5dp" + android:layout_marginRight="5dp" > + + + + { private final ViewGroup parent; private final int position; private final int imageId; + private int progressbarId = -1; public ImageLoader(ViewGroup parent, int position, int imageId) { this.parent = parent; @@ -30,7 +32,7 @@ public class ImageLoader extends AsyncTask { protected Drawable doInBackground(String... params) { if (params.length > 1) throw new InvalidParameterException("Too many arguments to the function!"); - + Drawable d = cache.get(params[0]); if (d != null) return d; @@ -55,9 +57,18 @@ public class ImageLoader extends AsyncTask { ViewGroup row = (ViewGroup)parent.getChildAt(position); if (row != null) { + if (progressbarId > 0) { + View pb = row.findViewById(progressbarId); + pb.setVisibility(View.GONE); + } ImageView image = (ImageView)row.findViewById(imageId); image.setImageDrawable(result); + image.setVisibility(View.VISIBLE); } } } + + public void setProgressbar(int id) { + this.progressbarId = id; + } } diff --git a/src/com/studentersamfundet/app/ui/lists/EventListActivity.java b/src/com/studentersamfundet/app/ui/lists/EventListActivity.java index ea7243a..371379d 100644 --- a/src/com/studentersamfundet/app/ui/lists/EventListActivity.java +++ b/src/com/studentersamfundet/app/ui/lists/EventListActivity.java @@ -96,6 +96,7 @@ public class EventListActivity extends BaseListActivity { /* Set images: */ ImageLoader loader = new ImageLoader(parent, position, R.id.event_list_row_image); + loader.setProgressbar(R.id.event_list_row_image_pb); loader.execute(e.getImageUri(imageSize).toString());