<commit_before># GridPagerSnapHelper
A powerful tools to impl grid paging layout by RecyclerView

# 效果图

![](screenshot/recyclerview.gif)

# 下载

## Gradle

**Step 1. Add it in your root build.gradle at the end of repositories:**

```
allprojects {
    repositories {
	...
        maven { url 'https://jitpack.io' }
    }
}
```

**Step 2. Add the dependency**

```
dependencies {
    compile 'com.github.hanhailong:GridPagerSnapHelper:0.0.1'
}
```

## 使用
<commit_msg>添加使用说明书<commit_after># GridPagerSnapHelper
A powerful tools to impl grid paging layout by RecyclerView

# 效果图

![](screenshot/recyclerview.gif)

# Download

## Gradle

**Step 1. Add it in your root build.gradle at the end of repositories:**

```
allprojects {
    repositories {
	...
        maven { url 'https://jitpack.io' }
    }
}
```

**Step 2. Add the dependency**

```
dependencies {
    compile 'com.github.hanhailong:GridPagerSnapHelper:0.0.1'
}
```

## Usage:

for example:

```
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);

//setLayoutManager
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, row, LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(gridLayoutManager);

//attachToRecyclerView
GridPagerSnapHelper gridPagerSnapHelper = new GridPagerSnapHelper();
gridPagerSnapHelper.setRow(row).setColumn(column);
gridPagerSnapHelper.attachToRecyclerView(recyclerView);

int screenWidth = ScreenUtils.getScreenWidth(this);
int itemWidth = screenWidth / column;

//transform data list
List<DataSourceUtils.ItemData> dataList = DataSourceUtils.getDataSource();
dataList = GridPagerUtils.transformAndFillEmptyData(
        new FirstOrderTransform<DataSourceUtils.ItemData>(column), dataList);

//setAdapter
RecyclerViewAdapter adapter = new RecyclerViewAdapter(this, dataList, itemWidth);
recyclerView.setAdapter(adapter);
```

**Step 1. setLayoutManager:**

You'd better set a horizontal direction *GridLayoutManager*

**Step 2. RecyclerView attach to GridPagerSnaperHelper**

```
GridPagerSnapHelper gridPagerSnapHelper = new GridPagerSnapHelper();
gridPagerSnapHelper.setRow(row).setColumn(column);
gridPagerSnapHelper.attachToRecyclerView(recyclerView);
```
Here,you must set row and column

**Step 3. transform data list**

if your src data is *dataList*,you must transform it to dst data

```
GridPagerUtils.transformAndFillEmptyData(
        new FirstOrderTransform<DataSourceUtils.ItemData>(column), dataList);
```
Here,I have provided three transform order functions

1. FirstOrderTransform

    mapping one row,n column
2. SecondOrderTransform

    mapping two row,n column 
3. ThirdOrderTransform

    mapping three row,n column

You can impl your custom order funcitons by extends **AbsDataTransform**


# Author

hanhailong worked in 58同城，A fantastic website

<EMAIL>
{'fraction_non_alphanumeric': 0.10469187675070028, 'fraction_numerical': 0.0063025210084033615, 'mean_word_length': 5.29295154185022, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4056690', 'n_tokens_mistral': 961, 'n_tokens_neox': 908, 'n_words': 227}