зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1301718: Use StreamPageIconLayout in Highlights. r=liuche
MozReview-Commit-ID: LLdJ9xhC4S7 --HG-- extra : rebase_source : df734859ed416b4110c1eba6c06667e2dc4cdb68
This commit is contained in:
Родитель
458585db53
Коммит
dc89d2abf4
|
@ -17,18 +17,17 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<org.mozilla.gecko.widget.FaviconView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/favicon_bg"
|
||||
android:layout_height="@dimen/favicon_bg"
|
||||
android:layout_marginBottom="@dimen/activity_stream_base_margin"
|
||||
android:layout_marginLeft="@dimen/activity_stream_base_margin"
|
||||
android:layout_marginStart="@dimen/activity_stream_base_margin"
|
||||
android:layout_marginTop="@dimen/activity_stream_base_margin"
|
||||
gecko:enableRoundCorners="false"
|
||||
gecko:overrideScaleType="false"
|
||||
android:scaleType="fitCenter"
|
||||
tools:background="@drawable/favicon_globe" />
|
||||
<org.mozilla.gecko.activitystream.homepanel.stream.StreamPageIconLayout
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/favicon_bg"
|
||||
android:layout_height="@dimen/favicon_bg"
|
||||
android:layout_marginStart="@dimen/activity_stream_base_margin"
|
||||
android:layout_marginLeft="@dimen/activity_stream_base_margin"
|
||||
android:layout_marginTop="@dimen/activity_stream_base_margin"
|
||||
android:layout_marginBottom="@dimen/activity_stream_base_margin"
|
||||
android:layout_gravity="center"
|
||||
tools:background="@drawable/favicon_globe" />
|
||||
<!-- todo: overrideScaleType, scaleType=fitCnetetr -->
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@ import org.mozilla.gecko.activitystream.Utils;
|
|||
import org.mozilla.gecko.activitystream.homepanel.menu.ActivityStreamContextMenu;
|
||||
import org.mozilla.gecko.activitystream.homepanel.model.Highlight;
|
||||
import org.mozilla.gecko.home.HomePager;
|
||||
import org.mozilla.gecko.icons.IconCallback;
|
||||
import org.mozilla.gecko.icons.IconResponse;
|
||||
import org.mozilla.gecko.icons.Icons;
|
||||
import org.mozilla.gecko.util.DrawableUtil;
|
||||
import org.mozilla.gecko.util.TouchTargetUtil;
|
||||
import org.mozilla.gecko.util.URIUtils;
|
||||
|
@ -32,9 +29,8 @@ import org.mozilla.gecko.widget.FaviconView;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class HighlightItem extends StreamItem implements IconCallback {
|
||||
public class HighlightItem extends StreamItem {
|
||||
private static final String LOGTAG = "GeckoHighlightItem";
|
||||
|
||||
public static final int LAYOUT_ID = R.layout.activity_stream_card_history_item;
|
||||
|
@ -43,13 +39,12 @@ public class HighlightItem extends StreamItem implements IconCallback {
|
|||
private Highlight highlight;
|
||||
private int position;
|
||||
|
||||
private final FaviconView pageIconView;
|
||||
private final StreamPageIconLayout pageIconLayout;
|
||||
private final TextView pageTitleView;
|
||||
private final TextView pageSourceView;
|
||||
private final TextView pageDomainView;
|
||||
private final ImageView pageSourceIconView;
|
||||
|
||||
private Future<IconResponse> ongoingIconLoad;
|
||||
private int tilesMargin;
|
||||
|
||||
public HighlightItem(final View itemView,
|
||||
|
@ -60,7 +55,7 @@ public class HighlightItem extends StreamItem implements IconCallback {
|
|||
tilesMargin = itemView.getResources().getDimensionPixelSize(R.dimen.activity_stream_base_margin);
|
||||
|
||||
pageTitleView = (TextView) itemView.findViewById(R.id.card_history_label);
|
||||
pageIconView = (FaviconView) itemView.findViewById(R.id.icon);
|
||||
pageIconLayout = (StreamPageIconLayout) itemView.findViewById(R.id.icon);
|
||||
pageSourceView = (TextView) itemView.findViewById(R.id.card_history_source);
|
||||
pageDomainView = (TextView) itemView.findViewById(R.id.page);
|
||||
pageSourceIconView = (ImageView) itemView.findViewById(R.id.source_icon);
|
||||
|
@ -86,7 +81,7 @@ public class HighlightItem extends StreamItem implements IconCallback {
|
|||
ActivityStreamContextMenu.MenuMode.HIGHLIGHT,
|
||||
highlight,
|
||||
onUrlOpenListener, onUrlOpenInBackgroundListener,
|
||||
pageIconView.getWidth(), pageIconView.getHeight());
|
||||
pageIconLayout.getWidth(), pageIconLayout.getHeight());
|
||||
|
||||
Telemetry.sendUIEvent(
|
||||
TelemetryContract.Event.SHOW,
|
||||
|
@ -107,23 +102,14 @@ public class HighlightItem extends StreamItem implements IconCallback {
|
|||
final String uiHighlightTitle = !TextUtils.isEmpty(backendHightlightTitle) ? backendHightlightTitle : highlight.getUrl();
|
||||
pageTitleView.setText(uiHighlightTitle);
|
||||
|
||||
ViewGroup.LayoutParams layoutParams = pageIconView.getLayoutParams();
|
||||
ViewGroup.LayoutParams layoutParams = pageIconLayout.getLayoutParams();
|
||||
layoutParams.width = tilesWidth;
|
||||
layoutParams.height = (int) Math.floor(tilesWidth * SIZE_RATIO);
|
||||
pageIconView.setLayoutParams(layoutParams);
|
||||
pageIconLayout.setLayoutParams(layoutParams);
|
||||
|
||||
updateUiForSource(highlight.getSource());
|
||||
updatePageDomain();
|
||||
|
||||
if (ongoingIconLoad != null) {
|
||||
ongoingIconLoad.cancel(true);
|
||||
}
|
||||
|
||||
ongoingIconLoad = Icons.with(itemView.getContext())
|
||||
.pageUrl(highlight.getUrl())
|
||||
.skipNetwork()
|
||||
.build()
|
||||
.execute(this);
|
||||
pageIconLayout.updateIcon(highlight.getUrl(), highlight.getMetadataSlow().getImageUrl());
|
||||
}
|
||||
|
||||
private void updateUiForSource(Utils.HighlightSource source) {
|
||||
|
@ -151,11 +137,6 @@ public class HighlightItem extends StreamItem implements IconCallback {
|
|||
hostSLDTask.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIconResponse(IconResponse response) {
|
||||
pageIconView.updateImage(response);
|
||||
}
|
||||
|
||||
/** Updates the text of the given view to the host second level domain. */
|
||||
private static class UpdatePageDomainAsyncTask extends URIUtils.GetHostSecondLevelDomainAsyncTask {
|
||||
private static final int VIEW_TAG_ID = R.id.page; // same as the view.
|
||||
|
|
Загрузка…
Ссылка в новой задаче