mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
sort participants list
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
690d09eb60
commit
b80396b34b
@ -26,6 +26,10 @@ import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.emoji.widget.EmojiTextView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
@ -40,11 +44,6 @@ import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.emoji.widget.EmojiTextView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
@ -269,7 +268,6 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
|
||||
static class UserItemViewHolder extends FlexibleViewHolder {
|
||||
|
||||
@BindView(R.id.name_text)
|
||||
@ -297,6 +295,4 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
ButterKnife.bind(this, view);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ import com.yarolegovich.mp.MaterialStandardPreference
|
||||
import com.yarolegovich.mp.MaterialSwitchPreference
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@ -142,8 +141,8 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
private var databaseStorageModule: DatabaseStorageModule? = null
|
||||
private var conversation: Conversation? = null
|
||||
|
||||
private var adapter: FlexibleAdapter<AbstractFlexibleItem<*>>? = null
|
||||
private var recyclerViewItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
||||
private var adapter: FlexibleAdapter<UserItem>? = null
|
||||
private var recyclerViewItems: MutableList<UserItem> = ArrayList()
|
||||
|
||||
private var saveStateHandler: LovelySaveStateHandler? = null
|
||||
|
||||
@ -376,6 +375,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(recyclerViewItems, UserItemComparator())
|
||||
|
||||
if (ownUserItem != null) {
|
||||
recyclerViewItems.add(0, ownUserItem)
|
||||
@ -684,4 +684,20 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
|
||||
private const val ID_DELETE_CONVERSATION_DIALOG = 0
|
||||
}
|
||||
|
||||
class UserItemComparator : Comparator<UserItem> {
|
||||
override fun compare(left: UserItem, right: UserItem): Int {
|
||||
if (left.isOnline && !right.isOnline) {
|
||||
return -1
|
||||
} else if (!left.isOnline && right.isOnline) {
|
||||
return 1
|
||||
}
|
||||
if (Participant.ParticipantType.MODERATOR == left.model.type && Participant.ParticipantType.MODERATOR != right.model.type) {
|
||||
return -1
|
||||
} else if (Participant.ParticipantType.MODERATOR != left.model.type && Participant.ParticipantType.MODERATOR == right.model.type) {
|
||||
return 1
|
||||
}
|
||||
return left.model.displayName.compareTo(right.model.displayName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user