Open MmingY opened 6 months ago
Problem: I followed every step mentined in the Codelab tutorial https://developer.android.com/codelabs/android-preferences-datastore?hl=zh-cn#5, but I encountered this problem"Type mismatch. Required: DataStore Found: DataStore".
TasksActivity viewModel = ViewModelProvider( this, TasksViewModelFactory( TasksRepository, UserPreferencesRepository(dataStore, this) ) ).get(TasksViewModel::class.java)
viewModel = ViewModelProvider( this, TasksViewModelFactory( TasksRepository, UserPreferencesRepository(dataStore, this) ) ).get(TasksViewModel::class.java)
UserPreferencesRepository class UserPreferencesRepository constructor( private val userPreferencesStore: DataStore<UserPreferences>, context: Context )... data class UserPreferences(val showCompleted: Boolean)
class UserPreferencesRepository constructor( private val userPreferencesStore: DataStore<UserPreferences>, context: Context )... data class UserPreferences(val showCompleted: Boolean)
Problem: I followed every step mentined in the Codelab tutorial https://developer.android.com/codelabs/android-preferences-datastore?hl=zh-cn#5, but I encountered this problem"Type mismatch. Required: DataStore Found: DataStore".
TasksActivity
viewModel = ViewModelProvider( this, TasksViewModelFactory( TasksRepository, UserPreferencesRepository(dataStore, this) ) ).get(TasksViewModel::class.java)
UserPreferencesRepository
class UserPreferencesRepository constructor( private val userPreferencesStore: DataStore<UserPreferences>, context: Context )... data class UserPreferences(val showCompleted: Boolean)