This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserViewModel(private val getUsersUseCase: GetUsersUseCase) : ViewModel() { | |
| private val _uiState = MutableStateFlow<UiState>(UiState.Loading) | |
| val uiState: StateFlow<UiState> = _uiState.asStateFlow() | |
| init { | |
| loadUsers() | |
| } | |
| fun loadUsers() { | |
| viewModelScope.launch { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // UserViewModel.kt | |
| class UserViewModel(private val repository: UserRepository) : ViewModel() { | |
| private val _users = MutableLiveData<Resource<List<User>>>() | |
| val users: LiveData<Resource<List<User>>> = _users | |
| fun loadUsers() { | |
| viewModelScope.launch { | |
| _users.value = Resource.Loading() | |
| _users.value = repository.getUsers() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivity : AppCompatActivity() { | |
| private val users = mutableListOf<User>() | |
| private lateinit var adapter: UserAdapter | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| val recyclerView = findViewById<RecyclerView>(R.id.recyclerView) | |
| adapter = UserAdapter(users) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val manager = ReviewManagerFactory.create(context) | |
| val request = manager.requestReviewFlow() | |
| request.addOnCompleteListener { request -> | |
| if (request.isSuccessful) { | |
| val reviewInfo = request.result | |
| val flow = manager.launchReviewFlow(this, reviewInfo) | |
| flow.addOnCompleteListener { _ -> | |
| //Continue your application process | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatefulWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| @override | |
| _MyAppState createState() => _MyAppState(); | |
| } | |
| class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencies { | |
| //other dependencies | |
| implementation 'com.google.android.gms:play-services:12.0.1' | |
| } |