mirror of
https://github.com/moparisthebest/k-9
synced 2024-08-13 17:03:48 -04:00
Extract code to display error/status messages to a separate method
This commit is contained in:
parent
dfe1771fcb
commit
187d760e5f
@ -287,9 +287,8 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
|||||||
* Abort early if there's no place to save the attachment. We don't want to spend
|
* Abort early if there's no place to save the attachment. We don't want to spend
|
||||||
* the time downloading it and then abort.
|
* the time downloading it and then abort.
|
||||||
*/
|
*/
|
||||||
Toast.makeText(mContext,
|
String message = mContext.getString(R.string.message_view_status_attachment_not_saved);
|
||||||
mContext.getString(R.string.message_view_status_attachment_not_saved),
|
displayMessageToUser(message);
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mMessage != null) {
|
if (mMessage != null) {
|
||||||
@ -309,22 +308,24 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
|||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(K9.LOG_TAG, "Could not display attachment of type " + contentType, e);
|
Log.e(K9.LOG_TAG, "Could not display attachment of type " + contentType, e);
|
||||||
Toast toast = Toast.makeText(mContext, mContext.getString(R.string.message_view_no_viewer, contentType),
|
|
||||||
Toast.LENGTH_LONG);
|
String message = mContext.getString(R.string.message_view_no_viewer, contentType);
|
||||||
toast.show();
|
displayMessageToUser(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachmentSaved(final String filename) {
|
public void attachmentSaved(final String filename) {
|
||||||
Toast.makeText(mContext, String.format(
|
String message = mContext.getString(R.string.message_view_status_attachment_saved, filename);
|
||||||
mContext.getString(R.string.message_view_status_attachment_saved), filename),
|
displayMessageToUser(message);
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachmentNotSaved() {
|
public void attachmentNotSaved() {
|
||||||
Toast.makeText(mContext,
|
String message = mContext.getString(R.string.message_view_status_attachment_not_saved);
|
||||||
mContext.getString(R.string.message_view_status_attachment_not_saved),
|
displayMessageToUser(message);
|
||||||
Toast.LENGTH_LONG).show();
|
}
|
||||||
|
|
||||||
|
private void displayMessageToUser(String message) {
|
||||||
|
Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCallback(AttachmentFileDownloadCallback callback) {
|
public void setCallback(AttachmentFileDownloadCallback callback) {
|
||||||
|
Loading…
Reference in New Issue
Block a user