Bug 1390203: Only get highlight images on wifi. r=sebastian
MozReview-Commit-ID: FtSDZ6Yu5Ql
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
@@ -14,16 +14,17 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
import org.mozilla.gecko.R;
import org.mozilla.gecko.icons.IconCallback;
import org.mozilla.gecko.icons.IconResponse;
import org.mozilla.gecko.icons.Icons;
+import org.mozilla.gecko.util.NetworkUtils;
import org.mozilla.gecko.widget.FaviconView;
import java.util.concurrent.Future;
/**
* A layout that represents page icons in Activity Stream, which can be overridden with a custom URL.
*
* Under the hood, it switches between multiple icon views because favicons (in FaviconView)
@@ -53,17 +54,20 @@ public class StreamOverridablePageIconLa
/**
* Updates the icon for the view. If a non-null overrideImageURL is provided, this image will be shown.
* Otherwise, a favicon will be retrieved for the given pageURL.
*/
public void updateIcon(@NonNull final String pageURL, @Nullable final String overrideImageURL) {
cancelPendingRequests();
- if (!TextUtils.isEmpty(overrideImageURL)) {
+ // We don't know how the large the non-favicon images could be (bug 1388415) so for now we're only going
+ // to download them on wifi. Alternatively, we could get these from the Gecko cache (see below).
+ if (NetworkUtils.isWifi(getContext()) &&
+ !TextUtils.isEmpty(overrideImageURL)) {
setUIMode(UIMode.NONFAVICON_IMAGE);
// TODO (bug 1322501): Optimization: since we've already navigated to these pages, there's a chance
// Gecko has the image in its cache: we should try to get it first before making this network request.
Picasso.with(getContext())
.load(Uri.parse(overrideImageURL))
.fit()
.centerCrop()