mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 05:44:51 +02:00
Refactoring
This commit is contained in:
@@ -215,7 +215,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
||||
else if (id == R.id.ibSave)
|
||||
onSave(attachment);
|
||||
else if (id == R.id.ibScan)
|
||||
Check.virus(context, owner, parentFragment.getParentFragmentManager(), attachment.id);
|
||||
onScan(attachment);
|
||||
else {
|
||||
if (attachment.available)
|
||||
onShare(attachment);
|
||||
@@ -310,6 +310,36 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
||||
.putExtra("type", attachment.getMimeType()));
|
||||
}
|
||||
|
||||
private void onScan(EntityAttachment attachment) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", attachment.id);
|
||||
|
||||
new SimpleTask<Bundle>() {
|
||||
@Override
|
||||
protected Bundle onExecute(Context context, Bundle args) throws Throwable {
|
||||
long id = args.getLong("id");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
EntityAttachment attachment = db.attachment().getAttachment(id);
|
||||
if (attachment == null)
|
||||
return null;
|
||||
|
||||
return VirusTotal.scan(context, attachment.getFile(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Bundle result) {
|
||||
String uri = result.getString("uri");
|
||||
Helper.view(context, Uri.parse(uri), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(context, owner, args, "attachment:scan");
|
||||
}
|
||||
|
||||
private void onShare(EntityAttachment attachment) {
|
||||
String title = (attachment.name == null ? attachment.cid : attachment.name);
|
||||
Helper.share(context, attachment.getFile(context), attachment.getMimeType(), title);
|
||||
|
||||
@@ -655,7 +655,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
tvVirusTotalPrivacy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Helper.view(v.getContext(), Uri.parse(Check.URI_VT_PRIVACY), true);
|
||||
Helper.view(v.getContext(), Uri.parse(VirusTotal.URI_PRIVACY), true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user