Skip to content

Commit

Permalink
Revert "Fixes issue where private blog images wouldn't load."
Browse files Browse the repository at this point in the history
This reverts commit c37fd90.
  • Loading branch information
roundhill committed Nov 9, 2015
1 parent aaa16e5 commit b7cf042
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,6 @@ public static boolean isImageUrl(String url) {
cleanedUrl.endsWith("gif") || cleanedUrl.endsWith("png");
}

/**
* Returns true if the url is on wordpress.com
*/
public static boolean isWPComUrl(String url) {
return !TextUtils.isEmpty(url) && url.contains("wordpress.com");
}


public static String appendUrlParameter(String url, String paramName, String paramValue) {
Map<String, String> parameters = new HashMap<>();
parameters.put(paramName, paramValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.util.ArrayMap;
import android.text.Html;
import android.text.TextUtils;
import android.widget.TextView;
Expand All @@ -14,18 +13,14 @@
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.PhotonUtils;
import org.wordpress.android.util.UrlUtils;

import java.lang.ref.WeakReference;
import java.util.Map;

/**
* ImageGetter for Html.fromHtml()
* adapted from existing ImageGetter code in NoteCommentFragment
*/
public class WPImageGetter implements Html.ImageGetter {
private static final String IMAGE_QUALITY = "65";

private final WeakReference<TextView> mWeakView;
private final int mMaxSize;
private ImageLoader mImageLoader;
Expand All @@ -37,13 +32,13 @@ public WPImageGetter(TextView view) {
}

public WPImageGetter(TextView view, int maxSize) {
mWeakView = new WeakReference<>(view);
mWeakView = new WeakReference<TextView>(view);
mMaxSize = maxSize;
}

public WPImageGetter(TextView view, int maxSize, ImageLoader imageLoader, Drawable loadingDrawable,
Drawable failedDrawable) {
mWeakView = new WeakReference<>(view);
mWeakView = new WeakReference<TextView>(view);
mMaxSize = maxSize;
mImageLoader = imageLoader;
mLoadingDrawable = loadingDrawable;
Expand All @@ -69,20 +64,10 @@ public Drawable getDrawable(String source) {
source = "http:" + source;
}

// Resize to max size if requested (otherwise the full-sized image will be downloaded
// use Photon if a max size is requested (otherwise the full-sized image will be downloaded
// and then resized)
if (mMaxSize > 0) {
if (UrlUtils.isWPComUrl(source)) {
// Adjust query params for wp.com urls
Map<String, String> params = new ArrayMap<>();
params.put("w", String.valueOf(mMaxSize));
params.put("quality", IMAGE_QUALITY);

source = UrlUtils.appendUrlParameters(UrlUtils.removeQuery(source), params);
} else {
// Otherwise use photon
source = PhotonUtils.getPhotonImageUrl(source, mMaxSize, 0);
}
source = PhotonUtils.getPhotonImageUrl(source, mMaxSize, 0);
}

final RemoteDrawable remote = new RemoteDrawable(mLoadingDrawable, mFailedDrawable);
Expand Down

0 comments on commit b7cf042

Please sign in to comment.