private void showView(ViewHolder holder, final ReaderComicBitmapBean.EpisodesBean.EpisodePictureBean readerItemData) {
String imageURI = readerItemData.getImageUrl() + "";
int imageWidth = readerItemData.getWidth();
int imageHeight = readerItemData.getHeight();
int tempWidth = DensityUtil.getScreenW(mContext);
int tempHeight = (int) (tempWidth * ((double) imageHeight / imageWidth));
imageShow(holder.image, imageURI, tempWidth, tempHeight);
}
/**
* 设置宽高的图片
* @param image
* @param imageURI
* @param tempWidth
* @param tempHeight
*/
private void imageShow(QiyiDraweeView image, String imageURI, int tempWidth, int tempHeight) {
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(image.getController())
.setControllerListener(new ControllerListener<ImageInfo>() {
@Override
public void onSubmit(String id, Object callerContext) {
}
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) image.getLayoutParams();
params.width = tempWidth;
params.height = tempHeight;
image.setLayoutParams(params);
}
@Override
public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
}
@Override
public void onIntermediateImageFailed(String id, Throwable throwable) {
}
@Override
public void onFailure(String id, Throwable throwable) {
}
@Override
public void onRelease(String id) {
}
})
.setUri(Uri.parse(imageURI))
.build();
image.setController(controller);
}