游戏-插件,推荐 卡片化。删除旧版游戏详情
This commit is contained in:
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ImageView.ScaleType;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.gh.common.view.CircleImageView;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -100,7 +101,11 @@ public class ImageUtils {
|
||||
}
|
||||
//增加一个上下文环境,图片宽度设最大,高度自适应
|
||||
public void display(String url, ImageView imageView, int drawable,Context context) {
|
||||
display(url, imageView, drawable, ScaleType.FIT_XY, null,context);
|
||||
display(url, imageView, drawable, ScaleType.FIT_XY, null ,context);
|
||||
}
|
||||
// 主页大图布局用到的
|
||||
public void display(String url, ImageView imageView, int drawable,Context context,RelativeLayout rlImage,int position) {
|
||||
display(url, imageView, drawable, ScaleType.FIT_XY, null ,context, rlImage,position);
|
||||
}
|
||||
public void display(String url, ImageView imageView, int drawable) {
|
||||
display(url, imageView, drawable, ScaleType.FIT_XY, null);
|
||||
@ -145,6 +150,70 @@ public class ImageUtils {
|
||||
});
|
||||
}
|
||||
|
||||
public void display(final String url, final ImageView imageView,
|
||||
final int drawable, final ScaleType scaleType,
|
||||
final OnLoadingCompleteListener listener,final Context context,final RelativeLayout rlImage, final int position) {
|
||||
imageLoader.displayImage(url, imageView, options,
|
||||
new ImageLoadingListener() {
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view,
|
||||
Bitmap loadedImage) {
|
||||
int width = loadedImage.getWidth();
|
||||
int height = loadedImage.getHeight();
|
||||
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
|
||||
widthPixels = widthPixels - DisplayUtils.dip2px(context,10);
|
||||
float index = (float) height / (float) width;
|
||||
int newHeight = (int)(index * widthPixels);
|
||||
|
||||
if (rlImage!= null){
|
||||
ViewGroup.LayoutParams layoutParams = rlImage.getLayoutParams();
|
||||
if (position != 0){
|
||||
layoutParams.height = newHeight + DisplayUtils.dip2px(context,8);
|
||||
}else {
|
||||
layoutParams.height = newHeight;
|
||||
}
|
||||
}
|
||||
|
||||
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
|
||||
if (layoutParams!=null){
|
||||
layoutParams.height = newHeight;
|
||||
layoutParams.width = widthPixels;
|
||||
imageView.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(new EBImage(imageUri, newHeight));
|
||||
|
||||
if (imageView instanceof CircleImageView) {
|
||||
imageView.setScaleType(ScaleType.CENTER_CROP);
|
||||
} else {
|
||||
imageView.setScaleType(scaleType);
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onLoadingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingStarted(String imageUri, View view) {
|
||||
imageView.setScaleType(ScaleType.CENTER);
|
||||
if (drawable != -1) {
|
||||
imageView.setImageResource(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingCancelled(String imageUri, View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view,
|
||||
FailReason reason) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void display(final String url, final ImageView imageView,
|
||||
final int drawable, final ScaleType scaleType,
|
||||
final OnLoadingCompleteListener listener,final Context context) {
|
||||
@ -156,7 +225,7 @@ public class ImageUtils {
|
||||
int width = loadedImage.getWidth();
|
||||
int height = loadedImage.getHeight();
|
||||
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
|
||||
widthPixels = widthPixels - (int)(context.getResources().getDisplayMetrics().density * 10);
|
||||
widthPixels = widthPixels - DisplayUtils.dip2px(context,10);
|
||||
float index = (float) height / (float) width;
|
||||
int newHeight = (int)(index * widthPixels);
|
||||
|
||||
@ -194,7 +263,7 @@ public class ImageUtils {
|
||||
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view,
|
||||
FailReason reason) {
|
||||
FailReason reason) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user