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

    Antoine Gagnon

    05/21/2020, 4:25 PM
    Hey everyone! Still trying to get the hang of MVVM here I’m having some issues with handling events from the view Let’s say I have a view where I can create a new flower. When I click “Add” i want my flower to be saved to my repository I’m currently calling a
    saveFlower(flowerData:FlowerData)
    method in my viewModel from my Fragment and passing it all the fields values. The ViewModel that holds my FlowerRepository is then creating the proper Flower object and saving to the FlowerRepository This feels wrong to have the ViewModel both presenting data and handling it, what should I do?
    o
    • 2
    • 4
  • u

    ursus

    05/22/2020, 7:48 AM
    How do you test repositories which touch network inside? mockwebserver+json files?
    g
    k
    • 3
    • 11
  • u

    ursus

    05/24/2020, 12:15 PM
    Given the fakes vs mocks debate, if you were to chose fakes, that means mostly that only db and network needs to be faked, all their dependants can be real
    g
    • 2
    • 2
  • u

    ursus

    05/24/2020, 12:16 PM
    so...Dagger in unit tests, and just swap out db provider maybe?
    g
    • 2
    • 1
  • u

    ursus

    05/24/2020, 12:17 PM
    what was even the issue people had against it?
    g
    m
    • 3
    • 88
  • r

    Rahul Ch

    05/24/2020, 5:44 PM
    I created my own android ribs architecture, which would help to create a super app/full modular app https://github.com/Bender-Story/android-modular-app-ribs
    💯 1
    s
    • 2
    • 1
  • n

    nino

    05/26/2020, 10:33 AM
    Can someone tell me how I can prevent creating an AbstractActivity or BaseActivity in a new project and still be able to do some customizations for all activities inside the app? E.g. setting up a custom toolbar… What’s the best approach for that?
    g
    t
    o
    • 4
    • 4
  • u

    ursus

    05/27/2020, 2:19 AM
    Is repositories depending on repositories a bad idea down the line?
    s
    t
    +2
    • 5
    • 15
  • u

    ursus

    05/28/2020, 1:56 PM
    IOfferManager+OfferManager OfferManager+OfferManagerImpl OfferManafer+ImplOfferManager OfferManager+RealOfferManager
    t
    j
    +3
    • 6
    • 6
  • r

    rkeazor

    05/28/2020, 4:52 PM
    In traditional MVVM, what do you guys consider your model(ie your networking layer) ?
    h
    o
    +2
    • 5
    • 10
  • u

    ursus

    06/13/2020, 11:20 PM
    fun <T> body(response: Response<T>): T? {
            return if (!response.isSuccessful) {
                val errorResponse = try {
                    val errorBody = response.errorBody()
                    if (errorBody != null) {
                        moshi.adapter(ErrorResponse::class.java).fromJson(errorBody.source())
                    } else {
                        null
                    }
                } catch (ex: Exception) {
                    null
                }
                val retryAfterTimestampMillis = errorResponse
                    ?.error
                    ?.retryAfter
                    ?.let(TimestampParserHelper::parseTimestampMillis)
    
                throw ApiException(
                    path = response.raw().request.url.encodedPath,
                    errorCode = response.code(),
                    errorMessage = errorResponse?.error?.errorMessage,
                    retryAfterTimestamp = retryAfterTimestampMillis
                )
            } else {
                response.body()
            }
        }
    o
    • 2
    • 1
  • u

    ursus

    06/13/2020, 11:21 PM
    I have code like this to unwrap Single<Response<T>> and throw my ApiException if needed
    h
    • 2
    • 2
  • u

    ursus

    06/13/2020, 11:21 PM
    can retrofit make this go away some way smart? or okhttp interceptor?
    a
    • 2
    • 2
  • u

    ursus

    06/16/2020, 7:08 PM
    How do you guys prefix your or postfix your rest stuff (retrofit interface + models)?
    PaymentApi? PaymentService?
    
    ApiCreditCard? ServiceCreditCard? RemoteCreditCard?
    o
    • 2
    • 4
  • s

    Steve

    06/16/2020, 9:11 PM
    how does one generally expose an app configuration to the rest of the app? Specifically, I do need part of it for my network requests, as the config is what provides the keys
    u
    j
    • 3
    • 2
  • m

    mattinger

    06/18/2020, 6:29 PM
    Anyone know how to react to returning from a navigation subgraph? I basically want to treat the subgraph as a black box and re-use it in several different other graphs. The problem is how do i detect when i’ve come back from it. I could use a destination listener, and add it prior to navigation, and remove it when it comes back to the destination i want, but that doesn’t work right if the app goes out of memory and is rebuilt.
    a
    • 2
    • 10
  • o

    OG

    06/30/2020, 1:37 AM
    Hello everyone, question about the MVI /MVVM architecture, I was wondering how folks handle navigation events / one shot events like showing a snack bar, navigating to a different fragment/activity, showing a dialog etc in their MVI/MVVM architecture. I know there's a SingleLiveEvent class created in a Google example repo, I've seen the Event wrapper solutions. But all of these are sort of workarounds. - The SingleLiveEvent option ties you to the MutableLiveData API and if that changes, your implementation breaks. Unless you create your own version that favors composition I suppose. -Using the Event wrapper to check if the value has been handled previously works, but brings about a redundant object wrapper and still doesn't fit with MVI/MVVM pattern of emitting a single state from your VM or w/e Is the only realistic approach to handling these one shot events as a separate thing from the "view state" that gets emitted in both MVI/MVVM patterns? Whats everyones thoughts?
    g
    m
    +5
    • 8
    • 18
  • d

    dewildte

    06/30/2020, 7:58 PM
    We need a google backed solution for this ☝️. Maybe a really good blog article (Not the
    SingleLiveEvent
    anti pattern post.) or some sort of AA Component. Kotlin
    Flow
    or
    Channel
    is good for this but it seems like that is not common knowledge.
    g
    • 2
    • 4
  • h

    Hakob Astvacatryan

    07/07/2020, 8:27 PM
    Hi guys, I’m using koin for di, I made mistake and put root activity’s viewmodel to activity scope and now viewmodel doesn’t get retained after rotation. The problem I needed to solve by putting viewmodel into activity scope is to allow child viewmodels inject root activity’s viewmodel. Is there way to do that and retain view model?
    v
    • 2
    • 5
  • s

    Slackbot

    07/10/2020, 7:56 AM
    This message was deleted.
    m
    • 2
    • 1
  • u

    ursus

    07/16/2020, 4:17 AM
    in dagger, can a module say "single instance per whatever component this module gets attached to,"?
    g
    a
    • 3
    • 32
  • u

    ursus

    07/18/2020, 12:50 PM
    Is creating multiple Retrofit service instances okay? One per module; lets say 20 overall; given the okhttp instance is shared? Or should I rather strive for a single big retrofit instance and have it extend some partial interfaces, so it then can get injected behind it?
    s
    o
    • 3
    • 5
  • j

    Joost Klitsie

    07/19/2020, 8:29 AM
    Hi all, I was wondering about something: If I use UseCases to do things in my app, and I have lets say a screen and I can load an item, lets say a user account, into the screen using the id of the user. I would like to observe the user by its id from the current value in the repository, and of course any changes in the user will be propagated in my flow. So I have a ObserveUserUseCase to handle this for me. My question: If lets say this user is not existing yet in my repository and I need to fetch it from the backend, would you put that logic into the a) The ObserveUserUseCase (if the repository returns null/not existing it fetches the user) b) In the repository, observing on the user might trigger a backend call in this case automatically c) Make the ObserveUserUseCase return something to show its not existing in the repository (like NullPointer) to my ViewModel and call a separate FetchUserUseCase to load the user
    b
    • 2
    • 3
  • u

    ursus

    07/27/2020, 5:17 PM
    why not split it into
    :payments
    :payments-ui
    ?
    p
    b
    • 3
    • 41
  • j

    JC

    07/30/2020, 6:48 PM
    Hello everyone, I'm just looking for a architecture or dessign patterns to handle app based on roles or permissions. For example, I have four different user types, and I want to handle some features enabled for two users and disababled by default. I read something about feature toggle, but I'm not sure if is the best option, because I want to avoid if statements checks in the code. Someone know something about this? Thanks!! 🙂
    a
    • 2
    • 1
  • v

    Vincent Williams

    08/06/2020, 2:43 AM
    when using sealed classes for the viewstate in android, how do you handle updating part of the viewstate? For example:
    sealed class ViewState {
        object Idle : ViewState()
        data class Content(
            val headerText: String,
            val bodyText: String
        ) : ViewState()
        data class Error(
            val message: String
        ) : ViewState
    }
    How do I update just the title for example? I see a lot of examples use sealed classes but they dont seem so great in practice...
    s
    o
    +3
    • 6
    • 11
  • u

    ursus

    08/14/2020, 3:56 AM
    Hey, I notice update to preferences take around 0-1ms, how is this possible with disc io? If it only updates some memcache, which is only later synchronized to disc async-ly; does it mean its not as durable as a sqlite would?
    s
    g
    • 3
    • 62
  • f

    Fanilog

    08/18/2020, 9:03 AM
    Hello all, I’ve a question/debate around clean architecture. 👋 I’m working on a project that follows the clean architecture principles. From https://blog.cleancoder.com/=> “_Typically the data that crosses the boundaries is simple data structures. You can use basic structs or simple Data Transfer objects if you like. Or the data can simply be arguments in function calls. Or you can pack it into a hashmap, or construct it into an object. The important thing is that isolated, simple, data structures are passed across the boundaries. We don’t want to cheat and pass Entities or Database rows. We don’t want the data structures to have any kind of dependency that violates The Dependency Rule._” We can see a lot of example in the web returning
    Flow<data>
    from the Service layer to their Repository and Interactor. I was wondering if doing this way it’s breaking one the principles by having a strong dependency with the current implementation of the Flow (external service)?
    j
    • 2
    • 1
  • u

    ursus

    08/18/2020, 8:24 PM
    Testing people who use fakes. Do you fake all the layers only the "edge" ones like db or api? Since I want to test a viewmodel now, and then have to recreate the whole stack just to swap the fake api at the end, and its so stupid, so much code Why not just mockito stub out the direct view model dependencies?
    👍 1
    j
    g
    • 3
    • 41
  • r

    Raj Trivedi

    08/21/2020, 10:57 AM
    We have an app right now..and want to move towards sdk so that our clients can easily use our services..do we have any sources on what architecture to follow for an android mobile sdk? I have clean architecture in mind..any suggestions?
    👍 1
    s
    j
    • 3
    • 3
Powered by Linen
Title
r

Raj Trivedi

08/21/2020, 10:57 AM
We have an app right now..and want to move towards sdk so that our clients can easily use our services..do we have any sources on what architecture to follow for an android mobile sdk? I have clean architecture in mind..any suggestions?
👍 1
s

Susheel

08/21/2020, 4:36 PM
Following this thread.
j

John Leeroy

08/21/2020, 5:43 PM
Look into domain-driven design and think of your code/technology as a domain. My favorite qualities of SDKs or libraries is the focus on simple interfaces and data models that are exposed.
❤️ 1
Look into Retrofit and how they achieved configurability and extensibility. Examples are how they support several json serializer like Moshi, Gson, Jackson, etc. They also support coroutines, Rx, etc through extension modules. Maybe your product have the opportunity to make integration easier.
View count: 6