mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-28 01:24:03 +03:00
Fix spotbugs
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
1f00f426c7
commit
232334efac
2 changed files with 23 additions and 16 deletions
|
@ -67,6 +67,8 @@ import eu.davidea.viewholders.FlexibleViewHolder;
|
|||
public class ConversationItem extends AbstractFlexibleItem<ConversationItem.ConversationItemViewHolder> implements
|
||||
ISectionable<ConversationItem.ConversationItemViewHolder, GenericTextHeaderItem>, IFilterable<String> {
|
||||
|
||||
public static final int VIEW_TYPE = R.layout.rv_item_conversation_with_last_message;
|
||||
|
||||
private static final float STATUS_SIZE_IN_DP = 9f;
|
||||
|
||||
private final Conversation conversation;
|
||||
|
@ -75,6 +77,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
|
|||
private GenericTextHeaderItem header;
|
||||
private final Status status;
|
||||
|
||||
|
||||
public ConversationItem(Conversation conversation, UserEntity userEntity, Context activityContext, Status status) {
|
||||
this.conversation = conversation;
|
||||
this.userEntity = userEntity;
|
||||
|
@ -114,6 +117,11 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
|
|||
return R.layout.rv_item_conversation_with_last_message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType() {
|
||||
return VIEW_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConversationItemViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
||||
return new ConversationItemViewHolder(view, adapter);
|
||||
|
|
|
@ -956,32 +956,31 @@ public class ConversationsListController extends BaseController implements Flexi
|
|||
@Override
|
||||
public boolean onItemClick(View view, int position) {
|
||||
final AbstractFlexibleItem item = adapter.getItem(position);
|
||||
if (item instanceof ConversationItem) {
|
||||
showConversation(((ConversationItem) Objects.requireNonNull(item)).getModel());
|
||||
} else if (item instanceof MessageResultItem) {
|
||||
if (item != null) {
|
||||
final int viewType = item.getItemViewType();
|
||||
if (viewType == MessageResultItem.VIEW_TYPE) {
|
||||
MessageResultItem messageItem = (MessageResultItem) item;
|
||||
String conversationToken = messageItem.getMessageEntry().getConversationToken();
|
||||
selectedMessageId = messageItem.getMessageEntry().getMessageId();
|
||||
showConversationByToken(conversationToken);
|
||||
} else if (item instanceof LoadMoreResultsItem) {
|
||||
} else if (viewType == LoadMoreResultsItem.VIEW_TYPE) {
|
||||
loadMoreMessages();
|
||||
} else if (viewType == ConversationItem.VIEW_TYPE) {
|
||||
showConversation(((ConversationItem) Objects.requireNonNull(item)).getModel());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showConversationByToken(String conversationToken) {
|
||||
Conversation conversation = null;
|
||||
for (AbstractFlexibleItem absItem : conversationItems) {
|
||||
ConversationItem conversationItem = ((ConversationItem) absItem);
|
||||
if (conversationItem.getModel().getToken().equals(conversationToken)) {
|
||||
conversation = conversationItem.getModel();
|
||||
}
|
||||
}
|
||||
if (conversation != null) {
|
||||
final Conversation conversation = conversationItem.getModel();
|
||||
showConversation(conversation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showConversation(@Nullable final Conversation conversation) {
|
||||
selectedConversation = conversation;
|
||||
|
@ -1390,7 +1389,7 @@ public class ConversationsListController extends BaseController implements Flexi
|
|||
clearMessageSearchResults();
|
||||
final List<SearchMessageEntry> entries = results.getMessages();
|
||||
if (entries.size() > 0) {
|
||||
List<AbstractFlexibleItem> adapterItems = new ArrayList<>();
|
||||
List<AbstractFlexibleItem> adapterItems = new ArrayList<>(entries.size() + 1);
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
final boolean showHeader = i == 0;
|
||||
adapterItems.add(new MessageResultItem(context, currentUser, entries.get(i), showHeader));
|
||||
|
|
Loading…
Reference in a new issue