Skip to content

More easily create Views that show Teller state.  #75

Open
@levibostian

Description

An important part of Teller is that it hopes that you make a positive experience of the UI of the app. Making Views in your app that tell the user the state of the cache is recommended.

But it can be a pain to make these Views as it's a pretty manual process. Let's make it easier for you.

Note: This is to create custom Views that show the state of Teller like, "Updating...", "Cache 5 seconds old". Not updating your RecyclerView with cache data.

Proposal

Make an interface that looks something like this:

interface TellerView {
  cacheState(...)
  cacheEmptyState(...)
  noCache(...)
}

You create any custom View in Android, inherit that interface, then when you get a cache state update, you send that to the View:

val newCacheState = ...
TellerView.updateViews(newCacheState, listOf(customView, ...))

Teller will parse the cache state and call the appropriate interface function for you.

Pros:

  • No need to extend any special class. Just inherit an interface. Very flexible.
    • Use on any View including 3rd party Views or androidx views.
      Cons:
  • Must call a Teller function, TellerView.updateViews... to perform the update. I would like to have it be more automated, but Teller has to know about your view somehow. I could do something more automated like Teller traversing a ViewGroup for children Views that inherit an interface but I like how this is more flexible. You decide what Views get updated, when.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions