Added menu item to mark all items as read
This commit is contained in:
parent
1cc0d763ba
commit
870b673527
|
@ -193,6 +193,20 @@ public class FeedManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Marks all items in the unread items list as read */
|
||||
public void markAllItemsRead(Context context) {
|
||||
Log.d(TAG, "marking all items as read");
|
||||
PodDBAdapter adapter = new PodDBAdapter(context);
|
||||
adapter.open();
|
||||
for (FeedItem item : unreadItems) {
|
||||
item.read = true;
|
||||
setFeedItem(item, adapter);
|
||||
}
|
||||
adapter.close();
|
||||
unreadItems.clear();
|
||||
sendUnreadItemsUpdateBroadcast(context, null);
|
||||
}
|
||||
|
||||
public void refreshAllFeeds(Context context) {
|
||||
Log.d(TAG, "Refreshing all feeds.");
|
||||
|
|
|
@ -105,6 +105,7 @@ public class FeedlistFragment extends SherlockListFragment implements
|
|||
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
||||
filter.addAction(DownloadService.ACTION_FEED_SYNC_COMPLETED);
|
||||
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
||||
filter.addAction(FeedManager.ACTION_UNREAD_ITEMS_UPDATE);
|
||||
|
||||
pActivity.registerReceiver(contentUpdate, filter);
|
||||
fla.notifyDataSetChanged();
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
package de.podfetcher.fragment;
|
||||
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import de.podfetcher.R;
|
||||
import de.podfetcher.feed.FeedManager;
|
||||
|
||||
/** Contains all unread items. */
|
||||
|
@ -31,6 +37,12 @@ public class UnreadItemlistFragment extends ItemlistFragment {
|
|||
new IntentFilter(FeedManager.ACTION_UNREAD_ITEMS_UPDATE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
private BroadcastReceiver unreadItemsUpdate = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
|
@ -40,4 +52,28 @@ public class UnreadItemlistFragment extends ItemlistFragment {
|
|||
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
menu.add(Menu.NONE, R.id.mark_all_read_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.mark_all_read_label));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.mark_all_read_item:
|
||||
manager.markAllItemsRead(getActivity());
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue