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

    rCorbellini

    04/05/2018, 12:24 PM
    I have a function that can receive either integer as a string (in case an integer will get from context.getString), in java I create two different functions whereas the one that receives integer only makes the call to context.getString and calls the function which is expecting a parameter string. In kotlin have some more elegant aprouch, or is it recommended to do likewise?
    j
    • 2
    • 1
  • l

    leosan

    04/05/2018, 4:47 PM
    is there any refactoring option on Android Studio/IntelliJ that converts ?
    fun getFoo = ...
    to
    val foo get() = ...
    j
    • 2
    • 1
  • d

    Damien

    04/05/2018, 6:42 PM
    Are there sample implementations of the tinder animation in Kotlin?
    a
    • 2
    • 4
  • m

    Manjee

    04/06/2018, 4:39 AM
    I want to create a MindMeister like app in the Play Store But I have no idea what to study help me somebody😭
    c
    • 2
    • 1
  • a

    arekolek

    04/06/2018, 11:51 AM
    @rudolf.hladik
    If a class has a member function, and an extension function is defined which has the same receiver type, the same name and is applicable to given arguments, the member always wins.
    https://kotlinlang.org/docs/reference/extensions.html#extensions-are-resolved-statically
    r
    • 2
    • 2
  • j

    Jeevan

    04/06/2018, 2:35 PM
    https://kotlinlang.slack.com/archives/C0922A726/p1523019871000373
    :stackoverflow: 4
    g
    r
    • 3
    • 3
  • s

    Seri

    04/06/2018, 4:16 PM
    Does anyone have recommendations for managing an asynchronous UI state with Kotlin and RxJava? Jwharton’s talk here was great, but I’m not sure if there have been any developments since then:

    https://www.youtube.com/watch?v=0IKHxjkgop4&feature=youtu.be▾

    c
    a
    +2
    • 5
    • 18
  • s

    Slackbot

    04/08/2018, 4:50 AM
    This message was deleted.
    :stackoverflow: 6
    d
    • 2
    • 1
  • a

    amanda.hinchman-dominguez

    04/09/2018, 3:53 AM
    What's your opinion on Picasso? That seems to be the recommended library to use to easily grab urls and (for my case) project resource drawable images
    g
    a
    k
    • 4
    • 11
  • a

    AzMoo

    04/09/2018, 4:11 AM
    Hi, I’m trying to use a ViewModel to chain queries to an API. eg, The first query returns an invoice with customer id’s, the second query returns the customer data related to those id’s. From what I’ve been reading I need to use a MediatorLiveData to observe LiveData objects representing the API calls, but I’m not really understanding how to chain these and only return a result, once I’ve received both responses. Does anybody have some documentation or an example to help me out here?
    g
    • 2
    • 1
  • a

    amanda.hinchman-dominguez

    04/09/2018, 4:59 AM
    What would be nice if there's a way to simply get all images in a file or all available resource ids for resource. I know Kotlin has a "walking" function to grab names of files
    g
    • 2
    • 32
  • j

    Jacks0n23

    04/09/2018, 2:09 PM
    Are i understand something wrong or it's kotlin bug? I have : data class Foo ( val initializationType: InitializationType) { val isInitDefault = initializationType == InitializationType.Default } and when i call this val it's working incorrect, but when i transform it to fun or just add custom get() = initializationType == InitializationType.Default it start working like it should what the problem? P.S. InitializationType it's enum
    g
    • 2
    • 15
  • d

    dylan

    04/09/2018, 2:45 PM
    anyone know where the code for data classes annotated with
    @Parcelize
    gets generated to? Can't seem to find them in the build folder
    g
    • 2
    • 13
  • a

    amanda.hinchman-dominguez

    04/09/2018, 3:05 PM
    for a resource
    TypedArray
    , do I need to implement an iterator to be able to loop through it?
    l
    • 2
    • 2
  • t

    Tarun

    04/10/2018, 9:29 AM
    Hey I am working on a library in Kotlin In this library, if I have some variable inside
    companion object
    , than those variable are treated as static in Java But when I try to access those variable in a java project, which is using library, It is like :
    MyClass.Companion.abcVariable
    I searched and found I had to append @JvmStatic in front of variable so that java can access it directly like :
    MyClass.abcVariable
    This works for
    classes
    but for
    interfaces
    it requires a min API level of 24 and my Min API level is 21 Is there any other way to directly access companion object variables for
    interface
    in API projects supporting min API level less than 24 like :
    MyClass.abcVariable
    g
    • 2
    • 9
  • m

    moetouban

    04/10/2018, 11:33 AM
    How can i override a property and add new properties to it ?.. currently getting
    Var-property type is "X" which is not a type of overridden ?
    g
    • 2
    • 1
  • c

    chrbongardt

    04/10/2018, 4:29 PM
    Hey guys.. I have a question regarding a kotlin library I’m building for the JVM. This library should be usable in android projects and regular kotlin/java projects. I’m targeting Java 1.8 which is only partly supported by android 4.4 - However I need the library to perfectly work with android 4.4. I have had some issues where some features of java 1.8 would obviously not work on Android 4.4 and I’ve only detected those at runtime on android. What method would you suggest to avoid this issues…? Is there any linter that would check wether there are features of Java 1.8 I’m using in my code that wouldn’t run on android 4.4? Thank you in advance 😛
    g
    • 2
    • 2
  • a

    adams2

    04/10/2018, 9:18 PM
    when would
    fragment
    forget what got put in its
    setListener
    • 1
    • 1
  • t

    Tudor Luca

    04/11/2018, 7:39 AM
    is anyone having problems with android studio when editing gradle files? it’s super laggy when I start typing into a .gradle file…
    🇳🇴 1
    :yes: 3
    a
    m
    • 3
    • 3
  • i

    Ivan Podhornyi

    04/11/2018, 5:57 PM
    Could somebody share the topic/faq/story on how to test android app with roboelectric or sth else
    m
    g
    • 3
    • 3
  • g

    gildor

    04/12/2018, 8:11 AM
    not sure what is “.numeric”, probably some more sofisticated algorithm that supports such comaparsion out of the box The problem that you just cannot compare strings 9 and 11. Also, you cannot just convert string to int, because you must also sort by letter My solution is pretty simple, you just sort by int number, then by letter. You can move number split to comparator, cached value just more efficient (parse only once), but not necessary (updated sample)
    s
    • 2
    • 4
  • k

    Kevin Janvier Chinabalire

    04/12/2018, 5:08 PM
    Hey guys .. how can i get AppCode Plugin for IntellJ
    s
    • 2
    • 2
  • s

    spierce7

    04/12/2018, 6:16 PM
    @jw So the official Kotlin style guide is contradictory against the Android style guide. I know they are 2 separate style guides, but my team has been using them as complementary, as have other projects like ktlint. i.e. Android Kotlin style guide recommends a continuation indent when giving function params their own line, while the kotlin style guide recommends a normal indent. Is this intentional, meaning the guides are meant to be used independently of one another? https://android.github.io/kotlin-guides/style.html#functions https://kotlinlang.org/docs/reference/coding-conventions.html#function-formatting
    c
    r
    • 3
    • 3
  • d

    Daniel

    04/12/2018, 6:42 PM
    Is there a way to define a IntDef in Kotlin?
    g
    r
    • 3
    • 7
  • q

    Qverkk

    04/12/2018, 7:09 PM
    guys, any ideas why i'm getting this error?

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

    :stackoverflow: 3
    t
    • 2
    • 1
  • m

    memphis

    04/13/2018, 9:52 AM
    it gives me an android.os.NetworkOnMainThreadException
    :stackoverflow: 4
    g
    • 2
    • 2
  • r

    rudolf.hladik

    04/13/2018, 2:19 PM
    how does look sealed class in Java? im trying to import it to xml with databinding but java can’t see it
    l
    • 2
    • 1
  • n

    nitrog42

    04/16/2018, 3:23 PM
    I just got the most fun buildcache bug ever : I had a if(something) {} block, when something was false, it would still go in it. when I changed for if(false) {}, same issue when I removed the block, same issue I tried on another device, same issue I did clean and rebuild, same issue ./gradlew cleanBuildCache => fixed !
    m
    • 2
    • 2
  • s

    Slackbot

    04/16/2018, 4:27 PM
    This message was deleted.
    k
    • 2
    • 1
  • c

    crazdrms

    04/16/2018, 5:46 PM
    I am using dagger2 to manage the dependencies , is it possible to inject dependencies in different modules. Suppose I have set up dagger two in app and if I want to use the same dependency in a module login?
    :stackoverflow: 5
    👍 2
    a
    s
    • 3
    • 18
Powered by Linen
Title
c

crazdrms

04/16/2018, 5:46 PM
I am using dagger2 to manage the dependencies , is it possible to inject dependencies in different modules. Suppose I have set up dagger two in app and if I want to use the same dependency in a module login?
:stackoverflow: 5
👍 2
a

agrosner

04/16/2018, 7:43 PM
yes
as long as that dep is on classpath and the modules tie up into a common component class, youll all good
and one of those modules provide the dependency
c

crazdrms

04/16/2018, 8:13 PM
I cannot access the dagger generated code in my login module, is there any resources I can read so that I can solve this issue?
a

agrosner

04/16/2018, 9:02 PM
You shouldn't access any dagger generated code in your modules except the generated dagger component if you need it. But that shouldn't be necessary in a library module
c

crazdrms

04/17/2018, 12:33 PM
That's what I am trying to accomplish but I am unable to, here is the repo if it helps https://github.com/dilipMaharjan/DaggerTwoAndroid I am trying to get the User in data package to be used in login module.
a

agrosner

04/17/2018, 7:35 PM
the example login does not provide any dependencies or use dagger at all
c

crazdrms

04/17/2018, 7:57 PM
The idea is to inject User object which I get from app to LoginActivity which is what I am trying to accomplish @agrosner.Questions: Am I trying to do it right? Is there a better way to accomplish it?
a

agrosner

04/17/2018, 8:08 PM
you need to place user object in login module or in another submodule that login inherits from
c

crazdrms

04/17/2018, 8:15 PM
How does it help to accomplish injection between different modules?I haven't found any resource that explains where I can inject between modules. It would be helpful if you could elaborate or point me to an example. Thank you so much for taking time to help me out.
a

agrosner

04/17/2018, 8:31 PM
np. just create a dagger
@Module
for Login. include that in the appcomponent in your project. make a
@Module
per submodule you need that supply dependencies. if you need to inject
User
you need to place that object either in the
Login
module where you can
@Inject
it or in its own
@Module
inherited by both app and login projects
c

crazdrms

04/17/2018, 8:36 PM
Could you please modify my repo or create an example app?
s

sujin

04/25/2018, 9:06 AM
you can take a loot at this for reference: https://github.com/cerberusv2px/android-dagger-support
c

crazdrms

04/25/2018, 12:16 PM
@sujin When I said module, it meant android modules not different packages(android lib modules)
a

agrosner

04/25/2018, 1:47 PM
theres plenty of examples online. I won't do the work for you 😛
c

crazdrms

04/25/2018, 1:53 PM
I am sorry but not trying to make you work for me. I am trying to learn that's all. I am so far to communicate between the modules with new annotations but I am stuck as I am unable to understand how to inject object with Constructor parameter such as User("username","password") . For reference here https://github.com/dilipMaharjan/DaggerTwoAndroid/tree/dagger-two-with-new-annotations
s

sujin

04/25/2018, 2:45 PM
do you mean injecting data module and the login module ?
c

crazdrms

04/25/2018, 3:10 PM
@sujin I could get the injection working with new annotations but I could only inject string as I was trying out example but I want to inject the User object where I am having difficulty.This is the repo ( https://github.com/dilipMaharjan/DaggerTwoAndroid/tree/dagger-two-with-new-annotations) if it helps, where I am trying to inject User object from data module to login module
View count: 3