зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1386735 - Support disabling titles in StreamRecyclerView. r=mcomella
MozReview-Commit-ID: 15h7Lp497JN --HG-- extra : rebase_source : 540b9b97975addab569f0f490959c0dc10755e36
This commit is contained in:
Родитель
825be7e3b6
Коммит
1bf5deb116
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -51,6 +51,9 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder
|
|||
private List<RowModel> recyclerViewModel; // List of item types backing this RecyclerView.
|
||||
private List<TopStory> 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<StreamViewHolder
|
|||
if (type == RowItemType.TOP_PANEL.getViewType()) {
|
||||
return new TopPanelRow(inflater.inflate(TopPanelRow.LAYOUT_ID, parent, false), onUrlOpenListener, onUrlOpenInBackgroundListener);
|
||||
} else if (type == RowItemType.TOP_STORIES_TITLE.getViewType()) {
|
||||
return new StreamTitleRow(inflater.inflate(StreamTitleRow.LAYOUT_ID, parent, false), R.string.activity_stream_topstories);
|
||||
return new StreamTitleRow(inflater.inflate(StreamTitleRow.LAYOUT_ID, parent, false), R.string.activity_stream_topstories, POCKET_ENABLED);
|
||||
} else if (type == RowItemType.TOP_STORIES_ITEM.getViewType()) {
|
||||
return new WebpageItemRow(inflater.inflate(WebpageItemRow.LAYOUT_ID, parent, false), this);
|
||||
} else if (type == RowItemType.WELCOME.getViewType()) {
|
||||
|
@ -132,7 +135,7 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder
|
|||
} else if (type == RowItemType.HIGHLIGHT_ITEM.getViewType()) {
|
||||
return new WebpageItemRow(inflater.inflate(WebpageItemRow.LAYOUT_ID, parent, false), this);
|
||||
} else if (type == RowItemType.HIGHLIGHTS_TITLE.getViewType()) {
|
||||
return new StreamTitleRow(inflater.inflate(StreamTitleRow.LAYOUT_ID, parent, false), R.string.activity_stream_highlights);
|
||||
return new StreamTitleRow(inflater.inflate(StreamTitleRow.LAYOUT_ID, parent, false), R.string.activity_stream_highlights, true);
|
||||
} else {
|
||||
throw new IllegalStateException("Missing inflation for ViewType " + type);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.mozilla.gecko.activitystream.homepanel.stream;
|
|||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -15,10 +16,23 @@ import org.mozilla.gecko.R;
|
|||
public class StreamTitleRow extends StreamViewHolder {
|
||||
public static final int LAYOUT_ID = R.layout.activity_stream_main_highlightstitle;
|
||||
|
||||
public StreamTitleRow(final View itemView, final @StringRes @NonNull int titleResId) {
|
||||
public StreamTitleRow(final View itemView, final @StringRes @NonNull int titleResId, boolean isEnabled) {
|
||||
super(itemView);
|
||||
final TextView titleView = (TextView) itemView.findViewById(R.id.title_highlights);
|
||||
titleView.setText(titleResId);
|
||||
if (!isEnabled) {
|
||||
hideView(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
private static void hideView(final View itemView) {
|
||||
itemView.setVisibility(View.GONE);
|
||||
// We also need to set the layout height, width, and margins to 0 for the RecyclerView child.
|
||||
final RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) itemView.getLayoutParams();
|
||||
layoutParams.setMargins(0, 0, 0, 0);
|
||||
layoutParams.height = 0;
|
||||
layoutParams.width = 0;
|
||||
itemView.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче