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,31 +2993,31 @@ 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 Bookmark bookmark = conversation.getBookmark();
final boolean sameBefore = StringUtils.equals(bookmark == null ? null : bookmark.getBookmarkName(), mucOptions.getName());
final MucOptions mucOptions = conversation.getMucOptions(); if (mucOptions.updateConfiguration(new ServiceDiscoveryResult(packet))) {
final Bookmark bookmark = conversation.getBookmark(); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": muc configuration changed for " + conversation.getJid().asBareJid());
final boolean sameBefore = StringUtils.equals(bookmark == null ? null : bookmark.getBookmarkName(), mucOptions.getName()); updateConversation(conversation);
}
if (mucOptions.updateConfiguration(new ServiceDiscoveryResult(packet))) { if (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": muc configuration changed for " + conversation.getJid().asBareJid()); if (bookmark.setBookmarkName(StringUtils.nullOnEmpty(mucOptions.getName()))) {
updateConversation(conversation); pushBookmarks(account);
} }
}
if (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) {
if (bookmark.setBookmarkName(StringUtils.nullOnEmpty(mucOptions.getName()))) {
pushBookmarks(account);
}
}
if (callback != null) { if (callback != null) {
callback.onConferenceConfigurationFetched(conversation); callback.onConferenceConfigurationFetched(conversation);
} }
updateConversationUi();
updateConversationUi(); } else if (packet.getType() == IqPacket.TYPE.TIMEOUT) {
} else if (packet.getType() == IqPacket.TYPE.ERROR) { 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;