MCPcopy Create free account
hub / github.com/M66B/FairEmail / load

Method load

app/src/main/java/eu/faircode/email/ActivityDSN.java:82–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80 }
81
82 private void load() {
83 Uri uri = getIntent().getData();
84 Log.i("DSN uri=" + uri);
85
86 Bundle args = new Bundle();
87 args.putParcelable("uri", uri);
88
89 new SimpleTask<Spanned>() {
90 @Override
91 protected void onPreExecute(Bundle args) {
92 pbWait.setVisibility(View.VISIBLE);
93 }
94
95 @Override
96 protected void onPostExecute(Bundle args) {
97 pbWait.setVisibility(View.GONE);
98 }
99
100 @Override
101 protected Spanned onExecute(Context context, Bundle args) throws Throwable {
102 Uri uri = args.getParcelable("uri");
103
104 NoStreamException.check(uri, context);
105
106 ContentResolver resolver = context.getContentResolver();
107 try (InputStream is = resolver.openInputStream(uri)) {
108 if (is == null)
109 throw new FileNotFoundException(uri.toString());
110
111 ByteArrayOutputStream bos = new ByteArrayOutputStream();
112 Helper.copy(is, bos);
113
114 String headers = bos.toString(StandardCharsets.UTF_8.name());
115 headers = MessageHelper.decodeMime(headers);
116 return HtmlHelper.highlightHeaders(context,
117 null, null, null, headers, false, false);
118 }
119 }
120
121 @Override
122 protected void onExecuted(Bundle args, Spanned result) {
123 tvHeaders.setText(result);
124 grpReady.setVisibility(View.VISIBLE);
125 }
126
127 @Override
128 protected void onException(Bundle args, Throwable ex) {
129 if (ex instanceof NoStreamException)
130 ((NoStreamException) ex).report(ActivityDSN.this);
131 else
132 Log.unexpectedError(getSupportFragmentManager(), ex, false);
133 }
134 }.execute(this, args, "disposition:decode");
135 }
136}

Callers 2

onCreateMethod · 0.95
onNewIntentMethod · 0.95

Calls 4

iMethod · 0.95
getDataMethod · 0.45
getIntentMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected