From fcf7a0e8c5815cd3d0e1baab0485527a853b2940 Mon Sep 17 00:00:00 2001 From: Fitz Date: Sun, 27 Sep 2020 21:10:07 +0800 Subject: [PATCH] :memo update doc --- PULL_REQUEST_TEMPLATE.md | 3 +- README_EN.md | 65 ++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 30ef1a892..756954719 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,2 +1 @@ -What's the PR for? -这个 PR 的目的是什么? \ No newline at end of file +这个 PR 是做什么的?(What's the PR for? ) diff --git a/README_EN.md b/README_EN.md index ee09dfa20..a970a5a3d 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,52 +1,52 @@ # Flap - -`Flap` is a library that makes `RecyclerView.Adapter` much more easier to use , by keeping you from writing boilerplate codes and providing lots advance features , especially when you have to support lots of different type items. - - +[![Build Status](https://travis-ci.org/AlanCheen/Flap.svg?branch=master)](https://travis-ci.org/AlanCheen/Flap) ![AndroidX](https://img.shields.io/badge/AndroidX-Migrated-brightgreen) ![RecyclerView](https://img.shields.io/badge/RecyclerView-1.1.0-brightgreen.svg) ![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat) [![license](https://img.shields.io/github/license/AlanCheen/Flap.svg)](./LICENSE) [![Author](https://img.shields.io/badge/%E4%BD%9C%E8%80%85-%E7%A8%8B%E5%BA%8F%E4%BA%A6%E9%9D%9E%E7%8C%BF-blue.svg)](https://github.com/AlanCheen) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/AlanCheen/Flap/pulls) ------ - - - -[![Build Status](https://travis-ci.org/AlanCheen/Flap.svg?branch=master)](https://travis-ci.org/AlanCheen/Flap) ![RecyclerView](https://img.shields.io/badge/RecyclerView-28.0.0-brightgreen.svg) ![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat) [![license](https://img.shields.io/github/license/AlanCheen/Flap.svg)](./LICENSE) [![Author](https://img.shields.io/badge/%E4%BD%9C%E8%80%85-%E7%A8%8B%E5%BA%8F%E4%BA%A6%E9%9D%9E%E7%8C%BF-blue.svg)](https://github.com/AlanCheen) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/AlanCheen/Flap/pulls) - [中文指南看这里(点我点我)](./README.md) +`Flap` is a library that makes `RecyclerView.Adapter` much more easier to use , by keeping you from writing boilerplate codes and providing lots advance features , especially when you have to support lots of different type items. ### Latest Version - -| module | flap | flap-annotations | flap-compiler | -| ------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| Version | [![Download](https://api.bintray.com/packages/alancheen/maven/flap/images/download.svg)](https://bintray.com/alancheen/maven/flap/_latestVersion) | [![Download](https://api.bintray.com/packages/alancheen/maven/flap-annotations/images/download.svg)](https://bintray.com/alancheen/maven/flap-annotations/_latestVersion) | [![Download](https://api.bintray.com/packages/alancheen/maven/flap-compiler/images/download.svg)](https://bintray.com/alancheen/maven/flap-compiler/_latestVersion) | - +| module | flap | flap-annotations | flap-compiler | Flap-plugin | +| ------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| Version | [![Download](https://api.bintray.com/packages/alancheen/maven/flap/images/download.svg)](https://bintray.com/alancheen/maven/flap/_latestVersion) | [![Download](https://api.bintray.com/packages/alancheen/maven/flap-annotations/images/download.svg)](https://bintray.com/alancheen/maven/flap-annotations/_latestVersion) | [![Download](https://api.bintray.com/packages/alancheen/maven/flap-compiler/images/download.svg)](https://bintray.com/alancheen/maven/flap-compiler/_latestVersion) | [![Download](https://api.bintray.com/packages/alancheen/maven/flap-plugin/images/download.svg)](https://bintray.com/alancheen/maven/flap-plugin/_latestVersion) | ## Getting Started - - ### Integrate Flap - - Add the latest `Flap` to your dependencies: ```groovy dependencies { - - implementation 'me.yifeiyuan.flap:flap:$lastest_version' - - implementation 'me.yifeiyuan.flap:flap-annotations:$lastest_version' - - annotationProcessor 'me.yifeiyuan.flap:flap-compiler:$lastest_version' + //add recyclerview also + implementation 'androidx.recyclerview:recyclerview:1.1.0' + + implementation "me.yifeiyuan.flap:flap:$lastest_version" + implementation "me.yifeiyuan.flap:flap-annotations:$lastest_version" + annotationProcessor "me.yifeiyuan.flap:flap-compiler:$lastest_version" } ``` +If you are using kotlin , replace `annotationProcessor` with `kapt` : + +```groovy +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' + +dependencies { + implementation "me.yifeiyuan.flap:flap:$lastest_version" + implementation "me.yifeiyuan.flap:flap-annotations:$lastest_version" + kapt "me.yifeiyuan.flap:flap-compiler:$lastest_version" +} +``` ### Usage @@ -56,7 +56,6 @@ dependencies { #### Step 1 : Create a model class : - ```java public class SimpleTextModel { @@ -70,29 +69,23 @@ public class SimpleTextModel { ``` - -#### Step 2 : Create a custom `FlapComponent` : - - -NOTE: `FlapComponent` is the base `ViewHolder` that `Flap` is using internally. +#### Step 2 : Create a custom `Component` : Here is a sample : ```java -@Component(layoutId = R.layout.flap_item_simple_text) -public class SimpleTextItem extends FlapComponent { - - private static final String TAG = "SimpleTextItem"; +@Proxy(layoutName = "flap_item_simple_text") +public class SimpleTextComponent extends Component { private TextView tvContent; - public SimpleTextItem(final View itemView) { + public SimpleTextComponent(final View itemView) { super(itemView); tvContent = findViewById(R.id.tv_content); } @Override - protected void onBind(@NonNull final SimpleTextModel model, @NonNull final FlapAdapter adapter, @NonNull final List payloads) { + protected void onBind(@NonNull final SimpleTextModel model) { tvContent.setText(model.content); } }