mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Rename classes
This commit is contained in:
parent
f51568b331
commit
cc4603b61f
7 changed files with 30 additions and 32 deletions
|
@ -28,8 +28,8 @@ class ContactsDataSource @Inject constructor(
|
|||
) {
|
||||
|
||||
@WorkerThread
|
||||
fun getContacts(): List<ContactModel> {
|
||||
val result = mutableListOf<ContactModel>()
|
||||
fun getContacts(): List<MappedContact> {
|
||||
val result = mutableListOf<MappedContact>()
|
||||
val contentResolver = context.contentResolver
|
||||
|
||||
contentResolver.query(
|
||||
|
@ -56,7 +56,7 @@ class ContactsDataSource @Inject constructor(
|
|||
val id = cursor.getLong(ContactsContract.Contacts._ID) ?: continue
|
||||
val displayName = cursor.getString(ContactsContract.Contacts.DISPLAY_NAME) ?: continue
|
||||
|
||||
val currentContact = ContactModelBuilder(
|
||||
val currentContact = MappedContactBuilder(
|
||||
id = id,
|
||||
displayName = displayName
|
||||
)
|
||||
|
@ -108,7 +108,7 @@ class ContactsDataSource @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
result.add(currentContact.toContactModel())
|
||||
result.add(currentContact.build())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,18 +18,16 @@ package im.vector.riotx.core.contacts
|
|||
|
||||
import android.net.Uri
|
||||
|
||||
/* TODO Rename to MxContact? */
|
||||
|
||||
class ContactModelBuilder(
|
||||
class MappedContactBuilder(
|
||||
val id: Long,
|
||||
val displayName: String) {
|
||||
|
||||
val displayName: String
|
||||
) {
|
||||
var photoURI: Uri? = null
|
||||
val msisdns = mutableListOf<MappedMsisdn>()
|
||||
val emails = mutableListOf<MappedEmail>()
|
||||
|
||||
fun toContactModel(): ContactModel {
|
||||
return ContactModel(
|
||||
fun build(): MappedContact {
|
||||
return MappedContact(
|
||||
id = id,
|
||||
displayName = displayName,
|
||||
photoURI = photoURI,
|
||||
|
@ -39,7 +37,7 @@ class ContactModelBuilder(
|
|||
}
|
||||
}
|
||||
|
||||
data class ContactModel(
|
||||
data class MappedContact(
|
||||
val id: Long,
|
||||
val displayName: String,
|
||||
val photoURI: Uri? = null,
|
|
@ -30,7 +30,7 @@ import com.bumptech.glide.request.target.DrawableImageViewTarget
|
|||
import com.bumptech.glide.request.target.Target
|
||||
import im.vector.matrix.android.api.session.content.ContentUrlResolver
|
||||
import im.vector.matrix.android.api.util.MatrixItem
|
||||
import im.vector.riotx.core.contacts.ContactModel
|
||||
import im.vector.riotx.core.contacts.MappedContact
|
||||
import im.vector.riotx.core.di.ActiveSessionHolder
|
||||
import im.vector.riotx.core.glide.GlideApp
|
||||
import im.vector.riotx.core.glide.GlideRequest
|
||||
|
@ -65,17 +65,17 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active
|
|||
}
|
||||
|
||||
@UiThread
|
||||
fun render(contactModel: ContactModel, imageView: ImageView) {
|
||||
fun render(mappedContact: MappedContact, imageView: ImageView) {
|
||||
// Create a Fake MatrixItem, for the placeholder
|
||||
val matrixItem = MatrixItem.UserItem(
|
||||
// Need an id starting with @
|
||||
id = "@${contactModel.displayName}",
|
||||
displayName = contactModel.displayName
|
||||
id = "@${mappedContact.displayName}",
|
||||
displayName = mappedContact.displayName
|
||||
)
|
||||
|
||||
val placeholder = getPlaceholderDrawable(imageView.context, matrixItem)
|
||||
GlideApp.with(imageView)
|
||||
.load(contactModel.photoURI)
|
||||
.load(mappedContact.photoURI)
|
||||
.apply(RequestOptions.circleCropTransform())
|
||||
.placeholder(placeholder)
|
||||
.into(imageView)
|
||||
|
|
|
@ -21,7 +21,7 @@ import android.widget.TextView
|
|||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.contacts.ContactModel
|
||||
import im.vector.riotx.core.contacts.MappedContact
|
||||
import im.vector.riotx.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.riotx.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.riotx.features.home.AvatarRenderer
|
||||
|
@ -30,13 +30,13 @@ import im.vector.riotx.features.home.AvatarRenderer
|
|||
abstract class ContactItem : VectorEpoxyModel<ContactItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
|
||||
@EpoxyAttribute lateinit var contact: ContactModel
|
||||
@EpoxyAttribute lateinit var mappedContact: MappedContact
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
// If name is empty, use userId as name and force it being centered
|
||||
holder.nameView.text = contact.displayName
|
||||
avatarRenderer.render(contact, holder.avatarImageView)
|
||||
holder.nameView.text = mappedContact.displayName
|
||||
avatarRenderer.render(mappedContact, holder.avatarImageView)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.airbnb.mvrx.Success
|
|||
import com.airbnb.mvrx.Uninitialized
|
||||
import im.vector.matrix.android.api.session.identity.ThreePid
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.contacts.ContactModel
|
||||
import im.vector.riotx.core.contacts.MappedContact
|
||||
import im.vector.riotx.core.epoxy.errorWithRetryItem
|
||||
import im.vector.riotx.core.epoxy.loadingItem
|
||||
import im.vector.riotx.core.epoxy.noResultItem
|
||||
|
@ -74,7 +74,7 @@ class PhoneBookController @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun renderSuccess(mappedContacts: List<ContactModel>,
|
||||
private fun renderSuccess(mappedContacts: List<MappedContact>,
|
||||
hasSearch: Boolean,
|
||||
onlyBoundContacts: Boolean) {
|
||||
if (mappedContacts.isEmpty()) {
|
||||
|
@ -84,11 +84,11 @@ class PhoneBookController @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun renderContacts(mappedContacts: List<ContactModel>, onlyBoundContacts: Boolean) {
|
||||
private fun renderContacts(mappedContacts: List<MappedContact>, onlyBoundContacts: Boolean) {
|
||||
for (mappedContact in mappedContacts) {
|
||||
contactItem {
|
||||
id(mappedContact.id)
|
||||
contact(mappedContact)
|
||||
mappedContact(mappedContact)
|
||||
avatarRenderer(avatarRenderer)
|
||||
}
|
||||
mappedContact.emails
|
||||
|
|
|
@ -30,8 +30,8 @@ import im.vector.matrix.android.api.MatrixCallback
|
|||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.identity.FoundThreePid
|
||||
import im.vector.matrix.android.api.session.identity.ThreePid
|
||||
import im.vector.riotx.core.contacts.ContactModel
|
||||
import im.vector.riotx.core.contacts.ContactsDataSource
|
||||
import im.vector.riotx.core.contacts.MappedContact
|
||||
import im.vector.riotx.core.extensions.exhaustive
|
||||
import im.vector.riotx.core.platform.EmptyViewEvents
|
||||
import im.vector.riotx.core.platform.VectorViewModel
|
||||
|
@ -71,8 +71,8 @@ class PhoneBookViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
}
|
||||
|
||||
private var allContacts: List<ContactModel> = emptyList()
|
||||
private var mappedContacts: List<ContactModel> = emptyList()
|
||||
private var allContacts: List<MappedContact> = emptyList()
|
||||
private var mappedContacts: List<MappedContact> = emptyList()
|
||||
|
||||
init {
|
||||
loadContacts()
|
||||
|
@ -104,7 +104,7 @@ class PhoneBookViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
}
|
||||
|
||||
private fun performLookup(data: List<ContactModel>) {
|
||||
private fun performLookup(data: List<MappedContact>) {
|
||||
viewModelScope.launch {
|
||||
val threePids = data.flatMap { contact ->
|
||||
contact.emails.map { ThreePid.Email(it.email) } +
|
||||
|
|
|
@ -19,17 +19,17 @@ package im.vector.riotx.features.userdirectory
|
|||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.MvRxState
|
||||
import im.vector.riotx.core.contacts.ContactModel
|
||||
import im.vector.riotx.core.contacts.MappedContact
|
||||
|
||||
data class PhoneBookViewState(
|
||||
// All the contacts on the phone
|
||||
val mappedContacts: Async<List<ContactModel>> = Loading(),
|
||||
val mappedContacts: Async<List<MappedContact>> = Loading(),
|
||||
// Use to filter contacts by display name
|
||||
val searchTerm: String = "",
|
||||
// Tru to display only bound contacts with their bound 2pid
|
||||
val onlyBoundContacts: Boolean = false,
|
||||
// All contacts, filtered by searchTerm and onlyBoundContacts
|
||||
val filteredMappedContacts: List<ContactModel> = emptyList(),
|
||||
val filteredMappedContacts: List<MappedContact> = emptyList(),
|
||||
// True when the identity service has return some data
|
||||
val isBoundRetrieved: Boolean = false
|
||||
) : MvRxState
|
||||
|
|
Loading…
Reference in a new issue