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

    Shahzad Aslam

    11/19/2019, 11:19 PM
    I think
    Approach 1
    is better because in option 1 caller of interactor (which is viewmodel) don’t have to worry about which dispatcher the interactor will use. And interctor knows if it is doing network or some computation it knows about the context and which dispatcher it should use. While in
    Approach 2
    interactor is performing the operation in parentContext and the caller should know about the right context/dispatcher it should use before calling the function.
    s
    c
    +3
    • 6
    • 16
  • u

    ursus

    11/21/2019, 8:27 AM
    How do you receive in the app? Do you use the DynamicLinks.getInstance.getDynanicLink thing or interogate the intent yourself?
    g
    • 2
    • 11
  • u

    ursus

    11/26/2019, 9:17 PM
    Tricky question: how do you handle item clicks in RecyclerView? do you recreate listeners every onBind? do you create listeners in constructor and pass in cached field Item? do you do the same but pass in adapterPosition, and pull out the object from the list at adapter level?
    a
    a
    • 3
    • 14
  • u

    ursus

    12/03/2019, 4:08 AM
    Folks who map domain model down to ui model
    a
    s
    g
    • 4
    • 27
  • s

    Sergey B

    12/04/2019, 3:56 PM
    Hi folks. how do you deal with requesting permissions in mvvm paradigm?
    s
    i
    +2
    • 5
    • 11
  • u

    ursus

    12/05/2019, 7:12 AM
    Which way of rendering sealed class hierarchy do you prefer?
    1️⃣ 3
    e
    r
    s
    • 4
    • 14
  • u

    ursus

    12/07/2019, 3:24 AM
    Has anyone attempted to have swipe-to-dismiss items in recycler view + unidirectional data flow? Should the item stay swiped out (but other items still are stationary, i.e. there is a hole) until the next emit of the List? which then diffs it and removed the item? or would this be too slow? (if its all backed by a db)
    t
    • 2
    • 8
  • m

    Madalin Valceleanu

    12/09/2019, 9:37 AM
    https://proandroiddev.com/android-components-architecture-in-a-modular-word-7414a0631969
    👍 8
    s
    • 2
    • 1
  • a

    Anastasia Finogenova

    12/09/2019, 8:29 PM
    So what do you all think about having reference to view in xml with databinding, like creating a variable of type Fragment or Activity and then setting it into binding to invoke methods directly on click for example
    j
    s
    r
    • 4
    • 30
  • u

    ubu

    12/12/2019, 9:22 PM
    Hi guys, what would be the best presentation pattern for implementing a rich text editor on Android? What do you think?
    a
    s
    u
    • 4
    • 7
  • s

    sanmi

    12/14/2019, 1:20 PM
    How do you handle dagger scoping using single activity Achi. Let's say I'd like to share a viewmodel amongst my reg fragments. How do I do it without creating another activity?
    t
    g
    • 3
    • 9
  • j

    Jason

    12/17/2019, 3:09 AM
    I were applying MVVM to my project and there is no problem so far, but I just confuse is there any problem with MVVM or what problem that MVVM can not resolve…
    t
    u
    +3
    • 6
    • 15
  • b

    Brendan Weinstein

    12/17/2019, 7:43 PM
    I recommend https://twitter.com/VasiliyZukanov/status/1206211507551375360?s=19 for some useful framing on design pattern trade-offs. One concept I like from CoRedux (https://github.com/freeletics/CoRedux) is you can use the design to enforce a log of all state changes. This is useful for sending breadcrumbs on crash reports. I have been playing around with implementing a similar pattern using coroutine flows. If we expand the discussion to what are some of the best ways to write an application, I am jealous that react/redux devs can replay state and hot reload.
    r
    • 2
    • 3
  • a

    Adam Hurwitz

    12/19/2019, 11:00 PM
    What do Android devs think of the Unidirectional Data Flow + LiveData pattern in Kotlin? In version 2.0 I improved the view events, effects, and cleaned up the ViewModel with Kotlin Coroutines. 👩‍💻🏻 https://proandroiddev.com/udf2-0-5052c3e1c62a?
    👏 1
    ❤️ 1
    d
    • 2
    • 2
  • u

    ursus

    12/23/2019, 5:23 AM
    to allow for parallel compilation of core, but have features depends on whole core still?
    g
    • 2
    • 10
  • j

    Jérôme Gully

    12/25/2019, 6:18 PM
    Hello, I follow this codelabs (https://codelabs.developers.google.com/codelabs/kotlin-android-training-coroutines-and-room/#3) and at any moment it's explained why we must write a custom ViewModelFactory. In my project I used
    ViewModel by viewModels()
    to avoid boilerplate code, so I'm a bit confused about it.
    • 1
    • 1
  • d

    Daniel

    12/25/2019, 10:21 PM
    Thoughts on the SharedPreferences component needed: Would you prefer a single class where all shared preferences are located (see example below) or would you have several classes which handle a subset of preferences? Or even several shared preferences? Currently thinking about the pros and cons of each and I am leaning to a single class. Since there I am sure that there are never duplicate keys (because they are not scattered over several classes) and I can immedeately say what the application saves in the preferences.
    class Preferences(private val sharedPreferences: SharedPreferences) {
        private companion object {
            private const val GENERATED_LEVEL_INFO_SEEN_KEY =
                    "generatedLevelInfoSeenKey"
    
           // ...
        }
    
        var generatedLevelInfoSeen by BooleanPreference(
                GENERATED_LEVEL_INFO_SEEN_KEY, false)
    
        // ...
    
        private inner class BooleanPreference(
                private val key: String,
                private val default: Boolean) {
    
            operator fun getValue(thisRef: Preferences, property: KProperty<*>) =
                    sharedPreferences.getBoolean(key, default)
    
            operator fun setValue(thisRef: Preferences, property: KProperty<*>, value: Boolean) =
                    sharedPreferences.edit { putBoolean(key, value) }
        }
    }
    p
    a
    • 3
    • 3
  • h

    Hitanshu Dhawan

    12/28/2019, 9:29 AM
    Hey guys, I am using LiveData coroutines KTX extension for my project. https://developer.android.com/topic/libraries/architecture/coroutines#livedata The code is something like this.
    ViewModel/Repository
    fun getData() = liveData {
        val a = getFromDB()
        emit(a)
        val b = getFromNetwork()
        emit(b)
    }
    View
    viewModel.getData().observe(this, Observer{
        // do ui stuff
    })
    This works perfectly fine. But the problem is now I want to add Swipe to Refresh feature, and want that the entire
    liveData {}
    block to run again. How do I trigger a refresh call to the
    getData()
    LiveData? One solution which is mentioned here (https://stackoverflow.com/a/58689791) is to introduce another
    MediatorLiveData
    and remove and re-add the
    liveData {}
    block on refresh. But I don't want to add 2 LiveDatas and it also seems like a hack. Any good and elegant solution for this guys? Thanks.
    v
    • 2
    • 3
  • u

    ursus

    12/29/2019, 2:45 AM
    Is name Repository established forever? I always read it as a Dao basically. I'd call is Manager. Should I just get used to it?
    s
    g
    +2
    • 5
    • 24
  • k

    Kashif

    12/31/2019, 11:46 AM
    DatSource is meant to load data from one source
    h
    • 2
    • 2
  • u

    ursus

    01/03/2020, 7:15 AM
    Given I call some async rx stuff in the view model constructor, and usual recommendation to have synchronous schedulers swapped in for testing, wouldnt this mean that I can never assert State.Loading? (Since Loading is emitted synchronously, so is then Success, now ctor is exited, and now I can test the state observable, meaning atleast I would miss Loading)
    s
    k
    d
    • 4
    • 32
  • i

    Ivann Ruiz

    01/03/2020, 5:34 PM
    Hi all 👋 what are your thoughts on having the
    ViewModel
    be a
    LifecycleObserver
    so it can react to the view's lifecycle? There's some good arguments for each scenario: on one hand we don't want the
    ViewModel
    to "_know"_ about the view's lifecycle, however, it may also help make the
    View
    as dumb as possible and have more logic be done on the
    ViewModel
    .
    h
    d
    • 3
    • 7
  • u

    ursus

    01/06/2020, 2:22 PM
    repository you have rxjava and viewmodels? I dont follow
    i
    • 2
    • 2
  • i

    ivano

    01/07/2020, 1:02 PM
    class Car() :MovingObjects{
        val carParts = CarParts()
        val carFunctionalities =CarFunctionalities()
        
    }
    
    class CarParts():MovingObjects(){
            fun engine(): Engine
            fun wheel(): Wheel
            fun doors():Doors
    
        } 
    }
    class CarFunctionalities():MovingObjects{
        fun switchOn()
        fun maxVelocity(): Int
    }
    👍 1
    a
    d
    u
    • 4
    • 34
  • g

    ghedeon

    01/13/2020, 10:53 PM
    People that are implementing UI as a set of custom components / widgets (aka Design System from Airbnb, Spotify), how does it look like? Custom views? Wrappers that return views? How does the widget interface looks like?
    👍 4
    🤔 1
    m
    u
    • 3
    • 13
  • u

    ursus

    01/17/2020, 5:21 PM
    but if I need to create changes for app2 in core, should I then create a :core-core, with base class, and then :core-app2 with the mutation? same for app1 now
    i
    a
    j
    • 4
    • 3
  • s

    Slackbot

    01/21/2020, 9:46 PM
    This message was deleted.
    a
    u
    • 3
    • 12
  • r

    Rohit Surwase

    01/23/2020, 12:11 PM
    I have seen, generally we pass instance of Repository to a ViewModel through Factory.
    class MainViewActVM(val repository: AppRepository) : ViewModel(){
    }
    
    //...Our Activity/Fragment
    private val mainViewActVM: MainViewActVM by lazy {
    ViewModelProviders.of(this, ReminderViewActVM.Factory(AppRepository.getInstance(this))).get(MainViewActVM::class.java)
    So instead of doing this why can’t (don’t) we use following
    class MainViewActVM(application: Application) : AndroidViewModel(application) {
        private val repository: AppRepository = AppRepository.getInstance(application)
    .....
    }
    What are the downside of using second approach?
    f
    s
    +4
    • 7
    • 17
  • u

    ursus

    01/26/2020, 12:14 AM
    I worry about the no-sql dbs being abandonned etc, its always some small company
    e
    • 2
    • 4
  • m

    moizest89

    01/29/2020, 5:31 PM
    I’ve checked the follow examples https://github.com/android/architecture-samples but the basic clean project has injection dependence 😞
    g
    a
    • 3
    • 3
Powered by Linen
Title
m

moizest89

01/29/2020, 5:31 PM
I’ve checked the follow examples https://github.com/android/architecture-samples but the basic clean project has injection dependence 😞
g

gabrielfv

01/29/2020, 5:38 PM
There are a few with Koin that I'd have to google for rn but without DI I don't really know. But you can always abstract the DI out of the example, since it doesn't change how the classes should behave.
a

Anastasia Finogenova

01/29/2020, 10:35 PM
To increase the testability and get the most of the clean architecture it makes a lot of sense to use DI pattern, it can be your custom service locator or koin or something else but it does make more sense to always use this pattern
👍 4
m

moizest89

01/30/2020, 1:20 PM
Thanks guys!!! ^_^
View count: 5