Bug 1306609 - Remove unused HighlightsItem. r?ahunt
Going forward there will be just one highlights item/layout with an optional image.
MozReview-Commit-ID: BmtUTtanjJr
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamItem.java
@@ -4,17 +4,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.home.activitystream;
import android.database.Cursor;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.RecyclerView;
import android.text.format.DateUtils;
import android.view.View;
-import android.widget.ImageView;
import android.widget.TextView;
import org.mozilla.gecko.R;
import org.mozilla.gecko.db.BrowserContract;
import org.mozilla.gecko.home.HomePager;
import org.mozilla.gecko.home.activitystream.topsites.CirclePageIndicator;
import org.mozilla.gecko.home.activitystream.topsites.TopSitesPagerAdapter;
import org.mozilla.gecko.icons.IconCallback;
@@ -118,34 +117,9 @@ public abstract class StreamItem extends
vSourceView.setText(vSourceView.getText());
}
@Override
public void onIconResponse(IconResponse response) {
vIconView.updateImage(response);
}
}
-
- public static class HighlightItem extends StreamItem {
- public static final int LAYOUT_ID = R.layout.activity_stream_card_highlights_item;
-
- final TextView vLabel;
- final TextView vTimeSince;
- final ImageView vThumbnail;
-
- public HighlightItem(View itemView) {
- super(itemView);
- vLabel = (TextView) itemView.findViewById(R.id.card_highlights_label);
- vTimeSince = (TextView) itemView.findViewById(R.id.card_highlights_time_since);
- vThumbnail = (ImageView) itemView.findViewById(R.id.card_highlights_thumbnail);
- }
-
- @Override
- public void bind(Cursor cursor) {
- vLabel.setText(cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.History.TITLE)));
-
- final long time = cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.Highlights.DATE));
- final String ago = DateUtils.getRelativeTimeSpanString(time, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, 0).toString();
- vTimeSince.setText(ago);
- }
- }
-
}
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamRecyclerAdapter.java
@@ -1,28 +1,24 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.home.activitystream;
import android.database.Cursor;
-import android.support.v4.app.LoaderManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import org.mozilla.gecko.home.HomePager;
import org.mozilla.gecko.home.activitystream.StreamItem.BottomPanel;
import org.mozilla.gecko.home.activitystream.StreamItem.CompactItem;
-import org.mozilla.gecko.home.activitystream.StreamItem.HighlightItem;
import org.mozilla.gecko.home.activitystream.StreamItem.TopPanel;
-import java.lang.ref.WeakReference;
-
public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamItem> {
private Cursor highlightsCursor;
private Cursor topSitesCursor;
private HomePager.OnUrlOpenListener onUrlOpenListener;
void setOnUrlOpenListener(HomePager.OnUrlOpenListener onUrlOpenListener) {
this.onUrlOpenListener = onUrlOpenListener;
@@ -44,18 +40,16 @@ public class StreamRecyclerAdapter exten
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
if (type == TopPanel.LAYOUT_ID) {
return new TopPanel(inflater.inflate(type, parent, false), onUrlOpenListener);
} else if (type == BottomPanel.LAYOUT_ID) {
return new BottomPanel(inflater.inflate(type, parent, false));
} else if (type == CompactItem.LAYOUT_ID) {
return new CompactItem(inflater.inflate(type, parent, false));
- } else if (type == HighlightItem.LAYOUT_ID) {
- return new HighlightItem(inflater.inflate(type, parent, false));
} else {
throw new IllegalStateException("Missing inflation for ViewType " + type);
}
}
private int translatePositionToCursor(int position) {
if (position == 0 ||
position == getItemCount() - 1) {
@@ -65,19 +59,17 @@ public class StreamRecyclerAdapter exten
// We have one blank panel at the top, hence remove that to obtain the cursor position
return position - 1;
}
@Override
public void onBindViewHolder(StreamItem holder, int position) {
int type = getItemViewType(position);
- if (type == CompactItem.LAYOUT_ID ||
- type == HighlightItem.LAYOUT_ID) {
-
+ if (type == CompactItem.LAYOUT_ID) {
final int cursorPosition = translatePositionToCursor(position);
highlightsCursor.moveToPosition(cursorPosition);
holder.bind(highlightsCursor);
} else if (type == TopPanel.LAYOUT_ID) {
holder.bind(topSitesCursor);
}
}
deleted file mode 100644
--- a/mobile/android/base/resources/layout/activity_stream_card_highlights_item.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.v7.widget.CardView
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:orientation="vertical"
- android:layout_marginRight="5dp"
- android:layout_marginEnd="5dp"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="10dp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:baselineAligned="false"
- android:orientation="vertical">
-
- <FrameLayout
- android:background="@color/disabled_grey"
- android:layout_width="match_parent"
- android:layout_height="140dp">
-
- <ImageView
- android:visibility="visible"
- android:id="@+id/card_highlights_thumbnail"
- android:src="@drawable/favicon_globe"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
- </FrameLayout>
- <RelativeLayout
- android:padding="3dp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <TextView
- android:id="@+id/card_highlights_label"
- android:textSize="10sp"
- android:maxLines="3"
- android:ellipsize="end"
- tools:text="FooBar"
- android:textColor="@android:color/black"
- android:layout_marginLeft="4dp"
- android:layout_marginStart="4dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_toStartOf="@+id/card_highlights_time_since"
- android:layout_toLeftOf="@+id/card_highlights_time_since"
- android:layout_alignParentTop="true"
- android:layout_alignBottom="@+id/card_highlights_time_since"/>
-
- <TextView
- android:id="@+id/card_highlights_time_since"
- tools:text="2h"
- android:textSize="10sp"
- android:layout_marginEnd="4dp"
- android:layout_marginRight="4dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true"/>
-
- <TextView
- tools:text="Bookmarked"
- android:textSize="10sp"
- android:drawableLeft="@drawable/search_icon_active"
- android:gravity="center_vertical"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/card_highlights_label"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"/>
- </RelativeLayout>
- </LinearLayout>
-</android.support.v7.widget.CardView>
\ No newline at end of file