• smilecs

    smilecs

    3 years ago
    should the data source operate by implementing interfaces defined in the repository
    smilecs
    g
    3 replies
    Copy to Clipboard
  • s

    Schadenfreude

    3 years ago
    Hey guys, I’m using MVVM in a project (for learning purposes mainly) and I’ve implemented a few Fragments with a ViewModel and an Adapter in Java, and haven’t had problems, but this is the first one I’ve written in Kotlin, and for some reason when I delete an item from the cart, I don’t get a notification in the ViewModel Observer and hence I don’t clear the adapter items. Any ideas why this might be happening?
    s
    2 replies
    Copy to Clipboard
  • u

    ursus

    3 years ago
    I feel like it warrants its own package, but its not a ui facing feature like news or weather, where should I put it? account/ package in root? in data/? if root, then data/ already has MessageRepository etc, wouldnt that be a mismatch?
    u
    g
    11 replies
    Copy to Clipboard
  • gumil

    gumil

    3 years ago
    Do you guys adapted Netflix’s componentization?
    gumil
    g
    3 replies
    Copy to Clipboard
  • Davide Giuseppe Farella

    Davide Giuseppe Farella

    3 years ago
    Assuming that we have a single Activity app with an architecture that delivers all the exceptions to the presentation layer. Actually I got an interface
    AndroidComponent
    that will be implemented by Activityes, Fragments, Workers/Services ( and basically nothing else ) that provides a reference to
    Notifier
    .
    Notifier
    jobs are 1 inform
    Timber
    ( that will eventually inform
    Crashlytics
    ) and 2 show a message to the user. Actually the message to the user is delivered through an abstraction of
    Toast
    injected in the constructor; but I would like to use a
    SnackBar
    instead, if the app is in foreground: so I was thinking about a
    SnackBarManager
    ( fantasy name 😁 ) that will be implemented by the
    Activity
    which will pass the set/remove the interface to
    Notifier
    (
    onStart()' /' onStop()
    ) , so the Notifier could call
    snackBarManager?.let { it.showSomething() } ?: showToast()
    What do you think about that? 🙂
    Davide Giuseppe Farella
    dave08
    4 replies
    Copy to Clipboard
  • u

    ursus

    3 years ago
    hm I wonder if okhttp Authenticator can even handle such case, afaik the return value is request to retry, and null to pass 401 downstream
    u
    d
    +1
    8 replies
    Copy to Clipboard
  • u

    ursus

    3 years ago
    how come? arent foreground services cool anymore to not have the process killed?
    u
    kioba
    +1
    18 replies
    Copy to Clipboard
  • g

    ghedeon

    3 years ago
    Do you use
    Router/Navigator
    pattern in your apps? If yes, do you inject it into the ViewModel or activity? I've been using it for a while, for the sake of SRP and stuff.. but honestly it's tightly coupled with activity/fragment anyways (context, animations, fragmentManager, etc) so I hardly see any benefit of another abstraction.
    g
    1 replies
    Copy to Clipboard
  • oday

    oday

    3 years ago
    when starting a screen for example, inside onCreate and you’re hooking up things to do this call, is this how it would go?
    leaseCarsVM.getLeaseCarsResult().observe(this, getLeaseCarsObserver)
            leaseCarsVM.getLeaseCars(true)
    
            swiperefreshLayout.setOnRefreshListener {
                leaseCarsVM.getLeaseCarsResult().observe(this, getLeaseCarsObserver)
                leaseCarsVM.getLeaseCars()
            }
    try moving it to say the beginning of the screen, all of them together hooked up to the various other observers, and then make the VM calls later, they don’t come back successfully, has to be before the call..
    oday
    d
    8 replies
    Copy to Clipboard
  • g

    ghedeon

    3 years ago
    For quite a while I was using the wrapper around the string resource. In order to delay context involvement. Ex: you have a string int, plus some params for the format, but you're not ready to pull the actual value, because it requires the context. So you delay it with a wrapper.
    class StringResource private constructor(
        val string: String?,
        @StringRes val stringRes: Int?,
        vararg val args: Any?
    ) {
        constructor(@StringRes stringRes: Int, vararg args: Any? = emptyArray()) : this(null, stringRes, args)
    
        constructor(string: String) : this(string, null, null)
    
        fun resolve(context: Context): String =
            if (stringRes != null) {
                context.getString(stringRes, args)
            } else requireNotNull(string)
    
      }
    =============
    Usage: 
    ViewModel: StringResource(R.string.foo, arg1, arg2)
    View: stringResource.resolve(context)
    I'm wondering if other people do something similar and how their wrapper looks like.
    g
    d
    +3
    15 replies
    Copy to Clipboard