Feeditems can now be marked as read or unread
This commit is contained in:
parent
324cbdc86c
commit
5001182aee
@ -4,6 +4,8 @@
|
|||||||
<item android:id="@+id/remove_item" android:icon="@drawable/content_discard" android:title="@string/remove_label" android:visible="false"></item>
|
<item android:id="@+id/remove_item" android:icon="@drawable/content_discard" android:title="@string/remove_label" android:visible="false"></item>
|
||||||
<item android:id="@+id/play_item" android:title="@string/play_label" android:visible="false" android:icon="@drawable/av_play"></item>
|
<item android:id="@+id/play_item" android:title="@string/play_label" android:visible="false" android:icon="@drawable/av_play"></item>
|
||||||
<item android:id="@+id/cancel_download_item" android:icon="@drawable/navigation_cancel" android:title="@string/cancel_download_label" android:visible="false"></item>
|
<item android:id="@+id/cancel_download_item" android:icon="@drawable/navigation_cancel" android:title="@string/cancel_download_label" android:visible="false"></item>
|
||||||
|
<item android:id="@+id/mark_read_item" android:title="@string/mark_read_label" android:showAsAction="collapseActionView" android:visible="false"></item>
|
||||||
|
<item android:id="@+id/mark_unread_item" android:title="@string/mark_unread_label" android:visible="false" android:showAsAction="collapseActionView"></item>
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -37,4 +37,6 @@
|
|||||||
<string name="player_error_msg">Error!</string>
|
<string name="player_error_msg">Error!</string>
|
||||||
<string name="player_stopped_msg">Stopped</string>
|
<string name="player_stopped_msg">Stopped</string>
|
||||||
<string name="player_preparing_msg">Preparing...</string>
|
<string name="player_preparing_msg">Preparing...</string>
|
||||||
|
<string name="mark_read_label">Mark read</string>
|
||||||
|
<string name="mark_unread_label">Mark unread</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -12,55 +12,74 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|||||||
import de.podfetcher.R;
|
import de.podfetcher.R;
|
||||||
import de.podfetcher.fragment.FeedlistFragment;
|
import de.podfetcher.fragment.FeedlistFragment;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class PodfetcherActivity extends SherlockFragmentActivity {
|
public class PodfetcherActivity extends SherlockFragmentActivity {
|
||||||
private static final String TAG = "PodfetcherActivity";
|
private static final String TAG = "PodfetcherActivity";
|
||||||
|
|
||||||
private FeedlistFragment feedlist;
|
private FeedlistFragment feedlist;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
// Set up tabs
|
// Set up tabs
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||||
actionBar.setDisplayShowTitleEnabled(false);
|
actionBar.setDisplayShowTitleEnabled(false);
|
||||||
|
|
||||||
Tab tab = actionBar.newTab()
|
Tab tab = actionBar
|
||||||
|
.newTab()
|
||||||
.setText(getText(R.string.feeds_label).toString())
|
.setText(getText(R.string.feeds_label).toString())
|
||||||
.setTabListener(new TabListener<FeedlistFragment>(
|
.setTabListener(
|
||||||
this, getText(R.string.feeds_label).toString(), FeedlistFragment.class));
|
new TabListener<FeedlistFragment>(this, getText(
|
||||||
|
R.string.feeds_label).toString(),
|
||||||
actionBar.addTab(tab);
|
FeedlistFragment.class));
|
||||||
tab = actionBar.newTab()
|
|
||||||
.setText(getText(R.string.new_label).toString())
|
|
||||||
.setTabListener(new TabListener<FeedlistFragment>(
|
|
||||||
this, getText(R.string.new_label).toString(), FeedlistFragment.class));
|
|
||||||
actionBar.addTab(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
actionBar.addTab(tab);
|
||||||
|
tab = actionBar
|
||||||
|
.newTab()
|
||||||
|
.setText(getText(R.string.new_label).toString())
|
||||||
|
.setTabListener(
|
||||||
|
new TabListener<FeedlistFragment>(this, getText(
|
||||||
|
R.string.new_label).toString(),
|
||||||
|
FeedlistFragment.class));
|
||||||
|
actionBar.addTab(tab);
|
||||||
|
}
|
||||||
|
|
||||||
/** TabListener for navigating between the main lists. */
|
/** TabListener for navigating between the main lists. */
|
||||||
private class TabListener<T extends Fragment> implements ActionBar.TabListener {
|
private class TabListener<T extends Fragment> implements
|
||||||
|
ActionBar.TabListener {
|
||||||
|
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
private final String tag;
|
private final String tag;
|
||||||
private final Class<T> fClass;
|
private final Class<T> fClass;
|
||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
|
private boolean attachedOnce = false;
|
||||||
|
|
||||||
public TabListener(Activity activity, String tag, Class<T> fClass) {
|
public TabListener(Activity activity, String tag, Class<T> fClass) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.fClass = fClass;
|
this.fClass = fClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public TabListener(Activity activity, String tag, Fragment fragment,
|
||||||
|
Class<T> fClass) {
|
||||||
|
super();
|
||||||
|
this.activity = activity;
|
||||||
|
this.tag = tag;
|
||||||
|
this.fragment = fragment;
|
||||||
|
this.fClass = fClass;
|
||||||
|
}
|
||||||
|
|
||||||
public void onTabSelected(Tab tab, FragmentTransaction ft) {
|
public void onTabSelected(Tab tab, FragmentTransaction ft) {
|
||||||
if (fragment == null) {
|
if (fragment == null) {
|
||||||
fragment = Fragment.instantiate(activity, fClass.getName());
|
fragment = Fragment.instantiate(activity, fClass.getName());
|
||||||
ft.replace(R.id.main_fragment, fragment);
|
ft.replace(R.id.main_fragment, fragment);
|
||||||
|
attachedOnce = true;
|
||||||
|
} else if (!attachedOnce) {
|
||||||
|
ft.replace(R.id.main_fragment, fragment);
|
||||||
|
attachedOnce = true;
|
||||||
} else {
|
} else {
|
||||||
ft.attach(fragment);
|
ft.attach(fragment);
|
||||||
}
|
}
|
||||||
@ -73,7 +92,7 @@ public class PodfetcherActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onTabReselected(Tab tab, FragmentTransaction ft) {
|
public void onTabReselected(Tab tab, FragmentTransaction ft) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
|
||||||
public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
|
public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
|
||||||
private OnClickListener onButActionClicked;
|
private OnClickListener onButActionClicked;
|
||||||
@ -42,6 +43,11 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.title.setText(item.getTitle());
|
holder.title.setText(item.getTitle());
|
||||||
|
if (!item.isRead()) {
|
||||||
|
holder.title.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
|
} else {
|
||||||
|
holder.title.setTypeface(Typeface.DEFAULT);
|
||||||
|
}
|
||||||
holder.size.setText(Converter.byteToString(item.getMedia().getSize()));
|
holder.size.setText(Converter.byteToString(item.getMedia().getSize()));
|
||||||
holder.butAction.setOnClickListener(onButActionClicked);
|
holder.butAction.setOnClickListener(onButActionClicked);
|
||||||
return convertView;
|
return convertView;
|
||||||
|
@ -119,6 +119,12 @@ public class FeedItemlistFragment extends SherlockListFragment {
|
|||||||
} else {
|
} else {
|
||||||
menu.findItem(R.id.cancel_download_item).setVisible(true);
|
menu.findItem(R.id.cancel_download_item).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectedItem.isRead()) {
|
||||||
|
menu.findItem(R.id.mark_unread_item).setVisible(true);
|
||||||
|
} else {
|
||||||
|
menu.findItem(R.id.mark_read_item).setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -143,8 +149,15 @@ public class FeedItemlistFragment extends SherlockListFragment {
|
|||||||
requester.cancelDownload(getSherlockActivity(), selectedItem
|
requester.cancelDownload(getSherlockActivity(), selectedItem
|
||||||
.getMedia().getDownloadId());
|
.getMedia().getDownloadId());
|
||||||
break;
|
break;
|
||||||
|
case R.id.mark_read_item:
|
||||||
|
selectedItem.setRead(true);
|
||||||
|
break;
|
||||||
|
case R.id.mark_unread_item:
|
||||||
|
selectedItem.setRead(false);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
fila.notifyDataSetChanged();
|
||||||
mode.finish();
|
mode.finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user