From 1bf5deb116188b8df3aa02f4720303a1d5232c18 Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Wed, 30 Aug 2017 18:58:12 -0700 Subject: [PATCH] Bug 1386735 - Support disabling titles in StreamRecyclerView. r=mcomella MozReview-Commit-ID: 15h7Lp497JN --HG-- extra : rebase_source : 540b9b97975addab569f0f490959c0dc10755e36 --- .../homepanel/ActivityStreamPanel.java | 4 +++- .../HighlightsDividerItemDecoration.java | 3 +++ .../homepanel/StreamRecyclerAdapter.java | 7 +++++-- .../homepanel/stream/StreamTitleRow.java | 16 +++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java index a13f4d1adef6..df3c76fbf0d8 100644 --- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java +++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java @@ -92,7 +92,9 @@ public class ActivityStreamPanel extends FrameLayout { public void load(LoaderManager lm) { lm.initLoader(LOADER_ID_TOPSITES, null, new TopSitesCallback()); lm.initLoader(LOADER_ID_HIGHLIGHTS, null, new HighlightsCallbacks()); - lm.initLoader(LOADER_ID_POCKET, null, new PocketStoriesCallbacks()); + if (StreamRecyclerAdapter.POCKET_ENABLED) { + lm.initLoader(LOADER_ID_POCKET, null, new PocketStoriesCallbacks()); + } } diff --git a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java index 89915a7cda81..0892bd4a0a67 100644 --- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java +++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java @@ -39,6 +39,9 @@ import android.view.View; final int childCount = parent.getChildCount(); for (int i = START_DRAWING_AT_POSITION; i < childCount; i++) { final View child = parent.getChildAt(i); + if (child.getVisibility() == View.GONE) { + continue; + } final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child .getLayoutParams(); final int top = child.getBottom() + params.bottomMargin; diff --git a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java index d67cd07ee0db..02fb9d204a23 100644 --- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java +++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java @@ -51,6 +51,9 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter recyclerViewModel; // List of item types backing this RecyclerView. private List topStoriesQueue; + // TODO: Replace temporary pref placeholder with pref + public static final boolean POCKET_ENABLED = false; + private final RowItemType[] FIXED_ROWS = {RowItemType.TOP_PANEL, RowItemType.WELCOME, RowItemType.TOP_STORIES_TITLE, RowItemType.HIGHLIGHTS_TITLE}; private final int MAX_TOP_STORIES = 3; @@ -124,7 +127,7 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter