MCPcopy Index your code
hub / github.com/500px/greedo-layout-for-android

github.com/500px/greedo-layout-for-android @v1.5.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.5.3 ↗ · + Follow
75 symbols 162 edges 9 files 17 documented · 23%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Greedo Layout for Android

A drop-in custom layout manager for Android RecyclerViews to layout a grid of photos while respecting their aspect ratios.

image

Setup

Download the latest release via Gradle:

repositories {
    maven { url 'https://github.com/500px/greedo-layout-for-android/raw/master/releases/' }
}

dependencies {
    compile 'com.fivehundredpx:greedo-layout:1.5.1'
}

Usage

See the sample project for a complete solution on how to use GreedoLayout. Below are the specific steps.

// Create an instance of the GreedoLayoutManager and pass it to the RecyclerView
MyRecyclerAdapter recyclerAdapter = new MyRecyclerAdapter(this);
GreedoLayoutManager layoutManager = new GreedoLayoutManager(recyclerAdapter);

RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(recyclerAdapter);

// Set the max row height in pixels
layoutManager.setMaxRowHeight(300);

// If you would like to add spacing between items (Note, MeasUtils is in the sample project)
int spacing = MeasUtils.dpToPx(4, this);
recyclerView.addItemDecoration(new GreedoSpacingItemDecoration(spacing));

And then, in your RecyclerView adapter, or some other class of your choosing, implement SizeCalculatorDelegate. This implementation got passed to the layout manager above.

public class MyRecyclerAdapter extends RecyclerView.Adapter<ViewHolder> implements SizeCalculatorDelegate {
    @Override
    public double aspectRatioForIndex(int index) {
        // Return the aspect ratio of your image at the given index
    }
}

License

GreedoLayout is released under the MIT license. See LICENSE for details.

Extension points exported contracts — how you extend this code

SizeCalculatorDelegate (Interface)
(no doc) [2 implementers]
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutSizeCalculator.java

Core symbols most depended-on inside this repo

getItemCount
called by 8
greedo-layout-sample/src/main/java/com/fivehundredpx/greedo_layout_sample/PhotosAdapter.java
getContentHeight
called by 6
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutManager.java
getHeight
called by 5
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/Size.java
reset
called by 5
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutSizeCalculator.java
preFillGrid
called by 5
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutManager.java
getWidth
called by 4
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/Size.java
sizeForChildAtPosition
called by 4
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutManager.java
getRowForChildPosition
called by 3
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutSizeCalculator.java

Shape

Method 63
Class 10
Enum 1
Interface 1

Languages

Java100%

Modules by API surface

greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutManager.java27 symbols
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoLayoutSizeCalculator.java19 symbols
greedo-layout-sample/src/main/java/com/fivehundredpx/greedo_layout_sample/PhotosAdapter.java10 symbols
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/GreedoSpacingItemDecoration.java5 symbols
greedo-layout/src/main/java/com/fivehundredpx/greedolayout/Size.java4 symbols
greedo-layout-sample/src/main/java/com/fivehundredpx/greedo_layout_sample/SampleActivity.java3 symbols
greedo-layout-sample/src/main/java/com/fivehundredpx/greedo_layout_sample/MeasUtils.java3 symbols
greedo-layout-sample/src/main/java/com/fivehundredpx/greedo_layout_sample/App.java3 symbols
greedo-layout-sample/src/main/java/com/fivehundredpx/greedo_layout_sample/Constants.java1 symbols

For agents

$ claude mcp add greedo-layout-for-android \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page