Fix thumbnail 404 positioning

filtering
Floens 10 years ago
parent d5a35346eb
commit f792014663
  1. 16
      Clover/app/src/main/java/org/floens/chan/ui/view/ThumbnailView.java

@ -61,6 +61,7 @@ public class ThumbnailView extends View implements ImageLoader.ImageListener {
private boolean error = false;
private String errorText;
private Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Rect tmpTextRect = new Rect();
public ThumbnailView(Context context) {
super(context);
@ -158,14 +159,16 @@ public class ThumbnailView extends View implements ImageLoader.ImageListener {
return;
}
int width = getWidth() - getPaddingLeft() - getPaddingRight();
int height = getHeight() - getPaddingTop() - getPaddingBottom();
if (error) {
canvas.save();
Rect bounds = new Rect();
textPaint.getTextBounds(errorText, 0, errorText.length(), bounds);
float x = (getWidth() - getPaddingLeft() + getPaddingRight() - bounds.width()) / 2;
float y = getHeight() - getPaddingTop() - getPaddingBottom() - (getHeight() - bounds.height()) / 2;
canvas.drawText(errorText, getPaddingLeft() + x, getPaddingTop() + y, textPaint);
textPaint.getTextBounds(errorText, 0, errorText.length(), tmpTextRect);
float x = width / 2f - tmpTextRect.exactCenterX();
float y = height / 2f - tmpTextRect.exactCenterY();
canvas.drawText(errorText, x + getPaddingLeft(), y + getPaddingTop(), textPaint);
canvas.restore();
} else {
@ -173,9 +176,6 @@ public class ThumbnailView extends View implements ImageLoader.ImageListener {
return;
}
int width = getWidth() - getPaddingLeft() - getPaddingRight();
int height = getHeight() - getPaddingTop() - getPaddingBottom();
if (calculate) {
calculate = false;
bitmapRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());

Loading…
Cancel
Save