diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-05-11 19:58:06 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-05-19 11:58:38 +0200 |
commit | 298b02b0aa20314187715aa9787d59e4292a0c64 (patch) | |
tree | 977673b90470df71343830e679c6fc6005a4c221 /app/src/main/java/de/danoeh/antennapod | |
parent | 4561f16f11ed2f27d711d3ea42f5e84bcccc002c (diff) | |
download | AntennaPod-298b02b0aa20314187715aa9787d59e4292a0c64.zip |
Fix for indicator, changes in context menus
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod')
4 files changed, 64 insertions, 5 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index 818f662cd..ae81779e4 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -277,7 +277,7 @@ public class NavListAdapter extends BaseAdapter holder.count.setText(String.valueOf(feedUnreadItems)); holder.count.setTypeface(holder.title.getTypeface()); } else { - holder.count.setVisibility(View.GONE); + holder.count.setVisibility(View.INVISIBLE); } return convertView; } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index 8a5cad137..ff5485251 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -10,6 +10,8 @@ import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v4.view.MenuItemCompat; import android.support.v7.widget.SearchView; +import android.util.Log; +import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -41,8 +43,10 @@ import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.LongList; +import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; import de.danoeh.antennapod.menuhandler.MenuItemUtils; /** @@ -67,6 +71,7 @@ public class AllEpisodesFragment extends Fragment { private AllEpisodesListAdapter listAdapter; private TextView txtvEmpty; private ProgressBar progLoading; + private ContextMenu contextMenu; private List<FeedItem> episodes; private LongList queuedItemsIds; @@ -293,6 +298,8 @@ public class AllEpisodesFragment extends Fragment { } }); + registerForContextMenu(listView); + if (!itemsLoaded) { progLoading.setVisibility(View.VISIBLE); txtvEmpty.setVisibility(View.GONE); @@ -307,6 +314,55 @@ public class AllEpisodesFragment extends Fragment { return root; } + private final FeedItemMenuHandler.MenuInterface contextMenuInterface = new FeedItemMenuHandler.MenuInterface() { + @Override + public void setItemVisibility(int id, boolean visible) { + if(contextMenu == null) { + return; + } + MenuItem item = contextMenu.findItem(id); + if (item != null) { + item.setVisible(visible); + } + } + }; + + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + AdapterView.AdapterContextMenuInfo adapterInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; + FeedItem item = itemAccess.getItem(adapterInfo.position); + + MenuInflater inflater = getActivity().getMenuInflater(); + inflater.inflate(R.menu.allepisodes_context, menu); + + if (item != null) { + menu.setHeaderTitle(item.getTitle()); + } + + contextMenu = menu; + FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, true, queuedItemsIds); + } + + @Override + public boolean onContextItemSelected(MenuItem item) { + AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); + FeedItem selectedItem = itemAccess.getItem(menuInfo.position); + + if (selectedItem == null) { + Log.i(TAG, "Selected item at position " + menuInfo.position + " was null, ignoring selection"); + return super.onContextItemSelected(item); + } + + try { + return FeedItemMenuHandler.onMenuItemClicked(getActivity(), item.getItemId(), selectedItem); + } catch (DownloadRequestException e) { + e.printStackTrace(); + Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); + return true; + } + } + private void onFragmentLoaded() { if (listAdapter == null) { listAdapter = new AllEpisodesListAdapter(activity.get(), itemAccess, diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 463d06376..07ae81100 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -26,6 +26,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.ListView; +import android.widget.RelativeLayout; import android.widget.TextView; import com.joanzapata.android.iconify.Iconify; @@ -301,7 +302,7 @@ public class ItemlistFragment extends ListFragment { } contextMenu = menu; - FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, false, queuedItemsIds); + FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, true, queuedItemsIds); } @Override @@ -428,6 +429,10 @@ public class ItemlistFragment extends ListFragment { if(feed.getItemFilter() != null) { FeedItemFilter filter = feed.getItemFilter(); if(filter.getValues().length > 0) { + if(feed.hasLastUpdateFailed()) { + RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) txtvInformation.getLayoutParams(); + p.addRule(RelativeLayout.BELOW, R.id.txtvFailure); + } txtvInformation.setText("{fa-info-circle} " + this.getString(R.string.filtered_label)); Iconify.addIcons(txtvInformation); txtvInformation.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 0ccca3e55..d82c7b8f7 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -329,7 +329,7 @@ public class QueueFragment extends Fragment { for(FeedItem queueItem : queue) { queueIds.add(queueItem.getId()); } - FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, false, queueIds); + FeedItemMenuHandler.onPrepareMenu(contextMenuInterface, item, true, queueIds); } @Override @@ -352,7 +352,6 @@ public class QueueFragment extends Fragment { } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); @@ -435,7 +434,6 @@ public class QueueFragment extends Fragment { }); - registerForContextMenu(listView); if (!itemsLoaded) { |