summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authorDaniel Oeh <daniel@danielpc.(none)>2012-04-13 16:21:34 +0200
committerDaniel Oeh <daniel@danielpc.(none)>2012-04-13 16:21:34 +0200
commitd3859b6763abafad11af40e7c2b61355ad498447 (patch)
tree35c4604e760804cbce13b14f6e89abba7071ed9f /src/de
parenteb24d41e1d25548aa9a830b1d15667103dd0ce13 (diff)
downloadAntennaPod-d3859b6763abafad11af40e7c2b61355ad498447.zip
Created Activity for viewing items
Diffstat (limited to 'src/de')
-rw-r--r--src/de/podfetcher/activity/FeedItemlistActivity.java9
-rw-r--r--src/de/podfetcher/activity/ItemviewActivity.java67
-rw-r--r--src/de/podfetcher/feed/FeedManager.java11
3 files changed, 86 insertions, 1 deletions
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) {