Fixed a crash that could occur when processing update messages

pull/14/head
Sam Bosley 12 years ago
parent 0de8e7ca4b
commit c515902223

@ -109,35 +109,40 @@ public class UpdateMessageService {
} }
} }
protected void displayUpdateDialog(Pair<String, Spannable> message) { protected void displayUpdateDialog(final Pair<String, Spannable> message) {
if(activity == null) if(activity == null)
return; return;
final DialogShower ds; final DialogShower ds;
if (message.getRight() != null) { 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() { ds = new DialogShower() {
@Override @Override
public void showDialog(Activity a) { public void showDialog(Activity a) {
final Dialog d = new AlertDialog.Builder(a) try {
.setTitle(R.string.UpS_updates_title) View view = activity.getLayoutInflater().inflate(R.layout.update_message_link, null);
.setView(view) TextView messageView = (TextView) view.findViewById(R.id.update_message);
.setPositiveButton(R.string.DLG_ok, null) messageView.setText(message.getLeft());
.create(); messageView.setTextColor(activity.getResources().getColor(ThemeService.getDialogTextColor()));
linkView.setOnClickListener(new OnClickListener() {
@Override TextView linkView = (TextView) view.findViewById(R.id.update_link);
public void onClick(View v) { linkView.setMovementMethod(LinkMovementMethod.getInstance());
d.dismiss(); linkView.setText(message.getRight());
}
}); final Dialog d = new AlertDialog.Builder(a)
d.show(); .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 { } else {

Loading…
Cancel
Save