mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Fix mentions
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
ed7afd842b
commit
55f72997ac
@ -23,6 +23,7 @@ package com.nextcloud.talk.presenters;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.nextcloud.talk.adapters.items.MentionAutocompleteItem;
|
import com.nextcloud.talk.adapters.items.MentionAutocompleteItem;
|
||||||
@ -61,6 +62,8 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
|
|
||||||
private String roomToken;
|
private String roomToken;
|
||||||
|
|
||||||
|
private List<AbstractFlexibleItem> abstractFlexibleItemList = new ArrayList<>();
|
||||||
|
|
||||||
public MentionAutocompletePresenter(Context context) {
|
public MentionAutocompletePresenter(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@ -76,14 +79,14 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RecyclerView.Adapter instantiateAdapter() {
|
protected RecyclerView.Adapter instantiateAdapter() {
|
||||||
adapter = new FlexibleAdapter<>(new ArrayList<AbstractFlexibleItem>(), context, true);
|
adapter = new FlexibleAdapter<>(abstractFlexibleItemList, context, true);
|
||||||
adapter.addListener(this);
|
adapter.addListener(this);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onQuery(@Nullable CharSequence query) {
|
protected void onQuery(@Nullable CharSequence query) {
|
||||||
if (query != null && query.length() > 0) {
|
if (!TextUtils.isEmpty(query)) {
|
||||||
UserEntity currentUser = userUtils.getCurrentUser();
|
UserEntity currentUser = userUtils.getCurrentUser();
|
||||||
|
|
||||||
adapter.setFilter(query.toString());
|
adapter.setFilter(query.toString());
|
||||||
@ -101,22 +104,24 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(MentionOverall mentionOverall) {
|
public void onNext(MentionOverall mentionOverall) {
|
||||||
List<Mention> mentionsList = mentionOverall.getOcs().getData();
|
List<Mention> mentionsList = mentionOverall.getOcs().getData();
|
||||||
List<AbstractFlexibleItem> internalUserItemList = new ArrayList<>();
|
|
||||||
if (mentionsList.size() == 0 ||
|
if (mentionsList.size() == 0) {
|
||||||
(mentionsList.size() == 1 && mentionsList.get(0).getId().equals(query.toString()))) {
|
adapter.clear();
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
} else {
|
} else {
|
||||||
|
List<AbstractFlexibleItem> internalAbstractFlexibleItemList = new ArrayList<>();
|
||||||
for (Mention mention : mentionsList) {
|
for (Mention mention : mentionsList) {
|
||||||
internalUserItemList.add(new MentionAutocompleteItem(mention.getId(), mention
|
internalAbstractFlexibleItemList.add(
|
||||||
.getLabel(), currentUser));
|
new MentionAutocompleteItem(mention.getId(), mention.getLabel(),
|
||||||
|
currentUser));
|
||||||
}
|
}
|
||||||
adapter.updateDataSet(internalUserItemList, true);
|
|
||||||
|
adapter.updateDataSet(internalAbstractFlexibleItemList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
adapter.updateDataSet(new ArrayList<>(), false);
|
adapter.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -125,7 +130,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
adapter.updateDataSet(new ArrayList<>(), false);
|
adapter.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user