Dbrant has uploaded a new change for review. https://gerrit.wikimedia.org/r/296656
Change subject: Progress indicator at bottom of feed. ...................................................................... Progress indicator at bottom of feed. - Implemented as a permanent "card" that sits at the bottom of the current list of cards. There's no logic to show or hide it, since seeing it always implies that more feed content is currently being fetched. - Changed the "base" view class for cards to be View instead of CardView. Change-Id: I903519d7e8b1f6426105fa0a4acc8d9ee95caa88 --- M app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java M app/src/main/java/org/wikipedia/feed/view/FeedRecyclerAdapter.java 2 files changed, 27 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/56/296656/1 diff --git a/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java b/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java index 03a79d0..d4079df 100644 --- a/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java +++ b/app/src/main/java/org/wikipedia/feed/FeedCoordinatorBase.java @@ -6,6 +6,7 @@ import org.wikipedia.Site; import org.wikipedia.feed.model.Card; +import org.wikipedia.feed.progress.ProgressCard; import java.util.ArrayList; import java.util.List; @@ -23,6 +24,7 @@ private int currentAge; private List<FeedClient> pendingClients = new ArrayList<>(); private FeedClient.Callback exhaustionClientCallback = new ExhaustionClientCallback(); + private Card progressCard = new ProgressCard(); public FeedCoordinatorBase(@NonNull Context context) { this.context = context; @@ -45,11 +47,12 @@ } pendingClients.clear(); cards.clear(); + appendProgressCard(cards); } public void more(@NonNull Site site) { this.site = site; - if (cards.size() > 0) { + if (cards.size() > 1) { currentAge++; } @@ -78,6 +81,7 @@ @Override public void success(@NonNull List<? extends Card> cardList) { cards.addAll(cardList); + appendProgressCard(cards); if (updateListener != null) { updateListener.update(cards); } @@ -91,4 +95,9 @@ requestNextCard(site); } } + + private void appendProgressCard(List<Card> cards) { + cards.remove(progressCard); + cards.add(progressCard); + } } diff --git a/app/src/main/java/org/wikipedia/feed/view/FeedRecyclerAdapter.java b/app/src/main/java/org/wikipedia/feed/view/FeedRecyclerAdapter.java index e11abfa..066d8c2 100644 --- a/app/src/main/java/org/wikipedia/feed/view/FeedRecyclerAdapter.java +++ b/app/src/main/java/org/wikipedia/feed/view/FeedRecyclerAdapter.java @@ -3,7 +3,7 @@ import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v7.widget.CardView; +import android.view.View; import android.view.ViewGroup; import org.wikipedia.feed.FeedCoordinatorBase; @@ -19,6 +19,8 @@ import org.wikipedia.feed.model.Card; import org.wikipedia.feed.mostread.MostReadCardView; import org.wikipedia.feed.mostread.MostReadListCard; +import org.wikipedia.feed.progress.ProgressCard; +import org.wikipedia.feed.progress.ProgressCardView; import org.wikipedia.feed.random.RandomCard; import org.wikipedia.feed.random.RandomCardView; import org.wikipedia.feed.searchbar.SearchCard; @@ -26,13 +28,14 @@ import org.wikipedia.views.DefaultRecyclerAdapter; import org.wikipedia.views.DefaultViewHolder; -public class FeedRecyclerAdapter extends DefaultRecyclerAdapter<Card, CardView> { +public class FeedRecyclerAdapter extends DefaultRecyclerAdapter<Card, View> { private static final int VIEW_TYPE_SEARCH_BAR = 0; private static final int VIEW_TYPE_CONTINUE_READING = 1; private static final int VIEW_TYPE_BECAUSE_YOU_READ = 2; private static final int VIEW_TYPE_MOST_READ = 3; private static final int VIEW_TYPE_FEATURED_ARTICLE = 4; private static final int VIEW_TYPE_RANDOM = 5; + private static final int VIEW_TYPE_PROGRESS = 99; private static final int VIEW_TYPE_INTEGER_LIST = 100; @NonNull private FeedCoordinatorBase coordinator; @@ -44,13 +47,13 @@ this.callback = callback; } - @Override public DefaultViewHolder<CardView> onCreateViewHolder(ViewGroup parent, int viewType) { + @Override public DefaultViewHolder<View> onCreateViewHolder(ViewGroup parent, int viewType) { return new DefaultViewHolder<>(newView(parent.getContext(), viewType)); } - @Override public void onBindViewHolder(DefaultViewHolder<CardView> holder, int position) { + @Override public void onBindViewHolder(DefaultViewHolder<View> holder, int position) { Card item = item(position); - CardView view = holder.getView(); + View view = holder.getView(); if (coordinator.finished() && position == getItemCount() - 1 @@ -66,6 +69,8 @@ if (view instanceof IntegerListCardView) { ((IntegerListCardView) view).set((IntegerListCard) item); + } else if (view instanceof ProgressCardView) { + ((ProgressCardView) view).set((ProgressCard) item); } else if (view instanceof ContinueReadingCardView) { ((ContinueReadingCardView) view).set((ContinueReadingCard) item); } else if (view instanceof BecauseYouReadCardView) { @@ -87,6 +92,8 @@ Card item = item(position); if (item instanceof IntegerListCard) { return VIEW_TYPE_INTEGER_LIST; + } else if (item instanceof ProgressCard) { + return VIEW_TYPE_PROGRESS; } else if (item instanceof ContinueReadingCard) { return VIEW_TYPE_CONTINUE_READING; } else if (item instanceof BecauseYouReadCard) { @@ -104,10 +111,12 @@ } } - @NonNull private CardView newView(@NonNull Context context, int viewType) { + @NonNull private View newView(@NonNull Context context, int viewType) { switch(viewType) { case VIEW_TYPE_INTEGER_LIST: return new IntegerListCardView(context); + case VIEW_TYPE_PROGRESS: + return new ProgressCardView(context); case VIEW_TYPE_CONTINUE_READING: return new ContinueReadingCardView(context).setCallback(callback); case VIEW_TYPE_BECAUSE_YOU_READ: @@ -125,11 +134,11 @@ } } - private boolean isCardAssociatedWithView(@NonNull CardView view, @NonNull Card card) { + private boolean isCardAssociatedWithView(@NonNull View view, @NonNull Card card) { return card.equals(view.getTag()); } - private void associateCardWithView(@NonNull CardView view, @NonNull Card card) { + private void associateCardWithView(@NonNull View view, @NonNull Card card) { view.setTag(card); } } -- To view, visit https://gerrit.wikimedia.org/r/296656 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I903519d7e8b1f6426105fa0a4acc8d9ee95caa88 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Dbrant <dbr...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits