Just center images

pull/153/head
M66B 7 years ago
parent afa8610b99
commit 5f99823bb3

@ -51,7 +51,6 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
private Context context; private Context context;
private LayoutInflater inflater; private LayoutInflater inflater;
private LifecycleOwner owner; private LifecycleOwner owner;
private int dp48;
private List<EntityAttachment> items = new ArrayList<>(); private List<EntityAttachment> items = new ArrayList<>();
@ -80,18 +79,15 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
if (attachment.available) { if (attachment.available) {
Bitmap bm = Helper.decodeImage(attachment.getFile(context), Bitmap bm = Helper.decodeImage(attachment.getFile(context),
context.getResources().getDisplayMetrics().widthPixels / 2); context.getResources().getDisplayMetrics().widthPixels / 2);
if (bm == null) { if (bm == null)
image.setPadding(dp48, dp48, dp48, dp48);
image.setImageResource(R.drawable.baseline_broken_image_24); image.setImageResource(R.drawable.baseline_broken_image_24);
} else { else {
image.setPadding(0, 0, 0, 0); image.setPadding(0, 0, 0, 0);
image.setImageBitmap(bm); image.setImageBitmap(bm);
} }
} else { } else
image.setPadding(dp48, dp48, dp48, dp48);
image.setImageResource(attachment.progress == null image.setImageResource(attachment.progress == null
? R.drawable.baseline_image_24 : R.drawable.baseline_hourglass_empty_24); ? R.drawable.baseline_image_24 : R.drawable.baseline_hourglass_empty_24);
}
caption.setText(attachment.name); caption.setText(attachment.name);
} }
@ -180,7 +176,6 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
this.context = context; this.context = context;
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.owner = owner; this.owner = owner;
this.dp48 = Helper.dp2pixels(context, 48);
setHasStableIds(true); setHasStableIds(true);
} }

@ -17,7 +17,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="centerCrop" android:scaleType="centerInside"
android:src="@mipmap/ic_launcher" android:src="@mipmap/ic_launcher"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

Loading…
Cancel
Save