|
YAACC - UPNP Client and Server
|
Shared, Android-framework-free helper for computing a GridLayoutManager span count from an available width and a target card width, both in pixels.
More...

Static Public Member Functions | |
| static int | computeSpanCount (int availableWidthPx, int targetCardWidthPx) |
| Computes how many card columns fit in the given available width, never fewer than 2 (so a very narrow or multi-window width still gets a usable 2-column grid instead of collapsing to 1). | |
Shared, Android-framework-free helper for computing a GridLayoutManager span count from an available width and a target card width, both in pixels.
Deliberately has no android.* imports - same testability precedent as de.yaacc.upnp.server.contentdirectory.SortSupport - so it can be unit-tested on the plain JVM without Robolectric.
|
static |
Computes how many card columns fit in the given available width, never fewer than 2 (so a very narrow or multi-window width still gets a usable 2-column grid instead of collapsing to 1).
| availableWidthPx | the available width, in pixels (e.g. the RecyclerView's current width) |
| targetCardWidthPx | the target width of a single card, in pixels |
GridLayoutManager#setSpanCount(int), always >= 2