diff options
author | Andy Doan <andy.doan@linaro.org> | 2011-09-21 14:02:59 -0500 |
---|---|---|
committer | Andy Doan <doanac@gmail.com> | 2011-09-21 14:47:04 -0500 |
commit | 436811b5891c7260b1d986229a4bda3e8568ecb1 (patch) | |
tree | 377010450100e2c7680f6a31584505ee8da4f43a | |
parent | 47237999e9c791adb38ad75ad05369ec193800d3 (diff) | |
download | LinaroConnect-436811b5891c7260b1d986229a4bda3e8568ecb1.tar.gz |
add activity to view a single JSONImageItem
-rw-r--r-- | AndroidManifest.xml | 6 | ||||
-rw-r--r-- | res/layout/image_view.xml | 17 | ||||
-rw-r--r-- | src/org/linaro/connect/ImageViewActivity.java | 45 |
3 files changed, 68 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 50d4ffe..f78537f 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -20,6 +20,12 @@ <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> + <activity android:name=".ImageViewActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + </intent-filter> + </activity> </application> </manifest>
\ No newline at end of file diff --git a/res/layout/image_view.xml b/res/layout/image_view.xml new file mode 100644 index 0000000..56b335e --- /dev/null +++ b/res/layout/image_view.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView android:id="@+id/image_view_label" + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:textColor="#88b12d" + android:gravity="center" + /> + <ImageView android:id="@+id/image_view_id" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + /> + </LinearLayout>
\ No newline at end of file diff --git a/src/org/linaro/connect/ImageViewActivity.java b/src/org/linaro/connect/ImageViewActivity.java new file mode 100644 index 0000000..c192f79 --- /dev/null +++ b/src/org/linaro/connect/ImageViewActivity.java @@ -0,0 +1,45 @@ +package org.linaro.connect; + +import android.app.Activity; +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; +import android.os.Bundle; +import android.view.Window; +import android.widget.ImageView; +import android.widget.TextView; + +public class ImageViewActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); + super.onCreate(savedInstanceState); + + setContentView(R.layout.image_view); + setProgressBarIndeterminateVisibility(true); + + Intent i = getIntent(); + String json = i.getStringExtra("json"); + JSONImageItem jsi = new JSONImageItem(JSONUtils.toJSON(json)); + + TextView tv = (TextView)findViewById(R.id.image_view_label); + tv.setText(jsi.getLabel()); + new DownloadTask().execute(jsi); + } + + private class DownloadTask extends AsyncTask<JSONImageItem, Void, Drawable> { + @Override + protected Drawable doInBackground(JSONImageItem... jsi) { + return jsi[0].getFullSize(); + } + + @Override + protected void onPostExecute(Drawable result) { + ImageView iv = (ImageView)findViewById(R.id.image_view_id); + if (result != null) + iv.setImageDrawable(result); + setProgressBarIndeterminateVisibility(false); + } + } +} |