Cleanup during PR review

This commit is contained in:
Benoit Marty 2020-01-09 09:42:34 +01:00
parent e14b9b3b20
commit 0f7d59a8c7
11 changed files with 20 additions and 38 deletions

View File

@ -116,7 +116,7 @@ interface RelationService {
fun getEventAnnotationsSummary(eventId: String): EventAnnotationsSummary? fun getEventAnnotationsSummary(eventId: String): EventAnnotationsSummary?
/** /**
* Get the a LiveData EventAnnotationsSummary * Get a LiveData of EventAnnotationsSummary for the specified eventId
* @param eventId the eventId to look for EventAnnotationsSummary * @param eventId the eventId to look for EventAnnotationsSummary
* @return the LiveData of EventAnnotationsSummary * @return the LiveData of EventAnnotationsSummary
*/ */

View File

@ -21,13 +21,13 @@ import io.realm.RealmQuery
fun <T : RealmObject, E : Enum<E>> RealmQuery<T>.process(field: String, enums: List<Enum<E>>): RealmQuery<T> { fun <T : RealmObject, E : Enum<E>> RealmQuery<T>.process(field: String, enums: List<Enum<E>>): RealmQuery<T> {
val lastEnumValue = enums.lastOrNull() val lastEnumValue = enums.lastOrNull()
this.beginGroup() beginGroup()
for (enumValue in enums) { for (enumValue in enums) {
this.equalTo(field, enumValue.name) equalTo(field, enumValue.name)
if (enumValue != lastEnumValue) { if (enumValue != lastEnumValue) {
this.or() or()
} }
} }
this.endGroup() endGroup()
return this return this
} }

View File

@ -25,16 +25,12 @@ import timber.log.Timber
fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: QueryStringValue): RealmQuery<T> { fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: QueryStringValue): RealmQuery<T> {
when (queryStringValue) { when (queryStringValue) {
is QueryStringValue.NoCondition -> Timber.v("No condition to process") is QueryStringValue.NoCondition -> Timber.v("No condition to process")
is QueryStringValue.IsNotNull -> this.isNotNull(field) is QueryStringValue.IsNotNull -> isNotNull(field)
is QueryStringValue.IsNull -> this.isNull(field) is QueryStringValue.IsNull -> isNull(field)
is QueryStringValue.IsEmpty -> this.isEmpty(field) is QueryStringValue.IsEmpty -> isEmpty(field)
is QueryStringValue.IsNotEmpty -> this.isNotEmpty(field) is QueryStringValue.IsNotEmpty -> isNotEmpty(field)
is QueryStringValue.Equals -> { is QueryStringValue.Equals -> equalTo(field, queryStringValue.string, queryStringValue.case.toRealmCase())
this.equalTo(field, queryStringValue.string, queryStringValue.case.toRealmCase()) is QueryStringValue.Contains -> contains(field, queryStringValue.string, queryStringValue.case.toRealmCase())
}
is QueryStringValue.Contains -> {
this.contains(field, queryStringValue.string, queryStringValue.case.toRealmCase())
}
} }
return this return this
} }

View File

@ -35,7 +35,7 @@ internal class RoomMemberEventHandler @Inject constructor() {
val userId = event.stateKey ?: return false val userId = event.stateKey ?: return false
val roomMemberEntity = RoomMemberEntityFactory.create(roomId, userId, roomMember) val roomMemberEntity = RoomMemberEntityFactory.create(roomId, userId, roomMember)
realm.insertOrUpdate(roomMemberEntity) realm.insertOrUpdate(roomMemberEntity)
if (roomMember.membership == Membership.JOIN || roomMember.membership == Membership.INVITE) { if (roomMember.membership in Membership.activeMemberships()) {
val userEntity = UserEntityFactory.create(userId, roomMember) val userEntity = UserEntityFactory.create(userId, roomMember)
realm.insertOrUpdate(userEntity) realm.insertOrUpdate(userEntity)
} }

View File

@ -18,7 +18,6 @@ package im.vector.riotx.features.autocomplete.group
import android.content.Context import android.content.Context
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.airbnb.mvrx.Async
import com.otaliastudios.autocomplete.RecyclerViewPresenter import com.otaliastudios.autocomplete.RecyclerViewPresenter
import im.vector.matrix.android.api.query.QueryStringValue import im.vector.matrix.android.api.query.QueryStringValue
import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.Session
@ -59,8 +58,4 @@ class AutocompleteGroupPresenter @Inject constructor(context: Context,
.sortedBy { it.displayName } .sortedBy { it.displayName }
controller.setData(groups.toList()) controller.setData(groups.toList())
} }
fun render(groups: Async<List<GroupSummary>>) {
controller.setData(groups())
}
} }

View File

@ -18,8 +18,6 @@ package im.vector.riotx.features.autocomplete.member
import android.content.Context import android.content.Context
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Success
import com.otaliastudios.autocomplete.RecyclerViewPresenter import com.otaliastudios.autocomplete.RecyclerViewPresenter
import com.squareup.inject.assisted.Assisted import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject import com.squareup.inject.assisted.AssistedInject
@ -71,10 +69,4 @@ class AutocompleteMemberPresenter @AssistedInject constructor(context: Context,
.sortedBy { it.displayName } .sortedBy { it.displayName }
controller.setData(members.toList()) controller.setData(members.toList())
} }
fun render(members: Async<List<RoomMember>>) {
if (members is Success) {
controller.setData(members())
}
}
} }

View File

@ -50,7 +50,7 @@ class AutoCompleter @AssistedInject constructor(
private val avatarRenderer: AvatarRenderer, private val avatarRenderer: AvatarRenderer,
private val commandAutocompletePolicy: CommandAutocompletePolicy, private val commandAutocompletePolicy: CommandAutocompletePolicy,
private val autocompleteCommandPresenter: AutocompleteCommandPresenter, private val autocompleteCommandPresenter: AutocompleteCommandPresenter,
private val autocompleteMemberPresenter: AutocompleteMemberPresenter.Factory, private val autocompleteMemberPresenterFactory: AutocompleteMemberPresenter.Factory,
private val autocompleteRoomPresenter: AutocompleteRoomPresenter, private val autocompleteRoomPresenter: AutocompleteRoomPresenter,
private val autocompleteGroupPresenter: AutocompleteGroupPresenter, private val autocompleteGroupPresenter: AutocompleteGroupPresenter,
private val autocompleteEmojiPresenter: AutocompleteEmojiPresenter private val autocompleteEmojiPresenter: AutocompleteEmojiPresenter
@ -107,10 +107,10 @@ class AutoCompleter @AssistedInject constructor(
} }
private fun setupMembers(backgroundDrawable: ColorDrawable, editText: EditText) { private fun setupMembers(backgroundDrawable: ColorDrawable, editText: EditText) {
val membersPresenter = autocompleteMemberPresenter.create(roomId) val autocompleteMemberPresenter = autocompleteMemberPresenterFactory.create(roomId)
Autocomplete.on<RoomMember>(editText) Autocomplete.on<RoomMember>(editText)
.with(CharPolicy('@', true)) .with(CharPolicy('@', true))
.with(membersPresenter) .with(autocompleteMemberPresenter)
.with(ELEVATION) .with(ELEVATION)
.with(backgroundDrawable) .with(backgroundDrawable)
.with(object : AutocompleteCallback<RoomMember> { .with(object : AutocompleteCallback<RoomMember> {

View File

@ -27,7 +27,6 @@ import im.vector.riotx.core.epoxy.VectorEpoxyModel
import im.vector.riotx.core.platform.CheckableView import im.vector.riotx.core.platform.CheckableView
import im.vector.riotx.core.ui.views.ReadReceiptsView import im.vector.riotx.core.ui.views.ReadReceiptsView
import im.vector.riotx.core.utils.DimensionConverter import im.vector.riotx.core.utils.DimensionConverter
import kotlinx.coroutines.*
/** /**
* Children must override getViewType() * Children must override getViewType()

View File

@ -398,7 +398,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
fun getNotificationRingTone(): Uri? { fun getNotificationRingTone(): Uri? {
val url = defaultPrefs.getString(SETTINGS_NOTIFICATION_RINGTONE_PREFERENCE_KEY, null) val url = defaultPrefs.getString(SETTINGS_NOTIFICATION_RINGTONE_PREFERENCE_KEY, null)
// the user selects "NoCondition" // the user selects "None"
if (url == "") { if (url == "") {
return null return null
} }
@ -425,7 +425,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
/** /**
* Provide the notification ringtone filename * Provide the notification ringtone filename
* *
* @return the filename or null if "NoCondition" is selected * @return the filename or null if "None" is selected
*/ */
fun getNotificationRingToneName(): String? { fun getNotificationRingToneName(): String? {
val toneUri = getNotificationRingTone() ?: return null val toneUri = getNotificationRingTone() ?: return null

View File

@ -47,12 +47,12 @@
android:maxLines="2" android:maxLines="2"
android:textColor="?riotx_text_secondary" android:textColor="?riotx_text_secondary"
android:textSize="17sp" android:textSize="17sp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/actionSelected" app:layout_constraintEnd_toStartOf="@+id/actionSelected"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@id/actionStartSpace" app:layout_constraintStart_toEndOf="@id/actionStartSpace"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constrainedWidth="true"
tools:text="zbla azjazjaz s sdkqdskdsqk kqsdkdqsk kdqsksqdk" /> tools:text="zbla azjazjaz s sdkqdskdsqk kqsdkdqsk kdqsksqdk" />