style: 加入 `ExperimentalCoroutinesApi::class`

This commit is contained in:
HuanCheng65 2023-07-17 12:50:37 +08:00
parent 3a9ea7b471
commit 1a97fe4f57
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
15 changed files with 33 additions and 33 deletions

View File

@ -14,7 +14,7 @@ import com.huanchengfly.tieba.post.ui.page.editprofile.EditProfilePartialChange
import com.huanchengfly.tieba.post.ui.page.editprofile.EditProfileState
import com.huanchengfly.tieba.post.utils.AccountUtil
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import javax.inject.Inject
@ -30,7 +30,7 @@ class EditProfileViewModel @Inject constructor() :
class EditProfilePartialChangeProducer(
private val tiebaApi: ITiebaApi
) : PartialChangeProducer<EditProfileIntent, EditProfilePartialChange, EditProfileState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<EditProfileIntent>): Flow<EditProfilePartialChange> =
merge(
intentFlow.filterIsInstance<EditProfileIntent.Init>()
@ -63,7 +63,7 @@ class EditProfileViewModel @Inject constructor() :
tiebaApi.profileModifyFlow(birthdayShowStatus, "${birthdayTime / 1000L}", intro, "$sex")
.map {
if (it.errorCode == 0) EditProfilePartialChange.Submit.Success else EditProfilePartialChange.Submit.Fail(
it.errorMsg ?: "unknown error"
it.errorMsg
)
}
.onStart {
@ -94,9 +94,9 @@ class EditProfileViewModel @Inject constructor() :
tiebaApi.imgPortrait(file)
.map {
if (it.errorCode == 0 || it.errorCode == 300003)
EditProfilePartialChange.UploadPortrait.Success(it.errorMsg ?: "success")
EditProfilePartialChange.UploadPortrait.Success(it.errorMsg)
else
EditProfilePartialChange.UploadPortrait.Fail(it.errorMsg ?: "")
EditProfilePartialChange.UploadPortrait.Fail(it.errorMsg)
}
.onStart { EditProfilePartialChange.UploadPortrait.Uploading }
.catch {

View File

@ -15,7 +15,7 @@ import com.huanchengfly.tieba.post.arch.UiIntent
import com.huanchengfly.tieba.post.arch.UiState
import com.huanchengfly.tieba.post.repository.FrsPageRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -64,7 +64,7 @@ class ForumViewModel @Inject constructor() :
private object ForumPartialChangeProducer :
PartialChangeProducer<ForumUiIntent, ForumPartialChange, ForumUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<ForumUiIntent>): Flow<ForumPartialChange> =
merge(
intentFlow.filterIsInstance<ForumUiIntent.Load>()

View File

@ -21,7 +21,7 @@ import com.huanchengfly.tieba.post.arch.wrapImmutable
import com.huanchengfly.tieba.post.repository.FrsPageRepository
import com.huanchengfly.tieba.post.utils.appPreferences
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -75,7 +75,7 @@ class GoodThreadListViewModel @Inject constructor() : ForumThreadListViewModel()
private class ForumThreadListPartialChangeProducer(val type: ForumThreadListType) :
PartialChangeProducer<ForumThreadListUiIntent, ForumThreadListPartialChange, ForumThreadListUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<ForumThreadListUiIntent>): Flow<ForumThreadListPartialChange> =
merge(
intentFlow.filterIsInstance<ForumThreadListUiIntent.FirstLoad>()

View File

@ -13,7 +13,7 @@ import com.huanchengfly.tieba.post.utils.DateTimeUtils
import com.huanchengfly.tieba.post.utils.HistoryUtil
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -60,7 +60,7 @@ class ForumHistoryListViewModel @Inject constructor() : HistoryListViewModel() {
private class HistoryListPartialChangeProducer(val type: Int) :
PartialChangeProducer<HistoryListUiIntent, HistoryListPartialChange, HistoryListUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<HistoryListUiIntent>): Flow<HistoryListPartialChange> =
merge(
intentFlow.filterIsInstance<HistoryListUiIntent.Refresh>()

View File

@ -11,7 +11,7 @@ import com.huanchengfly.tieba.post.arch.UiEvent
import com.huanchengfly.tieba.post.arch.UiIntent
import com.huanchengfly.tieba.post.arch.UiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -32,7 +32,7 @@ class HotTopicListViewModel @Inject constructor() :
private object HotTopicListPartialChangeProducer :
PartialChangeProducer<HotTopicListUiIntent, HotTopicListPartialChange, HotTopicListUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<HotTopicListUiIntent>): Flow<HotTopicListPartialChange> =
merge(
intentFlow.filterIsInstance<HotTopicListUiIntent.Load>()

View File

@ -17,7 +17,7 @@ import com.huanchengfly.tieba.post.arch.UiIntent
import com.huanchengfly.tieba.post.arch.UiState
import com.huanchengfly.tieba.post.utils.appPreferences
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -44,7 +44,7 @@ class ConcernViewModel @Inject constructor() :
}
private object ExplorePartialChangeProducer : PartialChangeProducer<ConcernUiIntent, ConcernPartialChange, ConcernUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<ConcernUiIntent>): Flow<ConcernPartialChange> =
merge(
intentFlow.filterIsInstance<ConcernUiIntent.Refresh>().flatMapConcat { produceRefreshPartialChange() },

View File

@ -13,7 +13,7 @@ import com.huanchengfly.tieba.post.arch.UiEvent
import com.huanchengfly.tieba.post.arch.UiIntent
import com.huanchengfly.tieba.post.arch.UiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -34,7 +34,7 @@ class HotViewModel @Inject constructor() :
private object HotPartialChangeProducer :
PartialChangeProducer<HotUiIntent, HotPartialChange, HotUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<HotUiIntent>): Flow<HotPartialChange> =
merge(
intentFlow.filterIsInstance<HotUiIntent.Load>()

View File

@ -22,7 +22,7 @@ import com.huanchengfly.tieba.post.arch.wrapImmutable
import com.huanchengfly.tieba.post.models.DislikeBean
import com.huanchengfly.tieba.post.utils.appPreferences
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -54,7 +54,7 @@ class PersonalizedViewModel @Inject constructor() :
}
private object ExplorePartialChangeProducer : PartialChangeProducer<PersonalizedUiIntent, PersonalizedPartialChange, PersonalizedUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<PersonalizedUiIntent>): Flow<PersonalizedPartialChange> =
merge(
intentFlow.filterIsInstance<PersonalizedUiIntent.Refresh>().flatMapConcat { produceRefreshPartialChange() },

View File

@ -8,7 +8,7 @@ import com.huanchengfly.tieba.post.arch.*
import com.huanchengfly.tieba.post.models.database.TopForum
import com.huanchengfly.tieba.post.utils.AccountUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import org.litepal.LitePal
@ -27,7 +27,7 @@ class HomeViewModel : BaseViewModel<HomeUiIntent, HomePartialChange, HomeUiState
object HomePartialChangeProducer :
PartialChangeProducer<HomeUiIntent, HomePartialChange, HomeUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<HomeUiIntent>): Flow<HomePartialChange> {
return merge(
intentFlow.filterIsInstance<HomeUiIntent.Refresh>()

View File

@ -6,7 +6,7 @@ import com.huanchengfly.tieba.post.api.models.MessageListBean
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
import com.huanchengfly.tieba.post.arch.*
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import javax.inject.Inject
@ -42,7 +42,7 @@ class AtMeListViewModel @Inject constructor() : NotificationsListViewModel() {
}
private class NotificationsListPartialChangeProducer(private val type: NotificationsType) : PartialChangeProducer<NotificationsListUiIntent, NotificationsListPartialChange, NotificationsListUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<NotificationsListUiIntent>): Flow<NotificationsListPartialChange> =
merge(
intentFlow.filterIsInstance<NotificationsListUiIntent.Refresh>().flatMapConcat { produceRefreshPartialChange() },

View File

@ -8,7 +8,7 @@ import com.huanchengfly.tieba.post.arch.*
import com.huanchengfly.tieba.post.models.database.Account
import com.huanchengfly.tieba.post.utils.AccountUtil
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import javax.inject.Inject
@ -28,7 +28,7 @@ class UserViewModel @Inject constructor() : BaseViewModel<UserUiIntent, UserPart
}
object UserPartialChangeProducer :PartialChangeProducer<UserUiIntent, UserPartialChange, UserUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<UserUiIntent>): Flow<UserPartialChange> =
merge(
intentFlow.filterIsInstance<UserUiIntent.Refresh>().flatMapConcat { it.toPartialChangeFlow() }

View File

@ -10,7 +10,7 @@ import com.huanchengfly.tieba.post.arch.UiIntent
import com.huanchengfly.tieba.post.arch.UiState
import com.huanchengfly.tieba.post.models.protos.LoadPicPageData
import com.huanchengfly.tieba.post.models.protos.PhotoViewData
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -27,7 +27,7 @@ class PhotoViewViewModel :
override fun createPartialChangeProducer(): PartialChangeProducer<PhotoViewUiIntent, PhotoViewPartialChange, PhotoViewUiState> = PhotoViewPartialChangeProducer
private object PhotoViewPartialChangeProducer : PartialChangeProducer<PhotoViewUiIntent, PhotoViewPartialChange, PhotoViewUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<PhotoViewUiIntent>): Flow<PhotoViewPartialChange> =
merge(
intentFlow.filterIsInstance<PhotoViewUiIntent.Init>()

View File

@ -5,7 +5,7 @@ import com.huanchengfly.tieba.post.arch.*
import com.huanchengfly.tieba.post.models.database.Block
import com.huanchengfly.tieba.post.toJson
import com.huanchengfly.tieba.post.utils.BlockManager
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
class BlockSettingsViewModel :
@ -26,7 +26,7 @@ class BlockSettingsViewModel :
}
private object BlockSettingsPartialChangeProducer : PartialChangeProducer<BlockSettingsUiIntent, BlockSettingsPartialChange, BlockSettingsUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<BlockSettingsUiIntent>): Flow<BlockSettingsPartialChange> =
merge(
intentFlow.filterIsInstance<BlockSettingsUiIntent.Load>().flatMapConcat { produceLoadPartialChange() },

View File

@ -15,7 +15,7 @@ import com.huanchengfly.tieba.post.arch.UiIntent
import com.huanchengfly.tieba.post.arch.UiState
import com.huanchengfly.tieba.post.arch.wrapImmutable
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterIsInstance
@ -48,7 +48,7 @@ class ThreadStoreViewModel @Inject constructor() :
private object ThreadStorePartialChangeProducer :
PartialChangeProducer<ThreadStoreUiIntent, ThreadStorePartialChange, ThreadStoreUiState> {
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override fun toPartialChangeFlow(intentFlow: Flow<ThreadStoreUiIntent>): Flow<ThreadStorePartialChange> =
merge(
intentFlow.filterIsInstance<ThreadStoreUiIntent.Refresh>()

View File

@ -10,7 +10,7 @@ import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
import com.huanchengfly.tieba.post.models.SignDataBean
import com.huanchengfly.tieba.post.models.database.Account
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.withContext
@ -109,7 +109,7 @@ class SingleAccountSigner(
return this
}
@OptIn(FlowPreview::class)
@OptIn(ExperimentalCoroutinesApi::class)
override suspend fun start(): Boolean {
var result = false
signData.clear()