mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 14:05:40 +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
|
public class ConversationItem extends AbstractFlexibleItem<ConversationItem.ConversationItemViewHolder> implements
|
||||||
ISectionable<ConversationItem.ConversationItemViewHolder, GenericTextHeaderItem>, IFilterable<String> {
|
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 static final float STATUS_SIZE_IN_DP = 9f;
|
||||||
|
|
||||||
private final Conversation conversation;
|
private final Conversation conversation;
|
||||||
|
@ -75,6 +77,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
|
||||||
private GenericTextHeaderItem header;
|
private GenericTextHeaderItem header;
|
||||||
private final Status status;
|
private final Status status;
|
||||||
|
|
||||||
|
|
||||||
public ConversationItem(Conversation conversation, UserEntity userEntity, Context activityContext, Status status) {
|
public ConversationItem(Conversation conversation, UserEntity userEntity, Context activityContext, Status status) {
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
this.userEntity = userEntity;
|
this.userEntity = userEntity;
|
||||||
|
@ -114,6 +117,11 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
|
||||||
return R.layout.rv_item_conversation_with_last_message;
|
return R.layout.rv_item_conversation_with_last_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType() {
|
||||||
|
return VIEW_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConversationItemViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
public ConversationItemViewHolder createViewHolder(View view, FlexibleAdapter<IFlexible> adapter) {
|
||||||
return new ConversationItemViewHolder(view, adapter);
|
return new ConversationItemViewHolder(view, adapter);
|
||||||
|
|
|
@ -956,31 +956,30 @@ public class ConversationsListController extends BaseController implements Flexi
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemClick(View view, int position) {
|
public boolean onItemClick(View view, int position) {
|
||||||
final AbstractFlexibleItem item = adapter.getItem(position);
|
final AbstractFlexibleItem item = adapter.getItem(position);
|
||||||
if (item instanceof ConversationItem) {
|
if (item != null) {
|
||||||
showConversation(((ConversationItem) Objects.requireNonNull(item)).getModel());
|
final int viewType = item.getItemViewType();
|
||||||
} else if (item instanceof MessageResultItem) {
|
if (viewType == MessageResultItem.VIEW_TYPE) {
|
||||||
MessageResultItem messageItem = (MessageResultItem) item;
|
MessageResultItem messageItem = (MessageResultItem) item;
|
||||||
String conversationToken = messageItem.getMessageEntry().getConversationToken();
|
String conversationToken = messageItem.getMessageEntry().getConversationToken();
|
||||||
selectedMessageId = messageItem.getMessageEntry().getMessageId();
|
selectedMessageId = messageItem.getMessageEntry().getMessageId();
|
||||||
showConversationByToken(conversationToken);
|
showConversationByToken(conversationToken);
|
||||||
} else if (item instanceof LoadMoreResultsItem) {
|
} else if (viewType == LoadMoreResultsItem.VIEW_TYPE) {
|
||||||
loadMoreMessages();
|
loadMoreMessages();
|
||||||
|
} else if (viewType == ConversationItem.VIEW_TYPE) {
|
||||||
|
showConversation(((ConversationItem) Objects.requireNonNull(item)).getModel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showConversationByToken(String conversationToken) {
|
private void showConversationByToken(String conversationToken) {
|
||||||
Conversation conversation = null;
|
|
||||||
for (AbstractFlexibleItem absItem : conversationItems) {
|
for (AbstractFlexibleItem absItem : conversationItems) {
|
||||||
ConversationItem conversationItem = ((ConversationItem) absItem);
|
ConversationItem conversationItem = ((ConversationItem) absItem);
|
||||||
if (conversationItem.getModel().getToken().equals(conversationToken)) {
|
if (conversationItem.getModel().getToken().equals(conversationToken)) {
|
||||||
conversation = conversationItem.getModel();
|
final Conversation conversation = conversationItem.getModel();
|
||||||
|
showConversation(conversation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (conversation != null) {
|
|
||||||
showConversation(conversation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showConversation(@Nullable final Conversation conversation) {
|
private void showConversation(@Nullable final Conversation conversation) {
|
||||||
|
@ -1390,7 +1389,7 @@ public class ConversationsListController extends BaseController implements Flexi
|
||||||
clearMessageSearchResults();
|
clearMessageSearchResults();
|
||||||
final List<SearchMessageEntry> entries = results.getMessages();
|
final List<SearchMessageEntry> entries = results.getMessages();
|
||||||
if (entries.size() > 0) {
|
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++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
final boolean showHeader = i == 0;
|
final boolean showHeader = i == 0;
|
||||||
adapterItems.add(new MessageResultItem(context, currentUser, entries.get(i), showHeader));
|
adapterItems.add(new MessageResultItem(context, currentUser, entries.get(i), showHeader));
|
||||||
|
|
Loading…
Reference in a new issue