@@ -178,6 +178,19 @@ private MuPDFCore openCore(Uri uri, long size, String mimetype) throws IOExcepti
178
178
}
179
179
}
180
180
181
+ private void showCannotOpenDialog (String reason ) {
182
+ Resources res = getResources ();
183
+ AlertDialog alert = mAlertBuilder .create ();
184
+ setTitle (String .format (Locale .ROOT , res .getString (R .string .cannot_open_document_Reason ), reason ));
185
+ alert .setButton (AlertDialog .BUTTON_POSITIVE , getString (R .string .dismiss ),
186
+ new DialogInterface .OnClickListener () {
187
+ public void onClick (DialogInterface dialog , int which ) {
188
+ finish ();
189
+ }
190
+ });
191
+ alert .show ();
192
+ }
193
+
181
194
/** Called when the activity is first created. */
182
195
@ Override
183
196
public void onCreate (final Bundle savedInstanceState )
@@ -257,17 +270,7 @@ public void onCreate(final Bundle savedInstanceState)
257
270
core = openCore (uri , size , mimetype );
258
271
SearchTaskResult .set (null );
259
272
} catch (Exception x ) {
260
- String reason = x .toString ();
261
- Resources res = getResources ();
262
- AlertDialog alert = mAlertBuilder .create ();
263
- setTitle (String .format (Locale .ROOT , res .getString (R .string .cannot_open_document_Reason ), reason ));
264
- alert .setButton (AlertDialog .BUTTON_POSITIVE , getString (R .string .dismiss ),
265
- new DialogInterface .OnClickListener () {
266
- public void onClick (DialogInterface dialog , int which ) {
267
- finish ();
268
- }
269
- });
270
- alert .show ();
273
+ showCannotOpenDialog (x .toString ());
271
274
return ;
272
275
}
273
276
}
0 commit comments