Always cut and scale thumb on some scenes

This commit is contained in:
tarsin committed 2022-06-15 23:10:12 +08:00
1 parent ca802940b4
commit ac74a30fcf
4 files changed
+9 -4

No files matched your search

@@ -28,6 +28,7 @@ public class FixedThumb extends LoadImageView {
private float minAspect;
private float maxAspect;
private boolean alwaysCutAndScale;
public FixedThumb(Context context) {
super(context);
@@ -48,6 +49,7 @@ public class FixedThumb extends LoadImageView {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FixedThumb, defStyleAttr, defStyleRes);
minAspect = a.getFloat(R.styleable.FixedThumb_minAspect, 0.0f);
maxAspect = a.getFloat(R.styleable.FixedThumb_maxAspect, 0.0f);
alwaysCutAndScale = a.getBoolean(R.styleable.FixedThumb_alwaysCutAndScale, false);
a.recycle();
}
@@ -58,6 +60,10 @@ public class FixedThumb extends LoadImageView {
@Override
public void onPreSetImageDrawable(Drawable drawable, boolean isTarget) {
if (alwaysCutAndScale) {
setScaleType(ScaleType.CENTER_CROP);
return;
}
if (isTarget && drawable != null) {
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
+1 -2
View File
@@ -33,8 +33,7 @@
android:id="@+id/thumb"
android:layout_width="@dimen/gallery_list_thumb_width"
android:layout_height="@dimen/gallery_list_thumb_height"
app:maxAspect="1.333"
app:minAspect="0.333"
app:alwaysCutAndScale="true"
app:retryType="longClick" />
<TextView
@@ -38,8 +38,7 @@
android:id="@+id/thumb"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:maxAspect="1.333"
app:minAspect="0.333"
app:alwaysCutAndScale="true"
app:retryType="click" />
</com.google.android.material.card.MaterialCardView>
+1
View File
@@ -53,6 +53,7 @@
<declare-styleable name="FixedThumb">
<attr name="minAspect" format="float" />
<attr name="maxAspect" format="float" />
<attr name="alwaysCutAndScale" format="boolean"/>
</declare-styleable>
<declare-styleable name="CheckTextView">