|
|
@@ -1758,10 +1758,16 @@ public class ViewUtil {
|
|
|
public static void setViewWH(View view, int width, float radio) {
|
|
|
LayoutParamsUtil.resetLayoutParams(view, new Lp().setWidth(width).setHeight((int) (width * radio)));
|
|
|
}
|
|
|
- public static void setImageWH(ImageView view, Object url, int width, int radius) {
|
|
|
+ public static void setImageWH(ImageView view, String url, int width, int radius) {
|
|
|
if(url == null || view == null){
|
|
|
return;
|
|
|
}
|
|
|
+ int w = DataUtil.getAsInt(url+"_w", 0);
|
|
|
+ int h = DataUtil.getAsInt(url+"_h", 0);
|
|
|
+ if(w > 0 && h > 0) {
|
|
|
+ float radio = h * 1.0f / w;
|
|
|
+ ViewUtil.setViewWH(view, width, radio);
|
|
|
+ }
|
|
|
Glide.with(SheepApp.getInstance())
|
|
|
.load(url)
|
|
|
.listener(new RequestListener<Drawable>() {
|
|
|
@@ -1774,10 +1780,8 @@ public class ViewUtil {
|
|
|
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
|
|
int w = resource.getIntrinsicWidth();
|
|
|
int h = resource.getIntrinsicHeight();
|
|
|
- if(w > 0 && h > 0) {
|
|
|
- float radio = h * 1.0f / w;
|
|
|
- ViewUtil.setViewWH(view, width, radio);
|
|
|
- }
|
|
|
+ DataUtil.putAsInt(url+"_w", w);
|
|
|
+ DataUtil.putAsInt(url+"_h", h);
|
|
|
return false;
|
|
|
}
|
|
|
})
|