refactor StartConversationsActivity

This commit is contained in:
Daniel Gultsch 2017-12-15 19:13:58 +01:00
parent cc6a001ac2
commit 0be41e0aab
1 changed files with 32 additions and 61 deletions

View File

@ -100,15 +100,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
mSearchEditText.post(new Runnable() {
@Override
public void run() {
mSearchEditText.post(() -> {
mSearchEditText.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mSearchEditText,
InputMethodManager.SHOW_IMPLICIT);
}
imm.showSoftInput(mSearchEditText, InputMethodManager.SHOW_IMPLICIT);
});
return true;
@ -204,23 +199,15 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private UiCallback<Conversation> mAdhocConferenceCallback = new UiCallback<Conversation>() {
@Override
public void success(final Conversation conversation) {
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(() -> {
hideToast();
switchToConversation(conversation);
}
});
}
@Override
public void error(final int errorCode, Conversation object) {
runOnUiThread(new Runnable() {
@Override
public void run() {
replaceToast(getString(errorCode));
}
});
runOnUiThread(() -> replaceToast(getString(errorCode)));
}
@Override
@ -422,9 +409,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
prefilledJid, null, invite == null || !invite.hasFingerprints()
);
dialog.setOnEnterJidDialogPositiveListener(new EnterJidDialog.OnEnterJidDialogPositiveListener() {
@Override
public boolean onEnterJidDialogPositive(Jid accountJid, Jid contactJid) throws EnterJidDialog.JidError {
dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {
if (!xmppConnectionServiceBound) {
return false;
}
@ -445,7 +430,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
switchToConversation(contact, invite == null ? null : invite.getBody());
return true;
}
}
});
mCurrentDialog = dialog.show();
@ -589,7 +573,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
} else {
ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
R.layout.simple_list_item,
Arrays.asList(new String[]{context.getString(R.string.no_accounts)}));
Arrays.asList(context.getString(R.string.no_accounts)));
adapter.setDropDownViewResource(R.layout.simple_list_item);
spinner.setAdapter(adapter);
spinner.setEnabled(false);
@ -877,29 +861,16 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
}
warning.setText(spannable);
builder.setView(view);
builder.setPositiveButton(R.string.confirm, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
if (isTrustedSource.isChecked() && invite.hasFingerprints()) {
xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
}
switchToConversation(contact, invite.getBody());
}
});
builder.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
StartConversationActivity.this.finish();
}
});
builder.setNegativeButton(R.string.cancel, (dialog, which) -> StartConversationActivity.this.finish());
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
StartConversationActivity.this.finish();
}
});
dialog.setOnCancelListener(dialog1 -> StartConversationActivity.this.finish());
dialog.show();
}