|
@@ -20,14 +20,15 @@ import rx.functions.Action1;
|
|
|
/**
|
|
/**
|
|
|
* Created by realicing on 2018/11/7.
|
|
* Created by realicing on 2018/11/7.
|
|
|
* realicing@sina.com
|
|
* realicing@sina.com
|
|
|
|
|
+ * 图片显示类
|
|
|
*/
|
|
*/
|
|
|
-public class ResImageGetter implements Html.ImageGetter {
|
|
|
|
|
|
|
+public class DetailImageGetter implements Html.ImageGetter {
|
|
|
|
|
|
|
|
private int textSize;
|
|
private int textSize;
|
|
|
private int maxWidth;
|
|
private int maxWidth;
|
|
|
private TextView textView;
|
|
private TextView textView;
|
|
|
private String content;
|
|
private String content;
|
|
|
- public ResImageGetter(TextView textView, String content, int maxWidth) {
|
|
|
|
|
|
|
+ public DetailImageGetter(TextView textView, String content, int maxWidth) {
|
|
|
this.textView = textView;
|
|
this.textView = textView;
|
|
|
this.content = content;
|
|
this.content = content;
|
|
|
this.maxWidth = maxWidth;
|
|
this.maxWidth = maxWidth;
|
|
@@ -47,13 +48,19 @@ public class ResImageGetter implements Html.ImageGetter {
|
|
|
if(path != null){
|
|
if(path != null){
|
|
|
Drawable drawable = Drawable.createFromPath(path);
|
|
Drawable drawable = Drawable.createFromPath(path);
|
|
|
if(drawable != null){
|
|
if(drawable != null){
|
|
|
- int imgWidth = G.getRealPix(drawable.getMinimumWidth());
|
|
|
|
|
- int imgHeight = G.getRealPix(drawable.getMinimumHeight());
|
|
|
|
|
|
|
+ int minimumWidth = drawable.getMinimumWidth();
|
|
|
|
|
+ int minimumHeight = drawable.getMinimumHeight();
|
|
|
|
|
+ int imgWidth = G.getRealPix(minimumWidth);
|
|
|
|
|
+ int imgHeight = G.getRealPix(minimumHeight);
|
|
|
|
|
+ int imgLeft = 0;
|
|
|
if(imgWidth > maxWidth && maxWidth > 0){
|
|
if(imgWidth > maxWidth && maxWidth > 0){
|
|
|
imgHeight = (int) (maxWidth * imgHeight * 1.0f / imgWidth);
|
|
imgHeight = (int) (maxWidth * imgHeight * 1.0f / imgWidth);
|
|
|
imgWidth = maxWidth;
|
|
imgWidth = maxWidth;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ imgLeft = (maxWidth - imgWidth) / 2;
|
|
|
|
|
+ imgWidth += imgLeft;
|
|
|
}
|
|
}
|
|
|
- drawable.setBounds(0, 0, imgWidth, imgHeight);
|
|
|
|
|
|
|
+ drawable.setBounds(imgLeft, 0, imgWidth, imgHeight);
|
|
|
return drawable;
|
|
return drawable;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|