Kotlin 1.9.0 (#3835)
Update to Kotlin 1.9.0 and migrate to newer language idioms. - Remove unnecessary @OptIn for features migrated to mainstream - Use `data object` where appropriate - Use new enum `entries` property
This commit is contained in:
parent
5391b5f797
commit
40bd95d752
29 changed files with 44 additions and 71 deletions
|
|
@ -285,7 +285,7 @@ public class NotificationHelper {
|
|||
int accountId = (int) account.getId();
|
||||
|
||||
// Initialise the map with all channel IDs.
|
||||
for (Notification.Type ty : Notification.Type.values()) {
|
||||
for (Notification.Type ty : Notification.Type.getEntries()) {
|
||||
channelGroups.put(getChannelId(account, ty), new ArrayList<>());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ class NotificationsFragment :
|
|||
val position = adapter.snapshot().indexOfFirst {
|
||||
it?.statusViewData?.status?.id == (action as StatusAction).statusViewData.id
|
||||
}
|
||||
if (position != RecyclerView.NO_POSITION) {
|
||||
if (position != NO_POSITION) {
|
||||
adapter.notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class NotificationsPagingAdapter(
|
|||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
|
||||
return when (NotificationViewKind.values()[viewType]) {
|
||||
return when (NotificationViewKind.entries[viewType]) {
|
||||
NotificationViewKind.STATUS -> {
|
||||
StatusViewHolder(
|
||||
ItemStatusBinding.inflate(inflater, parent, false),
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ import com.keylesspalace.tusky.util.toViewData
|
|||
import com.keylesspalace.tusky.viewdata.NotificationViewData
|
||||
import com.keylesspalace.tusky.viewdata.StatusViewData
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
|
@ -70,7 +69,6 @@ import kotlinx.coroutines.rx3.await
|
|||
import retrofit2.HttpException
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
data class UiState(
|
||||
/** Filtered notification types */
|
||||
|
|
@ -103,7 +101,7 @@ sealed class UiAction
|
|||
/** Actions the user can trigger from the UI. These actions may fail. */
|
||||
sealed class FallibleUiAction : UiAction() {
|
||||
/** Clear all notifications */
|
||||
object ClearNotifications : FallibleUiAction()
|
||||
data object ClearNotifications : FallibleUiAction()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,7 +127,7 @@ sealed class InfallibleUiAction : UiAction() {
|
|||
// Resets the account's `lastNotificationId`, which can't fail, which is why this is
|
||||
// infallible. Reloading the data may fail, but that's handled by the paging system /
|
||||
// adapter refresh logic.
|
||||
object LoadNewest : InfallibleUiAction()
|
||||
data object LoadNewest : InfallibleUiAction()
|
||||
}
|
||||
|
||||
/** Actions the user can trigger on an individual notification. These may fail. */
|
||||
|
|
@ -146,13 +144,13 @@ sealed class UiSuccess {
|
|||
// of these three should trigger the UI to refresh.
|
||||
|
||||
/** A user was blocked */
|
||||
object Block : UiSuccess()
|
||||
data object Block : UiSuccess()
|
||||
|
||||
/** A user was muted */
|
||||
object Mute : UiSuccess()
|
||||
data object Mute : UiSuccess()
|
||||
|
||||
/** A conversation was muted */
|
||||
object MuteConversation : UiSuccess()
|
||||
data object MuteConversation : UiSuccess()
|
||||
}
|
||||
|
||||
/** The result of a successful action on a notification */
|
||||
|
|
@ -286,7 +284,7 @@ sealed class UiError(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class, ExperimentalTime::class)
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModel @Inject constructor(
|
||||
private val repository: NotificationsRepository,
|
||||
private val preferences: SharedPreferences,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue