Commit 20cb09a0 authored by Francisco Cunha's avatar Francisco Cunha Committed by Hussein

P4A-950 - AttachmentView cleanup

parent de9eea3e
......@@ -24,7 +24,6 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
private Button viewButton;
private ImageView downloadButton;
private View attachmentContainer;
public AttachmentView(Context context, AttributeSet attrs, int defStyle) {
......@@ -60,25 +59,20 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
}
private void displayAttachmentInformation() {
attachmentContainer = findViewById(R.id.attachment_container);
viewButton = (Button) findViewById(R.id.view);
downloadButton = (ImageView) findViewById(R.id.download);
View attachmentContainer = findViewById(R.id.attachment_container);
viewButton = findViewById(R.id.view);
downloadButton = findViewById(R.id.download);
if (attachment.size > K9.MAX_ATTACHMENT_DOWNLOAD_SIZE) {
viewButton.setVisibility(View.GONE);
downloadButton.setVisibility(View.GONE);
}
attachmentContainer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onViewClick();
}
});
attachmentContainer.setOnClickListener(v -> onViewClick());
downloadButton.setOnClickListener(this);
downloadButton.setOnLongClickListener(this);
TextView attachmentName = (TextView) findViewById(R.id.attachment_name);
TextView attachmentName = findViewById(R.id.attachment_name);
attachmentName.setText(attachment.displayName);
setAttachmentSize(attachment.size);
......@@ -87,7 +81,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
}
private void setAttachmentSize(long size) {
TextView attachmentSize = (TextView) findViewById(R.id.attachment_info);
TextView attachmentSize = findViewById(R.id.attachment_info);
if (size == AttachmentViewInfo.UNKNOWN_SIZE) {
attachmentSize.setText("");
} else {
......@@ -98,11 +92,8 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.download: {
onSaveButtonClick();
break;
}
if (view.getId() == R.id.download) {
onSaveButtonClick();
}
}
......@@ -133,7 +124,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
}
public void refreshThumbnail() {
ImageView thumbnailView = (ImageView) findViewById(R.id.attachment_icon);
ImageView thumbnailView = findViewById(R.id.attachment_icon);
Glide.with(getContext())
.load(attachment.internalUri)
.placeholder(R.drawable.attached_image_placeholder)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment