mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Fix very small flair icon.
This commit is contained in:
parent
03ac342884
commit
0ba9cbafbe
@ -24,25 +24,19 @@ import java.lang.ref.WeakReference;
|
|||||||
public class GlideImageGetter implements Html.ImageGetter {
|
public class GlideImageGetter implements Html.ImageGetter {
|
||||||
|
|
||||||
private WeakReference<TextView> container;
|
private WeakReference<TextView> container;
|
||||||
private boolean matchParentWidth;
|
|
||||||
private boolean enlargeImage;
|
private boolean enlargeImage;
|
||||||
private HtmlImagesHandler imagesHandler;
|
private HtmlImagesHandler imagesHandler;
|
||||||
private float density = 1.0f;
|
private float density = 1.0f;
|
||||||
private float textSize;
|
private float textSize;
|
||||||
|
|
||||||
public GlideImageGetter(TextView textView, boolean enlargeImage) {
|
public GlideImageGetter(TextView textView, boolean enlargeImage) {
|
||||||
this(textView, false, false, null);
|
this(textView, false, null);
|
||||||
this.enlargeImage = enlargeImage;
|
this.enlargeImage = enlargeImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlideImageGetter(TextView textView, boolean matchParentWidth, HtmlImagesHandler imagesHandler) {
|
public GlideImageGetter(TextView textView, boolean densityAware,
|
||||||
this(textView, matchParentWidth, false, imagesHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlideImageGetter(TextView textView, boolean matchParentWidth, boolean densityAware,
|
|
||||||
@Nullable HtmlImagesHandler imagesHandler) {
|
@Nullable HtmlImagesHandler imagesHandler) {
|
||||||
this.container = new WeakReference<>(textView);
|
this.container = new WeakReference<>(textView);
|
||||||
this.matchParentWidth = matchParentWidth;
|
|
||||||
this.imagesHandler = imagesHandler;
|
this.imagesHandler = imagesHandler;
|
||||||
if (densityAware) {
|
if (densityAware) {
|
||||||
density = container.get().getResources().getDisplayMetrics().density;
|
density = container.get().getResources().getDisplayMetrics().density;
|
||||||
@ -97,15 +91,8 @@ public class GlideImageGetter implements Html.ImageGetter {
|
|||||||
float ratio = (float) drawableWidth / (float) drawableHeight;
|
float ratio = (float) drawableWidth / (float) drawableHeight;
|
||||||
drawableHeight = enlargeImage ? (int) (textSize * 1.5) : (int) textSize;
|
drawableHeight = enlargeImage ? (int) (textSize * 1.5) : (int) textSize;
|
||||||
drawableWidth = (int) (drawableHeight * ratio);
|
drawableWidth = (int) (drawableHeight * ratio);
|
||||||
int maxWidth = container.get().getMeasuredWidth();
|
drawable.setBounds(0, 0, drawableWidth, drawableHeight);
|
||||||
if ((maxWidth > 0 && (drawableWidth > maxWidth)) || matchParentWidth) {
|
setBounds(0, 0, drawableWidth, drawableHeight);
|
||||||
int calculatedHeight = maxWidth * drawableHeight / drawableWidth;
|
|
||||||
drawable.setBounds(0, 0, maxWidth, calculatedHeight);
|
|
||||||
setBounds(0, 0, maxWidth, calculatedHeight);
|
|
||||||
} else {
|
|
||||||
drawable.setBounds(0, 0, drawableWidth, drawableHeight);
|
|
||||||
setBounds(0, 0, drawableWidth, drawableHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
container.get().setText(container.get().getText());
|
container.get().setText(container.get().getText());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user