https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
android
  • l

    lawlorslaw

    06/29/2018, 6:42 AM
    or just the ones that will be different than the variable name?
    l
    c
    +2
    • 5
    • 4
  • l

    lovis

    06/29/2018, 7:32 AM
    anybody got experience using Kotlin + JNI on Android? Does it work nicely, or is it smarter to just use plain old Java for those parts of the app?
    g
    • 2
    • 5
  • l

    lawlorslaw

    06/29/2018, 4:34 PM
    i tried to use databinding to do some late binding of some data to an GoogleMap infowindow. but that doesn’t look like it will work. Is there any other work around to update an infowindow after it is showing?
    l
    • 2
    • 5
  • f

    Francesco megna

    06/30/2018, 10:34 AM
    Anyone know a good and complete resource about Dagger 2? i want to inject various thing, like context or retrofit interface in my view module and other stuff like that
    l
    g
    • 3
    • 2
  • n

    neuber

    06/30/2018, 12:06 PM
    I will test today
    • 1
    • 2
  • a

    Ayden

    06/30/2018, 1:45 PM
    Is there a way to create a ErrorAPI class to handle the error response?
    {
      "error": {
        "name": [
          "The name field is required."
        ],
        "email": [
          "The email field is required."
        ],
        "password": [
          "The password field is required."
        ]
      }
    }
    g
    j
    • 3
    • 4
  • a

    Ayden

    06/30/2018, 2:00 PM
    {
      "status": false,
      "message": "Duplicate entry '@gmail.com' for key 'users_email_unique'"
    }
    {
      "status": false,
      "message": {
        "code": "1048",
        "message": "Something goes wrong."
      }
    }
    g
    r
    • 3
    • 7
  • u

    ursus

    07/01/2018, 4:16 AM
    Should statemachines throw or noop in invalid cases?
    🤔 1
    l
    • 2
    • 1
  • a

    ar-g

    07/02/2018, 1:53 PM
    Does anyone came across issue of logging exceptions? Crashes are omitted from LogCat, but shown in Fabric.
    private fun processSelectedImages(selectedImages: LinkedHashMap<String, Image>) {
            assertMainThread()
    
            fun fillAdIds(
                index: Int,
                map: LinkedHashMap<String, Image>
            ) = map.values.map { image -> image.copy(adId = tempAdIds[index]!!) }
    
            val imagesWithAdId = listsOfImages
                .mapIndexed(::fillAdIds)
                .flatMap { it }
                .map { it.copy() }
    NPE happens in internal function
    fillAdIds
    l
    • 2
    • 2
  • n

    neuber

    07/02/2018, 2:42 PM
    https://stackoverflow.com/questions/51111290/android-things-using-commands-writebuffer-write-byte-to-write-many-bytes-in
    :stackoverflow: 1
    c
    • 2
    • 4
  • c

    cart

    07/03/2018, 7:08 PM
    Yeah I think that might be helpful, I would appreciate that thank you 🙂
    l
    • 2
    • 4
  • c

    cart

    07/03/2018, 7:10 PM
    I actually don't fully understand yet, which parts of Kotlin and the Android Studio plugin are closed source?
    l
    r
    • 3
    • 6
  • l

    lawlorslaw

    07/03/2018, 9:17 PM
    If you could choose only one book to buy in this list which one would it be https://kotlinlang.org/docs/books.html
    c
    • 2
    • 1
  • y

    yaakov

    07/04/2018, 12:32 AM
    So I'm using Google Maps in my Android app for a country picker but I keep getting this error:
    Java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    How can I prevent this kind of error? I think the problem comes from here:
    val address = geocoder.getFromLocation(it.latitude, it.longitude, 1)
    val country = address[0].countryCode.toLowerCase()
    f
    • 2
    • 2
  • c

    chetsachdeva

    07/04/2018, 8:34 AM
    Android Paging library is really good. I just published "Android Paging for Network Uncovered!" https://medium.com/@chet.deva/android-paging-for-network-uncovered-b9cb85ca637b
    😍 1
    g
    • 2
    • 1
  • a

    audax

    07/05/2018, 9:34 AM
    I am using kotlin with dagger and databindings on android. When I cleaned my
    .gradle
    folder in my project today I started getting compilation errors: https://gist.github.com/audax/54fffa916c420af70881ad891d3fc5f8 I am using kotlin 1.51 (but also tested 1.40 and 1.50) and the android gradle plugin 3.1.3. Anyone got an idea of why that is crashing?
    • 1
    • 1
  • f

    Francesco megna

    07/06/2018, 8:17 AM
    The best way would be to pass a function from the layout parent and in the layout of button i write “onClick=“@{onClickGenericMethod}“, but if i want to pass paramater this implementation not work
    n
    g
    • 3
    • 23
  • r

    rattleshirt

    07/06/2018, 8:25 AM
    Hi, how can I use an abstract class in databinding (3.2.0-beta02), it gives me a
    Could not find accessor companyName
    when using
    android:text="@{data.invoice.companyName}"
    (kotlin v1.2.51) with
    abstract var companyName: String?
    . In the kotlin bytecode I see a
    getCompanyName()
    method but that doesn’t work either
    a
    g
    • 3
    • 20
  • l

    locke

    07/06/2018, 5:31 PM
    When an Activity is destroyed and recreated, are all of it's associated Fragments also destroyed and recreated automatically? I am somehow ending up with 2 instances of a Fragment being initialized and not exactly sure how.
    :android: 1
    :stackoverflow: 1
    m
    • 2
    • 2
  • l

    lawlorslaw

    07/07/2018, 2:50 AM
    how do i set up a smoother transition without any flicker and also with activity B sliding on top of activity A
    r
    • 2
    • 3
  • b

    blakelee

    07/07/2018, 7:48 PM
    Is the new motion editor available in the canary? EDIT: Already googled and checked SO. Haven't seen anything else mentioned since it's relatively hard to find info on it
    :stackoverflow: 1
    :google: 1
    l
    • 2
    • 1
  • s

    seetha

    07/08/2018, 4:09 AM
    I'm working on a Kotlin talk for an upcoming conference. I wanted to gather some feedback from the community. If you/your team has been using Kotlin for Android dev, what noticeable improvements have you seen in your every day Android development life? (In terms of productivity/efficiency). Or have you seen any drawbacks? I'd love to hear your views. Thank you! 🙏🏼
    r
    • 2
    • 1
  • v

    Viktor Vostrikov

    07/08/2018, 8:22 AM
    Hello, I am native android developer and student in university, currently managed to get a mid developer job in local company. I really enjoy Android development, especially using most popular and advanced technologies: RxJava, Android Architecture Components, Dagger2, Retrofit. I even become almost complete Kotlin developer(use Java sometimes) I spend a lot of time learning all that, and now it seems it is all for nothing... Our company has started to use ReactNative, other companies also move to cross platform or even PWAs. Earlier it did not make sense to me, but now I see that cross platform apps are better choice. I even bet that within 2 years Hybrid apps or PWAs are going to become even more popular and take over. It all happens because devices become much faster and can handle all functions, being just web apps instead of native. Can someone share their experience? I believe it is good for young people to know about better and more used alternatives , instead of wasting time in Android native development, because skills are not transferable to web at all! Also, why people are not using Kotlin for IOS? That would solve issue! Learn Kotlin and use it for IOS too
    👍 2
    a
    s
    +3
    • 6
    • 10
  • l

    louiscad

    07/08/2018, 2:07 PM
    Hi, did anyone successfully migrate to AndroidX (which is now in beta)? Did you observe any build time impact (positive or negative) with jetifier enabled for compat with third-party libs relying on pre-AndroidX support libraries?
    r
    • 2
    • 1
  • r

    redrield

    07/08/2018, 2:41 PM
    Can anyone who's done networking with bluetooth check out this question? https://stackoverflow.com/questions/51110026/bluetooth-cant-find-custom-service-uuid-in-sdp-query I've been waiting for just over a week to get this one bit of my app working the way I want, and I haven't gotten any answer
    r
    • 2
    • 6
  • f

    Francesco megna

    07/08/2018, 8:05 PM
    It’s a good idea to bind the entire viewModel class to a view instead specifics properties? In some cases not all property and methods of the viewModel are used by the view
    🤔 1
    l
    e
    g
    • 4
    • 22
  • a

    Alin B.

    07/10/2018, 7:47 AM
    Hey all. I am trying to see what Kotlin is about and since I come from java one thing that I see is the way Nulls are handled. Of course, the habit for having null default values and != null check is strong on my end and the first step would be to better understand how to program without having the nulls in mind. So for starters, having a class
    class Person(val firstName: String, val lastName: String, var age: Int)
    and avoiding null means that whenever I instantiate it, I need to pass default values? So maybe have firstName="", lastName="" and age=0?
    l
    g
    • 3
    • 24
  • a

    Alin B.

    07/10/2018, 5:06 PM
    Maybe a bit out of case, but I see mostly naming convention like
    UserListFragment
    ,
    UserDetailsFragment
    ,
    UserListAdapter
    ,
    UserListViewModel
    . Now if I have all these open in Android studio I find it a lot harder to find which one is adapter, which is ModelView. Why not go with
    FragmentUserList
    ,
    AdapterUserList
    ,
    ViewModelUserList
    ?
    l
    • 2
    • 26
  • a

    Alin B.

    07/11/2018, 1:30 PM
    I have a class like class
    someClass(val id : String, val imageResourceId: Int)
    . Basically I want to set the drawable id as the source of the image resource to show in the app. However, resIds may change upon adding new resources so I end up with a database which hosts wrong ids. One way I can think of is adding the icons in the
    assets
    folder and user Glide to load from there. Any other thoughts?
    c
    g
    • 3
    • 58
  • c

    Can Orhan

    07/11/2018, 3:56 PM
    I haven't tried it but I imagine you should be able to. Higher order functions are first class citizens, after all. Have you tried anything yet?
    j
    r
    • 3
    • 12
Powered by Linen
Title
c

Can Orhan

07/11/2018, 3:56 PM
I haven't tried it but I imagine you should be able to. Higher order functions are first class citizens, after all. Have you tried anything yet?
@jc I've found an issue that had been opened and answered for you https://github.com/google/dagger/issues/900
j

jc

07/11/2018, 4:20 PM
Thank you @Can Orhan !
👍 1
r

rkeazor

07/12/2018, 12:33 AM
I cant imagine a good use case for injecting a high order function . Why would you really want to
c

Can Orhan

07/12/2018, 8:04 AM
@rkeazor Perhaps an on click listener in Android that needs different behaviour based on build variant or something?
👍 2
r

rkeazor

07/12/2018, 1:00 PM
hmm I see your point , i guess it could come in handy
did it end up working for you in the long run
by adding the surpressedWildcard anontation?
c

Can Orhan

07/12/2018, 2:43 PM
I personally haven't tried it. @jc?
👍 1
j

jc

07/13/2018, 8:28 AM
In our app we have MVP and Dagger 2. We have also a lot of RecyclerView’s adapters which need Listener’s for click actions. We try to avoid using Listeners which activities or fragments have to implement it. Right now we can inject presenter’s function directly to adapter. Inject must look something like this: @Module object MyModule { @Provides @JvmStatic @JvmSuppressWildcards @jsingle fun provideClickFunction(presenter: MyContract.Presenter): Function1<@JvmWildcard MyModel, Unit> = presenter::onModelClick @Provides @JvmStatic @jsingle fun providePresenter(presenter: MyPresenter): MyContract.Presenter = presenter @Provides @JvmStatic @jsingle fun provideAdapter(adapter: MyAdapter): ListAdapter<*, *> = adapter } class MyAdapter @Inject constructor(private val clickFunction: (MyModel) -> Unit) : ListAdapter ... { inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) { fun bind(model: MyModel) = itemView.setOnClickListener { clickFunction(model) } } }
I hope this dummy code is clear for you 🙂
r

rkeazor

07/16/2018, 5:30 AM
What's wrong with the presenter not implementing the listener instead?
j

jc

07/19/2018, 8:20 AM
nothing it’s only a different approach 😉
View count: 3