CBedzz
01/24/2020, 5:49 AMtrueButton.setOnClickListener {
val toast = Toast.makeText(
this,
R.string.correct_toast,
Toast.LENGTH_SHORT
)
toast.setGravity(<http://Gravity.TOP|Gravity.TOP>, 0 , 200)
toast.show()
}
falseButton.setOnClickListener {
Toast.makeText(
this,
R.string.incorrect_toast,
Toast.LENGTH_SHORT
).also {
it.setGravity(<http://Gravity.TOP|Gravity.TOP>, 0, 200)
}.show()
}
Jakub Gwóźdź
01/24/2020, 11:43 AMmain()
inside test source root)
So I created the new script
directory and a ...ws.kts
file inside it, but here I have three issues:
• the "use classpath of module:" toolbar menu is not present
• script, when run, has working directory set to kotlin home, not project dir
• although the build directory from project is present on classpath, the dependencies are not
What am I doing wrong?Chills
01/26/2020, 11:27 AMRun button
it shows set configuration. Feel Intellj is really complex.Chills
01/26/2020, 11:28 AMVadym
01/26/2020, 1:19 PMObaid Jatoi
01/28/2020, 10:17 AMMark
01/29/2020, 4:51 PMsomeInstance::someFun
) but where the function has a receiver?cookiecookiecookie
01/30/2020, 12:19 AMMark
01/30/2020, 10:39 AMfun myCheck(): Boolean
which I want to repeatedly call until it returns false. If I use while (myCheck()) {}
then I get a warning saying “control flow with empty body”. So I guess while
is supposed to be used with a non-empty body. Does this mean there is a more appropriate way?cookiecookiecookie
02/03/2020, 12:29 AMvar m3 = mutableMapOf<String, Any
Konstantin Petrukhnov
02/04/2020, 8:12 AMval myVal: Byte
...
if(myVal != 0.toByte()) {}
vitaly
02/04/2020, 6:28 PMDawid Hyzy
02/05/2020, 9:17 AM[{"kodenik":"2013129733","namakaryawan":"YASTI RIZKIA","kodebagian":"TRIE","tglupdate":"2019-12-09","tglabsen":"2019-12-09","jamin":"10:05","jamout":""},
{"kodenik":"2015184941","namakaryawan":"AGUNG SUBEKTI","kodebagian":"TUOL","tglupdate":"2019-12-09","tglabsen":"2019-12-09","jamin":"17:03","jamout":""}]
Tuang
02/05/2020, 2:50 PMval query = "INSERT INTO table (id, name, age) VALUES (?,?,?)"
this is ordinary way (i usually use) and the problem is, the parameter `?`need to append according to the increase or decrease of column id, name, age
so i tried,,,
var column = "id, name, age"
val query = "INSERT INTO table (${column}) VALUES (${(1..3).forEach { ? }})"
the part ${(1..3).forEach { ? }}
is incorrect, i don’t know how to do.
hope you got me,Stefan Russo
02/06/2020, 2:45 PMJ6ey
02/09/2020, 12:49 PMDawid Hyzy
02/10/2020, 1:15 AMatsushi-koshikizawa
02/10/2020, 4:03 AMkotlinc
. How do I fix it? (It may occur after updating OS X to 10.15.3.)Dawid Hyzy
02/11/2020, 6:44 AMvar abc2 = client2.newCall(post2).enqueue(object: Callback {
override fun onResponse(call: Call, response: Response) {
if(response.isSuccessful){
val resp = response.body?.string()
val gson = GsonBuilder().create()
val feed: List<Feed> = gson.fromJson(resp,Array<Feed>::class.java).toList()
}
override fun onFailure(call: Call, e: IOException) {
println("GAGAL")
}
})
class Feed(val feed: List<Penyimpangan>)
class Penyimpangan(val kodenik:String,val namakaryawan:String, val kodebagian:String, val tglupdate:String, val tglabsen:String,
val jamin:String, val jamout:String)
The problem is, when I try to see the value of feed, it throws something like this :
[com.example.penyimpangan_idm.ApprovalpenyimpanganActivity$Feed@4cef17c]
My output from resp is like this :
[{"kodenik":"2013129733","namakaryawan":"YASTI RIZKIA","kodebagian":"TRIE","tglupdate":"2019-12-09","tglabsen":"2019-12-09","jamin":"10:05","jamout":""}]
Wavecycle
02/11/2020, 1:12 PMval indexInc = {if (index++ == memory.size - 1) memory.add(0u)}
val commands = mapOf(">" to indexInc, "<" to indexDec)
Ani Mehta
02/12/2020, 11:27 PMwaitGroup
, build my own, shockingly bad one...
// TODO: Fix this hacky parallelism
var awaitingResponse = 0
for (v in needsResponses) {
GlobalScope.launch {
while (awaitingResponse >= 30) {
delay(5)
}
awaitingResponse++
// send API request, record response
awaitingResponse--
}
}
sleep(1000) // needed in order to not just skip before any request is sent off
while (awaitingResponse > 0) {
sleep(5000)
}
For reference it iterates over a map in parallel, what's a better way of doing this? There's an issue currently where it sometimes proceeds before all responses are fetched/ recordedDawid Hyzy
02/13/2020, 2:05 AMclass RecyclerViewAdapter(val feed: List<ApprovalpenyimpanganActivity.Penyimpangan>): RecyclerView.Adapter<CustomViewHolder>(){
override fun getItemCount(): Int {
return feed.count()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder {
val layoutinflater = LayoutInflater.from(parent?.context)
val row = layoutinflater.inflate(R.layout.penyimpanganlayout, parent, false)
return CustomViewHolder(row)
}
override fun onBindViewHolder(holder: CustomViewHolder, position: Int){
val feed = feed.get(position)
holder.view.textView5.text = feed.namakaryawan + " - " + feed.kodenik + "\n" +
feed.jamin + " - " + feed.jamout + "\n" +
"Tanggal : " + feed.tglabsen
holder.view.checkBox.setOnClickListener{
println(position)
println("CLICKED")
println(feed)
}
}
}
class CustomViewHolder(val view: View): RecyclerView.ViewHolder(view){
}
My data class :
data class Penyimpangan(
@SerializedName("kodenik") val kodenik : String,
@SerializedName("namakaryawan") val namakaryawan : String,
@SerializedName("kodebagian") val kodebagian : String,
@SerializedName("tglupdate") val tglupdate : String,
@SerializedName("tglabsen") val tglabsen : String,
@SerializedName("jamin") val jamin : String,
@SerializedName("jamout") val jamout : String
)
Yugandhar
02/13/2020, 6:49 AMSaku Ytti
02/13/2020, 7:18 AMMark
02/15/2020, 5:56 AMlistOfStuff.asSequence().mapNotNull { fromStuffToSomethingOrNull(it) }.firstOrNull()
Lukas Kraushofer
02/16/2020, 3:43 PMjohnfn
02/17/2020, 5:05 AMfun log(x: Int) { ... }
fun log(x: String) { ... }
fun log(x: Boolean) { ... }
to have log take 3 different types of valuesjohnfn
02/17/2020, 5:05 AMSlackbot
02/17/2020, 5:06 AMjohnfn
02/17/2020, 10:07 PMobject { val x = 1 }
and then i want to make a list of them, how would i write it? ideally, something that i could put in ???
class Foo {
private val myList = mutableListOf<???>()
private fun addItem(x: Int) =
myList.add(
object { val x = x }
)
}
johnfn
02/17/2020, 10:07 PMobject { val x = 1 }
and then i want to make a list of them, how would i write it? ideally, something that i could put in ???
class Foo {
private val myList = mutableListOf<???>()
private fun addItem(x: Int) =
myList.add(
object { val x = x }
)
}
Shawn
02/17/2020, 11:01 PMAny
Any
like everything does by defaultx
valMap
Chenn
02/18/2020, 8:25 AMval obj = js("{}")
obj["type"] = type
This is how I put a key - value pair in an anonymous object in kotlin. Maybe it helps.val obj: dynamic = object{}
reducers.forEach { obj[it.key] = it.value}
This practically generates the same code..Shawn
02/18/2020, 3:59 PMjs()
isn’t a stdlib function and dynamic
isn’t a standard type on JVM, and presumably elsewhereChenn
02/18/2020, 4:01 PM