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

    Joshua

    07/07/2020, 9:09 AM
    How come that upper-left button in the toolbar (default) navigates me back properly to the previous fragment but the upper right button (my implemented button) which is called via
    navController.navigate(R.id.action_global_goOnlineFragment)
    takes me to an empty fragment? All other fragments will also be displayed as empty... the only thing that loads properly is the toolbar. Please help me I have been scrathing my head for too long
    :stackoverflow: 1
    n
    • 2
    • 2
  • n

    Nikola Milovic

    07/07/2020, 4:45 PM
    What is a deeplink URI for another module? I am trying to deeplink 2 fragments together from different modules and connect them via deeplinks (as I cannot find any other way) and Idk how to structure the URI's. (here is the more detailed question on stackoverflow, ive went through 4,5 projects now and a couple of articles but they're horrible for getting started) This is the example from the article
    <deepLink app:uri="myApp://fragmentD"/>
    What does myApp represent, and how is it structured? By directories, or modules?
    j
    i
    • 3
    • 10
  • s

    Shawn Karber_

    07/07/2020, 8:49 PM
    I am trying to make a kotlin library for android for the first time, and I have what seems like a dumb question: Do i always have to add the dependencies from my library module into the gradle file of the app I'm importing the library into? Example. In my module I am using Ktor to fetch a file. I import the module into an a different android application but the application wont build without also adding Ktor its Gradle file. Is there a way to ensure the these dependencies are automatically included with the module?
    👍 1
    c
    t
    +2
    • 5
    • 8
  • m

    Michael Friend

    07/08/2020, 3:09 PM
    Im trying to test a ViewModel that lazily loads data when the LiveData is accessed and first emits a Loading state, the loads the data, then emits a Data state with the result. The data is loaded in a coroutine on the viewModelScope and I’m using TestCoroutineScope and MockK in my test but for some reason my mock observer doesn’t get the loading emission unless I pause the dispatcher then resume it. Here’s a basic example of my issue
    // The view model 
    class LazyViewModel(val repo: Repo) : ViewModel() {
        val state: LiveData<State<String>> by lazy {
            loadData()
            _state
        }
    
        private val _state = MutableLiveData<State<String>>()
        private fun loadData() {
            viewModelScope.launch {
                _state.value = State.Loading
                _state.value = State.Data(repo.getData())
            }
        }
    }
    // the test
        @Test
        fun `get loading then data`() = coroutinesTestRule.testScope.runBlockingTest {
            val mockObserver: Observer<State<String>> = mockk(relaxUnitFun = true)
    
            val mockRepo: Repo = mockk {
                coEvery { getData() } returns "data"
            }
            val viewModel = LazyViewModel(mockRepo)
            // If I don't pause then resume the dispatcher _state.value = State.Loading seemingly gets skipped
            pauseDispatcher()
            viewModel.state.observeForever(mockObserver)
            resumeDispatcher()
            verifyOrder {
                mockObserver.onChanged(State.Loading)
                mockObserver.onChanged(State.Data("data"))
            }
        }
    m
    • 2
    • 9
  • p

    paulex

    07/08/2020, 3:26 PM
    Good Afternoon.. ladies and gentlemen... Please i've been struggling on how to increase the padding of an Android Chip, all efforts have failed... The Chip is create programmatically.
    val chip = Chip(mContext).apply {
                    setPadding(130)
                    setTextAppearance(R.style.ChipTextStyle_ProductList)
                    isCheckedIconVisible = true
                    setTextColor(ContextCompat.getColorStateList(mContext, R.color.chip_state_list_bg))
                    chipBackgroundColor = ContextCompat.getColorStateList(mContext, R.color.chip_bg_state_list)
                    isCloseIconVisible = true
                    text = item.name
                }
    t
    • 2
    • 2
  • d

    Diayan siat

    07/08/2020, 5:40 PM
    Hi guys can someone help me, I have been trying to load an image from a url without an extension and haven't had any success. this is what I have: val url ="https://unsplash.com/photos/D8LcRLwZyPs"
    Picasso.get()
        .load(url)
        .fit()
        .centerCrop()
        .into(imageView)
    but this does not work
    b
    h
    • 3
    • 5
  • m

    Madalin Valceleanu

    07/09/2020, 6:30 AM
    I’m excited to announce that my open-source sample project about
    Android Modular Architecture
    just reach 1K ⭐️ on
    Github
    . Maybe sounds insignificant if you compare with video reproductions or a post likes on twitter. But isn’t, the project is among top 10 github projects in Kotlin related with Android Architecture Sample with several mentions/references like
    Android Weekly
    ,
    AndroidSweets
    ,
    Droidcon
    and
    KotlinBy
    . I want to say thank you ❤️ in this way for all the support received by the
    android/kotlin developer community
    and I hope that some of the architecture decisions taken help you to apply/inspire to your current or next project. Of course, nothing is perfect and this project isn’t an exception, there are a lot of things to improve, but the iteration is the key to my point of view. Project Link: https://github.com/VMadalin/android-modular-architecture
    🎉 5
    👍 11
    f
    • 2
    • 1
  • l

    Lilly

    07/09/2020, 2:54 PM
    Hi, I'm looking for the kotlin equivalent of
    Map<Class<? extends AbstractCode>
    I tried
    Class<? : AbstractCode>
    and
    Class<Any : AbstractCode>
    .Can someone help me please?
    m
    • 2
    • 3
  • s

    Slackbot

    07/09/2020, 3:15 PM
    This message was deleted.
    :stackoverflow: 1
    o
    t
    • 3
    • 2
  • a

    Andrew Kuryan

    07/09/2020, 4:04 PM
    Hey guys, can anyone advise a library for building android ui using dsl? From the requirements: at least a 1000 stars on the github and the last commit no later than a year ago.
    e
    c
    +2
    • 5
    • 4
  • d

    Deepti M

    07/09/2020, 6:04 PM
    Hi There, I am working with an exoplayer in a grid and it is consuming too much memory. Can anybody provide me any guidance on how to manage exoplayer in a grid? Thanks!
    g
    • 2
    • 5
  • l

    Lilly

    07/09/2020, 6:13 PM
    Hi, I have following class
    open class XModemPacket(protected var bytes: ByteArray = ByteArray(133))
    Can someone give me a hint, how I can have the getter public. I want that every sub class can set it and can be obtained from outside.
    m
    • 2
    • 2
  • j

    Joe Jensen

    07/09/2020, 11:37 PM
    Hi Everyone! I'm currently investigating Jetpack compose and how it might work for our project going forward, but we are heavy users of Dagger in the current world of Android. One project I've been looking around in is the JetNews app, and there is no use of Dagger or Hilt. Any idea how Dagger/Hilt will play with Compose? I'd imagine composables would end up being injectable, just like fragments and activities are right now.
    z
    m
    • 3
    • 4
  • n

    Nikola Milovic

    07/12/2020, 10:25 AM
    Hey guys what approach would you use to have something like this? (Multiple horizontal recviews, and other stuff underneath it etc..) I dont think nested scroll view works for this nor mergeAdapter. Just a general direction to look into is appreciated. I am aware SO is more fitting as this isnt specific to kotlin, but I dont have a concrete problem nor a question, so Id probably get shamed or ignored there.
    u
    k
    c
    • 4
    • 4
  • a

    Antonio

    07/12/2020, 11:36 AM
    Hello, how can i center a Toolbar text without using TextView tag inside the Toolbar?
    :stackoverflow: 6
    • 1
    • 1
  • d

    Deepti M

    07/12/2020, 9:29 PM
    Hey Guys, I received NullPointerException in logs even after putting a check for 'null'. Can anyone tell me how and when can I get NullPointerException for checking "isPreview" in the below statement...
    if (lastWallpaperEngine != null && !lastWallpaperEngine!!.isPreview) {
    }
    Logs received in play-store...
    java.lang.NullPointerException: 
      at android.service.wallpaper.WallpaperService$Engine.isPreview (WallpaperService.java:390)
      at VideoWallpaperEngine.onSurfaceDestroyed (VideoWallpaperService.java:158)
    v
    j
    • 3
    • 3
  • c

    Chethan

    07/13/2020, 9:18 AM
    CPU utilization is going 200% and above when I am working with Android Studio, How can over come this ?
    g
    • 2
    • 27
  • m

    Mohamed Ibrahim

    07/13/2020, 12:16 PM
    How I could achieve something like this in edittext? add like an indicator to hint about the typed text
    r
    • 2
    • 2
  • s

    sriram

    07/14/2020, 12:54 AM
    For Folks using ViewBinding -- I have a question, I am not sure if this is a bug. We have been using ViewBinding and so far it looks good, however, for a scenario where I wanted to include layouts that reside in a different library(AAR) in my app's current layout, unfortunately my binding variable has no visibility of the views that are available within the included layout, is this a known issue or is there any other way?
    l
    j
    • 3
    • 13
  • l

    Loboda Deni

    07/14/2020, 6:40 AM
    What do you think, to what extent is it permissible to load dataBinding with logic? for example, if I need to process a click on a button, should I create a separate interface for this event, or is it permissible to directly call viewModel methods to handle this event? for example, if all the presentation logic is one single click, would it not be unnecessary to create a separate interface for this?
    g
    • 2
    • 21
  • a

    Awodire babajide samuel

    07/14/2020, 11:34 AM
    Can i get a tutorial that specifically points to the MVP/MVVM in android development, necessary details on the structure ( packages/ modules ) in android studio, a short reference??
    b
    • 2
    • 2
  • p

    paulex

    07/14/2020, 2:18 PM
    Afternoon... I have a
    RecyclerView
    that uses a
    PagedListAdapter
    which fetches data from
    ROOM
    and Network API. It uses a
    BoundaryCallback
    to make request to the API of which the data returned is inserted into the Database(ROOM) i have a list item that has an increment and decrement button... I have attached an image of the list... The current list is filterable, e.g i can filter the list of products by category Problem If i increase a product item quantity using the increment button, to e.g 12 and then i try to add more to filter the list by, the current list doesn't refresh which is fine because the
    DiffUtil.ItemCallback
    confirms that the items are the same, but once i try to increment that same product's quantity after filtering by more category, it starts from zero again.... So i'm not really sure what the problem really is: below is the code that does the increment and decrement.
    override fun onIncrementQuantity(position: Int, item: ProductEntity) {
        item.quantity = item.quantity + 1
        selectedProducts[item.item.id!!] = item
        productAdapter?.notifyItemChanged(position, item)
    }
    
    override fun onDecrementQuantity(position: Int, item: ProductEntity) {
        item.quantity = if (item.quantity == 0) 0 else item.quantity - 1
        if (item.quantity == 0) {
            selectedProducts.remove(item.item.id)
        } else {
            selectedProducts[item.item.id!!] = item
        }
        productAdapter?.notifyItemChanged(position, item)
    }
    :stackoverflow: 2
    v
    • 2
    • 9
  • l

    Loboda Deni

    07/14/2020, 2:24 PM
    Does anyone know if there have been studies regarding the build speed of a project on kts vs groovy?
    o
    c
    • 3
    • 9
  • l

    Luis Munoz

    07/14/2020, 3:43 PM
    anyone know of any good books or courses on the android operating system itself not developing apps?
    👍🏼 1
    f
    g
    • 3
    • 2
  • o

    Ofir Bar

    07/14/2020, 5:18 PM
    Hey guys, junior here
    Car
    is a class, which extends an abstract class
    Vehicle
    I didn't write a constructor for
    Vehicle
    . why the compiler complains?
    z
    • 2
    • 6
  • s

    Slackbot

    07/14/2020, 8:07 PM
    This message was deleted.
    :stackoverflow: 1
    👎 1
    o
    d
    • 3
    • 2
  • h

    Hafs

    07/14/2020, 11:05 PM
    https://twitter.com/hafs_r/status/1283172524180869122?s=21
    🇳🇴 1
    v
    • 2
    • 2
  • l

    Loboda Deni

    07/15/2020, 6:52 AM
    Hi. I want to write an extension in buildSrc, something like this: fun List <String> .kapt () {this.forEatch {kapt (it)}}, but in buildSrc there is no visibility on the kapt method. can I somehow connect kotlin-kapt here, or will I call this method in another way?
    g
    • 2
    • 34
  • l

    Loboda Deni

    07/15/2020, 8:41 AM
    I just found out about the existence of Jetpack Compose. Is this technology already widely used? Should you think about switching to it?
    g
    • 2
    • 1
  • s

    sandi

    07/15/2020, 8:47 AM
    What happened to https://kotlinlang.org/docs/tutorials/android-plugin.html ? It used to show documentation for Android extensions eg. synthetic view bindings. Now it just redirects to a generic “Kotlin for Android” page. Have the docs moved somewhere else?
    e
    • 2
    • 3
Powered by Linen
Title
s

sandi

07/15/2020, 8:47 AM
What happened to https://kotlinlang.org/docs/tutorials/android-plugin.html ? It used to show documentation for Android extensions eg. synthetic view bindings. Now it just redirects to a generic “Kotlin for Android” page. Have the docs moved somewhere else?
e

Eugene

07/16/2020, 8:59 AM
Just wondeting, what information are you looking for? Maybe if you'll specify it will be easy to find it
s

sandi

07/16/2020, 10:24 AM
General usage on view bindings. Basically I’m looking for this documentation: https://web.archive.org/web/20191207171002/https://kotlinlang.org/docs/tutorials/android-plugin.html but up-to-date.
e

Eugene

07/17/2020, 8:54 AM
As far as I know, completely all documentation located in developers.android.com. Not sure kotlinlang is a good place to look for Android-specific things.
👍 1
View count: 3