diff options
Diffstat (limited to 'src/de/podfetcher/activity')
-rw-r--r-- | src/de/podfetcher/activity/FeedItemlistActivity.java | 9 | ||||
-rw-r--r-- | src/de/podfetcher/activity/ItemviewActivity.java | 67 |
2 files changed, 75 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()))); + } + } +} + + |