mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
92a0c84e89
commit
9d1afebfe2
|
@ -350,6 +350,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements
|
public class ViewHolder extends RecyclerView.ViewHolder implements
|
||||||
View.OnClickListener,
|
View.OnClickListener,
|
||||||
View.OnLongClickListener,
|
View.OnLongClickListener,
|
||||||
|
CompoundButton.OnCheckedChangeListener,
|
||||||
View.OnLayoutChangeListener {
|
View.OnLayoutChangeListener {
|
||||||
private ViewCardOptional card;
|
private ViewCardOptional card;
|
||||||
private View view;
|
private View view;
|
||||||
|
@ -1048,6 +1049,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
ibCopyHeaders.setOnClickListener(this);
|
ibCopyHeaders.setOnClickListener(this);
|
||||||
ibCloseHeaders.setOnClickListener(this);
|
ibCloseHeaders.setOnClickListener(this);
|
||||||
|
|
||||||
|
ibExpanderAttachments.setOnClickListener(this);
|
||||||
|
cbInline.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
ibSaveAttachments.setOnClickListener(this);
|
ibSaveAttachments.setOnClickListener(this);
|
||||||
ibDownloadAttachments.setOnClickListener(this);
|
ibDownloadAttachments.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -1165,6 +1169,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
ibCopyHeaders.setOnClickListener(null);
|
ibCopyHeaders.setOnClickListener(null);
|
||||||
ibCloseHeaders.setOnClickListener(null);
|
ibCloseHeaders.setOnClickListener(null);
|
||||||
|
|
||||||
|
ibExpanderAttachments.setOnClickListener(null);
|
||||||
|
cbInline.setOnCheckedChangeListener(null);
|
||||||
|
|
||||||
ibSaveAttachments.setOnClickListener(null);
|
ibSaveAttachments.setOnClickListener(null);
|
||||||
ibDownloadAttachments.setOnClickListener(null);
|
ibDownloadAttachments.setOnClickListener(null);
|
||||||
|
|
||||||
|
@ -3548,16 +3555,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
ibExpanderAttachments.setImageLevel(hide_attachments ? 1 /* more */ : 0 /* less */);
|
ibExpanderAttachments.setImageLevel(hide_attachments ? 1 /* more */ : 0 /* less */);
|
||||||
ibExpanderAttachments.setVisibility(show.size() > 0 ? View.VISIBLE : View.GONE);
|
ibExpanderAttachments.setVisibility(show.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
ibExpanderAttachments.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
prefs.edit().putBoolean("hide_attachments", !hide_attachments).apply();
|
|
||||||
cowner.restart();
|
|
||||||
bindAttachments(message, properties.getAttachments(message.id), false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cbInline.setOnCheckedChangeListener(null);
|
|
||||||
cbInline.setChecked(show_inline);
|
cbInline.setChecked(show_inline);
|
||||||
cbInline.setVisibility(has_inline && !hide_attachments ? View.VISIBLE : View.GONE);
|
cbInline.setVisibility(has_inline && !hide_attachments ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
@ -3565,15 +3563,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
ibDownloadAttachments.setVisibility(downloadable > 1 && suitable && !hide_attachments ? View.VISIBLE : View.GONE);
|
ibDownloadAttachments.setVisibility(downloadable > 1 && suitable && !hide_attachments ? View.VISIBLE : View.GONE);
|
||||||
tvNoInternetAttachments.setVisibility(downloading && !suitable && !hide_attachments ? View.VISIBLE : View.GONE);
|
tvNoInternetAttachments.setVisibility(downloading && !suitable && !hide_attachments ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
cbInline.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
properties.setValue("inline", message.id, isChecked);
|
|
||||||
cowner.restart();
|
|
||||||
bindAttachments(message, properties.getAttachments(message.id), true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rvAttachment.post(new Runnable() {
|
rvAttachment.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -4281,6 +4270,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
onCopyHeaders(message);
|
onCopyHeaders(message);
|
||||||
} else if (id == R.id.ibCloseHeaders) {
|
} else if (id == R.id.ibCloseHeaders) {
|
||||||
onMenuShowHeaders(message);
|
onMenuShowHeaders(message);
|
||||||
|
} else if (id == R.id.ibExpanderAttachments) {
|
||||||
|
onExpandAttachments(message);
|
||||||
} else if (id == R.id.ibSaveAttachments) {
|
} else if (id == R.id.ibSaveAttachments) {
|
||||||
onSaveAttachments(message);
|
onSaveAttachments(message);
|
||||||
} else if (id == R.id.ibDownloadAttachments) {
|
} else if (id == R.id.ibDownloadAttachments) {
|
||||||
|
@ -4613,6 +4604,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
|
||||||
|
final TupleMessageEx message = getMessage();
|
||||||
|
if (message == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int id = compoundButton.getId();
|
||||||
|
if (id == R.id.cbInline) {
|
||||||
|
onShowInlineAttachments(message, isChecked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onKeyPressed(KeyEvent event) {
|
public boolean onKeyPressed(KeyEvent event) {
|
||||||
TupleMessageEx message = getMessage();
|
TupleMessageEx message = getMessage();
|
||||||
if (message == null)
|
if (message == null)
|
||||||
|
@ -5253,6 +5256,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
}.execute(context, owner, args, "message:attachment:download");
|
}.execute(context, owner, args, "message:attachment:download");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onExpandAttachments(TupleMessageEx message) {
|
||||||
|
boolean hide_attachments = prefs.getBoolean("hide_attachments", false);
|
||||||
|
prefs.edit().putBoolean("hide_attachments", !hide_attachments).apply();
|
||||||
|
cowner.restart();
|
||||||
|
bindAttachments(message, properties.getAttachments(message.id), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onShowInlineAttachments(TupleMessageEx message, boolean isChecked) {
|
||||||
|
properties.setValue("inline", message.id, isChecked);
|
||||||
|
cowner.restart();
|
||||||
|
bindAttachments(message, properties.getAttachments(message.id), true);
|
||||||
|
}
|
||||||
|
|
||||||
private void onSaveAttachments(TupleMessageEx message) {
|
private void onSaveAttachments(TupleMessageEx message) {
|
||||||
((FragmentBase) parentFragment).onStoreAttachments(message.id);
|
((FragmentBase) parentFragment).onStoreAttachments(message.id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue