|
|
|
@ -27,6 +27,8 @@ import android.content.pm.PackageManager;
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
@ -34,6 +36,7 @@ import android.widget.ImageButton;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.core.content.FileProvider;
|
|
|
|
@ -66,7 +69,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
|
|
|
|
|
|
|
|
|
private List<EntityAttachment> items = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
|
|
|
|
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
|
|
|
|
private View view;
|
|
|
|
|
private ImageButton ibDelete;
|
|
|
|
|
private ImageView ivType;
|
|
|
|
@ -95,12 +98,14 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
|
|
|
|
|
|
|
|
|
private void wire() {
|
|
|
|
|
view.setOnClickListener(this);
|
|
|
|
|
view.setOnLongClickListener(this);
|
|
|
|
|
ibDelete.setOnClickListener(this);
|
|
|
|
|
ibSave.setOnClickListener(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void unwire() {
|
|
|
|
|
view.setOnClickListener(null);
|
|
|
|
|
view.setOnLongClickListener(null);
|
|
|
|
|
ibDelete.setOnClickListener(null);
|
|
|
|
|
ibSave.setOnClickListener(null);
|
|
|
|
|
}
|
|
|
|
@ -204,6 +209,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
|
|
|
|
int pos = getAdapterPosition();
|
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
EntityAttachment attachment = items.get(pos);
|
|
|
|
|
if (attachment == null)
|
|
|
|
|
return;
|
|
|
|
@ -222,6 +228,25 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
|
int pos = getAdapterPosition();
|
|
|
|
|
if (pos == RecyclerView.NO_POSITION)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
EntityAttachment attachment = items.get(pos);
|
|
|
|
|
if (attachment == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(attachment.name))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
Toast toast = ToastEx.makeText(context, attachment.name, Toast.LENGTH_LONG);
|
|
|
|
|
toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
|
|
toast.show();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onDelete(final EntityAttachment attachment) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", attachment.id);
|
|
|
|
|