Moved Feeditemlist into Fragment
This commit is contained in:
parent
d539786af6
commit
f9b0d1d318
|
@ -0,0 +1,13 @@
|
|||
<?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="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/feeditemlistFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,49 +1,48 @@
|
|||
package de.podfetcher.activity;
|
||||
|
||||
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 de.podfetcher.fragment.FeedlistFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
|
||||
import de.podfetcher.R;
|
||||
import de.podfetcher.feed.Feed;
|
||||
import de.podfetcher.feed.FeedManager;
|
||||
import de.podfetcher.fragment.FeedItemlistFragment;
|
||||
import de.podfetcher.fragment.FeedlistFragment;
|
||||
|
||||
/** Displays a List of FeedItems */
|
||||
public class FeedItemlistActivity extends SherlockListActivity {
|
||||
public class FeedItemlistActivity extends SherlockFragmentActivity {
|
||||
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;
|
||||
|
||||
/** The feed which the activity displays */
|
||||
private Feed feed;
|
||||
private FeedItemlistFragment filf;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.setContentView(R.layout.feeditemlist_activity);
|
||||
manager = FeedManager.getInstance();
|
||||
long feedId = getIntent().getLongExtra(FeedlistFragment.EXTRA_SELECTED_FEED, -1);
|
||||
if(feedId == -1) Log.e(TAG, "Received invalid feed selection.");
|
||||
|
||||
feed = manager.getFeed(feedId);
|
||||
|
||||
fila = new FeedItemlistAdapter(this, 0, feed.getItems());
|
||||
setListAdapter(fila);
|
||||
|
||||
setTitle(feed.getTitle());
|
||||
}
|
||||
|
||||
@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(FeedlistFragment.EXTRA_SELECTED_FEED, feed.getId());
|
||||
showItem.putExtra(EXTRA_SELECTED_FEEDITEM, selection.getId());
|
||||
|
||||
startActivity(showItem);
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
FragmentTransaction fT = fragmentManager.beginTransaction();
|
||||
filf = new FeedItemlistFragment(feed.getItems());
|
||||
fT.add(R.id.feeditemlistFragment, filf);
|
||||
fT.commit();
|
||||
|
||||
}
|
||||
|
||||
public void onButActionClicked(View v) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import de.podfetcher.feed.Feed;
|
|||
import de.podfetcher.feed.FeedItem;
|
||||
import de.podfetcher.feed.FeedManager;
|
||||
import de.podfetcher.feed.FeedMedia;
|
||||
import de.podfetcher.fragment.FeedItemlistFragment;
|
||||
import de.podfetcher.fragment.FeedlistFragment;
|
||||
import de.podfetcher.service.DownloadObserver;
|
||||
import de.podfetcher.service.PlaybackService;
|
||||
|
@ -99,7 +100,7 @@ public class ItemviewActivity extends SherlockActivity {
|
|||
/** Extracts FeedItem object the activity is supposed to display */
|
||||
private void extractFeeditem() {
|
||||
long itemId = getIntent().getLongExtra(
|
||||
FeedItemlistActivity.EXTRA_SELECTED_FEEDITEM, -1);
|
||||
FeedItemlistFragment.EXTRA_SELECTED_FEEDITEM, -1);
|
||||
long feedId = getIntent().getLongExtra(
|
||||
FeedlistFragment.EXTRA_SELECTED_FEED, -1);
|
||||
if (itemId == -1 || feedId == -1) {
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package de.podfetcher.fragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
|
||||
import de.podfetcher.activity.ItemviewActivity;
|
||||
import de.podfetcher.adapter.FeedItemlistAdapter;
|
||||
import de.podfetcher.feed.FeedItem;
|
||||
import de.podfetcher.feed.FeedManager;
|
||||
|
||||
public class FeedItemlistFragment extends SherlockListFragment {
|
||||
private static final String TAG = "FeedItemlistFragment";
|
||||
public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.podfetcher.activity.selected_feeditem";
|
||||
|
||||
private FeedItemlistAdapter fila;
|
||||
private FeedManager manager;
|
||||
|
||||
/** The feed which the activity displays */
|
||||
private ArrayList<FeedItem> items;
|
||||
|
||||
public FeedItemlistFragment(ArrayList<FeedItem> items) {
|
||||
super();
|
||||
this.items = items;
|
||||
manager = FeedManager.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fila = new FeedItemlistAdapter(getActivity(), 0, items);
|
||||
setListAdapter(fila);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
FeedItem selection = fila.getItem(position);
|
||||
Intent showItem = new Intent(getActivity(), ItemviewActivity.class);
|
||||
showItem.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED, selection.getFeed().getId());
|
||||
showItem.putExtra(EXTRA_SELECTED_FEEDITEM, selection.getId());
|
||||
|
||||
startActivity(showItem);
|
||||
}
|
||||
|
||||
public void onButActionClicked(View v) {
|
||||
Log.d(TAG, "Button clicked");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue