Sylvain Patenaude
09/13/2022, 3:14 PMSergio C.
09/13/2022, 4:57 PM"**/R\$*.class"
Radoslaw Juszczyk
09/14/2022, 11:27 AMA problem occurred configuring project ':android'.
> Failed to notify project evaluation listener.
> Could not create task ':android:compileDebugAndroidTestKotlin'.
> Cannot invoke "String.trim()" because "in" is null
> KotlinJvmAndroidCompilation with name 'debugAndroidTest' not found.
If I try the same with kotlin 1.6.10 it works fine. Any ideas?paulex
09/14/2022, 9:34 PMsvenjacobs
09/15/2022, 6:48 AMandroid {
compileSdkVersion 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}
I assume the Android Gradle plugin will desugar the bytecode to be compatible with Java 1.8 (or 1.6?) so what are the benefits of letting the Gradle plugin do this instead of using 1.8 as JVM target?martin suchodol
09/15/2022, 11:59 AMclass MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val _status = MutableLiveData<String?>()
val status: LiveData<String?> = _status
val api : String = "33aa634c216259f797f35e862f0*****"
val spinner = findViewById<Spinner>(R.id.cities)
//val result = findViewById<TextView>(R.id.result)
val cities = arrayOf("New York", "Sydney")
val cnt = findViewById<EditText>(R.id.NumberOfDays)
val button = findViewById<Button>(R.id.button)
val arrayAdapter: ArrayAdapter<*>
val data = arrayListOf<String>();
var listView = findViewById<ListView>(R.id.list)
arrayAdapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, data)
listView.adapter = arrayAdapter
spinner.adapter = ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, cities)
button.setOnClickListener {
val selected = spinner.selectedItem as String
var lat: String = ""
var lon: String = ""
if (selected == "New York") {
lat = "40.79052384606425"
lon = "-73.95908688800822"
} else if (selected == "Sydney") {
lat = "-33.8470241774331"
lon = "151.0624326592654"
}
if(!TextUtils.isEmpty(cnt.text.toString())){
lifecycleScope.launch{
WeatherApi.retrofitService.getWeatherData(lat, lon, api, "metric", cnt.text.toString()).enqueue(object: Callback<WeatherInfo> {
override fun onResponse(call: Call<WeatherInfo>, response: Response<WeatherInfo>) {
data.add(response.body()?.city?.name.toString())
//result.text = response.body().toString()
Log.d("Full response: ", response.body().toString())
}
override fun onFailure(call: Call<WeatherInfo>, t: Throwable) {
Log.d("Failure: ", t.message.toString())
}
})
}
}
}
}
}
Ahmed Dridi
09/15/2022, 12:53 PMChristy K
09/15/2022, 7:04 PMChristy K
09/15/2022, 7:02 PMBen Edwards
09/15/2022, 9:56 PMsupportActionBar?.setDefaultDisplayHomeAsUpEnabled(enableHome)
but this gives more errors, the version I am trying with true gives
`ActionBar.setDefaultDisplayHomeAsUpEnabled can only be called from within the same library group prefix (referenced groupId=androidx.appcompat
with prefix androidx from groupId=Flicker Browser
)`
Any ideas?
package com.funkytwig.flickerbrowser
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
private const val TAG = "BaseActivity"
// internal as don't have to be available outside this project ?? check ??
internal const val FLICKER_QUERY = "FLICKER_QUERY"
internal const val PHOTO_TRANSFUR = "PHOTO_TRANSFUR"
open class BaseActivity : AppCompatActivity() {
internal fun activateToolbar( home:Boolean) {
Log.d(TAG, "activateToolbar")
var toolbar = findViewById<View>(R.id.toolbar) as Toolbar
setSupportActionBar(toolbar)
supportActionBar?.setDefaultDisplayHomeAsUpEnabled(true) // does not work
}
}
nuhkoca
09/16/2022, 10:45 AMSarthak Gupta
09/16/2022, 12:31 PMKotlinLeaner
09/16/2022, 1:33 PMtasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
freeCompilerArgs += [
"-Xuse-experimental=com.google.accompanist.permissions.ExperimentalPermissionsApi"
]
}
}
I tried this piece of code but it giving me error. Can anyone guide me what I am doing wrong hereEric Womer
09/17/2022, 9:45 PMEric Womer
09/17/2022, 9:50 PMOmar Qadour
09/19/2022, 9:38 AMSufyan Sattar
09/19/2022, 2:51 PMSufyan Sattar
09/19/2022, 2:51 PMJorge Cordero Camarena
09/19/2022, 3:53 PMTravis Griggs
09/19/2022, 4:01 PMplugins {
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.10'
}
There's two build.gradle files. Which one? I've tried placing it in both of them at various locations, and I always get errors about it needing to above or before one thing or another. Is the snippet/instructions up to date?Lilly
09/19/2022, 11:11 PMLong
Int
and Byte
variables which I use across my codebase but have to convert them to different types. Lets take a Long
variable which I have to convert to int (toInt()
) or byte (toByte()) at different places. Is it common to provide the same variable as Int
or as Byte, e.g. myVariableAsLong
, myVariableAsInt
, myVariableAsByte
? Does this approach make sense, is there another common approach for this case or is it pointless?Harshad Pawar
09/20/2022, 6:42 AMczuckie
09/20/2022, 8:16 AMInk
09/21/2022, 9:54 AMdata
is a Request sealed class
and inside that class there 3 classes Opened, Success, NotSigned
How I can cast data
to have access to data.openedFrom
value? I want to avoid invoking 3 times navigate()
functionAlexandru Hadăr
09/21/2022, 10:36 AM"org.jetbrains.kotlin.android
and "org.jetbrains.kotlin.jvm
gradle plugins ?krmlv
09/21/2022, 2:26 PMalthaf
09/21/2022, 4:41 PMjava.lang.IllegalArgumentException: Flow context cannot contain job in it. Had [SupervisorJobImpl{Active}@7b4ca1f, <http://Dispatchers.IO|Dispatchers.IO>]
interface UseCaseScope : CoroutineScope {
override val coroutineContext: CoroutineContext
get() = SupervisorJob() + <http://Dispatchers.IO|Dispatchers.IO>
}
FlowUsecase : UseCaseScope {
<snip>
}
The intention here is to cancel the coroutine context when we business logic need to cancel it. So that i can call coroutineContext.cancel()
class LoginUseCase(private val authRepository: AuthRepository) : FlowUseCase<LoginRequest, Boolean>() {
override fun execute(parameter: LoginRequest): Flow<Result<Boolean>> =
flow {
authRepository.login(parameter.username, parameter.password).collect { response ->
this.defaultResultHandler(onSuccess = {
emit(Result.success(true))
}, response)
}
}.flowOn(coroutineContext)
override fun cancel() {
coroutineContext.cancel()
}
}
^^^ will cause app the crashNipun Rajput
09/22/2022, 9:26 AMimplementation("$rootDir/UI-Modules/carousel-release.aar"
Nathan Kleinschmidt
09/22/2022, 2:55 PM