Prevent crash

pull/210/head
M66B 2 years ago
parent 7d14b16ca0
commit f9b04e94bf

@ -1448,9 +1448,15 @@ public class FragmentCompose extends FragmentBase {
etTo.setOnItemClickListener(new AdapterView.OnItemClickListener() { etTo.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
Cursor cursor = (Cursor) adapterView.getAdapter().getItem(position); try {
int colEmail = cursor.getColumnIndex("email"); Cursor cursor = (Cursor) adapterView.getAdapter().getItem(position);
selectIdentityForEmail(colEmail < 0 ? null : cursor.getString(colEmail)); if (cursor != null && cursor.getCount() > 0) {
int colEmail = cursor.getColumnIndex("email");
selectIdentityForEmail(colEmail < 0 ? null : cursor.getString(colEmail));
}
} catch (Throwable ex) {
Log.e(ex);
}
} }
}); });
@ -7482,22 +7488,27 @@ public class FragmentCompose extends FragmentBase {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
int target = spTarget.getSelectedItemPosition(); try {
Cursor cursor = (Cursor) spGroup.getSelectedItem(); int target = spTarget.getSelectedItemPosition();
if (target != INVALID_POSITION && cursor != null) { Cursor cursor = (Cursor) spGroup.getSelectedItem();
long group = cursor.getLong(0); if (target != INVALID_POSITION &&
String name = cursor.getString(1); cursor != null && cursor.getCount() > 0) {
long group = cursor.getLong(0);
Bundle args = getArguments(); String name = cursor.getString(1);
args.putLong("id", working);
args.putInt("target", target); Bundle args = getArguments();
args.putLong("group", group); args.putLong("id", working);
args.putString("name", name); args.putInt("target", target);
args.putInt("type", spType.getSelectedItemPosition()); args.putLong("group", group);
args.putString("name", name);
sendResult(RESULT_OK); args.putInt("type", spType.getSelectedItemPosition());
} else
sendResult(RESULT_CANCELED); sendResult(RESULT_OK);
} else
sendResult(RESULT_CANCELED);
} catch (Throwable ex) {
Log.e(ex);
}
} }
}) })
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)

Loading…
Cancel
Save