aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-06-25 17:32:58 +0200
committeriNPUTmice <daniel@gultsch.de>2014-06-25 17:32:58 +0200
commit5db04a37bd5b7acc41a8f2dad941fabd9a6a97e8 (patch)
treee3408dbca307de6b4c395876eb321089b2388993 /src/eu/siacs/conversations/ui
parent31657974bfb3e7cab10956bb9661794f4f4cdb43 (diff)
fixed two rare npe
Diffstat (limited to 'src/eu/siacs/conversations/ui')
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java88
1 files changed, 45 insertions, 43 deletions
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
index d89c35f1..bee93713 100644
--- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -305,68 +305,70 @@ public class ContactDetailsActivity extends XmppActivity {
protected void onStop() {
super.onStop();
boolean updated = false;
- boolean online = contact.getAccount().getStatus() == Account.STATUS_ONLINE;
- if (contact.getOption(Contact.Options.FROM)) {
- if (!send.isChecked()) {
- if (online) {
- contact.resetOption(Contact.Options.FROM);
- contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
- activity.xmppConnectionService.stopPresenceUpdatesTo(contact);
- }
- updated = true;
- }
- } else {
- if (contact
- .getOption(Contact.Options.PREEMPTIVE_GRANT)) {
+ if (contact!=null) {
+ boolean online = contact.getAccount().getStatus() == Account.STATUS_ONLINE;
+ if (contact.getOption(Contact.Options.FROM)) {
if (!send.isChecked()) {
if (online) {
+ contact.resetOption(Contact.Options.FROM);
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
+ activity.xmppConnectionService.stopPresenceUpdatesTo(contact);
}
updated = true;
}
} else {
- if (send.isChecked()) {
- if (online) {
- contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
+ if (contact
+ .getOption(Contact.Options.PREEMPTIVE_GRANT)) {
+ if (!send.isChecked()) {
+ if (online) {
+ contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
+ }
+ updated = true;
+ }
+ } else {
+ if (send.isChecked()) {
+ if (online) {
+ contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
+ }
+ updated = true;
}
- updated = true;
- }
- }
- }
- if (contact.getOption(Contact.Options.TO)) {
- if (!receive.isChecked()) {
- if (online) {
- contact.resetOption(Contact.Options.TO);
- activity.xmppConnectionService.stopPresenceUpdatesFrom(contact);
}
- updated = true;
}
- } else {
- if (contact.getOption(Contact.Options.ASKING)) {
+ if (contact.getOption(Contact.Options.TO)) {
if (!receive.isChecked()) {
if (online) {
- contact.resetOption(Contact.Options.ASKING);
- activity.xmppConnectionService
- .stopPresenceUpdatesFrom(contact);
+ contact.resetOption(Contact.Options.TO);
+ activity.xmppConnectionService.stopPresenceUpdatesFrom(contact);
}
updated = true;
}
} else {
- if (receive.isChecked()) {
- if (online) {
- contact.setOption(Contact.Options.ASKING);
- activity.xmppConnectionService
- .requestPresenceUpdatesFrom(contact);
+ if (contact.getOption(Contact.Options.ASKING)) {
+ if (!receive.isChecked()) {
+ if (online) {
+ contact.resetOption(Contact.Options.ASKING);
+ activity.xmppConnectionService
+ .stopPresenceUpdatesFrom(contact);
+ }
+ updated = true;
+ }
+ } else {
+ if (receive.isChecked()) {
+ if (online) {
+ contact.setOption(Contact.Options.ASKING);
+ activity.xmppConnectionService
+ .requestPresenceUpdatesFrom(contact);
+ }
+ updated = true;
}
- updated = true;
}
}
- }
- if (updated) {
- if (online) {
- Toast.makeText(getApplicationContext(), getString(R.string.subscription_updated), Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(getApplicationContext(), getString(R.string.subscription_not_updated_offline), Toast.LENGTH_SHORT).show();
+ if (updated) {
+ if (online) {
+ Toast.makeText(getApplicationContext(), getString(R.string.subscription_updated), Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(getApplicationContext(), getString(R.string.subscription_not_updated_offline), Toast.LENGTH_SHORT).show();
+ }
}
}
}