Skip to content

Commit

Permalink
支持选择时间线的图片质量
Browse files Browse the repository at this point in the history
  • Loading branch information
郭文明 committed Sep 6, 2016
1 parent ff4f1c1 commit 7570efd
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,12 @@ private static void displayLongPic(File file, Bitmap bitmap, SubsamplingScaleIma
longImg.setZoomEnabled(false);
longImg.setPanEnabled(false);
longImg.setQuickScaleEnabled(false);
longImg.setImage(ImageSource.uri(file.getAbsolutePath()), new ImageViewState(0, new PointF(0, 0), 0));
longImg.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP);
if (NewFeature.timeline_img_quality != NewFeature.thumbnail_quality) {
longImg.setImage(ImageSource.uri(file.getAbsolutePath()), new ImageViewState(0, new PointF(0, 0), 0));
longImg.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP);
} else {
longImg.setImage(ImageSource.uri(file.getAbsolutePath()));
}
}

public static void displayNorImg(File file, Bitmap bitmap, ImageView norImg, ImageView imageLable) {
Expand Down Expand Up @@ -475,7 +479,14 @@ public static void displayGif(File file, GifImageView gifImageView, ImageView im
* @param imageLabel
*/
public static void fillImageList(final Context context, final Status status, DisplayImageOptions options, final int position, final SubsamplingScaleImageView longImg, final ImageView norImg, final GifImageView gifImg, final ImageView imageLabel) {
final ArrayList<String> urllist = status.bmiddle_pic_urls;
final ArrayList<String> urllist;
if (NewFeature.timeline_img_quality == NewFeature.thumbnail_quality) {
urllist = status.thumbnail_pic_urls;
} else if (NewFeature.timeline_img_quality == NewFeature.bmiddle_quality) {
urllist = status.bmiddle_pic_urls;
} else {
urllist = status.origin_pic_urls;
}
ImageLoader.getInstance().loadImage(urllist.get(position), options, new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String s, View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,13 @@ public class NewFeature {
*/
public static boolean refresh_profileLayout = false;

public static int bmiddle_quality = 1;

public static int thumbnail_quality = 2;

public static int origin_quality = 3;

public static int timeline_img_quality = bmiddle_quality;


}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.nostra13.universalimageloader.utils.DiskCacheUtils;
import com.wenming.weiswift.R;
import com.wenming.weiswift.ui.common.ImageUtil;
import com.wenming.weiswift.ui.common.NewFeature;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -199,8 +200,15 @@ private void showPreviewImg(final String url, final PhotoView preNorImg, final S
hidePreviewImg(preNorImg, preLongImg);
return;
}

final String bmiddleUrl = url.replace("large", "bmiddle");
String replacement = "";
if (NewFeature.timeline_img_quality == NewFeature.bmiddle_quality) {
replacement = "bmiddle";
} else if (NewFeature.timeline_img_quality == NewFeature.thumbnail_quality) {
replacement = "thumbnail";
} else {
replacement = "large";
}
final String bmiddleUrl = url.replace("large", replacement);
//加载图片
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheOnDisk(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.wenming.weiswift.R;
import com.wenming.weiswift.entity.Status;
import com.wenming.weiswift.ui.common.FillContent;
import com.wenming.weiswift.ui.common.NewFeature;
import com.wenming.weiswift.utils.ScreenUtil;

import java.util.ArrayList;
Expand All @@ -38,33 +38,35 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder>
.cacheInMemory(true)
.cacheOnDisk(true)
.build();
private final ImageSize mSingleImageSize;
private final ImageSize mDoubleImgSize;
private final ImageSize mThreeImgSize;


public ImageAdapter(Status status, Context context) {
this.mStatus = status;
this.mData = status.bmiddle_pic_urls;
if (NewFeature.timeline_img_quality == NewFeature.thumbnail_quality) {
this.mData = status.thumbnail_pic_urls;
} else if (NewFeature.timeline_img_quality == NewFeature.bmiddle_quality) {
this.mData = status.bmiddle_pic_urls;
} else {
this.mData = status.origin_pic_urls;
}
this.mContext = context;
mSingleImageSize = new ImageSize(ScreenUtil.getScreenWidth(context), (int) (ScreenUtil.getScreenWidth(context) * 0.7));
mDoubleImgSize = new ImageSize(ScreenUtil.getScreenWidth(context) / 2, ScreenUtil.getScreenWidth(context) / 2);
mThreeImgSize = new ImageSize(ScreenUtil.getScreenWidth(context) / 3,ScreenUtil.getScreenWidth(context) / 3);

}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.mainfragment_weiboitem_imageitem, parent, false);
ViewHolder viewHolder = new ViewHolder(view);
//设置加载中的图片样式
setImgSize(mData, mContext, viewHolder.norImg, viewHolder.longImg, viewHolder.gifImg);
if (NewFeature.timeline_img_quality != NewFeature.thumbnail_quality) {
setImgSize(mData, mContext, viewHolder.norImg, viewHolder.longImg, viewHolder.gifImg);
}
return viewHolder;
}

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
FillContent.fillImageList(mContext, mStatus, options, position, holder.longImg, holder.norImg, holder.gifImg, holder.imageLabel);


}

@Override
Expand Down

0 comments on commit 7570efd

Please sign in to comment.