Implemented Feeditemlist in App
This commit is contained in:
parent
c633acfa8b
commit
789f78fe41
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
<TextView
|
||||
android:id="@+id/txtvItemname"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
/>
|
||||
</RelativeLayout>
|
|
@ -5,17 +5,30 @@ import android.view.View;
|
|||
import android.widget.ListView;
|
||||
import android.os.Bundle;
|
||||
import de.podfetcher.feed.*;
|
||||
import de.podfetcher.adapter.FeedItemlistAdapter;
|
||||
import android.util.Log;
|
||||
|
||||
/** Displays a List of FeedItems */
|
||||
public class FeedItemlistActivity extends SherlockListActivity {
|
||||
private static final String TAG = "FeedItemlistActivity";
|
||||
|
||||
private FeedItemlistAdapter fila;
|
||||
private FeedManager manager;
|
||||
|
||||
/** The feed which the activity displays */
|
||||
private Feed feed;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
manager = FeedManager.getInstance();
|
||||
long feedId = getIntent().getLongExtra(FeedlistActivity.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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.podfetcher.activity;
|
||||
|
||||
import de.podfetcher.R;
|
||||
import de.podfetcher.feed.FeedManager;
|
||||
import de.podfetcher.feed.*;
|
||||
import de.podfetcher.adapter.FeedlistAdapter;
|
||||
import de.podfetcher.service.FeedSyncService;
|
||||
import de.podfetcher.storage.DownloadRequester;
|
||||
|
@ -11,6 +11,7 @@ import android.content.Intent;
|
|||
import android.content.IntentFilter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.widget.ListView;
|
||||
import com.actionbarsherlock.app.SherlockListActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
|
@ -19,6 +20,7 @@ import com.actionbarsherlock.view.MenuItem;
|
|||
|
||||
public class FeedlistActivity extends SherlockListActivity {
|
||||
private static final String TAG = "FeedlistActivity";
|
||||
public static final String EXTRA_SELECTED_FEED = "extra.de.podfetcher.activity.selected_feed";
|
||||
|
||||
private FeedManager manager;
|
||||
private FeedlistAdapter fla;
|
||||
|
@ -73,4 +75,13 @@ public class FeedlistActivity extends SherlockListActivity {
|
|||
fla.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
Feed selection = fla.getItem(position);
|
||||
Intent showFeed = new Intent(this, FeedItemlistActivity.class);
|
||||
showFeed.putExtra(EXTRA_SELECTED_FEED, selection.getId());
|
||||
|
||||
startActivity(showFeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,25 +3,44 @@ package de.podfetcher.adapter;
|
|||
import java.util.List;
|
||||
|
||||
import de.podfetcher.feed.FeedItem;
|
||||
import de.podfetcher.R;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.content.Context;
|
||||
|
||||
public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
|
||||
|
||||
int resource;
|
||||
|
||||
public FeedItemlistAdapter(Context context, int resource,
|
||||
public FeedItemlistAdapter(Context context,
|
||||
int textViewResourceId, List<FeedItem> objects) {
|
||||
super(context, resource, textViewResourceId, objects);
|
||||
this.resource = resource;
|
||||
super(context, textViewResourceId, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return null;
|
||||
Holder holder;
|
||||
FeedItem item = getItem(position);
|
||||
|
||||
if(convertView == null) {
|
||||
holder = new Holder();
|
||||
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.feeditemlist_item, null);
|
||||
holder.title = (TextView) convertView.findViewById(R.id.txtvItemname);
|
||||
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.title.setText(item.getTitle());
|
||||
return convertView;
|
||||
|
||||
}
|
||||
|
||||
static class Holder {
|
||||
TextView title;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue