Sudhir Singh Khanger
06/07/2021, 4:20 AMNonCancellable
in the following case? Would it outlive the scope and finish the job?
viewModelScope.launch {
withContext(NonCancellable + <http://Dispatchers.IO|Dispatchers.IO>) {
// some job
}
}
James Black
06/07/2021, 4:36 AMSudhir Singh Khanger
06/07/2021, 6:32 AMsomeDbCall()
should be a suspend
function.
private fun someDbCall() { //some db call }
someScope.launch {
someDBCall()
}
Do you have a personal philosophy such as don't use suspend keyword unless the compiler forces you to as I have been reading on Stack overflow?
someScope.launch {
withContext(NonCancellable + <http://Dispatchers.IO|Dispatchers.IO>) { someDBCall() }
}
If you do have a philosophy of not using suspend keyword when not needed then how does construct like withContext affect using them with non-suspend keyword function.haris mehmood
06/07/2021, 9:15 AMAnkit Dubey
06/07/2021, 9:30 AMsuspend fun <T> commonPost (query: HashMap<String, String>, mUrl : String) : DataState.Success<T> {
val mClient = KtorClientFactory().build()
val res = <http://mClient.post|mClient.post><MemberResponse>("${baseURL}$mUrl")
return DataState.Success(res)
}
I want to create a generic method that will call multiple APIs using ktor.Ranjan Rukhaya
06/07/2021, 10:33 AMMarcello Galhardo
06/07/2021, 3:02 PMsolidogen
06/07/2021, 4:15 PMmelatonina
06/07/2021, 11:17 PMStateFlow
is a good replacement for LiveData
on Android?
There is often a noticeable delay in updates, which leads to the UI to represent incorrect information when it first shows up.
That never happened to me with LiveData
.brian
06/08/2021, 6:14 AMSlackbot
06/08/2021, 6:29 AMMarko Novakovic
06/08/2021, 8:02 AM2 files found with path 'META-INF/AL2.0'.
this started to appear all of a sudden in my project. why? what does this mean?y9san9
06/08/2021, 2:23 PMbuild.gradle.kts
.
Here is how my build file and buildSrc
looks like, everything builds OK, but I have highlighting issues. Maybe the problem is my runtime classpath contains the dependency while compile classpath doesn't. So does anyone know how to inspect this?Mert Demir
06/08/2021, 5:31 PMVivek Modi
06/09/2021, 10:41 AMprivate var categoryType = arrayListOf<CategoryType>()
get() {
if (category1List != null) {
field = arrayListOf(CategoryType.Category1)
}
if (category2List != null) {
field = arrayListOf(CategoryType.Category2)
}
if (category3List != null) {
field = arrayListOf(CategoryType.Category3)
}
return field
}
enum class CategoryType(val valueName: String) {
ALL("ALL"),
Category1("Category1"),
Category2("Category2"),
Category3("Category3");
companion object {
fun getArray(): List<CategoryType> {
return values().map {
it
}
}
}
}
Sivan
06/09/2021, 2:56 PMharis mehmood
06/10/2021, 7:26 AMVivek Modi
06/10/2021, 2:23 PMMary Owuor
06/11/2021, 5:19 AMSlackbot
06/11/2021, 8:45 AMLaw Gimenez
06/11/2021, 9:05 AMprivate val binding get() = _binding!!
line. Thanks in advance for the help!Vinícius Santos
06/11/2021, 12:47 PMviewModelScope.launch {
launch { a = one() }
launch { b = two() }
print(a+b)
}
Caio Costa
06/11/2021, 8:19 PMBilagi
06/13/2021, 10:38 AMActivity Results API
stable for production use?Lilly
06/13/2021, 12:32 PMkotlinOptions.jvmTarget
? I'm wondering because we don't write Java Code so what prevents me to set it to 16
?rajesh
06/13/2021, 6:18 PMCaio Costa
06/13/2021, 6:57 PMclass MainActivity : AppCompatActivity() {
private val viewModel: MainViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
runTaskOnBackground {
viewModel.errorStateFlow.collect {
println("CALLED")
Toast.makeText(applicationContext, "$it", Toast.LENGTH_LONG).show()
}
}
}
private fun runTaskOnBackground(task: suspend () -> Unit) =
addRepeatingJob(Lifecycle.State.CREATED) {
task()
}
}
////////////////////////////////////////////////////
internal class MainViewModel : ViewModel() {
private val _errorStateFlow = MutableStateFlow(0)
val errorStateFlow: StateFlow<Int>
get() = _errorStateFlow
}
The problem i'm getting is that both the Toast and the println i declared are being shown even without posting a value to that MutableStateFlow inside my ViewModel because the value I'm getting is the same as the default one. Looks like the MutableStateFlow is posting the default value automatically. Do you know why this is happening and if there's a way to avoid that? I've searched across the internet but couldn't find someone with the same problem. Thank you in advance KRamprasad
06/13/2021, 7:04 PMRamprasad
06/13/2021, 7:04 PMLaw Gimenez
06/14/2021, 6:10 AMbuildToolsVersion
correct? If yes it is currently throwing an error Installed Build Tools revision 31.0.0 rc5 is corrupted