https://kotlinlang.org logo
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
  • g

    gabrielfv

    07/23/2020, 5:32 PM
    If I have an interface like so
    interface Foo<A : Bar, B : Baz>
    And a series of implementations which I want to bind into a dagger map, is it possible to bind them like so?
    @Binds
    @IntoMap
    @FooKey(ExampleFoo::class)
    fun bindExampleFoo(exampleFoo: ExampleFoo): Foo<*, *>
    To me, if I have a key like this:
    @MapKey
    annotation class FooKey(val value: KClass<out Foo<*, *>>)
    It will fail me with a weird error message:
    error: incompatible types: Class<ExampleFoo> cannot be converted to Class<? extends Foo<?,?>>
    • 1
    • 1
  • v

    vesp

    07/23/2020, 8:06 PM
    Does anyone have a best practices primer/repo/blog/anything I can refer to when learning and improving my use of coroutines? I'm so-so on the topic, I've been reading conflicting Medium posts, and I'm not too terribly comfortable using it myself. Any help would be greatly appreciated. I've been using the docs (https://kotlinlang.org/docs/tutorials/coroutines/async-programming.html) but I want something that dives a little deeper.
    a
    z
    • 3
    • 2
  • a

    Ananiya

    07/24/2020, 8:42 AM
    Hello 👋, I was trying to save every title here is my code . . . val title = edittext?.text OnClick . . . context.getSharedPreferences(TAG, Context.MODE_PRIVATE).let { It.edit().putStringSet(TAG, HashSet<String>().also{ It.add(title) }).apply() } . . . . . . It saves the title but it also replace the the old with newer(delete all values and add new values) for e.g my first title was foo When I add another title in edittext and save it Like "hello world" during retrieving it shows only [hello world] all I want was [foo, hello world]
    g
    • 2
    • 4
  • a

    Alejandro Rios

    07/24/2020, 12:24 PM
    Hello, anyone knows some tool to use for
    Code Coverage
    besides Jacoco or Sonar?, i'm looking if there's an alternative to do that on an Android project that's written in Kotlin
    e
    c
    +4
    • 7
    • 15
  • v

    vgonda

    07/24/2020, 8:03 PM
    That's generally how I use lateinit, the way you described
    👍 4
    🙂 1
    s
    p
    • 3
    • 3
  • p

    pollux-

    07/24/2020, 10:50 PM
    Anyone know what is the best approach to initialize Viemodel without injecting factory in Dagger. Also I need see how that can be scope this correctly. Any good blog will be helpful. Thanks 👍
    j
    • 2
    • 2
  • c

    Christopher Elías

    07/25/2020, 6:06 AM
    Hello my friends. I've been struggling with this for 2 days now. I'm trying to run my InstrumentedTest, but the build window throw this output "More than one file was found with OS independent path 'META-INF/AL2.0"? I already add this:
    packagingOptions {
            
    exclude 'META-INF/DEPENDENCIES'
            
    exclude 'META-INF/LICENSE'
            
    exclude 'META-INF/LICENSE.txt'
            
    exclude 'META-INF/license.txt'
            
    exclude 'META-INF/NOTICE'
            
    exclude 'META-INF/NOTICE.txt'
            
    exclude 'META-INF/notice.txt'
            
    exclude 'META-INF/ASL2.0'
            
    exclude 'META-INF/main.kotlin_module'
        
    }
    but it have no effects. Im using also Kotlin Gradle DSL. and my AS version is Android Studio 4.0.1 Build #AI-193.6911.18.40.6626763, built on June 24, 2020 Runtime version: 1.8.0_242-release-1644-b01 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1237M Cores: 8 Registry: ide.new.welcome.screen.force=true, ide.balloon.shadow.size=0 Non-Bundled Plugins: org.jetbrains.kotlin, com.google.services.firebase, com.thoughtworks.gauge
    m
    • 2
    • 2
  • k

    Kulwinder Singh

    07/25/2020, 8:33 AM
    open class BaseViewModel {
        private val _event = SingleLiveEvent<Events>()
        val event: LiveData<Events> = _event
    
        sealed class Events {
            data class ShowMessage(val message: String) : Events()
        }
    }
    
    class LoginViewModel : BaseViewModel() {
    
        object LoginSuccess : Events()
        //Cannot access '<init>': it is private in 'Events'.
        // This type is sealed, so it can be inherited by only its own nested classes or objects.
    }
    is there a way to achieve it somehow ? i'm getting ->
    Cannot access '<init>': it is private in 'Events'.This type is sealed, so it can be inherited by only its own nested classes or objects.
    j
    j
    e
    • 4
    • 6
  • e

    Eugene

    07/27/2020, 10:37 AM
    Hey Community! 🙌 JetBrains and I are looking for android developers who have something to say about Kotlin adoption for Android development. 1. Please, DM me and share contacts of people who had problems with adoption or even can't use Kotlin in the company because of some reason. 2. Also, if you had problems at the beginning with Koltin, then share what it was using thread (or dm me to keep it private). And please, specify the year/month if possible. Thanks in advance, and happy coding! ✌️ :kotlin:
    👍 9
    c
    h
    +5
    • 8
    • 9
  • j

    Justin Tullgren

    07/28/2020, 2:40 PM
    Hi everyone. Does anyone recommend a websocket client/server library for use with android?
    a
    n
    +3
    • 6
    • 8
  • d

    Deepti M

    07/28/2020, 4:23 PM
    Hi There, Has anybody worked on ExoPlayer? I am finding black background before my video starts and want to remove it. Any suggestion, how can I achieve it? Thanks!
    y
    g
    • 3
    • 12
  • p

    pollux-

    07/28/2020, 7:44 PM
    You have two tables in Room(Rx), let say A & B. You have to check in table A, if the value returned is valid then check table B and return the result. Else return error to the user. How can this be done using single stream in Rx. Any suggestions?
    g
    p
    • 3
    • 9
  • a

    Archie

    07/29/2020, 6:03 AM
    @Ian Lake May I ask a question about Navigation Component? Back in the Days where we directly mange
    FragmentTransaction
    ourselves, we have situation where we need to jump to a certain destination fragment but also have to create the backstack along the way. For example:
    A -> B -> C -> D
    so in code we do:
    fun jumpToDFromA() {
        // Assuming in in A
        fragmentManger.beginTransaction()
            .replace(id, B())
            .addToBackStack("state1")
            .setReorderingAllowed(true)
            .commit()
    
        fragmentManger.beginTransaction()
            .replace(id, C())
            .addToBackStack("state2")
            .setReorderingAllowed(true)
            .commit()
    
        fragmentManger.beginTransaction()
            .replace(id, D())
            .addToBackStack("state3")
            .setReorderingAllowed(true)
            .commit()
    }
    With this, I am able to Jump to
    D
    but also have the backstack
    A -> B -> C
    . Is this possible to do in
    Navigation Component
    ?
    a
    o
    +2
    • 5
    • 15
  • v

    Vincent Williams

    07/29/2020, 8:06 PM
    tasks.register("clean", Delete::class) {
        delete(rootProject.buildDir)
    }
    this is the default clean task. Does this need to look different for multi-module projects or will this work just fine? maybe
    delete(rootProject.buildDir)
    needs to be run on each buildDir? im not sure though
    g
    • 2
    • 21
  • c

    Chethan

    07/30/2020, 7:04 AM
    Dear Team, I want to find out width and height of the view which is holding wrap content OR match parent . we know that height and width of the view will be available only when the view is shown on the screen, once the view is drawn to screen. Is there way I can find out this earlier before the view is drawn on the screen ? My requirement is to make network call to bring exact image size which is same as view size on the screen
    o
    a
    • 3
    • 7
  • r

    ritesh

    07/30/2020, 8:12 AM
    Hi Everyone, Wondering if any know or worked on any alternative to 
    SYSTEM_ALERT_WINDOW
      to display an overlay across all activities. Why not use 
    SYSTEM_ALERT_WINDOW
      and Services like every other stackoverflow solution tells me to do that. Requirement is to add a chat feature in the app, that would be available across all activities in minimized view once initiated - you can start a chat within one activity and keep it live when changing activities. Solution -> Use this permission, and create a service, to overlay across all screens.
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    Problem with the requirement we have ->  1. I don't need a view visible over all applications - a view visible only to our app. 2. Using the above solution requires run time permission from users for api level above >=M. 3. User can disable this permission from settings, and overlay won’t work. 4. this permission is not available on all devices, and I suspect that it will be retired in a year or two.
    k
    • 2
    • 5
  • k

    Kulwinder Singh

    07/30/2020, 12:49 PM
    Hi, did anyone worked on Paging 3, i want to know how we can mutate one item from paged list https://stackoverflow.com/questions/63171749/how-can-we-mutate-items-loaded-using-paging-3-android
    g
    j
    c
    • 4
    • 10
  • g

    George Theocharis

    07/30/2020, 1:40 PM
    Hello all 👋 Quick question does the navigation component support shared element transitions from fragment to a second activity?
    a
    i
    b
    • 4
    • 10
  • a

    Arpan Sarkar

    07/30/2020, 5:28 PM
    I have two android app module one is
    :user
    and
    :admin
    in admin module if i create any Navigation Resource File it showing in the Navigation Editor Design tab, but if i crate any Navigation Resource File in the user module its not showing in the Navigation Editor Design tab. But every defined actions are working properly. I tried deleting
    .idea
    folder Invalidating Cache, still same issue. How can is resolve this issue?
    i
    • 2
    • 2
  • v

    vesp

    07/30/2020, 5:45 PM
    Apologies if this question isn't Kotlin enough but I have a question about this bit of code. 1. Will
    externalStorageVolumes
    only return two elements max? Will the first element always be phone storage that isn't removable? 2. Is that
    map
    efficient? I think it looks a little verbose and I'm not sure how to tighten it up
    Untitled.kt
    z
    • 2
    • 3
  • o

    OG

    07/30/2020, 5:59 PM
    What would be the best way to go about creating a waveform "seek bar" like the one in Instagram app, or sound cloud, to progress through a song for example. The waveform seekbar in Instagram seems to be bundled into a horizontal recyclerview which seems weird to me.. but I'm guessing the right way to go about it is to create a custom view that handles gestures and does the scroll animation of the waveform/seekbar itself, rather than creating a waveform/seekbar and just plopping it in a recyclerview as a list of just one item.
    a
    • 2
    • 2
  • h

    Horv

    07/30/2020, 10:18 PM
    Found the issue, I was using LiveData-directly, instead of
    observeAsState
    f
    j
    • 3
    • 5
  • a

    allan.conda

    07/31/2020, 7:18 AM
    Should/will the error be removed in future Kotlin versions when using
    .not()
    ?
    Untitled.kt
    v
    v
    t
    • 4
    • 4
  • j

    ja.son

    07/31/2020, 2:35 PM
    Hello! Can't I update the view if I submitlist on ListAdapter? I'd like to update ViewHolder again.
    k
    b
    • 3
    • 2
  • j

    Joshua

    07/31/2020, 5:40 PM
    Any clue why I get the background like that? I want to make my rounded corners more visible...
    :stackoverflow: 1
    k
    j
    +2
    • 5
    • 11
  • d

    Deepti M

    07/31/2020, 8:47 PM
    Hi Guys, Is there any listener for finding the recycler-view state when data is rendered, or something like that? Please let me know. Thanks!
    👋 2
    :stackoverflow: 1
    o
    g
    • 3
    • 2
  • m

    Marcin Środa

    08/01/2020, 6:26 AM
    Hi! I’ve got a weird case. Let’s take a sample function:
    fun test(channel: List<String> = listOf(), channelGroups: List<String> = listOf())
    Any idea how to set one parameter as “required”? I understand that the best way will be separate function to 2 different usecases, but in my scenario I need to accept: • not empty channel list • not empty channel groups • both not empty channel and channel groups
    l
    r
    z
    • 4
    • 4
  • r

    Remy Benza

    08/01/2020, 12:28 PM
    I'm using a LottieAnimationView in an Android app. I want to use a cached version so performance is better and the JSON parsing does not show a short flicker. Problem is I want to use a negative speed (which will play the animation backwards) based on a boolean condition
    • 1
    • 6
  • s

    Slackbot

    08/01/2020, 3:14 PM
    This message was deleted.
    r
    s
    • 3
    • 6
  • b

    brandonmcansh

    08/02/2020, 12:41 AM
    Cc'ing this here for more visibility
    a
    • 2
    • 2
Powered by Linen
Title
b

brandonmcansh

08/02/2020, 12:41 AM
Cc'ing this here for more visibility
a

Afzal Najam

08/03/2020, 3:43 AM
As long as this is still open: https://github.com/kotlin/KEEP/issues/110 Yes, providing a companion object wrapper is probably your best bet.
b

brandonmcansh

08/03/2020, 12:21 PM
thanks @Afzal Najam Less than ideal, but realistically is probably a small subset of users at this point.
View count: 4