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
  • p

    Pradyumna

    05/07/2018, 11:09 AM
    is it possible to do?
    :stackoverflow: 8
    d
    • 2
    • 1
  • s

    Slackbot

    05/09/2018, 12:38 AM
    This message was deleted.
    s
    s
    • 3
    • 2
  • j

    jfelrod1960

    05/09/2018, 8:50 PM
    Anyone know of an Android game library written in Kotlin?
    b
    • 2
    • 2
  • a

    amanda.hinchman-dominguez

    05/10/2018, 2:18 AM
    // Replace contents of a view invoked by the layout manager
        (no override) fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
            holder as ImageViewHolder
            holder.bindView(position)
        }
    r
    • 2
    • 2
  • k

    kikebodi

    05/10/2018, 3:40 PM
    Hi all! I'm developing an app for runners with a heart rate monitor integration. Currently supports only Polar, but I need to support several more devices (Garmin, Suunto, etc ...). Do you know any library to handle this? All suggestions are welcome 🙂
    :google: 2
    :stackoverflow: 3
    d
    • 2
    • 1
  • l

    Lukas Anda

    05/11/2018, 10:34 AM
    Hi guys, anyone tried the new Canary build of Android studio with Navigation Editor ? It does not want to run with GitHubViewer sample from Google. I mean it compiles without errors but I can not visually see what there should be with fragment navigation, only "Waiting for build to finish" although I tried to build the project like 20 times
    :stackoverflow: 3
    a
    d
    • 3
    • 3
  • r

    rCorbellini

    05/11/2018, 1:48 PM
    Does anyone know if Coroutines plans at some point don't be a library? and become part of kotlin's core
    d
    a
    • 3
    • 4
  • k

    kenkyee

    05/11/2018, 10:32 PM
    When you target P or anything not a released version, it's always been painful. Don't do it unless you have to
    ➕ 2
    c
    • 2
    • 16
  • a

    arekolek

    05/12/2018, 7:59 PM
    Where would one submit an issue against the Data Binding library, about interop with Kotlin? There's a new method
    android.databinding.ViewDataBinding#setLifecycleOwner
    that doesn't have a corresponding getter, which means that we can't use property access syntax, unless https://youtrack.jetbrains.com/issue/KT-6519 is resolved.
    a
    • 2
    • 2
  • s

    samp

    05/12/2018, 8:36 PM
    Does anyone know how to test android application on virtual brand specific device? I want to test something on Huawei phones and I don’t have any real Huawei device/phone.
    :stackoverflow: 4
    d
    • 2
    • 1
  • y

    yuvraj24

    05/13/2018, 5:40 AM
    Check out my new Kotlin library which offers a great alternative to native Snack bar & Toast in Android. https://medium.com/@yuvrajpandey24/bored-of-snackbar-toast-livesmashbar-to-the-rescue-b124034033fc
    d
    • 2
    • 1
  • f

    Filip Husnjak

    05/13/2018, 10:01 AM
    Hey guys! I am currently converting some java code to kotlin for my app and i have a question regarding Callbacks vs Closures. My java code uses a callback: Ex:
    public interface Callback {
       void onSuccess(Class item);
       void onError(Error error);
    }
    I was thinking of replacing this callback with a closure instead and my question is if it is better to add two closure parameters or to just have one? Is there a best practice for this? Ex:
    onSuccess: (item: Class) -> Unit, onError: (error: Error) -> Unit
    OR
    callback: (item: Class, error: Error) -> Unit
    /Thanks
    o
    • 2
    • 2
  • k

    kioba

    05/14/2018, 9:47 AM
    How do you solve the issue with the
    @Nullable
    annotation on the
    getActivity()
    and
    getContext()
    in the android SDK 27 changes ? Personally I’m not keen to spread the nullable context all around the app.
    g
    a
    • 3
    • 2
  • w

    w_bianrytree

    05/14/2018, 10:23 AM
    Hi there. not kotlin related but android question. I have a flavor for prod/preprod but i can't use
    preprodDebugImplementation
    . Anyone knows why?
    Error:(96, 0) Could not find method preprodDebugImplementation() for arguments [] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    Thanks!
    :stackoverflow: 7
    a
    • 2
    • 2
  • s

    sindrenm

    05/14/2018, 11:34 AM
    What do you guys think about the added visibility setters and getters on
    View
    in android-ktx? I find the getters really handy and readable, but the setters feel “imbalanced” and not thought through:
    inline var View.isVisible: Boolean
        get() = visibility == View.VISIBLE
        set(value) {
            visibility = if (value) View.VISIBLE else View.GONE
        }
    
    inline var View.isInvisible: Boolean
        get() = visibility == View.INVISIBLE
        set(value) {
            visibility = if (value) View.INVISIBLE else View.VISIBLE
        }
    
    inline var View.isGone: Boolean
        get() = visibility == View.GONE
        set(value) {
            visibility = if (value) View.GONE else View.VISIBLE
        }
    In my opinion, saying
    button.isVisible = false
    in Android doesn't really make sense because of the difference between
    View.INVISIBLE
    and
    View.GONE
    . What do you guys think?
    👍 1
    s
    g
    +2
    • 5
    • 6
  • z

    Znkenza

    05/14/2018, 11:48 AM
    hello everyone, I am a beginner under android and I am very happy to be among you
    👋 20
    👍 1
    s
    • 2
    • 1
  • r

    rkeazor

    05/15/2018, 2:21 AM
    Instead of opening a existing project try opening a new project and see if the issue persist. If it doesnt than it probably means you might have to upgrade some of your plugins.also keep in mind it's still in alpha,so there will always be bugs
    a
    • 2
    • 1
  • d

    Darshan Mistry

    05/15/2018, 5:17 AM
    Hello can you suggest me kotlin open source project like kotlinconf-app(https://github.com/JetBrains/kotlinconf-app).
    :google: 2
    :stackoverflow: 3
    u
    g
    • 3
    • 3
  • o

    oleksiyp

    05/15/2018, 9:21 PM
    MockK now supports Android instrumentation tests http://mockk.io/ANDROID 🎉🎉🎉🎉🎉
    👏 1
    🎉 5
    a
    • 2
    • 2
  • d

    damian

    05/15/2018, 9:21 PM
    My Android Studio has been having lots of trouble resolving
    kotlinx.android
    synthetic extensions lately... I would say that they're just unresolved 80% of the time, which makes editing very difficult. I keep looking at the bug tracker but haven't seen any issues... is this a known or common problem? Has it been fixed in a recent update to something that I'm not aware of? Currently on AS 3.1.2 w/ Kotlin plugin
    1.2.41-release-Studio3.1-1
    of the plugin 😕
    l
    a
    +2
    • 5
    • 29
  • s

    sudhanshu singh

    05/16/2018, 8:24 AM
    I have a singleton Class
    class UserManager private constructor() {
    	private object Holder {
    		val INSTANCE = UserManager()
    	}
    
    	var currentUser: UserModel? = null
    		private set
    
    	companion object {
    		val instance: UserManager by lazy { Holder.
    and I want to use this in xml for databinding, but the following gives 
    android:text="UserManager.Companion.getInstance().getCurrentUser()}
    
    error: Could not find accessor for UserManager.Companion.
    s
    u
    • 3
    • 4
  • p

    paras

    05/16/2018, 9:17 AM
    Hey guys, anyone here have worked on custom canvas drawing before… I need help.
    :stackoverflow: 5
    g
    • 2
    • 1
  • a

    adams2

    05/16/2018, 4:24 PM
    where can I read more about the status of KAE view caching
    • 1
    • 3
  • s

    sudhanshu singh

    05/17/2018, 11:05 AM
    is there any difference in these two
    val isEmpty: Boolean
        get() = this.size == 0
    
    val isEmpty =  this.size==0
    l
    j
    +3
    • 6
    • 7
  • n

    nickk

    05/18/2018, 9:37 AM
    I replaced
    compile
    with
    implementation
    in my Gradle build files and now I am getting this cryptic error: Internal compiler error. See log for more details
    Caused by: java.lang.AssertionError: annotation tree hasn't been attributed yet: @kotlin.Metadata(mv = {1, 1, 10}, bv = {1, 0, 2}, k = 1, d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\u0018\u00002\u00020\u0001B\u0005\u00a2\u0006\u0002\u0010\u0002J\b\u0010\u0003\u001a\u00020\u0004H\u0016\u00a8\u0006\u0005"}, d2 = {"Lgr/test/fieldobservations/ui/LocationPickerExt;", "Lgr/test/ui/LocationPicker;", "()V", "createAnnotations", "", "app_debug"})
    Any idea? (using AS 3.1, Kotlin 1.2.41) This seems to be related to kapt.
    l
    g
    • 3
    • 4
  • g

    ghedeon

    05/18/2018, 2:44 PM
    Hi, would like to validate an approach. Some time ago I asked here about kotlinx synthetic and long view ids. To give you an idea, I happened to work on a project with this frankenstein:

    https://i.imgur.com/QzedJhB.png▾

    Possible solutions: 1) don't bother with synthetic 2) get rid of id prefixes, have ids with same names in different layouts and let the android to figure out the context As a proof of concept I decided to workaround with kotlin imports aliases, so I can rename my variables regardless of the actual xml id and here is a small demo of the plugin that helps to automate the process.

    https://i.imgur.com/Bdg931e.gif▾

    It's pretty much self-explanatory, the
    Generate Synthetic
    action is added, that imports ids from layout file with alias that can be edited to your taste. Also, it can be configured to convert underscore to camelCase. Now, the real question is, would it benefit anyone or I'm solving nonexistent problem?)
    d
    • 2
    • 4
  • r

    Ronald Daugherty

    05/18/2018, 3:06 PM
    I'm getting a response from a server with information when a task was done. The data has to be converted to a float to so it can be displayed in a chart. I would like to filter the data display but a 7 day , 30 day, and year results. Can someone point me in the right direction to how I would do sort this info? Thanks
    :stackoverflow: 3
    d
    u
    • 3
    • 2
  • d

    Darius Morar

    05/18/2018, 5:58 PM
    Take too much time until test is finished...1-5min. If is written in Java take just 1-2 sec
    p
    a
    +3
    • 6
    • 13
  • p

    pga4711

    05/18/2018, 9:20 PM
    Hello, I am very new to app development. I wonder some basic concepta. For example if I have a an app running on a smartphone with 4k resolution with 5 inch and then run the same app on a 4k 10 inch big tablet. In the 90's thinking, the apps would look the same (per pixel thinking). But today the content will look different on the both. Size of buttons, texts ect will be different on the comparing devices. What are these size-concept called?
    :android: 2
    :google: 8
    :stackoverflow: 4
    n
    u
    • 3
    • 2
  • h

    henrytao

    05/20/2018, 1:55 AM
    Hi all, if you are using LiveData, these extensions can be useful
    val liveData: MutableLiveDataBoolean = MutableLiveData()
    liveData
      .distinct()
      .filter { it == false }
      .map { true }
      .nonNull()
      .observe(lifecycleOwner, { result ->
        // result is non-null and always true
      })
    Check it out: https://medium.com/@henrytao/chaining-livedata-like-rxjava-with-kotlin-extension-e3a2c15ac11
    👍 3
    g
    • 2
    • 1
Powered by Linen
Title
h

henrytao

05/20/2018, 1:55 AM
Hi all, if you are using LiveData, these extensions can be useful
val liveData: MutableLiveDataBoolean = MutableLiveData()
liveData
  .distinct()
  .filter { it == false }
  .map { true }
  .nonNull()
  .observe(lifecycleOwner, { result ->
    // result is non-null and always true
  })
Check it out: https://medium.com/@henrytao/chaining-livedata-like-rxjava-with-kotlin-extension-e3a2c15ac11
👍 3
g

ghedeon

05/21/2018, 5:51 PM
nice job! What would be the final goal of such effort? To get rid of RxJava? I'm using both just to be in sync with android updates, but honestly, it's hard to justify LiveData presence when you already have Rx. The out of the box lyfecycle management is just a matter of one line from AutoDispose library or similar.
View count: 1