mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
spotbugs: improve exception handling
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
4790e7b7e4
commit
d8b167ebfa
@ -75,6 +75,7 @@ import org.greenrobot.eventbus.Subscribe;
|
|||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -129,7 +130,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
@BindView(R.id.loading_content)
|
@BindView(R.id.loading_content)
|
||||||
LinearLayout loadingContent;
|
LinearLayout loadingContent;
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
|
||||||
@ -527,45 +527,49 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
EnumActorTypeConverter actorTypeConverter = new EnumActorTypeConverter();
|
EnumActorTypeConverter actorTypeConverter = new EnumActorTypeConverter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AutocompleteOverall autocompleteOverall = LoganSquare.parse(responseBody.string(), AutocompleteOverall.class);
|
AutocompleteOverall autocompleteOverall = LoganSquare.parse(
|
||||||
autocompleteUsersHashSet.addAll(autocompleteOverall.getOcs().getData());
|
responseBody.string(),
|
||||||
|
AutocompleteOverall.class);
|
||||||
|
autocompleteUsersHashSet.addAll(autocompleteOverall.getOcs().getData());
|
||||||
|
|
||||||
for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) {
|
for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) {
|
||||||
if (!autocompleteUser.getId().equals(currentUser.getUserId()) && !existingParticipants.contains(autocompleteUser.getId())) {
|
if (!autocompleteUser.getId().equals(currentUser.getUserId())
|
||||||
participant = new Participant();
|
&& !existingParticipants.contains(autocompleteUser.getId())) {
|
||||||
participant.setActorId(autocompleteUser.getId());
|
participant = new Participant();
|
||||||
participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.getSource()));
|
participant.setActorId(autocompleteUser.getId());
|
||||||
participant.setDisplayName(autocompleteUser.getLabel());
|
participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.getSource()));
|
||||||
participant.setSource(autocompleteUser.getSource());
|
participant.setDisplayName(autocompleteUser.getLabel());
|
||||||
|
participant.setSource(autocompleteUser.getSource());
|
||||||
|
|
||||||
String headerTitle;
|
String headerTitle;
|
||||||
|
|
||||||
if (participant.getActorType() == Participant.ActorType.GROUPS) {
|
|
||||||
headerTitle = getResources().getString(R.string.nc_groups);
|
|
||||||
} else if (participant.getActorType() == Participant.ActorType.CIRCLES) {
|
|
||||||
headerTitle = getResources().getString(R.string.nc_circles);
|
|
||||||
} else {
|
|
||||||
headerTitle = participant.getDisplayName().substring(0, 1).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
GenericTextHeaderItem genericTextHeaderItem;
|
|
||||||
if (!userHeaderItems.containsKey(headerTitle)) {
|
|
||||||
genericTextHeaderItem = new GenericTextHeaderItem(headerTitle);
|
|
||||||
userHeaderItems.put(headerTitle, genericTextHeaderItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
UserItem newContactItem = new UserItem(participant, currentUser,
|
|
||||||
userHeaderItems.get(headerTitle));
|
|
||||||
|
|
||||||
if (!contactItems.contains(newContactItem)) {
|
|
||||||
newUserItemList.add(newContactItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (participant.getActorType() == Participant.ActorType.GROUPS) {
|
||||||
|
headerTitle = getResources().getString(R.string.nc_groups);
|
||||||
|
} else if (participant.getActorType() == Participant.ActorType.CIRCLES) {
|
||||||
|
headerTitle = getResources().getString(R.string.nc_circles);
|
||||||
|
} else {
|
||||||
|
headerTitle = participant.getDisplayName().substring(0, 1).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GenericTextHeaderItem genericTextHeaderItem;
|
||||||
|
if (!userHeaderItems.containsKey(headerTitle)) {
|
||||||
|
genericTextHeaderItem = new GenericTextHeaderItem(headerTitle);
|
||||||
|
userHeaderItems.put(headerTitle, genericTextHeaderItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
UserItem newContactItem = new UserItem(
|
||||||
|
participant,
|
||||||
|
currentUser,
|
||||||
|
userHeaderItems.get(headerTitle)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!contactItems.contains(newContactItem)) {
|
||||||
|
newUserItemList.add(newContactItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (IOException ioe) {
|
||||||
Log.e(TAG, "Parsing response body failed while getting contacts");
|
Log.e(TAG, "Parsing response body failed while getting contacts", ioe);
|
||||||
}
|
}
|
||||||
|
|
||||||
userHeaderItems = new HashMap<>();
|
userHeaderItems = new HashMap<>();
|
||||||
@ -575,7 +579,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
String firstName;
|
String firstName;
|
||||||
String secondName;
|
String secondName;
|
||||||
|
|
||||||
|
|
||||||
if (o1 instanceof UserItem) {
|
if (o1 instanceof UserItem) {
|
||||||
firstName = ((UserItem) o1).getModel().getDisplayName();
|
firstName = ((UserItem) o1).getModel().getDisplayName();
|
||||||
} else {
|
} else {
|
||||||
@ -627,7 +630,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
String firstName;
|
String firstName;
|
||||||
String secondName;
|
String secondName;
|
||||||
|
|
||||||
|
|
||||||
if (o1 instanceof UserItem) {
|
if (o1 instanceof UserItem) {
|
||||||
firstName = ((UserItem) o1).getModel().getDisplayName();
|
firstName = ((UserItem) o1).getModel().getDisplayName();
|
||||||
} else {
|
} else {
|
||||||
@ -653,7 +655,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
return firstName.compareToIgnoreCase(secondName);
|
return firstName.compareToIgnoreCase(secondName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (newUserItemList.size() > 0) {
|
if (newUserItemList.size() > 0) {
|
||||||
adapter.updateDataSet(newUserItemList);
|
adapter.updateDataSet(newUserItemList);
|
||||||
} else {
|
} else {
|
||||||
@ -664,7 +665,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -673,7 +673,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
||||||
dispose(contactsQueryDisposable);
|
dispose(contactsQueryDisposable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user