• u

    ursus

    3 years ago
    Hi, I have a margin item decoration which overrides getItemOffsets and for simplicity lets say adds bottom margin X to every 3rd item, and some smaller X/2 margin to others. So my issue is that without invalidating the item decoration, views keep these margins, and when animation recyclerview via notifyItemInserted and friends (via DiffUtil), it causes wrong margin (not big margin every 3rd item) So I google'd, I need to invalidate like this
    adapter.items = diff.list
    diff.result.dispatchUpdatesTo(adapter)
    recyclerView.invalidateItemDecorations()
    Which does make the margins correct, however this doesn't get calculated into the animations*, and view jump to some incorrect intial position and animate to their end position* Has anyone encountered this? Its very annoying. Do I need to write my own ItemAnimator?
    u
    Eugen Martynov
    2 replies
    Copy to Clipboard
  • Pablichjenkov

    Pablichjenkov

    3 years ago
    Some folks from iOS has been talking for some time about the popularity of MVVM-Coordinator or just Coordinators Architecture in iOS. Has anyone tried a similar approach to tackle navigation logic in Android?
    Pablichjenkov
    r
    +1
    20 replies
    Copy to Clipboard
  • Melih Aksoy

    Melih Aksoy

    3 years ago
    Hey all ! I’ve recently open sourced an example modularized app - using some of most common libraries, tried to implement cases like structured DI, clean architecture, navigation between features etc. ( you can see modularization graph & DI graph on README ). I’ll be writing about many things I’ve came across and learned during development when I have enough time ! I’m trying to improve it with more cases to cover, not going too fast, but still it’s something. If you have any suggestions, it’d be great hear ! https://github.com/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture
    Melih Aksoy
    a
    +1
    6 replies
    Copy to Clipboard
  • kevin.cianfarini

    kevin.cianfarini

    3 years ago
    Does anyone know if flow extensions for
    DataSource.Factory
    already exist as a package? If not, is there somewhere that makes sense to contribute them?
    kevin.cianfarini
    m
    +1
    7 replies
    Copy to Clipboard
  • a

    Adam Hurwitz

    3 years ago
    I'm happy to share the live sample app for the Android Unidirectional Data Flow (UDF) pattern, featuring Coinverse. Code in the wild is always better to learn from than slide samples. Coinverse’s Open App showcases a live UDF pattern which makes the app more readable, easier to develop for, and debug. Next step - JUnit testing the ViewModels! 🧪🔬🥼 https://buff.ly/2T9Yyw3
    a
    m
    2 replies
    Copy to Clipboard
  • n

    nicopasso

    3 years ago
    We are trying to understand how viewmodels and recyclerviews can work together. In our case we have a custom view, used in an activity, with its own viewmodel. Now this custom view need to be part of the layout of items in a recyclerview. That means each ViewHolder will have a ViewModel attached to it. We think it’s not a good solution but we’re wondering what would it be a way to structure this type of situation. ViewModel attached to the adapter (we think it’s bad)? use DataBinding to connect VH and VM? we don’t have databinding set up in the project though. What do you guys think?
    n
    g
    +1
    11 replies
    Copy to Clipboard
  • v

    voben

    3 years ago
    What’s the best way to retrieve LiveData value in a click listener? Is it ok to just perform a null check to synchronously get the livedata value?
    button.setOnClickListener {
         if (viewmodel.getMyLiveData().value != null) {
             // do something
         }
    }
    v
    a
    +3
    22 replies
    Copy to Clipboard
  • Melih Aksoy

    Melih Aksoy

    3 years ago
    Hey all ! I was wondering how do you structure your project to apply dependency inversion between modules - it seems to end up in low modules depending on high ones for sake of inversion - but I was wondering if this is correct approach in general, or something else ?
    Melih Aksoy
    e
    +2
    13 replies
    Copy to Clipboard
  • j

    jermainedilao

    3 years ago
    Hi guys! I have a question regarding MVVM. Let’s say I have a ViewPager that has 3 pages and has automatic scrolling feature. (this viewpager goes back to page 1 when reaching page 3). The auto scrolling feature is PAUSED everytime the viewpager receives a touch action. Now, should the logic of setting view pager’s current item to 1 if it reaches 3, and the pausing of auto scroll when view pager receives touch event RESIDE in ViewModel? In my understanding. Purely UI logic can stay in activity/fragment. Logic that can reside in ViewModel can include enabling/disabling buttons (depending on the input), validating inputs, etc. Any inputs are greatly appreciated! 🙂
    j
    a
    2 replies
    Copy to Clipboard
  • u

    ursus

    3 years ago
    Hi, has anyone tried to automate generating DiffUtil.Callback methods? Mostly areContentsTheSameand
    getChangePayload
    ) Say I have a model, the usual case fo areItemsEqual is to use equals(), but what if I dont want to compare all the fields? So, I could write a reflection util / codegen for this, but it requires to have some sort of a @Exclude annotation on a given field which in turn means that our data/domain layer Foo model knows about diff util stuff so not sure if this is the way to go should it maybe be manual code and keep reflection (traversing all the fields) unit test to check if new fields are added) (edited) -- or, create a UI layer level model from it, and use just the plain equals from it (or not, doesnt matter, since now diffutil annotations make sense)
    u
    1 replies
    Copy to Clipboard