From 143ca4df262b2cbf2e10758188b1a40ce2a1c47d Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 14 Feb 2011 20:26:00 -0500 Subject: [PATCH] replace redundant calls with a helper --- src/com/fsck/k9/activity/MessageView.java | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index 75be442c2..2a70a3d53 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -235,31 +235,26 @@ public class MessageView extends K9Activity implements OnClickListener { }); } - public void networkError() { + /* A helper for a set of "show a toast" methods */ + private void showToast(final String message, final int toastLength) { runOnUiThread(new Runnable() { public void run() { - Toast.makeText(MessageView.this, R.string.status_network_error, Toast.LENGTH_LONG).show(); + Toast.makeText(MessageView.this, message, toastLength).show(); } }); } + public void networkError() { + showToast(getString(R.string.status_network_error), Toast.LENGTH_LONG); + } + public void invalidIdError() { - runOnUiThread(new Runnable() { - public void run() { - Toast.makeText(MessageView.this, R.string.status_invalid_id_error, Toast.LENGTH_LONG).show(); - } - }); + showToast(getString(R.string.status_invalid_id_error), Toast.LENGTH_LONG); } public void fetchingAttachment() { - runOnUiThread(new Runnable() { - public void run() { - Toast.makeText(MessageView.this, - getString(R.string.message_view_fetching_attachment_toast), - Toast.LENGTH_SHORT).show(); - } - }); + showToast(getString(R.string.message_view_fetching_attachment_toast), Toast.LENGTH_SHORT); }