├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── layout
│ │ │ │ ├── item_tv.xml
│ │ │ │ └── activity_main.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── dasu
│ │ │ └── customrecyclerview
│ │ │ ├── UserInfo.java
│ │ │ ├── DiffUtils.java
│ │ │ ├── RvAdapter.java
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── dasu
│ │ │ └── customrecyclerview
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── dasu
│ │ └── customrecyclerview
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── recyclerlibrary
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ ├── item_head_foot_parent.xml
│ │ │ │ ├── item_defalut_refresh_view.xml
│ │ │ │ └── item_defalut_loadmore_view.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── dasu
│ │ │ └── recyclerlibrary
│ │ │ ├── listener
│ │ │ ├── ICustomClickListener.java
│ │ │ ├── IScrollListener.java
│ │ │ └── ICustomScrollListener.java
│ │ │ ├── module
│ │ │ └── ViewConfig.java
│ │ │ └── ui
│ │ │ ├── CustomRecyclerView.java
│ │ │ ├── CustomAdapter.java
│ │ │ └── ScrollWrapRecycler.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── dasu
│ │ │ └── recyclerlibrary
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── dasu
│ │ └── recyclerlibrary
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── vcs.xml
├── runConfigurations.xml
├── gradle.xml
├── codeStyles
│ └── Project.xml
└── misc.xml
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/recyclerlibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':recyclerlibrary'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CustomRecyclerView
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RecyclerLibrary
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Huazhiling/CustomRecyclerView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_tv.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/res/layout/item_head_foot_parent.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/java/com/dasu/recyclerlibrary/listener/ICustomClickListener.java:
--------------------------------------------------------------------------------
1 | package com.dasu.recyclerlibrary.listener;
2 |
3 | import android.view.View;
4 |
5 | public interface ICustomClickListener {
6 | void onClick(View view, int position, int type, Object... data);
7 |
8 | void onLongClick(View view, int position, int type, Object... data);
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/java/com/dasu/recyclerlibrary/listener/IScrollListener.java:
--------------------------------------------------------------------------------
1 | package com.dasu.recyclerlibrary.listener;
2 |
3 | /**
4 | * 2018.11.4
5 | * 当使用默认刷新是调用该接口
6 | * 该接口只用于回调刷新和加载数据
7 | * 优先级小于{@link ICustomScrollListener}
8 | */
9 | public interface IScrollListener {
10 |
11 | /**
12 | * 在此方法内写刷新的逻辑
13 | */
14 | void refresh();
15 |
16 | /**
17 | * 在此方法内写加载的逻辑
18 | */
19 | void loadMore();
20 | }
21 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/res/layout/item_defalut_refresh_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/res/layout/item_defalut_loadmore_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/com/dasu/customrecyclerview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.dasu.customrecyclerview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/recyclerlibrary/src/test/java/com/dasu/recyclerlibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.dasu.recyclerlibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/java/com/dasu/recyclerlibrary/listener/ICustomScrollListener.java:
--------------------------------------------------------------------------------
1 | package com.dasu.recyclerlibrary.listener;
2 |
3 | /**
4 | * 2018.11.4
5 | * 使用了自己的刷新加载view时,需要实现改接口,不然接受不到数据
6 | * 如果不需要使用自定义的刷新View,可使用{@link IScrollListener}
7 | */
8 | public interface ICustomScrollListener {
9 | /**
10 | * 下拉刷新时候的回调
11 | * @param state
12 | */
13 | void scrollRefreshState(int state);
14 |
15 | /**
16 | * 上拉加载时候的回调
17 | * @param state
18 | */
19 | void scrollLoadMoreState(int state);
20 |
21 | /**
22 | * 在此方法内写刷新的逻辑
23 | */
24 | void refresh();
25 | /**
26 | * 在此方法内写加载的逻辑
27 | */
28 | void loadMore();
29 | }
30 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dasu/customrecyclerview/UserInfo.java:
--------------------------------------------------------------------------------
1 | package com.dasu.customrecyclerview;
2 |
3 | public class UserInfo {
4 | private int id; //人物ID,一般不会改变
5 | private String name;
6 | private int age;
7 |
8 | public UserInfo(int id, String name, int age) {
9 | this.id = id;
10 | this.name = name;
11 | this.age = age;
12 | }
13 |
14 | public int getId() {
15 | return id;
16 | }
17 |
18 | public void setId(int id) {
19 | this.id = id;
20 | }
21 |
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | public void setName(String name) {
27 | this.name = name;
28 | }
29 |
30 | public int getAge() {
31 | return age;
32 | }
33 |
34 | public void setAge(int age) {
35 | this.age = age;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/recyclerlibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/dasu/customrecyclerview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.dasu.customrecyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 | assertEquals("com.dasu.customrecyclerview", appContext.getPackageName());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/androidTest/java/com/dasu/recyclerlibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.dasu.recyclerlibrary;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.dasu.recyclerlibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CustomRecyclerView
2 | 用于减少ScrollView嵌套RecyclerView, 可将View当成头部添加到Rv中,同时可设置刷新加载,可采用默认的刷新加载也可使用自定义的,但是目前仅支持简单的刷新加载View
3 | ### 添加Header的样子
4 | 
5 | ### 添加Footer的样子
6 | 
7 |
8 | 目前已经增加了下拉刷新以及上拉加载的逻辑
9 |
10 | ## 使用方法
11 | 在build.gradle :project添加
12 | ```
13 | allprojects {
14 | repositories {
15 | ...
16 | maven { url 'https://jitpack.io' }
17 | }
18 | }
19 | ```
20 | 在build.gradle :app添加
21 | ```
22 | dependencies {
23 | implementation 'com.github.Huazhiling:CustomRecyclerView:1.1.09'
24 | }
25 | ```
26 | 使用方法可参考demo
27 | [MainActivity](https://github.com/Huazhiling/CustomRecyclerView/blob/master/app/src/main/java/com/dasu/customrecyclerview/MainActivity.java)
28 |
29 | # 在activity的xml布局中将RecyclerView替换成ScrollWrapRecycler即可
30 | # 后续会添加更多的功能 比如刷新加载(`已完成`),滑动删除等等, 想到的有时间一般都会加上去。。
31 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "com.dasu.customrecyclerview"
7 | minSdkVersion 15
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | implementation 'com.android.support:appcompat-v7:26.1.0'
24 | testImplementation 'junit:junit:4.12'
25 | implementation 'com.android.support:design:26.1.0'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28 | implementation project(':recyclerlibrary')
29 | }
30 |
--------------------------------------------------------------------------------
/recyclerlibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 26
5 |
6 | defaultConfig {
7 | minSdkVersion 15
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation 'com.android.support:appcompat-v7:26.1.0'
28 | testImplementation 'junit:junit:4.12'
29 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
32 | implementation 'com.android.support:recyclerview-v7:26.1.0'
33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dasu/customrecyclerview/DiffUtils.java:
--------------------------------------------------------------------------------
1 | package com.dasu.customrecyclerview;
2 |
3 | import android.support.v7.util.DiffUtil;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | public class DiffUtils extends DiffUtil.Callback {
9 | private List mOldData;
10 | private List mNewsData;
11 |
12 | public DiffUtils(List mOldData, List mNewsData) {
13 | this.mOldData = mOldData;
14 | this.mNewsData = mNewsData;
15 | }
16 |
17 | @Override
18 | public int getOldListSize() {
19 | return mOldData.size();
20 | }
21 |
22 | @Override
23 | public int getNewListSize() {
24 | return mNewsData.size();
25 | }
26 |
27 | @Override
28 | public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
29 | return mOldData.get(oldItemPosition).getId() == mNewsData.get(newItemPosition).getId();
30 | }
31 |
32 | @Override
33 | public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
34 | return mOldData.get(oldItemPosition).getName().equals(mNewsData.get(newItemPosition).getName());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
22 |
23 |
29 |
30 |
--------------------------------------------------------------------------------
/recyclerlibrary/src/main/java/com/dasu/recyclerlibrary/module/ViewConfig.java:
--------------------------------------------------------------------------------
1 | package com.dasu.recyclerlibrary.module;
2 |
3 |
4 | import android.view.View;
5 |
6 | public class ViewConfig {
7 | public static final String HEADVIEW = "_head_";
8 | public static final String FOOTVIEW = "_foot_";
9 | public static final int HEADVIEW_TYPE = 100000;
10 | public static final int FOOTVIEW_TYPE = 100001;
11 | private int type; // 100000 代表头部 100001 代表尾部
12 | private int view;
13 | private String tag;
14 | private View contentView;
15 | private boolean isCache; //是否需要缓存
16 |
17 | public boolean isCache() {
18 | return isCache;
19 | }
20 |
21 | public void setCache(boolean cache) {
22 | isCache = cache;
23 | }
24 |
25 | public View getContentView() {
26 | return contentView;
27 | }
28 |
29 | public void setContentView(View contentView) {
30 | this.contentView = contentView;
31 | }
32 |
33 | public int getType() {
34 | return type;
35 | }
36 |
37 | public void setType(int type) {
38 | this.type = type;
39 | }
40 |
41 | public int getView() {
42 | return view;
43 | }
44 |
45 | public void setView(int view) {
46 | this.view = view;
47 | }
48 |
49 | public String getTag() {
50 | return tag;
51 | }
52 |
53 | public void setTag(String tag) {
54 | this.tag = tag;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dasu/customrecyclerview/RvAdapter.java:
--------------------------------------------------------------------------------
1 | package com.dasu.customrecyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import java.util.List;
12 |
13 | public class RvAdapter extends RecyclerView.Adapter {
14 | private List mData;
15 | private Context context;
16 | private LayoutInflater inflater;
17 |
18 | public RvAdapter(List mData, Context context) {
19 | this.mData = mData;
20 | this.context = context;
21 | this.inflater = LayoutInflater.from(context);
22 | }
23 |
24 | @NonNull
25 | @Override
26 | public RvViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
27 | return new RvViewHolder(inflater.inflate(R.layout.item_tv, viewGroup, false));
28 | }
29 |
30 | @Override
31 | public void onBindViewHolder(@NonNull RvViewHolder rvViewHolder, int i) {
32 | rvViewHolder.tv.setText(mData.get(i).getName());
33 | }
34 |
35 | @Override
36 | public void onBindViewHolder(RvViewHolder holder, int position, List