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

    Justin Yue

    06/24/2021, 6:12 AM
    I'm looking to wait for a coroutine to finish before continuing with some other processes. From what I've found in Kotlin and Android documentation,
    async
    would be my best bet since it returns a
    Deferred
    that "represents a promise to provide a result later." However, I am not looking to wait for a result to be return. While I know I could probably return a dummy value (probably a boolean to represent the coroutine finished), are there any other alternatives to
    async
    ?
    l
    • 2
    • 4
  • s

    Saidiali

    06/24/2021, 8:18 AM
    Hello, I want to integrate video calls in my android app. Is there any open source api I can use, i dont mind if it is free or not. Thanks in advance.
    :not-kotlin: 5
    a
    • 2
    • 2
  • h

    Hovhannes

    06/24/2021, 11:45 AM
    Hello, everybody, I created an app with Hilt DI, but I'm new at DI. The app works well, but when I remove Hilt's annotations, the app works well again. How is possible? Can Hilt work without its annotations.
    :not-kotlin: 3
    a
    c
    k
    • 4
    • 9
  • c

    Cole K

    06/24/2021, 11:48 PM
    Hey I have a search toolbar
    <?xml version=“1.0” encoding=“utf-8"?>
    <com.google.android.material.appbar.AppBarLayout xmlns:android=“http://schemas.android.com/apk/res/android”
    android:layout_width=“match_parent”
    android:layout_height=“wrap_content”
    android:background=“@null”>
    <FrameLayout
    android:layout_width=“match_parent”
    android:layout_height=“wrap_content”>
    <com.comapny.apps.view.custom.ui.MyToolbar
    android:id=“@+id/toolbar”
    style=“@style/AppTheme.Toolbar”
    android:layout_width=“match_parent”/>
    <com.comapny.apps.view.custom.SearchView
    android:id=“@+id/search_view”
    android:layout_width=“match_parent”
    android:layout_height=“wrap_content”
    android:layout_gravity=“bottom”
    android:visibility=“invisible”/>
    </FrameLayout>
    </com.google.android.material.appbar.AppBarLayout>
    It seems like I can only see the shadow under my search view when I
    include
    the layout in other views. When I use it as a custom ui component (
    <com.company.apps.view.custom.ui.SearchToolbar/>
    ), it does not show the shadow. Any idea as to why?
    :not-kotlin: 6
    k
    c
    • 3
    • 3
  • a

    aniruddha dhamal

    06/25/2021, 4:23 PM
    Hello, How to inject variable in kotlin extension function? I have dependency that is provided through Hilt. I'm trying to create extension function which will use default value as this dependency.
    r
    • 2
    • 9
  • s

    Slackbot

    06/26/2021, 5:25 AM
    This message was deleted.
    i
    a
    a
    • 4
    • 4
  • v

    Vivek Modi

    06/26/2021, 10:04 PM
    What is the use of flow. In which case it can be use any suggestions for this ?
    g
    t
    g
    • 4
    • 15
  • t

    Timo Drick

    06/26/2021, 11:16 PM
    Is it possible to load classes during runtime in Android? So can i compile a class and convert it to dex and than load this dynamically inside of a running android app?
    :not-kotlin: 4
    e
    r
    • 3
    • 8
  • d

    David Martin

    06/27/2021, 2:43 AM
    Good morning guys, Do you know how long does it take for Android kill an activity when it moved to background(onPause, onStop)? I mean exactly time for ex: 1 minute.
    :not-kotlin: 2
    k
    • 2
    • 1
  • d

    David Martin

    06/27/2021, 2:44 AM
    Example context: I open an app then I press device’s home button and I leave the app in the background, so how many second or minute this app will be terminate by Android?
    :not-kotlin: 3
    r
    c
    t
    • 4
    • 14
  • m

    Mark

    06/27/2021, 3:08 AM
    Using Android Studio 4.2.1 with Kotlin 1.5.20 plugin. However, in my gradle scripts I still have Kotlin 1.4.32 specified. I’ve noticed, for example, that
    Char.toInt()
    is marked as deprecated so I change it to
    Char.code
    and add
    @OptIn(ExperimentalStdlibApi::class)
    . This seems to work but how is that possible considering
    Char.code
    is 1.5+?
    r
    d
    • 3
    • 5
  • a

    Alexandru Martin

    06/27/2021, 1:14 PM
    Hello there, I have some questions about nav_graph, hope anybody can help me. Thank's a lot. Every activity should contain a navigation graph? It is ok if I have just activities and I don't use a navigation graph? If I have one host activity, how many fragments are ok to use for navigation? There is a stack that remains in memory and which I can overload? When I need activities and when I need fragments?
    :not-kotlin: 2
    r
    i
    m
    • 4
    • 7
  • p

    Pedro Azevedo

    06/27/2021, 6:43 PM
    I need to talk with some that understands using Firebase with Kotlin , I know its very simple but I think I lost my line of thought
    c
    • 2
    • 1
  • p

    Pedro Azevedo

    06/27/2021, 8:03 PM
    Im using Kotlin with Firasebase. Imagine , on the document I have username and username , how do I get that data into new variables
    k
    • 2
    • 1
  • p

    PhongBM

    06/28/2021, 2:23 AM
    I use Navigation and I have a lot of subgraph (nested graph). How to navigate to specific Fragment in nested graph (other startDestination).
    :not-kotlin: 5
    i
    m
    • 3
    • 10
  • n

    Nicolas Verinaud

    06/28/2021, 2:16 PM
    [SOLVED] Hi ! I used to run my unit tests using a gradle configuration running through Android Studio but it does not show the test pane anymore. 😞 Do you know how to get it back ?
    Android Studio 4.2.1 / KMM Plugin 0.2.6
    m
    • 2
    • 2
  • s

    Sean Aguirre

    06/29/2021, 1:14 AM
    Hello! I'm not new to Kotlin, but I am new to Kotlin Native. I'm trying to just get a basic multiplatform application up and running. I want to create an application that's for Android and iOS. The problem I'm having is with creating the initial project, I can't seem to find the drop down for
    Xcode build phases (packForXcode task)
    in the
    iOS framework distribution
    on step 5 in the tutorial: https://kotlinlang.org/docs/mobile/create-first-app.html. I did complete the initial set up just fine for step 1 FYI. Which is the KMM set up (https://kotlinlang.org/docs/mobile/setup.html) Attached a screenshot of the drop down values. All it shows is
    Regular framework
    and
    CocoaPods dependency manager
    . Any help would be appreciated, and if I'm going about setting up this project improperly (even though this is what the docs state) let me know. Thanks!
    a
    • 2
    • 3
  • s

    Slackbot

    06/29/2021, 7:15 AM
    This message was deleted.
    a
    m
    • 3
    • 2
  • j

    JungIn Choi

    06/29/2021, 9:05 AM
    I usually import drawables as png images in three sizes (1x 2x 3x), and all of the sudden I got curious if there’s any better method🤔 Maybe I’m using a very old & inefficient way that takes app capacity so.. any tips on optimizing app size w.r.t. image resource?
    :not-kotlin: 8
    m
    c
    • 3
    • 4
  • s

    Slackbot

    06/29/2021, 1:38 PM
    This message was deleted.
    :thread-please: 10
    🤦 3
    :not-kotlin: 7
    i
    i
    • 3
    • 7
  • a

    Aidooyaw1992

    06/29/2021, 10:46 PM
    can anyone help me with best practices in writing input validation functions in kotlin
    c
    c
    • 3
    • 3
  • m

    MAYANK SINGHAL

    06/30/2021, 4:56 PM
    Can anyone please help in making this type of progress bar
    :android-new: 1
    :not-kotlin: 21
    d
    • 2
    • 1
  • z

    Zun

    06/30/2021, 6:51 PM
    Just me or does this not make sense? How can it return from within withContext?
    z
    e
    a
    • 4
    • 5
  • s

    Slackbot

    07/01/2021, 3:58 AM
    This message was deleted.
    e
    s
    • 3
    • 4
  • h

    haris mehmood

    07/01/2021, 7:16 AM
    Can any please suggest sdk for calling like whatsapp?\
    :not-kotlin: 10
    :google: 8
    d
    • 2
    • 3
  • w

    Waqas Tahir

    07/01/2021, 10:30 AM
    How to serialize kotlin delegates in kotlin serialization library ?
    j
    • 2
    • 1
  • j

    Jacare_krk

    07/01/2021, 7:44 PM
    Hello, do you have any tutorial on hilt in multi module project? I want to iternalize my modules' usecases and implementations but when doing it straightforward hilt doesn't find dependencies
    :not-kotlin: 2
    b
    j
    t
    • 4
    • 13
  • j

    Jorge Cordero

    07/01/2021, 8:22 PM
    Hi everyone, I’m new here, quick question. (not sure if it belongs to this channel) Does anybody know when the Google Associate Developer certification will include Compose or how can I get more information about this?
    :not-kotlin: 2
    q
    • 2
    • 2
  • h

    Hovhannes

    07/02/2021, 7:03 AM
    Hello everybody, I want to convert Dagger into Hilt, but I'm new at Hilt. I get these non  understandable errors. What mistakes did I make?  Thanks in advance.
    error: [Dagger/MissingBinding] com.example.feed.feedApp cannot be provided without an @Inject constructor or an @Provides-annotated method.
      public abstract static class SingletonC implements HiltWrapper_ActivityRetainedComponentManager_ActivityRetainedComponentBuilderEntryPoint,
                             ^
          com.example.feed.feedApp is injected at
              com.example.feed.dagger.viewmodel.FeedViewModelModule.providePauseAbleObservable(feedApp)
          com.example.feed.util.PauseAbleObservable<?> is injected at
              com.example.feed.viewmodel.FeedViewModel(�, PauseAbleObservable)
          com.example.feed.viewmodel.FeedViewModel is injected at
              com.example.feed.viewmodel.FeedViewModel_HiltModules.BindsModule.binds(vm)
          @dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map<java.lang.String,javax.inject.Provider<androidx.lifecycle.ViewModel>> is requested at
              dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [com.example.feed.feedApp_HiltComponents.SingletonC ? com.example.feed.feedApp_HiltComponents.ActivityRetainedC ? com.example.feed
    FeedViewModelModule.kt
    @Module
    @InstallIn(ActivityComponent::class)
    class FeedViewModelModule {
    
        @Provides
        fun providePauseAbleObservable(feedApp: FeedApp):  PauseAbleObservable<*> {
            return PauseAbleInterval(
                { System.currentTimeMillis() },
                sportsFeedApp.resources.getInteger(R.integer.pollingPeriodSeconds).toLong(),
                TimeUnit.SECONDS
            )
        }
    }
    PauseAbleObservable.kt
    interface PauseAbleObservable<T> {
         val observable: Observable<T>
    
        fun pause()
    
        fun resume()
    }
    FeedViewModel .kt
    @HiltViewModel
    class FeedViewModel @Inject constructor(
        private val feedRepository: FeedRepository,
        var pauseAbleObservable: PauseAbleObservable<*>
    ) : ViewModel() {....}
    :thread-please: 5
    :not-kotlin: 3
    i
    • 2
    • 1
  • i

    Ink

    07/02/2021, 11:31 AM
    How Can I add Headers for sections in my item list? I sorted and grouped by
    Category
    items in my list and now I want to add Header for each single section.
    model.apply {
        val archiveList: MutableList<ArchiveItem> = mutableListOf()
        val itemList: MutableList<ListItem> = mutableListOf()
    
        archives.map {
            archiveList.add(
                ArchiveItem(
                    category = it.translateToCategory(it.domain.toString()),
                    title = it.title,
                    agreementNumber = it.agreementNumber,
                    startDate = it.startDate
                )
            )
            archiveList
                .sortedBy { it.category }
                .groupBy { it.category }
                .apply { 
                    itemList.add(ArchiveListHeader(title = "My category"))
                }
        }
    
        itemList.addAll(archiveList)
    
        items = itemList
    
    }
    :not-kotlin: 5
    • 1
    • 1
Powered by Linen
Title
i

Ink

07/02/2021, 11:31 AM
How Can I add Headers for sections in my item list? I sorted and grouped by
Category
items in my list and now I want to add Header for each single section.
model.apply {
    val archiveList: MutableList<ArchiveItem> = mutableListOf()
    val itemList: MutableList<ListItem> = mutableListOf()

    archives.map {
        archiveList.add(
            ArchiveItem(
                category = it.translateToCategory(it.domain.toString()),
                title = it.title,
                agreementNumber = it.agreementNumber,
                startDate = it.startDate
            )
        )
        archiveList
            .sortedBy { it.category }
            .groupBy { it.category }
            .apply { 
                itemList.add(ArchiveListHeader(title = "My category"))
            }
    }

    itemList.addAll(archiveList)

    items = itemList

}
:not-kotlin: 5
Is it possible to simplify that code?
model.apply {
    items =  archives.groupBy { it.domain }
        .map {
            listOf(ArchiveListHeader(it.key ?: ""))
                .plus(
                it.value.map {
                    ArchiveItem(
                        category = it.translateToCategory(it.domain.toString()),
                        title = it.title,
                        agreementNumber = it.agreementNumber,
                        startDate = it.startDate
                    )
                }
            )
        }
        .flatten()
}
View count: 10