fixed some minor NPE

This commit is contained in:
Daniel Gultsch 2019-09-16 14:20:15 +02:00
parent ab57c59838
commit d963d95e30
4 changed files with 29 additions and 25 deletions

View File

@ -2551,6 +2551,9 @@ public class XmppConnectionService extends Service {
final MucOptions mucOptions = conversation.getMucOptions(); final MucOptions mucOptions = conversation.getMucOptions();
if (mucOptions.nonanonymous() && !mucOptions.membersOnly() && !conversation.getBooleanAttribute("accept_non_anonymous", false)) { if (mucOptions.nonanonymous() && !mucOptions.membersOnly() && !conversation.getBooleanAttribute("accept_non_anonymous", false)) {
synchronized (account.inProgressConferenceJoins) {
account.inProgressConferenceJoins.remove(conversation);
}
mucOptions.setError(MucOptions.Error.NON_ANONYMOUS); mucOptions.setError(MucOptions.Error.NON_ANONYMOUS);
updateConversationUi(); updateConversationUi();
if (onConferenceJoined != null) { if (onConferenceJoined != null) {
@ -2990,7 +2993,6 @@ public class XmppConnectionService extends Service {
@Override @Override
public void onIqPacketReceived(Account account, IqPacket packet) { public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) { if (packet.getType() == IqPacket.TYPE.RESULT) {
final MucOptions mucOptions = conversation.getMucOptions(); final MucOptions mucOptions = conversation.getMucOptions();
final Bookmark bookmark = conversation.getBookmark(); final Bookmark bookmark = conversation.getBookmark();
final boolean sameBefore = StringUtils.equals(bookmark == null ? null : bookmark.getBookmarkName(), mucOptions.getName()); final boolean sameBefore = StringUtils.equals(bookmark == null ? null : bookmark.getBookmarkName(), mucOptions.getName());
@ -3012,9 +3014,10 @@ public class XmppConnectionService extends Service {
} }
updateConversationUi(); updateConversationUi();
} else if (packet.getType() == IqPacket.TYPE.ERROR) { } else if (packet.getType() == IqPacket.TYPE.TIMEOUT) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received timeout waiting for conference configuration fetch");
} else {
if (callback != null) { if (callback != null) {
callback.onFetchFailed(conversation, packet.getError()); callback.onFetchFailed(conversation, packet.getError());
} }

View File

@ -1552,7 +1552,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
intent = GeoHelper.getFetchIntent(activity); intent = GeoHelper.getFetchIntent(activity);
break; break;
} }
if (intent.resolveActivity(getActivity().getPackageManager()) != null) { final Context context = getActivity();
if (context != null && intent.resolveActivity(context.getPackageManager()) != null) {
if (chooser) { if (chooser) {
startActivityForResult( startActivityForResult(
Intent.createChooser(intent, getString(R.string.perform_action_with)), Intent.createChooser(intent, getString(R.string.perform_action_with)),

View File

@ -16,6 +16,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.databinding.SearchResultItemBinding; import eu.siacs.conversations.databinding.SearchResultItemBinding;
import eu.siacs.conversations.http.services.MuclumbusService; import eu.siacs.conversations.http.services.MuclumbusService;
import eu.siacs.conversations.ui.util.AvatarWorkerTask; import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import rocks.xmpp.addr.Jid;
public class ChannelSearchResultAdapter extends ListAdapter<MuclumbusService.Room, ChannelSearchResultAdapter.ViewHolder> { public class ChannelSearchResultAdapter extends ListAdapter<MuclumbusService.Room, ChannelSearchResultAdapter.ViewHolder> {
@ -61,7 +62,8 @@ public class ChannelSearchResultAdapter extends ListAdapter<MuclumbusService.Roo
viewHolder.binding.language.setText(language.toUpperCase(Locale.ENGLISH)); viewHolder.binding.language.setText(language.toUpperCase(Locale.ENGLISH));
viewHolder.binding.language.setVisibility(View.VISIBLE); viewHolder.binding.language.setVisibility(View.VISIBLE);
} }
viewHolder.binding.room.setText(searchResult.getRoom().asBareJid().toString()); final Jid room = searchResult.getRoom();
viewHolder.binding.room.setText(room != null ? room.asBareJid().toString() : "");
AvatarWorkerTask.loadAvatar(searchResult, viewHolder.binding.avatar, R.dimen.avatar); AvatarWorkerTask.loadAvatar(searchResult, viewHolder.binding.avatar, R.dimen.avatar);
viewHolder.binding.getRoot().setOnClickListener(v -> listener.onChannelSearchResult(searchResult)); viewHolder.binding.getRoot().setOnClickListener(v -> listener.onChannelSearchResult(searchResult));
} }

View File

@ -147,6 +147,8 @@ public final class MucDetailsContextMenuHelper {
activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.ADMIN, onAffiliationChanged); activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.ADMIN, onAffiliationChanged);
return true; return true;
case R.id.give_membership: case R.id.give_membership:
case R.id.remove_admin_privileges:
case R.id.revoke_owner_privileges:
activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged); activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged);
return true; return true;
case R.id.give_owner_privileges: case R.id.give_owner_privileges:
@ -155,10 +157,6 @@ public final class MucDetailsContextMenuHelper {
case R.id.remove_membership: case R.id.remove_membership:
activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.NONE, onAffiliationChanged); activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.NONE, onAffiliationChanged);
return true; return true;
case R.id.remove_admin_privileges:
case R.id.revoke_owner_privileges:
activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged);
return true;
case R.id.remove_from_room: case R.id.remove_from_room:
removeFromRoom(user, activity, onAffiliationChanged); removeFromRoom(user, activity, onAffiliationChanged);
return true; return true;