From c5159022237c927ea5bdd127ec9075bda9711a82 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Tue, 2 Oct 2012 16:54:13 -0700 Subject: [PATCH] Fixed a crash that could occur when processing update messages --- .../astrid/service/UpdateMessageService.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java index e27c1c21b..df50b4abb 100644 --- a/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java +++ b/astrid/src/com/todoroo/astrid/service/UpdateMessageService.java @@ -109,35 +109,40 @@ public class UpdateMessageService { } } - protected void displayUpdateDialog(Pair message) { + protected void displayUpdateDialog(final Pair message) { if(activity == null) return; final DialogShower ds; if (message.getRight() != null) { - final View view = activity.getLayoutInflater().inflate(R.layout.update_message_link, null); - TextView messageView = (TextView) view.findViewById(R.id.update_message); - messageView.setText(message.getLeft()); - messageView.setTextColor(activity.getResources().getColor(ThemeService.getDialogTextColor())); - - final TextView linkView = (TextView) view.findViewById(R.id.update_link); - linkView.setMovementMethod(LinkMovementMethod.getInstance()); - linkView.setText(message.getRight()); ds = new DialogShower() { @Override public void showDialog(Activity a) { - final Dialog d = new AlertDialog.Builder(a) - .setTitle(R.string.UpS_updates_title) - .setView(view) - .setPositiveButton(R.string.DLG_ok, null) - .create(); - linkView.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - d.dismiss(); - } - }); - d.show(); + try { + View view = activity.getLayoutInflater().inflate(R.layout.update_message_link, null); + TextView messageView = (TextView) view.findViewById(R.id.update_message); + messageView.setText(message.getLeft()); + messageView.setTextColor(activity.getResources().getColor(ThemeService.getDialogTextColor())); + + TextView linkView = (TextView) view.findViewById(R.id.update_link); + linkView.setMovementMethod(LinkMovementMethod.getInstance()); + linkView.setText(message.getRight()); + + final Dialog d = new AlertDialog.Builder(a) + .setTitle(R.string.UpS_updates_title) + .setView(view) + .setPositiveButton(R.string.DLG_ok, null) + .create(); + linkView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + d.dismiss(); + } + }); + d.show(); + } catch (Exception e) { + // This should never ever crash + } } }; } else {