YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.CardGridSpanCount Class Reference

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

Collaboration diagram for de.yaacc.browser.CardGridSpanCount:
Collaboration graph

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).
 

Detailed Description

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.

Member Function Documentation

◆ computeSpanCount()

static int de.yaacc.browser.CardGridSpanCount.computeSpanCount ( int availableWidthPx,
int targetCardWidthPx )
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).

Parameters
availableWidthPxthe available width, in pixels (e.g. the RecyclerView's current width)
targetCardWidthPxthe target width of a single card, in pixels
Returns
the span count to pass to GridLayoutManager#setSpanCount(int), always >= 2

The documentation for this class was generated from the following file: