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

    scottiedog45

    04/05/2019, 10:11 PM
    I’m working on this android tutorial and I have the following kotlin file, and
    parent
    is coming up as undefined. Not sure what I’m doing wrong 😅
    package com.example.scottotoole.recyclerviewtutorial
    
    import android.support.v7.widget.RecyclerView
    import android.text.Layout
    import android.view.LayoutInflater
    import android.view.View
    import android.view.ViewGroup
    import android.widget.TextView
    import kotlinx.android.synthetic.main.activity_main.view.*.
    
    
    class UsersAdapter(val users: ArrayList<String>) : RecyclerView.Adapter<UsersAdapter.ViewHolder>() {
        class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
            val firstName : TextView = itemView.findViewById(R.id.firstName)
        }
    
        override fun onCreateViewHolder(p0: ViewGroup, p1: Int): ViewHolder {
            val view : View = LayoutInflater.from(parent.context).inflate(R.layout.userrow, parent, false)
            return ViewHolder(view)
        }
    
        override fun getItemCount() : Int = users.size
    
        override fun onBindViewHolder(holder: ViewHolder, p1: Int) {
            holder.firstName.text = users[p1]
        }
    
    
    }
    l
    2 replies · 2 participants
  • f

    Frankdroid7

    04/06/2019, 12:35 PM
    “Android’s ClipboardManager” by Frankdroid7 https://link.medium.com/QzmI6mRlFV
    👎 1
    m
    f
    6 replies · 3 participants
  • s

    Slackbot

    04/07/2019, 2:28 PM
    This message was deleted.
    2️⃣ 1
    1️⃣ 1
    r
    1 reply · 2 participants
  • s

    scottiedog45

    04/07/2019, 4:48 PM
    What’s the go to kotlin library for testing application flow? I understand how to write basic unit tests in kotlin, and also how to mock api responses, for my app, but I need something that can assert “when this button is tapped this new activity/these UI elements is/are showing on the screen”, so I guess it translates to testing navigation.
    l
    r
    2 replies · 3 participants
  • s

    scottiedog45

    04/08/2019, 2:15 PM
    is there an android studio equivalent for the xcode storyboard? Where I can see all the activities at the same time and give them identifiers in this context?
    s
    r
    +3
    12 replies · 6 participants
  • g

    gumil

    04/08/2019, 3:04 PM
    Is it possible to ignore a member to
    @Parcelize
    in kotlin android extensions?
    m
    3 replies · 2 participants
  • i

    iammini5

    04/08/2019, 9:43 PM
    is there any reason that Job intent from old application will be retained during application upgrade ? I am getting a weird issue that a new intent received in the upgraded application is coming from the old serialized format.
    s
    4 replies · 2 participants
  • p

    pablisco

    04/09/2019, 3:55 PM
    I’m having a very bizarre issue. In one of our modules (which is an Android lib module) we have Kotlin enabled but only a couple of Kotlin files. On all of them, when I try to do an auto complete it puts in the full path instead of adding an import at the top of the file. Has anyone observed this behaviour before? I’ve tried googling, but I’m not sure how to phrase it simply for Google to understand it (Hopefully I was clear here 😅)
    r
    3 replies · 2 participants
  • e

    es0329

    04/09/2019, 5:16 PM
    @natansalda Maybe a transitive dependency; what’s the output of
    ./gradlew dependencies
    ?
    n
    d
    10 replies · 3 participants
  • s

    scottiedog45

    04/09/2019, 7:41 PM
    I’m looking for some insight into architecture paradigms (I think) for an android app (in Kotlin 😃). Do you want to basically have one activity and use the navigation component to switch out fragments inside of it? Or, do you want to have an activity for each screen of your application?
    d
    r
    +1
    14 replies · 4 participants
  • c

    CarlosBlanco

    04/09/2019, 9:28 PM
    Hi, its possible show a viewpager in fragment that its in other fragment? something like Activity have fragment that has another fragment that has a viewpager
    :stackoverflow: 2
    r
    p
    3 replies · 3 participants
  • n

    nicka

    04/10/2019, 1:43 AM
    question: I want to sue android’s native “activity transition” outside of the context of an activity changing. the animation exists in open_enter_animation.xml and it consists of 2 animations: 1) a translation and 2) a cliprect animation. When i apply the animation to my view; the translation works as expected but the cliprect animation does not get applied. why is this? and how do I overcome it? any insight?
    g
    5 replies · 2 participants
  • a

    Adam Kirk

    04/10/2019, 2:23 AM
    Anyone know if its possible to use Mockk to mock android.util.Base64 ?? I have 2 static functions encrypt and decrypt and would like to write unit test for them. https://stackoverflow.com/questions/55603438/mocking-java-base64-with-mockk
    g
    5 replies · 2 participants
  • j

    jw

    04/10/2019, 2:25 AM
    you never need to mock that class as it's stateless and contains only pure functions
    ➕ 6
    a
    t
    +3
    33 replies · 6 participants
  • i

    iammini5

    04/10/2019, 2:47 AM
    Not sure if there is a API to cancel a existing job intent inside system. What i found is a crash happened inside the onHandleWork of a JobIntentService, the job intent then be retained and resent to the JobIntentService over and over again. It becomes very painful because the jobIntentService is implemented inside a library.
    l
    1 reply · 2 participants
  • s

    scottiedog45

    04/10/2019, 6:23 PM
    for an android kotlin project, where in the project do you usually put your networking logic? somewhere in the java > project directory?
    d
    g
    +1
    3 replies · 4 participants
  • a

    Alexandra Tsampikakis

    04/11/2019, 8:10 AM
    Hello 👋 🙂 I have a question regarding my android project. Recently I just had App1, but now I need to be able to build another apk (different package name) from the same code base, App2 So, what I did so far is to split up the app in modules like this: com.base se.app1 se.app2 both app1 and app2 depend on base in base i have a file: com.base.Constants.kt in app2 I want to override that file. So app2 also has file com.base.Constants.kt but with different values. When I run both app1 and app2 in debug everything works well! But when I am trying to generate a signed apk for app1 and app2 I get error:
    Duplicate jar entry [com/base/Constants.class]
    Does anyone know how to deals with this? Can I specify in gradle somehow to now include the Constant.kt in base? Or did I misunderstood how to use modules with multiple apps? Thankful for any answers 🙏 🙏 🙏 FYI: I know that gradle can be used to handle constants but right now I am just using that file to test if this structure of modules is possible
    r
    d
    +1
    13 replies · 4 participants
  • j

    jurajsolarml

    04/11/2019, 8:55 AM
    Hello,Can you help you ? I have bugs.How do I fix it? I tried to change gradle wraper to 4.10.2-all, open and close project, ivalidate caches/restart. https://pastebin.com/vHFwEWYj https://pastebin.com/naQuCiPQ
    :stackoverflow: 11
    l
    2 replies · 2 participants
  • j

    jw

    04/11/2019, 3:55 PM
    1.3.30
    🎉 8
    👍 13
    🚀 4
    a
    p
    4 replies · 3 participants
  • e

    eygraber

    04/11/2019, 6:30 PM
    Is the Android Studio Plugin for 1.3.30 released? I don't see it in the list of plugins to update. I somehow already have it installed 🤯
    g
    1 reply · 2 participants
  • s

    Samer Hobeika

    04/11/2019, 6:41 PM
    Anyone has a good tutorial to have sections within a recycler view ?
    g
    1 reply · 2 participants
  • z

    zokipirlo

    04/12/2019, 7:46 AM
    Can't get breakpoint working in suspend function... anyone knows why?
    g
    2 replies · 2 participants
  • g

    Geert

    04/12/2019, 8:25 AM
    I was trying out the Factory pattern. What do you guys recommend? Using a constructor or factory pattern? (I know the use of isXavailable and isXabsent is not smart, but copied something from iOS sourceCode, still need to fix this)
    g
    r
    +3
    29 replies · 6 participants
  • n

    Nelson Almendra

    04/12/2019, 10:03 AM
    Hey all! Does it make any sense to use Inject (member injection) in a ViewModel or should be only used in Activities and Fragments?
    g
    j
    2 replies · 3 participants
  • z

    zokipirlo

    04/12/2019, 11:33 AM
    In MPAndroidChart library there are
    public class LineChart extends BarLineChartBase<LineData>
    and
    public class BarChart extends BarLineChartBase<BarData>
    . How to write an extension function
    fun BarLineChartBase<what_to_insert_here?>.applyDefaultChartProperties()
    on
    BarLineChartBase
    ? Or how to write a function which accepts
    BarLineChartBase
    as parameter?
    g
    a
    5 replies · 3 participants
  • d

    Damien O'Reilly

    04/13/2019, 10:04 AM
    Is there a recommended approach to using SharedPreferences when dealing with MVVM and LiveData?
    :stackoverflow: 5
    :google: 3
    s
    g
    4 replies · 3 participants
  • r

    Rok Koncina

    04/15/2019, 9:21 AM
    Hello, I need an advice. I'm trying to implement a clean RecyclerView Adapter for multiple view types. This is as close as I can get but I can't get rid of that @Suppress annotation (or a Lint warning). Do you have any suggestion on how to clean this up even more?
    Kotlin_Generics.kt
    g
    d
    8 replies · 3 participants
  • a

    Alf_

    04/15/2019, 9:56 AM
    i.e.: Activity have an TextView that must be updated since Fragment but this TextView is a lateinit var that might not have been initialized when thisFragment updates its value. I am trying to check if it's null with ? operator but this always give me that variable cannot be null.
    g
    9 replies · 2 participants
  • d

    Damien O'Reilly

    04/15/2019, 1:11 PM
    Anyone now of a nice way to do this, I am interacting with a API, and apart from the expected response , it can give about 3 different body responses in case of an error, depending on the error. Is there any way I can with gson or moshi, attempt to deserialize to one object type, and if fail, try the next one. Similar to how circe's
    attemptAs
    work in the scala world.
    :google: 1
    :stackoverflow: 2
    1 reply · 1 participant
  • g

    gsala

    04/15/2019, 1:47 PM
    Has anyone tried to use inline classes in a Room entity? I'm trying this:
    @Entity
    data class DailySummary(
            @PrimaryKey val date: LocalDate,
            val activeTime: Duration,
            val calories: KCal // <- inline class wrapping a Float
    )
    and it doesn't work even if I provide a
    @TypeConverter
    for it. The error coming from Gradle is very meaningless so i won't post it here but changing the entity above to use
    Float
    instead of
    KCal
    automatically works. The Type Converters are these:
    @TypeConverter
        fun toKCal(value: Float?): KCal? {
            return value?.let { KCal(it) }
        }
    
        @TypeConverter
        fun fromKCal(kcal: KCal?): Float? {
            return kcal?.value
        }
    s
    r
    4 replies · 3 participants
Powered by Linen
Title
g

gsala

04/15/2019, 1:47 PM
Has anyone tried to use inline classes in a Room entity? I'm trying this:
@Entity
data class DailySummary(
        @PrimaryKey val date: LocalDate,
        val activeTime: Duration,
        val calories: KCal // <- inline class wrapping a Float
)
and it doesn't work even if I provide a
@TypeConverter
for it. The error coming from Gradle is very meaningless so i won't post it here but changing the entity above to use
Float
instead of
KCal
automatically works. The Type Converters are these:
@TypeConverter
    fun toKCal(value: Float?): KCal? {
        return value?.let { KCal(it) }
    }

    @TypeConverter
    fun fromKCal(kcal: KCal?): Float? {
        return kcal?.value
    }
s

Sam

04/15/2019, 3:03 PM
https://issuetracker.google.com/issues/124624218
g

gsala

04/15/2019, 3:05 PM
Ok... Star and wait I guess. Thanks 👍
r

rkeazor

04/15/2019, 3:07 PM
Arent inline classes still experimental? probably when they reach a more stable version, support for it will be available . it probably wouldn't make sense for them to add support now, when they api itself is subject to change in the future
g

gsala

04/15/2019, 3:09 PM
I guess that's true. I really hoped it would at least work providing the
TypeConverter
for it
View count: 3