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

    mg6maciej

    05/22/2017, 12:59 PM
    I'd avoid using
    p0
    and
    p1
    as argument names to make code shorter. Rather remove unnecessary
    ?
    here and there.
    l
    m
    • 3
    • 3
  • m

    Moe

    05/22/2017, 1:43 PM
    Did anyone here install studio 3.0
    l
    r
    d
    • 4
    • 11
  • s

    sankarvaiyapuri

    05/22/2017, 1:51 PM
    @Moe Yep. I did
    m
    • 2
    • 2
  • c

    cuddlecheek

    05/22/2017, 2:51 PM
    I have list of events in recyclerview and in each row I want to show the time elapsed since the event with precision to seconds. The event objects have property time as Instant (from java8 datetime api). How can I update the time data every second?
    :stackoverflow: 3
    m
    • 2
    • 6
  • r

    rwachol

    05/22/2017, 3:32 PM
    @ihor.kucherenko nice. why not databinding ? not complaining, just want to know if there’s some issue 🙂
    c
    • 2
    • 2
  • z

    zak.taccardi

    05/22/2017, 4:49 PM
    with official kotlin support in 3.0, do you still need to apply the
    kotlin-android
    plugin?
    i
    l
    • 3
    • 7
  • k

    khacpv

    05/22/2017, 5:06 PM
    Hello, I'm trying Kotlin today. ✨ ✨ Seem
    kotlin-android-extensions
    only support for productFlavours without buildTypes. import
    kotlinx.android.synthetic.debug.activity_main
    but not success. How do you know use the plugin with buildTypes (ex: debug & release)? 🙌
    v
    t
    l
    • 4
    • 5
  • r

    ra1nmak3r

    05/22/2017, 10:42 PM
    What to use instead hungarian notation?
    g
    • 2
    • 1
  • b

    blakelee

    05/23/2017, 6:14 AM
    How do I convert this to a lambda?
    viewModel.getClasses().observe(this, object : Observer<MutableList<Classes>> {
                override fun onChanged(classes: MutableList<Classes>?) {
    
                }
            })
    Kotlin is yelling at me about the
    object : Observer<MutableList<Classes>>
    part Is this the same as the previous?
    viewModel.getClasses().observe(this, Observer<MutableList<Classes>> {
                it?.let { classAdapter.notifyDataSetChanged() }
            })
    i
    • 2
    • 4
  • c

    chris.zou

    05/23/2017, 8:17 AM
    Hi there, I wonder if there is a way that I can calculate the diff between two objects? Say, I have a
    person1 = Person(name = "chris", age = 18)
    , and
    person2 = Person(name = "chris", age = 20)
    , Is there a way that I can check the diff between person1 and person2 is property
    age
    , besides checking the properties one-by-one myself?
    d
    m
    • 3
    • 6
  • s

    smuldr

    05/23/2017, 9:06 AM
    I'm trying to update to kotlin 1.1.2-4, but getting this error:
    * What went wrong:
    Circular dependency between the following tasks:
    :dto:compileReleaseKotlin
    \--- :dto:kaptReleaseKotlin
         \--- :dto:compileReleaseKotlin (*)
    Anyone else with the same issue?
    v
    • 2
    • 1
  • i

    igroeg

    05/23/2017, 9:24 AM
    I'm java dev and want to develop some android apps. Whit what language should i start? Kotlin or Java? Please have in mind that i'll need some reaources, tutorials and support from the community.
    d
    • 2
    • 1
  • a

    audhil

    05/23/2017, 12:37 PM
    Hi, is there a simple way to add spinning progress bar in all activities/fragments for sometime. I'm not a fan of adding progress bar in all layout files. any suggestions? anything different you tried.
    d
    • 2
    • 7
  • m

    myanmarking

    05/23/2017, 12:56 PM
    you can, for example, create a method in a base class, that find the rootView and add it programatically when showing, or remove it when hidding
    a
    i
    • 3
    • 10
  • i

    ihor.kucherenko

    05/23/2017, 5:02 PM
    “Android Architecture Components” https://medium.com/proandroiddev/android-architecture-components-cb1ea88d3835
    👍🏼 2
    m
    • 2
    • 3
  • j

    jw

    05/23/2017, 5:11 PM
    we don't bind anything in fragments, dialogs, or activities
    i
    • 2
    • 1
  • d

    Daniel

    05/23/2017, 9:19 PM
    Might I ask how you guys use a logging framework in code that has to be unit tested? Standard Android Log. provokes the not mocked exception.
    m
    l
    • 3
    • 9
  • j

    janechung

    05/23/2017, 11:14 PM
    Has anyone run into kapt causing Circle to fail by exceeding the 4G memory limit? (sorry if this has already been asked)
    s
    • 2
    • 2
  • v

    vmironov

    05/24/2017, 1:25 PM
    removeOnGlobalLayoutListener(this)
    j
    • 2
    • 1
  • a

    alex.hart

    05/24/2017, 4:09 PM
    What is the actual output of the exception? It should tell you a little more than “what chunk of code” it happens in
    z
    d
    m
    • 4
    • 7
  • y

    yperess

    05/24/2017, 4:29 PM
    Does anyone know how I can use Dagger 2 to inject dependencies for an object? I'm looking to do something like: data API { @Inject val Auth: AuthenticationApi } Then have AuthenticationApiImpl for the actual implementation. Then in testing be able to provide a new dependency that injects MockAuthenticationApiImpl instead. I can't send to get an ApiModule working for the injection.
    a
    d
    • 3
    • 4
  • m

    myanmarking

    05/24/2017, 4:41 PM
    but why not
    data API(val auth: AuthenticationApi) ...
    y
    • 2
    • 1
  • j

    jw

    05/24/2017, 5:18 PM
    @kirillrakhman use
    @JvmSuppressWildcard
    to get rid of the extends
    k
    • 2
    • 1
  • k

    kirillrakhman

    05/24/2017, 5:24 PM
    I tried the following:
    @Binds @IntoMap @ClassKey(UserViewModel::class)
            abstract fun bindUserViewModel(vm: UserViewModel) : UserViewModel
    
            @Binds @IntoMap @ClassKey(UserViewModel::class)
            abstract fun bindUserViewModel(vm: UserViewModel) : ViewModel
    
            @Binds @IntoMap @ViewModelKey(UserViewModel::class)
            abstract fun bindUserViewModel(vm: UserViewModel) : UserViewModel
    
            @Binds @IntoMap @ViewModelKey(UserViewModel::class)
            abstract fun bindUserViewModel(vm: UserViewModel) : ViewModel
    where
    @MustBeDocumented
    @Target(AnnotationTarget.FUNCTION)
    @Retention(AnnotationRetention.RUNTIME)
    @MapKey
    annotation class ViewModelKey(val value: KClass<out ViewModel>)
    k
    • 2
    • 5
  • m

    mg6maciej

    05/24/2017, 8:39 PM
    :kotlin:otlinize! #inlinereified
    inline fun <reified T : ViewModel> FragmentActivity.getViewModel(key: String? = null): T {
        val provider = ViewModelProviders.of(this)
        return if (key != null) {
            provider.get(key, T::class.java)
        } else {
            provider.get(T::class.java)
        }
    }
    usage:
    userViewModel = getViewModel()
    instead of:
    userViewModel = ViewModelProviders.of(this).get(UserViewModel::class.java)
    👍 1
    :kotlin: 4
    s
    • 2
    • 3
  • p

    Paul Woitaschek

    05/25/2017, 9:10 AM
    Because one is a phone and the other isnt?
    🤔 7
    j
    • 2
    • 11
  • r

    rwachol

    05/25/2017, 9:19 AM
    Hi. I have a problem with kotlin and android - sometimes I need to compile my project twice to see my changes (maybe something to deal with cache) Does anyone else have this problem too ?
    s
    d
    • 3
    • 14
  • r

    ravidsrk

    05/25/2017, 12:43 PM
    My sample kotlin architecture is here. This sample has example for UnitTests and Espresso tests as well. https://github.com/ravidsrk/android-mvp-kotlin-starter
    👍 1
    d
    • 2
    • 3
  • m

    manzar

    05/25/2017, 5:26 PM
    Can anyone suggest me free video tutorials for learning kotlin?
    m
    r
    • 3
    • 4
  • r

    rwachol

    05/26/2017, 8:13 AM
    can anyone recommend mocking library for kotlin ?
    d
    • 2
    • 12
Powered by Linen
Title
r

rwachol

05/26/2017, 8:13 AM
can anyone recommend mocking library for kotlin ?
d

David W

05/26/2017, 11:41 AM
rwachol: Either Mockito or JMockit
r

rwachol

05/26/2017, 11:41 AM
I had problem with final classes but got through
d

David W

05/26/2017, 11:41 AM
I've used both and Mockito is more popular and I find it easier to use, plus it has a library for easier kotlin use
r

rwachol

05/26/2017, 12:05 PM
yes, I was using mockito in that project but I was wondering if I’d have to add powermock too
d

David W

05/26/2017, 12:06 PM
nope, there is an experimental extension for mockito that you can use
let me find the doc on it
in short, it lets you mock finals without powermock
https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2#unmockable
there ya go
Mocking of final classes and methods is an incubating, opt-in feature. It uses a combination of Java agent instrumentation and subclassing in order to enable mockability of these types. As this works differently to our current mechanism and this one has different limitations and as we want to gather experience and user feedback, this feature had to be explicitly activated to be available ; it can be done via the mockito extension mechanism by creating the file src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker containing a single line:
mock-maker-inline
i use it and have no trouble using it with kotlin
r

rwachol

05/26/2017, 12:37 PM
yeah I’ve seen that. makes compilation longer
View count: 4