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

    Shalom Halbert

    02/24/2019, 3:54 PM
    This may be an odd question. Would updating all states versus just one at a time consume more battery? I.e. Could it be that MVI is less battery efficient than MVVM since all states are updated every-time one state changes, rather than only the changed state being updated when it changes?
    g
    s
    • 3
    • 4
  • r

    rkeazor

    02/24/2019, 6:59 PM
    @Shalom Halbert I would say No architecture doesnt have any correlation with Battery consumption. They will all get turned into bitecode. With that being said, its important to try and write efficient code
    s
    g
    +2
    • 5
    • 25
  • u

    ubu

    03/06/2019, 7:44 PM
    Hi there. I have a question about clean architecture. Is there some good practice to follow when dealing with use case (i.e. some single operation) result when you want to share it between, say, different view models or interactors?
    g
    • 2
    • 1
  • u

    ursus

    03/08/2019, 3:49 AM
    can one instance be technically part of 2 viewgroups?
    e
    k
    • 3
    • 12
  • u

    ursus

    03/10/2019, 4:56 PM
    as you know in general upperlayer should not know who is using it
    g
    • 2
    • 2
  • u

    ursus

    03/10/2019, 5:02 PM
    -- Guys, back to the reactions / slack example, would you put views which might get used only sometimes (like Edited, and Reactions) in your item view and the just visible/gone them, or viewstub, or dynamically add/removeView ?
    g
    • 2
    • 2
  • o

    oday

    03/11/2019, 11:27 PM
    but just packages
    g
    d
    • 3
    • 34
  • u

    ursus

    03/12/2019, 9:17 PM
    tldr; how to figure out what to delete from locals, if remotes are paginated
    g
    g
    b
    • 4
    • 110
  • g

    ghedeon

    03/18/2019, 6:22 AM
    There we go: https://developer.android.com/reference/android/app/Activity.html#onTopResumedActivityChanged(boolean)
    😆 2
    u
    • 2
    • 2
  • u

    ursus

    03/18/2019, 5:43 PM
    Should the app handle this or should I just throw my arms in the air and not commit the whole transaction?
    g
    • 2
    • 5
  • g

    ghedeon

    03/19/2019, 10:29 AM
    The more I use shared viewmodels like google suggests, the more I think it's a bad practice. (It's when you share activity VM between multiple fragments). You end up having 2 VM's for one fragment view. You pull something from the activity VM, something from the fragment VM, multiple sources of truth, thats already against the idea of 1:1 view-controller relation. So, probably to make it cleaner, you can try to merge 2 VMs via some sort of VMReducer, trying to combine some livedatas, idk.. Eventually, in your fragment VM you'll introduce some init call,
    initWithDataFromActivityVM()
    that you'd call in onViewCreated, which is again seems stupid, because ideally you'd want a normal constructor injection... Looks like a mess so far. Wouldn't a dagger scope be a perfect fit? Like, define a shared data holder and scope it to the activity and inject it into your fragments?
    r
    • 2
    • 8
  • u

    ursus

    03/20/2019, 4:31 AM
    I think I can live with all the other views being added programatically via kotlin, but how can I make for example the <ImageView> be child of NestedWhatever. Afaik if added as the latter samples, its gonna be on the same level as NestedWhatever, right?
    g
    r
    • 3
    • 11
  • u

    ursus

    03/31/2019, 4:17 PM
    How do you guys deal with thumbnails in apps? Whats the best way of future proofing this? Should the app tell backend what resolution the screen is and backend scale the image accordingly, or rather backend provide N sizes and app picks the best one? Do you also recalculate this based on current resolution?
    m
    r
    • 3
    • 25
  • d

    dewildte

    04/10/2019, 7:12 PM
    The use case in my mind would be to ensure the UI receives all it's states upon starting so I can do animations, or am I cray cray?
    g
    m
    +2
    • 5
    • 18
  • u

    ursus

    04/15/2019, 11:56 PM
    yea I dont worry about that, Im just naively asking if there is an issue with downloading for example lets say 3 1GB in parallel
    g
    • 2
    • 1
  • u

    ursus

    04/15/2019, 11:57 PM
    and if having it singlethreaded would not actually be better perf wise
    g
    • 2
    • 92
  • g

    ghedeon

    04/17/2019, 7:47 PM
    Currently looking for examples of Server Driven UI on android. Simply, some kind of screen representation (ex. in json form) is pushed by server and rendered by client. Links and articles are much appreciated, thank you.
    s
    s
    +2
    • 5
    • 9
  • a

    alexsullivan114

    04/18/2019, 8:58 PM
    Question for those who use RxBindings - I noticed the following warning while moving to add the library to a new app I'm working on:
    Warning: The created observable keeps a strong reference to
    view
    . Unsubscribe
    * to free this reference. Since we're not supposed to hold hard references to an activity or fragment or view in a
    ViewModel
    from the architecture components, should we avoid passing an observable produced via RxBindings into a
    ViewModel
    ?
    :yes: 1
    ☝️🏻 1
    c
    d
    +2
    • 5
    • 67
  • u

    ursus

    04/26/2019, 6:44 PM
    Does anyone have a logging interceptor for okhttp, that is not totally useless with parallel requests? How the fck am I suppsed to read interleaved lines 😕
    a
    r
    • 3
    • 12
  • u

    ursus

    04/29/2019, 1:55 AM
    Guys, does it make sense to have 2 of the same vector drawable, with only different size? Do I get some perf benefit? Why do they even have size if its vector? Shouldnt I only chose image view size?
    g
    • 2
    • 2
  • r

    Rok Koncina

    05/01/2019, 4:25 PM
    Custom view and MVP So, I have a slightly complex custom view for adding and removing items: + and - buttons and "add" button when you have 0 items selected. There are disabled states if you can't get over or below some value. The view is heavily reused, mostly (but not exclusively) inside recycler views, on different elements, multiple screens. So now the question - how to structure the code in the MVP pattern? Does this custom view get it's own presenter? If yes, how does it connect to the main presenter (and how to handle recycling in this case)? Else, do I have to repeat the logic in each presenter for each screen or inject some kind of controller and pass it through the adapter to items (in which case, what's the difference with individual presenters)?
    c
    • 2
    • 6
  • u

    ursus

    05/02/2019, 5:59 AM
    + This presumes SELECT * projections..How about partial projections? Would you rather have scoped object of only user name and imagr url? Or full User object with name and url filled and rest of fields null?
    g
    d
    • 3
    • 287
  • u

    ursus

    05/02/2019, 4:48 PM
    or should I maybe insert the search messages into db with some flag isFromSearch=true?
    d
    • 2
    • 1
  • a

    alexsullivan114

    05/06/2019, 8:15 PM
    Has anyone who's used the navigation library figured out a way to get a reference to a newly added fragment? I'm trying to use the google places API and they provide a fragment of their own. That fragment needs a few values set on it so I'm trying to figure out how to do that.
    s
    • 2
    • 4
  • u

    ursus

    05/07/2019, 9:07 PM
    When in MVI what would you do a thing that has no diff? Like lets say some list of dynamically added buttons in a horizontal scroll view and you want to select one (and show border around it for example) by mvi it should be a click routed to viewmodel or wherever, where it copy mutates the state and emits a new tuple of list + selected index for example but now what, what about the list? only the index basically changed. Do you teardown the whole buttons list and recreate?
    b
    • 2
    • 5
  • u

    ursus

    05/11/2019, 6:08 AM
    I have 32 view types in recycler view. I think its too much. But most of them are variations of the same (like item A with and without header, or item A with big margin left to visualize nesting). Maybe it makes sense to have that be the same view type and visible/gone the header in on bindview? Is there some perf penalty to this? In my head it causes layout, but so does setting text on wrap_content height textview. What would be the heuristic to create a new viewtype if views are like that? (variations of the same?)
    m
    t
    • 3
    • 9
  • d

    dewildte

    05/11/2019, 7:01 PM
    Where would be a good place to start preparing our current applications to migrate over to the new Jetpack Compose code? Could we start wrapping views in a construct that works similar to how it works already?
    s
    r
    e
    • 4
    • 4
  • u

    ursus

    05/20/2019, 8:15 AM
    Paginating the changes is probably stupid since you need it all
    s
    • 2
    • 3
  • s

    scottiedog45

    05/22/2019, 8:30 PM
    is there a disadvantage (or is it an antipattern to) have a viewmodel for each fragment? My app architecture is one activity that switches out fragments as screens.
    🇳🇴 5
    d
    • 2
    • 2
  • s

    scottiedog45

    05/23/2019, 12:08 PM
    ^^following up, would this generally mean that a shared view model could cover this need for each fragment to be backed by a viewmodel (instead of each fragment having a standalone VM)? I don’t see why not, but a little more research has shown that a shared view model can be an efficient way to handle passing data between fragments.
    e
    d
    • 3
    • 7
Powered by Linen
Title
s

scottiedog45

05/23/2019, 12:08 PM
^^following up, would this generally mean that a shared view model could cover this need for each fragment to be backed by a viewmodel (instead of each fragment having a standalone VM)? I don’t see why not, but a little more research has shown that a shared view model can be an efficient way to handle passing data between fragments.
e

escodro

05/23/2019, 12:14 PM
I think that the SharedViewModel does not replaces the specific ViewModel. The specific one has use cases/access/data to that screen and the shared one has the data that needs to be shared. They can work together if needed.
https://developer.android.com/topic/libraries/architecture/viewmodel#sharing
s

scottiedog45

05/23/2019, 12:18 PM
so it would be more sound architecturally to have a shared VM that takes care of shared data, and a unique VM for each fragment, versus just a shared VM that handles both the shared and unique data for each screen. On the one hand, less view models, on the other hand, more specific view models…
e

escodro

05/23/2019, 12:21 PM
The problem having only one is the possibility to call a function on Fragment A that is only related to Fragment B. This can be a problem of scoping and messy when the project grows.
The example that they share on the docs are Master/Detail screen. I know that that example is very simple, but there are no
fetchData()
on this ViewModel. The fetch logic should only be accessed by the Master screen.
s

scottiedog45

05/23/2019, 12:27 PM
Gotcha. Thanks Igor 😃
😉 1
d

dewildte

05/23/2019, 4:15 PM
Another alternative to data communication is an EventBus of some kind.
View count: 3