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

    matt tighe

    07/10/2019, 5:35 PM
    is there an elegant way to achieve something like this:
    interface PreferenceAccessor {
        val fileName: String
        val context: Context
        val prefs: SharedPreferences 
                get() = context.getSharedPreferences(fileName, Context.MODE_PRIVATE)
    }
    
    class PrefAccessorImpl(ctx: Context): PreferenceAccessor {
        override val fileName: String
            get() = "somePrefFileName"
        override val context: Context
            get() = ctx
    }
    What I’m looking for is a way to define a bunch of shared preference implementations with different file names, but save on the boilerplate of using context to initialize them. i’d also like to avoid having
    Context
    objects actually injected
    :google: 1
    f
    e
    +3
    • 6
    • 20
  • f

    flaccus

    07/10/2019, 10:00 PM
    Hi everyone, I need advice for recyclerview adapter library. Any suggestions?
    :google: 2
    i
    s
    • 3
    • 2
  • d

    Darrinps

    07/11/2019, 1:19 AM
    Performance question for reading a stream of bytes concurrently while in an app (coroutine here maybe)? I'm looking for the best way to read a characteristic (BLE) that in this case, has streaming data (yes, I know it can only emit packets of 20 on BLE 4). The data will mostly be 0's which I will ignore, but at some point a tag byte (0xFF let's say) hits the stream, then after that, the next 15 bytes have significance. It could return to more 0's after or be another tag byte (0xFF) to signify the start of another 15 bytes of valid data. Now, when the connection is established and the app starts to read, it has no way to know if the stream being omitted by the BLE device is in the middle of a packet or not. The only thing we know is that there won't be a tag within the packet...only at the beginning of one. So, it's basically a process of read...read....read until we see a 0xFF, grab the next 15 bytes, process it, then start again...read read read.... Thoughts?
    r
    • 2
    • 3
  • z

    Zaraki596

    07/11/2019, 12:25 PM
    ActivityFile.kt
    s
    • 2
    • 2
  • z

    Zaraki596

    07/11/2019, 1:33 PM
    secondactivity.kt
    • 1
    • 1
  • d

    darkmoon_uk

    07/12/2019, 12:06 AM
    Anyone else encountered problems with Android lint class-path in a mixed Android/JVM multi-module project. The whole project assembles just fine! But lint fails with:
    Execution failed for task ':android-client-common:lint'.
    > Configuration with name 'compileClasspath' not found.
    j
    • 2
    • 2
  • b

    Ben Skiff

    07/12/2019, 12:11 AM
    does anyone have any experience testing material-ui components with espresso? Is there a library for viewmatchers available or will i need to write some custom view matchers? (Note - sorry if this is the wrong channel - I just requested an invite to the android community channel)
    p
    • 2
    • 1
  • d

    dawidhyzy

    07/12/2019, 10:49 AM
    How to disable kotlinx.android.synthetic? This doesn’t work:
    androidExtensions {
        features = ["parcelize"]
    }
    j
    i
    t
    • 4
    • 5
  • j

    Jinal Barot

    07/15/2019, 6:42 AM
    Does anyone have idea how to solve this error : "only safe (?.) Or non-null asserted(!!.) Calls are allowed on a nullable receiver of type cursor?" I'm trying to extract contacts using ContactsContract content provider by query which return response as a Cursor
    g
    l
    • 3
    • 4
  • s

    Suraj Shah

    07/15/2019, 10:54 AM
    Is the
    maven_push.gradle
    by Chris Banes still a good way to push aars to maven central? Also, https://github.com/quiph/RecyclerView-FastScroller
    :yes: 1
    ❤️ 1
    j
    s
    g
    • 4
    • 8
  • k

    Kulwinder Singh

    07/16/2019, 7:06 AM
    i have to use two fields of
    object
    in almost every activity, so therfore i have to create variables in each activity, i'm creating this variables to just use shorter names nothing else.
    private val api 
           get() = UserRestApi.instance
       private val authorization
           get() = AccountUtils.userAuthToken
    So now my question is that i'm thinking to create
    interface
    like below.
    interface Networking {
        val api
            get() = UserRestApi.instance
        val authorization
            get() = AccountUtils.userAuthToken
    }
    and then in each activity i will implement this interface and then i will directly access this
    api
    and
    authorization
    variables. so i don't have to create this variables in each activity, so like below i just have to
    implement
    Networking
    interface and i have access to this variables
    class MyActivity : AppCompatActivity(), Networking {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.my_activity)
            api.loadSomething(authorization)// so by implementing Networking i can access this fields
        }
    }
    **1. So is something bad in this approach ? 2. is there any other solution to this problem in kotlin ?**
    j
    v
    +3
    • 6
    • 9
  • j

    Joao Birk

    07/16/2019, 2:01 PM
    Hi there, does anyone have tried App Links? I have added the
    assetlinks.json
    with the correct pkg name and SHA I have set the
    android:autoVerify="true"
    for the
    intent-filter
    I have added:
    <meta-data android:name="asset_statements" android:resource="@string/asset_statements"/>
    I have tested:
    <https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain.name:optional_port&relation=delegate_permission/common.handle_all_urls>
    But I still get the chooser. Anything else I'm missing?
    s
    • 2
    • 2
  • d

    Darrinps

    07/16/2019, 3:26 PM
    What happened to Parcelable? Used to work fine for me when it was experimental, now it gripes that "Class SOMECLASS is not abstract and does not implement abstract member public abstract fun writeToParcel(po: Parcel!, p1: Int): Unit defined in android.os.Parcelable
    s
    • 2
    • 2
  • s

    SrSouza

    07/16/2019, 7:03 PM
    Hi guys, any one know how to suspend support is impl on room? I want to know if he use withContext to IO and if is safe to use in UI/Main thread without blocking and without using withContext to IO
    d
    • 2
    • 1
  • a

    AlexJuca

    07/17/2019, 6:38 AM
    BiometricKit is a simple to use and android fingerprint authentication Library written in pure kotlin for Android M (API 23) and above that follows the material design guidelines. Any feedback will be appreciated! https://github.com/AlexJuca/BiometricKit
    a
    • 2
    • 2
  • n

    Nikola Milovic

    07/17/2019, 10:12 AM
    Using this( https://github.com/JamesFT/Database-Quotes-JSON/blob/master/quotes.json ) and gson i keep getting an error that
    java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
    :google: 1
    m
    • 2
    • 3
  • a

    adams2

    07/17/2019, 10:44 PM
    if I were using
    @Parcelize
    and had this member
    val someMap: Map<String, Any>
    , do I need to add an
    @TypeParceler
    • 1
    • 4
  • f

    fada21

    07/18/2019, 1:23 PM
    anyone getting decent coverage measures?
    m
    i
    +2
    • 5
    • 12
  • d

    dnp

    07/19/2019, 1:31 PM
    hi anybody knows how to debug coroutines in Android?
    g
    a
    • 3
    • 5
  • g

    girafferson

    07/19/2019, 4:49 PM
    Hello, I am using the suspend in retrofit and when I make a call it immediately throws ConnectionException when there's no internet connection. My question is, shouldn't it be waiting for the timeout? I'm using timeout in httpclient and in an interceptor. Here is the error thrown: https://pastebin.com/QKLB34j8 The error says after 30000ms but it definitely does not wait that long. Any help very much appreciated!
    d
    a
    r
    • 4
    • 6
  • g

    g_robl

    07/19/2019, 9:43 PM
    Hello, I am trying to create an instance of a Builder class (
    Place.Builder().setLatLong(LatLong(x,y)).build()
    ) but I get `Cannot create an instance of an abstract class`; Place.Builder is an abstract class in Java.
    g
    • 2
    • 2
  • в

    Виталий Перятин

    07/20/2019, 7:28 AM
    How much is RxJava needed now, when Kotlin features replace a lot of Rx functions?
    j
    p
    a
    • 4
    • 5
  • p

    pavi2410

    07/20/2019, 11:04 AM
    Thanks Kotlin for making this utility function soooooo simple 🤗🙃😋
    fun ImageView.loadImage(
            url: String?,
            @DrawableRes placeholder: Int? = null,
            circular: Boolean = false,
            roundedCorners: Int = 0
    ) {
        Glide.with(context)
                .load(url)
                .apply {
                    placeholder?.let { apply(RequestOptions().placeholder(it)) }
                    if (circular) {
                        apply(RequestOptions.circleCropTransform())
                    } else if (roundedCorners != 0) {
                        apply(RequestOptions.bitmapTransform(RoundedCorners(context.dip(roundedCorners))))
                   }
                }
                .into(this)
    }
    I would love to get any suggestions/improvements to this function.
    d
    k
    +3
    • 6
    • 12
  • v

    vapoyan

    07/22/2019, 6:01 AM
    Where do you keep your Extension methods?
    p
    u
    +4
    • 7
    • 15
  • d

    dave08

    07/22/2019, 8:06 AM
    Do coroutines flows replace LiveData, or should they be used side by side? If they do replace them, is it enough to use the view's lifecycle scope to manage cancelling when the view is gone?
    a
    g
    +3
    • 6
    • 59
  • k

    kevin.cianfarini

    07/22/2019, 10:56 PM
    I've heard conflicting views on this, but should I be avoiding the Kotlin synthetics for binding views?
    j
    r
    p
    • 4
    • 10
  • w

    william

    07/23/2019, 3:44 AM
    if i access my view via a synthetic binding, can i access it in all lifecycle methods or only after
    onCreateView
    (for a
    Fragment
    )
    v
    r
    • 3
    • 6
  • i

    ignus

    07/23/2019, 7:27 AM
    Is there any Logging library which works for Kotlin modules and Android modules but I can change implementation to whenever/whatever I want (e.g. change implementation to Timber on Application onCreate).
    g
    p
    • 3
    • 32
  • s

    Slackbot

    07/23/2019, 11:11 AM
    This message was deleted.
    d
    d
    • 3
    • 4
  • s

    scienticious

    07/23/2019, 12:04 PM
    Hi, is it good to change default implementation of Android Methods through data binding For e.g if use this method @BindingAdapter("android:src") public static void setImageUrl(ImageView view, String url) { Glide.with(view.getContext()).load(url).into(view); } in xml <ImageView android:id="@+id/icon" android:layout_width="40dp" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_alignParentTop="true" android:layout_marginRight="6dip" android:contentDescription="TODO" android:src="@{obj.url}" />
    g
    c
    w
    • 4
    • 5
Powered by Linen
Title
s

scienticious

07/23/2019, 12:04 PM
Hi, is it good to change default implementation of Android Methods through data binding For e.g if use this method @BindingAdapter("android:src") public static void setImageUrl(ImageView view, String url) { Glide.with(view.getContext()).load(url).into(view); } in xml <ImageView android:id="@+id/icon" android:layout_width="40dp" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_alignParentTop="true" android:layout_marginRight="6dip" android:contentDescription="TODO" android:src="@{obj.url}" />
g

gildor

07/23/2019, 12:49 PM
It’s pretty bad approach IMO Much better to be explicit and use special binding name for it, like imageUrl instead of android:src
👍 3
But it should work, probably you just didn’t apply databinding dependencies to kapt or kapt plugin itself
c

czuckie

07/23/2019, 1:03 PM
as a dev adopting a code base, I'd curse the guy who decided to override the default like that, just as a personal opinion
➕ 2
w

Will Shelor

07/24/2019, 2:04 AM
In this case, you're not overriding the default (which takes a drawable)- you're applying a different type (string) to the default name. I actually like this, as it doesn't pollute your autocomplete. We try to avoid overriding the default behavior, though.
we actually override src, but also include extra elemnts, like "placeholder" and "error"
View count: 5