diff options
author | Daniel Oeh <daniel@danielpc.(none)> | 2012-04-13 16:21:34 +0200 |
---|---|---|
committer | Daniel Oeh <daniel@danielpc.(none)> | 2012-04-13 16:21:34 +0200 |
commit | d3859b6763abafad11af40e7c2b61355ad498447 (patch) | |
tree | 35c4604e760804cbce13b14f6e89abba7071ed9f | |
parent | eb24d41e1d25548aa9a830b1d15667103dd0ce13 (diff) | |
download | AntennaPod-d3859b6763abafad11af40e7c2b61355ad498447.zip |
Created Activity for viewing items
-rw-r--r-- | AndroidManifest.xml | 1 | ||||
-rw-r--r-- | res/layout/feeditemview.xml | 41 | ||||
-rw-r--r-- | res/values/strings.xml | 6 | ||||
-rw-r--r-- | src/de/podfetcher/activity/FeedItemlistActivity.java | 9 | ||||
-rw-r--r-- | src/de/podfetcher/activity/ItemviewActivity.java | 67 | ||||
-rw-r--r-- | src/de/podfetcher/feed/FeedManager.java | 11 |
6 files changed, 134 insertions, 1 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 83dcf0dad..ac575230b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -28,6 +28,7 @@ <activity android:name="de.podfetcher.activity.AddFeedActivity" android:label="@string/add_new_feed_label"/> <activity android:name="de.podfetcher.activity.FeedItemlistActivity"/> + <activity android:name="de.podfetcher.activity.ItemviewActivity"/> <service android:enabled="true" android:name="de.podfetcher.service.DownloadService" /> </application> diff --git a/res/layout/feeditemview.xml b/res/layout/feeditemview.xml new file mode 100644 index 000000000..d3149ba46 --- /dev/null +++ b/res/layout/feeditemview.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical"> + <TextView + android:id="@+id/txtvItemname" + android:layout_width="fill_parent" + android:layout_height="wrap_content"/> + + <RelativeLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content"> + <ImageView + android:id="@+id/imgvFeedimage" + android:layout_height="90dip" + android:layout_width="90dip" + android:layout_alignParentLeft="true"/> + <LinearLayout + android:layout_height="fill_parent" + android:layout_width="wrap_content" + android:layout_alignParentRight="true" + android:orientation="vertical"> + <Button + android:id="@+id/butPlay" + android:text="@string/play_label" + android:layout_width="fill_parent" + android:layout_height="wrap_content"/> + <Button + android:id="@+id/butDownload" + android:text="@string/download_label" + android:layout_width="fill_parent" + android:layout_height="wrap_content"/> + <Button + android:id="@+id/butRemove" + android:text="@string/remove_label" + android:layout_width="fill_parent" + android:layout_height="wrap_content"/> + </LinearLayout> + </RelativeLayout> +</LinearLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml index 01409a894..ac12da982 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10,4 +10,10 @@ <!-- --> <string name="confirm_label">Confirm</string> + <!-- Feeditemview labels--> + <string name="download_label">Download</string> + <string name="play_label">Play</string> + <string name="description_label">Description</string> + <string name="remove_label">Remove</string> + </resources> diff --git a/src/de/podfetcher/activity/FeedItemlistActivity.java b/src/de/podfetcher/activity/FeedItemlistActivity.java index 6c6d422b1..8bdde2c79 100644 --- a/src/de/podfetcher/activity/FeedItemlistActivity.java +++ b/src/de/podfetcher/activity/FeedItemlistActivity.java @@ -4,6 +4,7 @@ import com.actionbarsherlock.app.SherlockListActivity; import android.view.View; import android.widget.ListView; import android.os.Bundle; +import android.content.Intent; import de.podfetcher.feed.*; import de.podfetcher.adapter.FeedItemlistAdapter; import android.util.Log; @@ -11,6 +12,7 @@ import android.util.Log; /** Displays a List of FeedItems */ public class FeedItemlistActivity extends SherlockListActivity { private static final String TAG = "FeedItemlistActivity"; + public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.podfetcher.activity.selected_feeditem"; private FeedItemlistAdapter fila; private FeedManager manager; @@ -35,6 +37,11 @@ public class FeedItemlistActivity extends SherlockListActivity { @Override protected void onListItemClick(ListView l, View v, int position, long id) { - + FeedItem selection = fila.getItem(position); + Intent showItem = new Intent(this, ItemviewActivity.class); + showItem.putExtra(FeedlistActivity.EXTRA_SELECTED_FEED, feed.getId()); + showItem.putExtra(EXTRA_SELECTED_FEEDITEM, selection.getId()); + + startActivity(showItem); } } diff --git a/src/de/podfetcher/activity/ItemviewActivity.java b/src/de/podfetcher/activity/ItemviewActivity.java new file mode 100644 index 000000000..7322925dc --- /dev/null +++ b/src/de/podfetcher/activity/ItemviewActivity.java @@ -0,0 +1,67 @@ +package de.podfetcher.activity; + +import java.io.File; +import android.net.Uri; +import com.actionbarsherlock.app.SherlockActivity; +import android.view.View; +import android.widget.ListView; +import android.os.Bundle; +import de.podfetcher.feed.*; +import android.util.Log; +import android.content.Intent; +import android.widget.Button; +import android.widget.TextView; +import android.widget.ImageView; +import de.podfetcher.R; + +/** Displays a single FeedItem and provides various actions */ +public class ItemviewActivity extends SherlockActivity { + private static final String TAG = "ItemviewActivity"; + + private FeedManager manager; + private FeedItem item; + + // Widgets + private ImageView imgvImage; + private TextView txtvTitle; + private Button butPlay; + private Button butDownload; + private Button butRemove; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + manager = FeedManager.getInstance(); + extractFeeditem(); + populateUI(); + } + + /** Extracts FeedItem object the activity is supposed to display */ + private void extractFeeditem() { + long itemId = getIntent().getLongExtra(FeedItemlistActivity.EXTRA_SELECTED_FEEDITEM, -1); + long feedId = getIntent().getLongExtra(FeedlistActivity.EXTRA_SELECTED_FEED, -1); + if(itemId == -1 || feedId == -1) { + Log.e(TAG, "Received invalid selection of either feeditem or feed."); + } + Feed feed = manager.getFeed(feedId); + item = manager.getFeedItem(itemId, feed); + } + + private void populateUI() { + setContentView(R.layout.feeditemview); + txtvTitle = (TextView) findViewById(R.id.txtvItemname); + imgvImage = (ImageView) findViewById(R.id.imgvFeedimage); + butPlay = (Button) findViewById(R.id.butPlay); + butDownload = (Button) findViewById(R.id.butDownload); + butRemove = (Button) findViewById(R.id.butRemove); + + setTitle(item.getFeed().getTitle()); + + txtvTitle.setText(item.getTitle()); + if(item.getFeed().getImage() != null) { + imgvImage.setImageURI(Uri.fromFile(new File(item.getFeed().getImage().getFile_url()))); + } + } +} + + diff --git a/src/de/podfetcher/feed/FeedManager.java b/src/de/podfetcher/feed/FeedManager.java index 2630846e6..0e9eac9f6 100644 --- a/src/de/podfetcher/feed/FeedManager.java +++ b/src/de/podfetcher/feed/FeedManager.java @@ -156,6 +156,17 @@ public class FeedManager { } return null; } + + /** Get a Feed Item by its id and its feed*/ + public FeedItem getFeedItem(long id, Feed feed) { + for(FeedItem item : feed.getItems()) { + if(item.getId() == id) { + return item; + } + } + Log.w(TAG, "Couldn't find FeedItem with id " + id); + return null; + } /** Reads the database */ public void loadDBData(Context context) { |