From 406dab0a24543f4332b338f64689948cdc96c3bc Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 26 Apr 2015 12:59:01 +0200 Subject: Show feed new items and refresh failure --- .../antennapod/adapter/FeedItemlistAdapter.java | 24 +++------- .../danoeh/antennapod/adapter/NavListAdapter.java | 46 +++++++++++------- .../antennapod/config/StorageCallbacksImpl.java | 7 +++ .../antennapod/fragment/ItemlistFragment.java | 13 ++++- .../danoeh/antennapod/fragment/QueueFragment.java | 2 - .../antennapod/menuhandler/FeedMenuHandler.java | 4 +- app/src/main/res/layout/feeditemlist_header.xml | 15 ++++++ app/src/main/res/layout/feeditemlist_item.xml | 56 ++++++++++++---------- app/src/main/res/layout/nav_feedlistitem.xml | 36 ++++++++++++-- app/src/main/res/layout/new_episodes_listitem.xml | 46 +++++++++--------- 10 files changed, 158 insertions(+), 91 deletions(-) (limited to 'app') diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java index 74fd4d9c0..30e0b0b57 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java @@ -110,22 +110,8 @@ public class FeedItemlistAdapter extends BaseAdapter { } holder.title.setText(buffer.toString()); - FeedItem.State state = item.getState(); - switch (state) { - case PLAYING: - holder.statusUnread.setVisibility(View.INVISIBLE); - holder.episodeProgress.setVisibility(View.VISIBLE); - break; - case IN_PROGRESS: - holder.statusUnread.setVisibility(View.INVISIBLE); - holder.episodeProgress.setVisibility(View.VISIBLE); - break; - case NEW: - holder.statusUnread.setVisibility(View.VISIBLE); - break; - default: - holder.statusUnread.setVisibility(View.INVISIBLE); - break; + if(item.isRead()) { + holder.statusUnread.setVisibility(View.INVISIBLE); } holder.published.setText(DateUtils.formatDateTime(context, item.getPubDate().getTime(), DateUtils.FORMAT_ABBREV_ALL)); @@ -153,7 +139,9 @@ public class FeedItemlistAdapter extends BaseAdapter { holder.episodeProgress.setProgress(((ItemAccess) itemAccess).getItemDownloadProgressPercent(item)); holder.published.setVisibility(View.GONE); } else { - holder.episodeProgress.setVisibility(View.GONE); + if(media.getPosition() == 0) { + holder.episodeProgress.setVisibility(View.GONE); + } holder.published.setVisibility(View.VISIBLE); } @@ -217,6 +205,7 @@ public class FeedItemlistAdapter extends BaseAdapter { } public interface ItemAccess { + boolean isInQueue(FeedItem item); int getItemDownloadProgressPercent(FeedItem item); @@ -224,6 +213,7 @@ public class FeedItemlistAdapter extends BaseAdapter { int getCount(); FeedItem getItem(int position); + } } 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 907093ad6..6cde97148 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -10,6 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; +import android.widget.IconTextView; import android.widget.ImageView; import android.widget.TextView; @@ -26,6 +27,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.preferences.UserPreferences; +import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.fragment.AddFeedFragment; import de.danoeh.antennapod.fragment.AllEpisodesFragment; import de.danoeh.antennapod.fragment.DownloadsFragment; @@ -190,9 +192,9 @@ public class NavListAdapter extends BaseAdapter convertView = inflater.inflate(R.layout.nav_listitem, parent, false); + holder.image = (ImageView) convertView.findViewById(R.id.imgvCover); holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.count = (TextView) convertView.findViewById(R.id.txtvCount); - holder.image = (ImageView) convertView.findViewById(R.id.imgvCover); convertView.setTag(holder); } else { holder = (NavHolder) convertView.getTag(); @@ -248,45 +250,57 @@ public class NavListAdapter extends BaseAdapter convertView = inflater.inflate(R.layout.nav_feedlistitem, parent, false); - holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.image = (ImageView) convertView.findViewById(R.id.imgvCover); + holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); + holder.failure = (IconTextView) convertView.findViewById(R.id.itxtvFailure); + holder.count = (TextView) convertView.findViewById(R.id.txtvCount); convertView.setTag(holder); } else { holder = (FeedHolder) convertView.getTag(); } - holder.title.setText(feed.getTitle()); - Picasso.with(context) .load(feed.getImageUri()) .fit() .into(holder.image); + holder.title.setText(feed.getTitle()); + + int feedUnreadItems = DBReader.getNumberOfUnreadItems(context, feed.getId()); + if(feed.hasLastUpdateFailed()) { + holder.failure.setVisibility(View.VISIBLE); + } else { + holder.failure.setVisibility(View.GONE); + } + if(feedUnreadItems > 0) { + holder.count.setVisibility(View.VISIBLE); + holder.count.setText(String.valueOf(feedUnreadItems)); + holder.count.setTypeface(holder.title.getTypeface()); + } else { + holder.count.setVisibility(View.GONE); + } return convertView; } static class NavHolder { + ImageView image; TextView title; TextView count; - ImageView image; } static class FeedHolder { - TextView title; ImageView image; + TextView title; + IconTextView failure; + TextView count; } - public interface ItemAccess { - public int getCount(); - - public Feed getItem(int position); - - public int getSelectedItemIndex(); - - public int getQueueSize(); - - public int getNumberOfUnreadItems(); + int getCount(); + Feed getItem(int position); + int getSelectedItemIndex(); + int getQueueSize(); + int getNumberOfUnreadItems(); } } diff --git a/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java index 2c5bc9cff..3445b109f 100644 --- a/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java +++ b/app/src/main/java/de/danoeh/antennapod/config/StorageCallbacksImpl.java @@ -125,6 +125,7 @@ public class StorageCallbacksImpl implements StorageCallbacks { PodDBAdapter.KEY_CHAPTER_TYPE)); } if(oldVersion <= 14) { + db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + " ADD COLUMN " + PodDBAdapter.KEY_AUTO_DOWNLOAD + " INTEGER"); db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS @@ -133,8 +134,14 @@ public class StorageCallbacksImpl implements StorageCallbacks { + " FROM " + PodDBAdapter.TABLE_NAME_FEEDS + " WHERE " + PodDBAdapter.TABLE_NAME_FEEDS + "." + PodDBAdapter.KEY_ID + " = " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + "." + PodDBAdapter.KEY_FEED + ")"); + db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + " ADD COLUMN " + PodDBAdapter.KEY_HIDE + " TEXT"); + + + db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + + " ADD COLUMN " + PodDBAdapter.KEY_LAST_UPDATE_FAILED + " INTEGER DEFAULT 0"); + } } } 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 fb3c95e7d..0f4ee9013 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -19,6 +19,7 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; +import android.widget.IconTextView; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListAdapter; @@ -91,6 +92,8 @@ public class ItemlistFragment extends ListFragment { private MoreContentListFooterUtil listFooter; private boolean isUpdatingFeed; + + private IconTextView txtvFailure; private TextView txtvInformation; @@ -309,7 +312,7 @@ public class ItemlistFragment extends ListFragment { @Override public void update(EventDistributor eventDistributor, Integer arg) { if ((EVENTS & arg) != 0) { - Log.d(TAG, "Received contentUpdate Intent."); + Log.d(TAG, "Received contentUpdate Intent. arg " + arg); if ((EventDistributor.DOWNLOAD_QUEUED & arg) != 0) { updateProgressBarVisibility(); } else { @@ -358,6 +361,11 @@ public class ItemlistFragment extends ListFragment { } private void refreshHeaderView() { + if(feed.hasLastUpdateFailed()) { + txtvFailure.setVisibility(View.VISIBLE); + } else { + txtvFailure.setVisibility(View.GONE); + } if(feed.getItemFilter() != null) { FeedItemFilter filter = feed.getItemFilter(); if(filter.getValues().length > 0) { @@ -368,6 +376,7 @@ public class ItemlistFragment extends ListFragment { txtvInformation.setVisibility(View.GONE); } } else { + txtvInformation.setVisibility(View.GONE); } } @@ -407,6 +416,7 @@ public class ItemlistFragment extends ListFragment { ImageView imgvCover = (ImageView) header.findViewById(R.id.imgvCover); ImageButton butShowInfo = (ImageButton) header.findViewById(R.id.butShowInfo); txtvInformation = (TextView) header.findViewById(R.id.txtvInformation); + txtvFailure = (IconTextView) header.findViewById(R.id.txtvFailure); txtvTitle.setText(feed.getTitle()); txtvAuthor.setText(feed.getAuthor()); @@ -437,6 +447,7 @@ public class ItemlistFragment extends ListFragment { }); } + private void setupFooterView() { if (getListView() == null || feed == null) { Log.e(TAG, "Unable to setup listview: listView = null or feed = null"); 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 259d4a574..a17194dee 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -418,7 +418,6 @@ public class QueueFragment extends Fragment { Log.d(TAG, "remove(" + which + ")"); stopItemLoader(); FeedItem item = (FeedItem) listView.getAdapter().getItem(which); - DBWriter.markItemRead(getActivity(), item.getId(), true); DBWriter.removeQueueItem(getActivity(), item, true); } }); @@ -433,7 +432,6 @@ public class QueueFragment extends Fragment { if (token != null) { long itemId = token.getFeedItemId(); int position = token.getPosition(); - DBWriter.markItemRead(context, itemId, false); DBWriter.addQueueItemAt(context, itemId, position, false); } } diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java index 6947c73c9..af3368c41 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java @@ -15,7 +15,6 @@ import java.util.Arrays; import java.util.List; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.BuildConfig; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.storage.DBTasks; @@ -39,8 +38,7 @@ public class FeedMenuHandler { return true; } - if (BuildConfig.DEBUG) - Log.d(TAG, "Preparing options menu"); + Log.d(TAG, "Preparing options menu"); menu.findItem(R.id.mark_all_read_item).setVisible( selectedFeed.hasNewItems(true)); if (selectedFeed.getPaymentLink() != null && selectedFeed.getFlattrStatus().flattrable()) diff --git a/app/src/main/res/layout/feeditemlist_header.xml b/app/src/main/res/layout/feeditemlist_header.xml index 943f4fc92..667f777af 100644 --- a/app/src/main/res/layout/feeditemlist_header.xml +++ b/app/src/main/res/layout/feeditemlist_header.xml @@ -78,6 +78,21 @@ tools:text="Podcast author" tools:background="@android:color/holo_green_dark" /> + + + + android:layout_alignTop="@id/txtvPublished" + android:layout_alignBottom="@id/txtvPublished" + tools:background="@android:color/holo_blue_light" + android:max="100" + android:progress="42" + android:indeterminate="false" + /> + - diff --git a/app/src/main/res/layout/nav_feedlistitem.xml b/app/src/main/res/layout/nav_feedlistitem.xml index 38f4f21aa..238beff88 100644 --- a/app/src/main/res/layout/nav_feedlistitem.xml +++ b/app/src/main/res/layout/nav_feedlistitem.xml @@ -7,7 +7,6 @@ android:layout_height="@dimen/listitem_iconwithtext_height" tools:background="@android:color/darker_gray"> - - - \ No newline at end of file + tools:background="@android:color/holo_green_dark"/> + + + + + + diff --git a/app/src/main/res/layout/new_episodes_listitem.xml b/app/src/main/res/layout/new_episodes_listitem.xml index 43ada14b0..b738cf836 100644 --- a/app/src/main/res/layout/new_episodes_listitem.xml +++ b/app/src/main/res/layout/new_episodes_listitem.xml @@ -37,7 +37,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" - android:layout_alignParentTop="true" /> + android:layout_alignParentTop="true" + android:layout_marginLeft="8dp"/> + + - - - - + + -- cgit v1.2.3