check if service is bound before adding conferences or contacts
This commit is contained in:
parent
9f4043c679
commit
7f5456e41b
|
@ -143,11 +143,11 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private OnRosterUpdate onRosterUpdate = new OnRosterUpdate() {
|
private OnRosterUpdate onRosterUpdate = new OnRosterUpdate() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRosterUpdate() {
|
public void onRosterUpdate() {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mSearchEditText != null) {
|
if (mSearchEditText != null) {
|
||||||
|
@ -191,7 +191,8 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mConferenceAdapter = new ListItemAdapter(getApplicationContext(),conferences);
|
mConferenceAdapter = new ListItemAdapter(getApplicationContext(),
|
||||||
|
conferences);
|
||||||
mConferenceListFragment.setListAdapter(mConferenceAdapter);
|
mConferenceListFragment.setListAdapter(mConferenceAdapter);
|
||||||
mConferenceListFragment.setContextMenu(R.menu.conference_context);
|
mConferenceListFragment.setContextMenu(R.menu.conference_context);
|
||||||
mConferenceListFragment
|
mConferenceListFragment
|
||||||
|
@ -204,7 +205,8 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mContactsAdapter = new ListItemAdapter(getApplicationContext(),contacts);
|
mContactsAdapter = new ListItemAdapter(getApplicationContext(),
|
||||||
|
contacts);
|
||||||
mContactsListFragment.setListAdapter(mContactsAdapter);
|
mContactsListFragment.setListAdapter(mContactsAdapter);
|
||||||
mContactsListFragment.setContextMenu(R.menu.contact_context);
|
mContactsListFragment.setContextMenu(R.menu.contact_context);
|
||||||
mContactsListFragment
|
mContactsListFragment
|
||||||
|
@ -218,7 +220,7 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
@ -270,11 +272,10 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
builder.setTitle(R.string.action_delete_contact);
|
builder.setTitle(R.string.action_delete_contact);
|
||||||
builder.setMessage(
|
builder.setMessage(getString(R.string.remove_contact_text,
|
||||||
getString(R.string.remove_contact_text,
|
contact.getJid()));
|
||||||
contact.getJid()));
|
builder.setPositiveButton(R.string.delete, new OnClickListener() {
|
||||||
builder.setPositiveButton(R.string.delete,new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
xmppConnectionService.deleteContactOnServer(contact);
|
xmppConnectionService.deleteContactOnServer(contact);
|
||||||
|
@ -282,21 +283,20 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deleteConference() {
|
protected void deleteConference() {
|
||||||
int position = conference_context_id;
|
int position = conference_context_id;
|
||||||
final Bookmark bookmark = (Bookmark) conferences.get(position);
|
final Bookmark bookmark = (Bookmark) conferences.get(position);
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
builder.setTitle(R.string.delete_bookmark);
|
builder.setTitle(R.string.delete_bookmark);
|
||||||
builder.setMessage(
|
builder.setMessage(getString(R.string.remove_bookmark_text,
|
||||||
getString(R.string.remove_bookmark_text,
|
bookmark.getJid()));
|
||||||
bookmark.getJid()));
|
builder.setPositiveButton(R.string.delete, new OnClickListener() {
|
||||||
builder.setPositiveButton(R.string.delete,new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
bookmark.unregisterConversation();
|
bookmark.unregisterConversation();
|
||||||
|
@ -307,7 +307,7 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showCreateContactDialog() {
|
protected void showCreateContactDialog() {
|
||||||
|
@ -331,6 +331,9 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (!xmppConnectionServiceBound) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Validator.isValidJid(jid.getText().toString())) {
|
if (Validator.isValidJid(jid.getText().toString())) {
|
||||||
String accountJid = (String) spinner
|
String accountJid = (String) spinner
|
||||||
.getSelectedItem();
|
.getSelectedItem();
|
||||||
|
@ -377,6 +380,9 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (!xmppConnectionServiceBound) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Validator.isValidJid(jid.getText().toString())) {
|
if (Validator.isValidJid(jid.getText().toString())) {
|
||||||
String accountJid = (String) spinner
|
String accountJid = (String) spinner
|
||||||
.getSelectedItem();
|
.getSelectedItem();
|
||||||
|
@ -398,7 +404,8 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
conferenceJid, true);
|
conferenceJid, true);
|
||||||
conversation.setBookmark(bookmark);
|
conversation.setBookmark(bookmark);
|
||||||
if (!conversation.getMucOptions().online()) {
|
if (!conversation.getMucOptions().online()) {
|
||||||
xmppConnectionService.joinMuc(conversation);
|
xmppConnectionService
|
||||||
|
.joinMuc(conversation);
|
||||||
}
|
}
|
||||||
switchToConversation(conversation);
|
switchToConversation(conversation);
|
||||||
}
|
}
|
||||||
|
@ -466,12 +473,10 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event)
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
{
|
if (keyCode == KeyEvent.KEYCODE_SEARCH && !event.isLongPress()) {
|
||||||
if(keyCode == KeyEvent.KEYCODE_SEARCH && !event.isLongPress())
|
|
||||||
{
|
|
||||||
mOptionsMenu.findItem(R.id.action_search).expandActionView();
|
mOptionsMenu.findItem(R.id.action_search).expandActionView();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +485,7 @@ public class StartConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onBackendConnected() {
|
void onBackendConnected() {
|
||||||
xmppConnectionService.setOnRosterUpdateListener(this.onRosterUpdate );
|
xmppConnectionService.setOnRosterUpdateListener(this.onRosterUpdate);
|
||||||
if (mSearchEditText != null) {
|
if (mSearchEditText != null) {
|
||||||
filter(mSearchEditText.getText().toString());
|
filter(mSearchEditText.getText().toString());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue