mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 06:31:17 +00:00
Show more image data
This commit is contained in:
parent
3fa67067ee
commit
612c252313
2 changed files with 45 additions and 13 deletions
|
@ -56,15 +56,19 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
private View view;
|
private View view;
|
||||||
private ImageView image;
|
private ImageView ivImage;
|
||||||
private TextView caption;
|
private TextView tvCaption;
|
||||||
|
private TextView tvType;
|
||||||
|
private TextView tvSize;
|
||||||
|
|
||||||
ViewHolder(View itemView) {
|
ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
view = itemView.findViewById(R.id.clItem);
|
view = itemView.findViewById(R.id.clItem);
|
||||||
image = itemView.findViewById(R.id.image);
|
ivImage = itemView.findViewById(R.id.ivImage);
|
||||||
caption = itemView.findViewById(R.id.caption);
|
tvCaption = itemView.findViewById(R.id.tvCaption);
|
||||||
|
tvType = itemView.findViewById(R.id.tvType);
|
||||||
|
tvSize = itemView.findViewById(R.id.tvSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void wire() {
|
private void wire() {
|
||||||
|
@ -76,18 +80,25 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindTo(EntityAttachment attachment) {
|
private void bindTo(EntityAttachment attachment) {
|
||||||
|
Bitmap bm = null;
|
||||||
if (attachment.available) {
|
if (attachment.available) {
|
||||||
Bitmap bm = Helper.decodeImage(attachment.getFile(context),
|
bm = Helper.decodeImage(attachment.getFile(context),
|
||||||
context.getResources().getDisplayMetrics().widthPixels);
|
context.getResources().getDisplayMetrics().widthPixels);
|
||||||
if (bm == null)
|
if (bm == null)
|
||||||
image.setImageResource(R.drawable.baseline_broken_image_24);
|
ivImage.setImageResource(R.drawable.baseline_broken_image_24);
|
||||||
else
|
else
|
||||||
image.setImageBitmap(bm);
|
ivImage.setImageBitmap(bm);
|
||||||
} else
|
} else
|
||||||
image.setImageResource(attachment.progress == null
|
ivImage.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);
|
tvCaption.setVisibility(TextUtils.isEmpty(attachment.name) ? View.GONE : View.VISIBLE);
|
||||||
|
tvSize.setVisibility(bm == null ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
|
tvCaption.setText(attachment.name);
|
||||||
|
tvType.setText(attachment.type);
|
||||||
|
if (bm != null)
|
||||||
|
tvSize.setText(bm.getWidth() + "x" + bm.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,7 +152,6 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
|
||||||
protected Void onExecute(Context context, Bundle args) {
|
protected Void onExecute(Context context, Bundle args) {
|
||||||
long id = args.getLong("id");
|
long id = args.getLong("id");
|
||||||
long message = args.getLong("message");
|
long message = args.getLong("message");
|
||||||
long sequence = args.getInt("sequence");
|
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
android:padding="6dp">
|
android:padding="6dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/ivImage"
|
||||||
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"
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/caption"
|
android:id="@+id/tvCaption"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
|
@ -33,6 +33,28 @@
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/image" />
|
app:layout_constraintTop_toBottomOf="@id/ivImage" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvType"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="image/jpg"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvCaption" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvSize"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="160x320"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvType" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Loading…
Reference in a new issue