Fixed loading of thumbnails.

This commit is contained in:
Lars Jansøn Engvik committed 2013-01-13 19:23:05 +01:00
1 parent c741d41d71
commit a47b9f23ee
5 files changed
+34 -15

No files matched your search

+19 -7
View File
@@ -6,23 +6,35 @@
android:paddingTop="3px"
android:paddingBottom="3px">
<ImageView android:id="@+id/event_list_row_image"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
<FrameLayout android:id="@+id/event_list_row_image_fl"
android:layout_height="40dp"
android:layout_width="40dp"
android:layout_alignParentLeft="true"
android:padding="5px"
android:layout_marginRight="5px" />
android:padding="5dp"
android:layout_marginRight="5dp" >
<ProgressBar android:id="@+id/event_list_row_image_pb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
/>
<ImageView android:id="@+id/event_list_row_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:scaleType="fitXY"/>
</FrameLayout>
<TextView android:id="@+id/event_list_row_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/event_list_row_image"
android:layout_toRightOf="@id/event_list_row_image_fl"
android:layout_alignParentTop="true" />
<TextView android:id="@+id/event_list_row_date"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/event_list_row_image"
android:layout_toRightOf="@id/event_list_row_image_fl"
android:layout_below="@id/event_list_row_text" />
<TextView android:id="@+id/event_list_row_price"
+1 -7
View File
@@ -83,13 +83,7 @@ public class Event implements Serializable {
if (this.id <= 0) {
return null;
}
String imageUri = "http://studentersamfundet.no/imageResize.php?pic=bilder/program/{img}&maxwidth={width}&maxheight={height}&crop=1";
imageUri = imageUri.replace("{img}", this.image);
imageUri = imageUri.replace("{width}", Integer.toString(size));
imageUri = imageUri.replace("{height}", Integer.toString(size));
return Uri.parse(imageUri);
return Uri.parse(image);
}
public String getPriceString() {
@@ -57,6 +57,7 @@ public class JSONParserProgram implements IParser {
date = tempJSON.getString("date");
text = tempJSON.getString("content");
image = tempJSON.getString("thumbnail");
Log.d("TMB", image);
category = tempJSON.getString("event");
tempJSON = tempJSON.getJSONObject("custom_fields");
@@ -11,6 +11,7 @@ import java.util.concurrent.ConcurrentMap;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -19,6 +20,7 @@ public class ImageLoader extends AsyncTask<String, Void, Drawable> {
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<String, Void, Drawable> {
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<String, Void, Drawable> {
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;
}
}
@@ -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());