Use NoOpMatrixCallback when it's possible
This commit is contained in:
parent
47ee2a24a7
commit
a3ec0e03a0
|
@ -26,6 +26,7 @@ import com.squareup.moshi.Types
|
|||
import com.zhuinden.monarchy.Monarchy
|
||||
import dagger.Lazy
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.NoOpMatrixCallback
|
||||
import im.vector.matrix.android.api.auth.data.Credentials
|
||||
import im.vector.matrix.android.api.failure.Failure
|
||||
import im.vector.matrix.android.api.listeners.ProgressListener
|
||||
|
@ -189,7 +190,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
this.callback = object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
// bg refresh of crypto device
|
||||
downloadKeys(listOf(credentials.userId), true, object : MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>> {})
|
||||
downloadKeys(listOf(credentials.userId), true, NoOpMatrixCallback())
|
||||
callback.onSuccess(data)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package im.vector.matrix.android.internal.task
|
||||
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.NoOpMatrixCallback
|
||||
import im.vector.matrix.android.api.util.Cancelable
|
||||
import java.util.UUID
|
||||
|
||||
|
@ -47,7 +48,7 @@ internal data class ConfigurableTask<PARAMS, RESULT>(
|
|||
var callbackThread: TaskThread = TaskThread.MAIN,
|
||||
var executionThread: TaskThread = TaskThread.IO,
|
||||
var retryCount: Int = 0,
|
||||
var callback: MatrixCallback<RESULT> = object : MatrixCallback<RESULT> {}
|
||||
var callback: MatrixCallback<RESULT> = NoOpMatrixCallback()
|
||||
) {
|
||||
|
||||
fun build() = ConfigurableTask(
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.airbnb.mvrx.*
|
|||
import com.squareup.inject.assisted.Assisted
|
||||
import com.squareup.inject.assisted.AssistedInject
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.NoOpMatrixCallback
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupService
|
||||
import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupState
|
||||
|
@ -68,7 +69,7 @@ class KeysBackupSettingsViewModel @AssistedInject constructor(@Assisted initialS
|
|||
}
|
||||
|
||||
private fun init() {
|
||||
keysBackupService.forceUsingLastVersion(object : MatrixCallback<Boolean> {})
|
||||
keysBackupService.forceUsingLastVersion(NoOpMatrixCallback())
|
||||
}
|
||||
|
||||
private fun getKeysBackupTrust() = withState { state ->
|
||||
|
|
|
@ -158,7 +158,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
observeUnreadState()
|
||||
observeMyRoomMember()
|
||||
room.getRoomSummaryLive()
|
||||
room.markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT, object : MatrixCallback<Any> {})
|
||||
room.markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT, NoOpMatrixCallback())
|
||||
room.rx(session).loadRoomMembersIfNeeded().subscribeLogError().disposeOnClear()
|
||||
// Inform the SDK that the room is displayed
|
||||
session.onRoomDisplayed(initialState.roomId)
|
||||
|
@ -225,7 +225,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
private fun stopTrackingUnreadMessages() {
|
||||
if (trackUnreadMessages.getAndSet(false)) {
|
||||
mostRecentDisplayedEvent?.root?.eventId?.also {
|
||||
room.setReadMarker(it, callback = object : MatrixCallback<Unit> {})
|
||||
room.setReadMarker(it, callback = NoOpMatrixCallback())
|
||||
}
|
||||
mostRecentDisplayedEvent = null
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
|
||||
private fun popDraft() {
|
||||
room.deleteDraft(object : MatrixCallback<Unit> {})
|
||||
room.deleteDraft(NoOpMatrixCallback())
|
||||
}
|
||||
|
||||
private fun legacyRiotQuoteText(quotedText: String?, myText: String): String {
|
||||
|
@ -631,11 +631,11 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
|
||||
private fun handleRejectInvite() {
|
||||
room.leave(null, object : MatrixCallback<Unit> {})
|
||||
room.leave(null, NoOpMatrixCallback())
|
||||
}
|
||||
|
||||
private fun handleAcceptInvite() {
|
||||
room.join(callback = object : MatrixCallback<Unit> {})
|
||||
room.join(callback = NoOpMatrixCallback())
|
||||
}
|
||||
|
||||
private fun handleEditAction(action: RoomDetailAction.EnterEditMode) {
|
||||
|
@ -808,14 +808,14 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
bufferedMostRecentDisplayedEvent.root.eventId?.let { eventId ->
|
||||
room.setReadReceipt(eventId, callback = object : MatrixCallback<Unit> {})
|
||||
room.setReadReceipt(eventId, callback = NoOpMatrixCallback())
|
||||
}
|
||||
})
|
||||
.disposeOnClear()
|
||||
}
|
||||
|
||||
private fun handleMarkAllAsRead() {
|
||||
room.markAsRead(ReadService.MarkAsReadParams.BOTH, object : MatrixCallback<Any> {})
|
||||
room.markAsRead(ReadService.MarkAsReadParams.BOTH, NoOpMatrixCallback())
|
||||
}
|
||||
|
||||
private fun handleReportContent(action: RoomDetailAction.ReportContent) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.airbnb.mvrx.FragmentViewModelContext
|
|||
import com.airbnb.mvrx.MvRxViewModelFactory
|
||||
import com.airbnb.mvrx.ViewModelContext
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.NoOpMatrixCallback
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.room.model.Membership
|
||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||
|
@ -182,7 +183,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
|
|||
?.filter { it.membership == Membership.JOIN }
|
||||
?.map { it.roomId }
|
||||
?.toList()
|
||||
?.let { session.markAllAsRead(it, object : MatrixCallback<Unit> {}) }
|
||||
?.let { session.markAllAsRead(it, NoOpMatrixCallback()) }
|
||||
}
|
||||
|
||||
private fun handleChangeNotificationMode(action: RoomListAction.ChangeRoomNotificationState) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import android.content.BroadcastReceiver
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.app.RemoteInput
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.NoOpMatrixCallback
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.room.Room
|
||||
import im.vector.matrix.android.api.session.room.read.ReadService
|
||||
|
@ -75,21 +75,21 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
private fun handleJoinRoom(roomId: String) {
|
||||
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
||||
session.getRoom(roomId)
|
||||
?.join(callback = object : MatrixCallback<Unit> {})
|
||||
?.join(callback = NoOpMatrixCallback())
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleRejectRoom(roomId: String) {
|
||||
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
||||
session.getRoom(roomId)
|
||||
?.leave(callback = object : MatrixCallback<Unit> {})
|
||||
?.leave(callback = NoOpMatrixCallback())
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleMarkAsRead(roomId: String) {
|
||||
activeSessionHolder.getActiveSession().let { session ->
|
||||
session.getRoom(roomId)
|
||||
?.markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT, object : MatrixCallback<Unit> {})
|
||||
?.markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT, NoOpMatrixCallback())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue