├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── crazysunj
│ │ └── multityperecyclerviewadapter
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── crazysunj
│ │ │ └── multityperecyclerviewadapter
│ │ │ ├── GridActivity.java
│ │ │ ├── IDUtil.java
│ │ │ ├── LinearActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── OpenCloseActivity.java
│ │ │ ├── Refresh240Activity.java
│ │ │ ├── RxContinuityActivity.java
│ │ │ ├── RxErrorAndEmptyLinearActivity.java
│ │ │ ├── RxLinearActivity.java
│ │ │ ├── RxMixedLinearActivity.java
│ │ │ ├── RxStandardLinearActivity.java
│ │ │ ├── TestLevelActivity.java
│ │ │ ├── component
│ │ │ ├── BaseAdapter.java
│ │ │ ├── BaseViewHolder.java
│ │ │ ├── ComponentActivity.java
│ │ │ ├── ComponentSubject.java
│ │ │ ├── IEvent.java
│ │ │ ├── LoadMore.java
│ │ │ ├── LoadMoreEvent.java
│ │ │ ├── LoadMoreHelper.java
│ │ │ ├── LoadMoreViewHolder.java
│ │ │ ├── MainAdapter.java
│ │ │ ├── MainHelper.java
│ │ │ ├── TypeOne.java
│ │ │ ├── TypeOneViewHolder.java
│ │ │ ├── TypeThree.java
│ │ │ ├── TypeThreeViewHolder.java
│ │ │ ├── TypeTwo.java
│ │ │ └── TypeTwoViewHolder.java
│ │ │ ├── constant
│ │ │ └── Constants.java
│ │ │ ├── data
│ │ │ ├── ErrorAndEmptyEmptyEntity.java
│ │ │ ├── ErrorAndEmptyErrorEntity.java
│ │ │ ├── ErrorAndEmptyLoadingEntity.java
│ │ │ ├── FirstItem.java
│ │ │ ├── FourthItem.java
│ │ │ ├── LoadingEntity.java
│ │ │ ├── MyEmptyEntity.java
│ │ │ ├── MyErrorAndEmptyEmptyEntity.java
│ │ │ ├── MyErrorAndEmptyErrorEntity.java
│ │ │ ├── MyErrorEntity.java
│ │ │ ├── NoStickyEntity.java
│ │ │ ├── SecondItem.java
│ │ │ ├── SimpleEmptyEntity.java
│ │ │ ├── SimpleErrorEntity.java
│ │ │ └── ThirdItem.java
│ │ │ ├── expand
│ │ │ ├── EmptyOCEntity.java
│ │ │ ├── ErrorOCEntity.java
│ │ │ ├── FirstOCEntity.java
│ │ │ ├── FooterOCEntity.java
│ │ │ ├── LoadingOCEntity.java
│ │ │ ├── OpenCloseAdapter.java
│ │ │ ├── OpenCloseAdapterHelper.java
│ │ │ ├── OpenCloseItem.java
│ │ │ ├── SecondOCEntity.java
│ │ │ ├── ThirdOCEntity.java
│ │ │ └── TitleOCEntity.java
│ │ │ ├── header
│ │ │ ├── HeaderFirstItem.java
│ │ │ ├── HeaderFourthItem.java
│ │ │ ├── HeaderSecondItem.java
│ │ │ └── HeaderThirdItem.java
│ │ │ ├── helper
│ │ │ ├── BaseHelperAdapter.java
│ │ │ ├── BaseViewHolder.java
│ │ │ ├── DefaultMultiHeaderEntity.java
│ │ │ ├── ErrorAndEmptyAdapterHelper.java
│ │ │ ├── ErrorAndrEmptyHelperAdapter.java
│ │ │ ├── MultiHeaderEntity.java
│ │ │ ├── RxAdapterHelper.java
│ │ │ ├── ShimmerViewHolder.java
│ │ │ ├── SimpleHelper.java
│ │ │ ├── SimpleHelperAdapter.java
│ │ │ └── SimpleRxHelperAdapter.java
│ │ │ ├── sticky
│ │ │ ├── FirstStickyItem.java
│ │ │ ├── FourthStickyItem.java
│ │ │ ├── SecondStickyItem.java
│ │ │ ├── StickyItem.java
│ │ │ └── ThirdStickyItem.java
│ │ │ ├── switchtype
│ │ │ ├── FirstType.java
│ │ │ ├── FourthType.java
│ │ │ ├── SecondType.java
│ │ │ ├── SwitchTypeActivity.java
│ │ │ ├── SwitchTypeAdapter.java
│ │ │ ├── SwitchTypeAdapterHelper.java
│ │ │ ├── SwtichType.java
│ │ │ └── ThirdType.java
│ │ │ └── testlevel
│ │ │ ├── ItemConvert.java
│ │ │ ├── LevelFirstEmptyItem.java
│ │ │ ├── LevelFirstItemConvert.java
│ │ │ ├── LevelFooterItem.java
│ │ │ ├── LevelLoadingItem.java
│ │ │ ├── LevelSecondErrorItem.java
│ │ │ ├── LevelSecondItemConvert.java
│ │ │ ├── LevelThirdItemConvert.java
│ │ │ ├── LevelTitleItem.java
│ │ │ ├── MultiTypeTitleEntity.java
│ │ │ ├── TestLevelAdapter.java
│ │ │ ├── TestLevelAdapterHelper.java
│ │ │ ├── TypeEmptyAllItem.java
│ │ │ ├── TypeFiveItem.java
│ │ │ ├── TypeFourItem.java
│ │ │ ├── TypeOneItem.java
│ │ │ ├── TypeThreeItem.java
│ │ │ └── TypeTwoItem.java
│ └── res
│ │ ├── drawable
│ │ ├── bg_fifth_bottom_line.xml
│ │ ├── bg_first_bottom_line.xml
│ │ ├── bg_fourth_bottom_line.xml
│ │ ├── bg_header.xml
│ │ ├── bg_second_bottom_line.xml
│ │ └── bg_third_bottom_line.xml
│ │ ├── layout
│ │ ├── activity_apt_default.xml
│ │ ├── activity_component.xml
│ │ ├── activity_concurrent.xml
│ │ ├── activity_home.xml
│ │ ├── activity_main.xml
│ │ ├── activity_mixed.xml
│ │ ├── activity_open_close.xml
│ │ ├── activity_refresh240.xml
│ │ ├── activity_rx180.xml
│ │ ├── activity_standard.xml
│ │ ├── activity_standard_apt.xml
│ │ ├── activity_switch_type.xml
│ │ ├── activity_test_level.xml
│ │ ├── item_fifth.xml
│ │ ├── item_first.xml
│ │ ├── item_footer.xml
│ │ ├── item_fourth.xml
│ │ ├── item_header.xml
│ │ ├── item_header_img.xml
│ │ ├── item_second.xml
│ │ ├── item_switch_type.xml
│ │ ├── item_third.xml
│ │ ├── item_type_load_more.xml
│ │ ├── item_type_one.xml
│ │ ├── item_type_three.xml
│ │ ├── item_type_two.xml
│ │ ├── layout_default_shimmer_header_view.xml
│ │ ├── layout_default_shimmer_view.xml
│ │ ├── layout_empty.xml
│ │ ├── layout_empty_all.xml
│ │ ├── layout_error.xml
│ │ ├── layout_error_two.xml
│ │ └── layout_header.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ ├── empty.jpg
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── shimmer_attrs.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── crazysunj
│ └── multityperecyclerviewadapter
│ └── ExampleUnitTest.java
├── build.gradle
├── component
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── crazysunj
│ │ └── recycler
│ │ ├── BindLayout.java
│ │ ├── CrazyAdapter.java
│ │ └── CrazyViewHolder.java
│ └── res
│ └── values
│ └── strings.xml
├── config.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── multitypeadapter
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── crazysunj
│ └── multitypeadapter
│ ├── adapter
│ ├── EmptyEntityAdapter.java
│ ├── ErrorEntityAdapter.java
│ └── LoadingEntityAdapter.java
│ ├── entity
│ ├── HandleBase.java
│ ├── LevelData.java
│ └── MultiTypeEntity.java
│ ├── helper
│ ├── AdapterBindException.java
│ ├── AdapterHelper.java
│ ├── AsynAdapterHelper.java
│ ├── DataException.java
│ ├── DiffCallBack.java
│ ├── LoadingConfig.java
│ ├── LoadingConfigEntity.java
│ ├── RecyclerViewAdapterHelper.java
│ ├── RefreshException.java
│ ├── ResourcesManager.java
│ └── SynAdapterHelper.java
│ └── holder
│ └── Holder.java
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── crazysunj
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── crazysunj
│ │ │ └── sample
│ │ │ ├── FooterItemFragment.java
│ │ │ ├── IDUtil.java
│ │ │ ├── MainActivity.java
│ │ │ ├── NormalActivity.java
│ │ │ ├── adapter
│ │ │ ├── FooterVPAdapter.java
│ │ │ ├── HeadAdapter.java
│ │ │ ├── MyHelperAdapter.java
│ │ │ └── helper
│ │ │ │ └── MyAdapterHelper.java
│ │ │ ├── app
│ │ │ └── APP.java
│ │ │ ├── base
│ │ │ ├── BaseAdapter.java
│ │ │ ├── BaseHelperAdapter.java
│ │ │ ├── BaseViewHolder.java
│ │ │ └── MutiTypeTitleEntity.java
│ │ │ ├── constant
│ │ │ └── Constants.java
│ │ │ ├── entity
│ │ │ ├── CommonFooterEntity.java
│ │ │ ├── CommonHeadEntity.java
│ │ │ ├── ItemEntity1.java
│ │ │ ├── ItemEntity2.java
│ │ │ ├── ItemEntity3.java
│ │ │ ├── ItemEntity4.java
│ │ │ └── LoadingEntity.java
│ │ │ ├── normal
│ │ │ ├── Type1Adapter.java
│ │ │ ├── Type2Adapter.java
│ │ │ └── Type3Adapter.java
│ │ │ ├── util
│ │ │ ├── MD5Util.java
│ │ │ └── SnackBarUtil.java
│ │ │ └── view
│ │ │ ├── AppBarLayoutOverScrollViewBehavior.java
│ │ │ └── FloatingActionButtonAnimBehavior.java
│ └── res
│ │ ├── drawable
│ │ ├── shape_bottom_line.xml
│ │ ├── shape_circle_5c93f7.xml
│ │ ├── shape_circle_f7657d.xml
│ │ ├── shape_circle_f9ba43.xml
│ │ ├── shape_cursor.xml
│ │ └── shape_top_bottom_line.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_normal.xml
│ │ ├── footer_home.xml
│ │ ├── fragment_footer.xml
│ │ ├── head_home.xml
│ │ ├── header_common.xml
│ │ ├── item_1.xml
│ │ ├── item_2.xml
│ │ ├── item_3.xml
│ │ ├── item_4.xml
│ │ ├── item_footer.xml
│ │ ├── item_head_home.xml
│ │ ├── label_tag.xml
│ │ ├── layout_loading.xml
│ │ └── layout_loading_header.xml
│ │ ├── menu
│ │ └── menu.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_all.png
│ │ ├── ic_back_top.png
│ │ ├── ic_bf_1.png
│ │ ├── ic_bf_2.png
│ │ ├── ic_boy.png
│ │ ├── ic_device.png
│ │ ├── ic_doctor_1.png
│ │ ├── ic_doctor_2.png
│ │ ├── ic_doctor_3.png
│ │ ├── ic_drug.png
│ │ ├── ic_fab.png
│ │ ├── ic_fam_doc.png
│ │ ├── ic_go.png
│ │ ├── ic_healthy.png
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_nutrition.png
│ │ ├── ic_physical.png
│ │ ├── ic_queue.png
│ │ ├── ic_recharge.png
│ │ ├── ic_register.png
│ │ ├── ic_room_1.png
│ │ ├── ic_room_2.png
│ │ ├── ic_room_3.png
│ │ ├── ic_scan.png
│ │ └── ic_search.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── bg_healthy.png
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── crazysunj
│ └── sample
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | /.gradle/
10 | /app/build/
11 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | jdk: oraclejdk8
3 | sudo: false
4 | android:
5 | components:
6 | - android-28
7 | - build-tools-28.0.3
8 | - extra-android-support
9 | - extra-android-m2repository
10 | - platform-tools
11 | - tools
12 | before_install:
13 | - chmod +x gradlew
14 | - yes | sdkmanager "platforms;android-28"
15 | licenses:
16 | - 'android-sdk-license.*'
17 | script: ./gradlew assembleRelease
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | def configs = rootProject.ext.android //android配置
3 | def libs = rootProject.ext.dependencies //依赖库配置
4 | android {
5 | compileSdkVersion configs.compileSdkVersion
6 | defaultConfig {
7 | applicationId "com.crazysunj.multityperecyclerviewadapter"
8 | minSdkVersion configs.minSdkVersion
9 | targetSdkVersion configs.targetSdkVersion
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | compileOptions {
21 | sourceCompatibility JavaVersion.VERSION_1_8
22 | targetCompatibility JavaVersion.VERSION_1_8
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(include: ['*.jar'], dir: 'libs')
28 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
29 | exclude group: 'com.android.support', module: 'support-annotations'
30 | })
31 | // implementation project(libs.MTRVA_File)
32 | // implementation project(libs.component_File)
33 | implementation libs.MTRVA
34 | implementation libs.component
35 | implementation libs.appcompat
36 | implementation libs.constraintlayout
37 | implementation libs.itemDecoration
38 | implementation libs.shimmer
39 | implementation libs.recyclerview
40 | implementation libs.rxandroid
41 | implementation libs.rxjava
42 | implementation libs.smartRefreshLayout
43 | testImplementation libs.junit
44 | // implementation libs.diffutil
45 | }
46 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/sunjian/Downloads/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/crazysunj/multityperecyclerviewadapter/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter;
2 |
3 | import android.content.Context;
4 |
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 |
8 | import androidx.test.InstrumentationRegistry;
9 | import androidx.test.runner.AndroidJUnit4;
10 |
11 | import static org.junit.Assert.assertEquals;
12 |
13 | /**
14 | * Instrumentation test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() throws Exception {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getTargetContext();
24 |
25 | assertEquals("com.crazysunj.multityperecyclerviewadapter", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.crazysunj.multityperecyclerviewadapter;
17 |
18 | /**
19 | * author: sunjian
20 | * created on: 2018/7/6 下午2:54
21 | * description: 辅助开发者自定义ID
22 | */
23 | public class IDUtil {
24 | private static final long MIN_ID = Long.MIN_VALUE;
25 | private static final long MAX_ID = Long.MAX_VALUE;
26 | private static long sCurrentId = MIN_ID;
27 |
28 | private IDUtil() {
29 | }
30 |
31 | /**
32 | * 辅助id
33 | * 有特殊要求的同学可以自己设计
34 | *
35 | * @return 返回不重复Id
36 | */
37 | public static long getId() {
38 | if (MAX_ID <= sCurrentId) {
39 | throw new RuntimeException("it's the biggest");
40 | }
41 | return sCurrentId++;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import androidx.appcompat.app.AppCompatActivity;
8 |
9 | import com.crazysunj.multityperecyclerviewadapter.component.ComponentActivity;
10 | import com.crazysunj.multityperecyclerviewadapter.switchtype.SwitchTypeActivity;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_home);
18 | }
19 |
20 | public void click1(View view) {
21 | startActivity(new Intent(this, LinearActivity.class));
22 | }
23 |
24 | public void click3(View view) {
25 | startActivity(new Intent(this, GridActivity.class));
26 | }
27 |
28 | public void click6(View view) {
29 | startActivity(new Intent(this, RxLinearActivity.class));
30 | }
31 |
32 | public void click7(View view) {
33 | startActivity(new Intent(this, RxErrorAndEmptyLinearActivity.class));
34 | }
35 |
36 | public void click8(View view) {
37 |
38 | startActivity(new Intent(this, RxContinuityActivity.class));
39 | }
40 |
41 | public void click9(View view) {
42 | startActivity(new Intent(this, RxStandardLinearActivity.class));
43 | }
44 |
45 | public void click10(View view) {
46 | startActivity(new Intent(this, RxMixedLinearActivity.class));
47 | }
48 |
49 | public void click14(View view) {
50 | startActivity(new Intent(this, OpenCloseActivity.class));
51 | }
52 |
53 | public void click16(View view) {
54 | startActivity(new Intent(this, SwitchTypeActivity.class));
55 | }
56 |
57 | public void click17(View view) {
58 | startActivity(new Intent(this, TestLevelActivity.class));
59 | }
60 |
61 | public void click18(View view) {
62 | startActivity(new Intent(this, Refresh240Activity.class));
63 | }
64 |
65 | public void click19(View view) {
66 | startActivity(new Intent(this, ComponentActivity.class));
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/BaseViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.component;
2 |
3 | import android.view.View;
4 |
5 | import androidx.annotation.CallSuper;
6 | import androidx.annotation.NonNull;
7 |
8 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
9 | import com.crazysunj.recycler.CrazyViewHolder;
10 |
11 | /**
12 | * @author sunjian
13 | * @date 2019-10-18 20:03
14 | */
15 | public class BaseViewHolder
6 | * Created by sunjian on 2017/7/7.
7 | */
8 |
9 | public interface Constants {
10 | String FOLD = "点击收回";
11 | String EXPAND = "查看更多";
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/ErrorAndEmptyEmptyEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import java.util.UUID;
6 |
7 | /**
8 | * description
9 | *
10 | * Created by sunjian on 2017/5/16.
11 | */
12 |
13 | public class ErrorAndEmptyEmptyEntity extends NoStickyEntity {
14 |
15 | private long id;
16 |
17 | private int type;
18 |
19 | public ErrorAndEmptyEmptyEntity(int type) {
20 | this.id = UUID.nameUUIDFromBytes(("empty_" + type).getBytes()).hashCode();
21 | this.type = type;
22 | }
23 |
24 | public void setType(int type) {
25 | this.type = type;
26 | }
27 |
28 | public void setId(long id) {
29 | this.id = id;
30 | }
31 |
32 | @Override
33 | public int getItemType() {
34 | return type;
35 | }
36 |
37 | @Override
38 | public boolean equals(@Nullable Object obj) {
39 | if (!(obj instanceof ErrorAndEmptyEmptyEntity)) {
40 | return false;
41 | }
42 | return id == ((ErrorAndEmptyEmptyEntity) obj).id;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/ErrorAndEmptyErrorEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import java.util.UUID;
6 |
7 | /**
8 | * description
9 | *
10 | * Created by sunjian on 2017/5/16.
11 | */
12 |
13 | public class ErrorAndEmptyErrorEntity extends NoStickyEntity {
14 |
15 | private long id;
16 | private int type;
17 |
18 | public ErrorAndEmptyErrorEntity(int type) {
19 | this.id = UUID.nameUUIDFromBytes(("error_" + type).getBytes()).hashCode();
20 | this.type = type;
21 | }
22 |
23 | public void setId(long id) {
24 | this.id = id;
25 | }
26 |
27 | public void setType(int type) {
28 | this.type = type;
29 | }
30 |
31 | @Override
32 | public int getItemType() {
33 | return type;
34 | }
35 |
36 | @Override
37 | public boolean equals(@Nullable Object obj) {
38 | if (!(obj instanceof ErrorAndEmptyErrorEntity)) {
39 | return false;
40 | }
41 | return id == ((ErrorAndEmptyErrorEntity) obj).id;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/ErrorAndEmptyLoadingEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.sticky.StickyItem;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/7/3.
13 | */
14 |
15 | public class ErrorAndEmptyLoadingEntity implements StickyItem {
16 |
17 | private long id;
18 |
19 | private int type;
20 |
21 | private long headerId;
22 |
23 | private String stickyName;
24 |
25 | public ErrorAndEmptyLoadingEntity(int type) {
26 | this.id = UUID.nameUUIDFromBytes(("loading_" + type).getBytes()).hashCode();
27 | this.type = type;
28 | }
29 |
30 | @Override
31 | public int getItemType() {
32 | return type;
33 | }
34 |
35 | @Override
36 | public boolean equals(@Nullable Object obj) {
37 | if (!(obj instanceof ErrorAndEmptyLoadingEntity)) {
38 | return false;
39 | }
40 | return id == ((ErrorAndEmptyLoadingEntity) obj).id;
41 | }
42 |
43 | @Override
44 | public long getHeaderId() {
45 | return headerId;
46 | }
47 |
48 | @Override
49 | public void setHeaderId(long headerId) {
50 | this.headerId = headerId;
51 | }
52 |
53 | @Override
54 | public void setStickyName(String stickyName) {
55 | this.stickyName = stickyName;
56 | }
57 |
58 | @Override
59 | public String getStickyName() {
60 | return stickyName;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/FirstItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.R;
6 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
7 | import com.crazysunj.multityperecyclerviewadapter.sticky.FirstStickyItem;
8 |
9 | import java.util.UUID;
10 |
11 | /**
12 | * Created by sunjian on 2017/3/28.
13 | */
14 |
15 | public class FirstItem implements FirstStickyItem {
16 |
17 | private String name;
18 |
19 | private String stickyName = "第一条粘性";
20 |
21 | private int img = R.mipmap.ic_launcher;
22 |
23 | private long id;
24 |
25 | public FirstItem(String name) {
26 | this.name = name;
27 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
28 | }
29 |
30 | public FirstItem(String name, long id) {
31 | this.name = name;
32 | this.id = id;
33 | }
34 |
35 | public int getImg() {
36 | return img;
37 | }
38 |
39 | public String getName() {
40 | return name;
41 | }
42 |
43 | @Override
44 | public boolean equals(@Nullable Object obj) {
45 | if (!(obj instanceof FirstItem)) {
46 | return false;
47 | }
48 | return id == ((FirstItem) obj).id;
49 | }
50 |
51 | @Override
52 | public long getHeaderId() {
53 | return 1;
54 | }
55 |
56 | @Override
57 | public int getItemType() {
58 | return SimpleHelper.TYPE_ONE;
59 | }
60 |
61 | @Override
62 | public void setHeaderId(long headerId) {
63 |
64 | }
65 |
66 | @Override
67 | public void setStickyName(String stickyName) {
68 |
69 | }
70 |
71 | @Override
72 | public String getStickyName() {
73 | return stickyName;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/FourthItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.R;
6 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
7 | import com.crazysunj.multityperecyclerviewadapter.sticky.FourthStickyItem;
8 |
9 | import java.util.UUID;
10 |
11 | /**
12 | * Created by sunjian on 2017/3/28.
13 | */
14 |
15 | public class FourthItem implements FourthStickyItem {
16 |
17 | private String name;
18 |
19 | private int img = R.mipmap.ic_launcher;
20 |
21 | private long id;
22 | private String stickyName = "第四条粘性";
23 |
24 | public FourthItem(String name) {
25 | this.name = name;
26 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
27 | }
28 |
29 | public FourthItem(String name, long id) {
30 | this.name = name;
31 | this.id = id;
32 | }
33 |
34 | public int getImg() {
35 | return img;
36 | }
37 |
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | @Override
43 | public boolean equals(@Nullable Object obj) {
44 | if (!(obj instanceof FourthItem)) {
45 | return false;
46 | }
47 | return id == ((FourthItem) obj).id;
48 | }
49 |
50 | @Override
51 | public long getHeaderId() {
52 | return 4;
53 | }
54 |
55 | @Override
56 | public int getItemType() {
57 | return SimpleHelper.TYPE_TWO;
58 | }
59 |
60 | @Override
61 | public void setHeaderId(long headerId) {
62 |
63 | }
64 |
65 | @Override
66 | public void setStickyName(String stickyName) {
67 |
68 | }
69 |
70 | @Override
71 | public String getStickyName() {
72 | return stickyName;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/LoadingEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.helper.DefaultMultiHeaderEntity;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/7/3.
13 | */
14 |
15 | public class LoadingEntity extends DefaultMultiHeaderEntity {
16 |
17 | private long id;
18 |
19 | private int type;
20 |
21 | public LoadingEntity(int type) {
22 | this.id = UUID.nameUUIDFromBytes(("loading_" + type).getBytes()).hashCode();
23 | this.type = type;
24 | }
25 |
26 | @Override
27 | public int getItemType() {
28 | return type;
29 | }
30 |
31 | @Override
32 | public boolean equals(@Nullable Object obj) {
33 | if (!(obj instanceof LoadingEntity)) {
34 | return false;
35 | }
36 | return id == ((LoadingEntity) obj).id;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/MyEmptyEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | /**
4 | * description
5 | *
6 | * Created by sunjian on 2017/5/16.
7 | */
8 |
9 | public class MyEmptyEntity extends SimpleEmptyEntity {
10 |
11 | private String title;
12 |
13 | public MyEmptyEntity(int type, String title) {
14 |
15 | super(type);
16 | this.title = title;
17 | }
18 |
19 | public String getTitle() {
20 | return title;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/MyErrorAndEmptyEmptyEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | /**
4 | * description
5 | *
6 | * Created by sunjian on 2017/5/16.
7 | */
8 |
9 | public class MyErrorAndEmptyEmptyEntity extends ErrorAndEmptyEmptyEntity {
10 |
11 | private String title;
12 |
13 | public MyErrorAndEmptyEmptyEntity(int type, String title) {
14 |
15 | super(type);
16 | this.title = title;
17 | }
18 |
19 | public String getTitle() {
20 | return title;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/MyErrorAndEmptyErrorEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | /**
4 | * description
5 | *
6 | * Created by sunjian on 2017/5/16.
7 | */
8 |
9 | public class MyErrorAndEmptyErrorEntity extends ErrorAndEmptyErrorEntity {
10 |
11 | private String title;
12 | private String message;
13 |
14 | public MyErrorAndEmptyErrorEntity(int type, String title, String message) {
15 | super(type);
16 | this.title = title;
17 | this.message = message;
18 | }
19 |
20 | public String getTitle() {
21 | return title;
22 | }
23 |
24 | public String getMessage() {
25 | return message;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/MyErrorEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | /**
4 | * description
5 | *
6 | * Created by sunjian on 2017/5/16.
7 | */
8 |
9 | public class MyErrorEntity extends SimpleErrorEntity {
10 |
11 | private String title;
12 | private String message;
13 |
14 | public MyErrorEntity(int type, String title, String message) {
15 | super(type);
16 | this.title = title;
17 | this.message = message;
18 | }
19 |
20 | public String getTitle() {
21 | return title;
22 | }
23 |
24 | public String getMessage() {
25 | return message;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/NoStickyEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
4 | import com.crazysunj.multityperecyclerviewadapter.sticky.StickyItem;
5 |
6 | /**
7 | * description
8 | *
9 | * Created by sunjian on 2017/7/3.
10 | */
11 |
12 | public abstract class NoStickyEntity implements StickyItem {
13 |
14 | @Override
15 | public void setHeaderId(long headerId) {
16 |
17 | }
18 |
19 | @Override
20 | public void setStickyName(String stickyName) {
21 |
22 | }
23 |
24 | @Override
25 | public String getStickyName() {
26 | return null;
27 | }
28 |
29 | @Override
30 | public long getHeaderId() {
31 | return StickyHeaderDecoration.NO_HEADER_ID;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/SecondItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.R;
6 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
7 | import com.crazysunj.multityperecyclerviewadapter.sticky.SecondStickyItem;
8 |
9 | import java.util.UUID;
10 |
11 | /**
12 | * Created by sunjian on 2017/3/28.
13 | */
14 |
15 | public class SecondItem implements SecondStickyItem {
16 |
17 | private String name;
18 | private long id;
19 | private int img = R.mipmap.ic_launcher;
20 |
21 | private String stickyName = "第二条粘性";
22 |
23 | public SecondItem(String name) {
24 | this.name = name;
25 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
26 | }
27 |
28 | public SecondItem(String name, long id) {
29 | this.name = name;
30 | this.id = id;
31 | }
32 |
33 | public int getImg() {
34 | return img;
35 | }
36 |
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | @Override
42 | public boolean equals(@Nullable Object obj) {
43 | if (!(obj instanceof SecondItem)) {
44 | return false;
45 | }
46 | return id == ((SecondItem) obj).id;
47 | }
48 |
49 | @Override
50 | public long getHeaderId() {
51 | return 2;
52 | }
53 |
54 | @Override
55 | public int getItemType() {
56 | return SimpleHelper.TYPE_THREE;
57 | }
58 |
59 | @Override
60 | public void setHeaderId(long headerId) {
61 |
62 | }
63 |
64 | @Override
65 | public void setStickyName(String stickyName) {
66 |
67 | }
68 |
69 | @Override
70 | public String getStickyName() {
71 | return stickyName;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/SimpleEmptyEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.helper.DefaultMultiHeaderEntity;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/5/16.
13 | */
14 |
15 | public class SimpleEmptyEntity extends DefaultMultiHeaderEntity {
16 |
17 | private long id;
18 |
19 | private int type;
20 |
21 | public SimpleEmptyEntity(int type) {
22 | this.id = UUID.nameUUIDFromBytes(("empty_" + type).getBytes()).hashCode();
23 | this.type = type;
24 | }
25 |
26 | public void setType(int type) {
27 | this.type = type;
28 | }
29 |
30 | public void setId(long id) {
31 | this.id = id;
32 | }
33 |
34 | @Override
35 | public int getItemType() {
36 | return type;
37 | }
38 |
39 | @Override
40 | public boolean equals(@Nullable Object obj) {
41 | if (!(obj instanceof SimpleEmptyEntity)) {
42 | return false;
43 | }
44 | return id == ((SimpleEmptyEntity) obj).id;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/SimpleErrorEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.helper.DefaultMultiHeaderEntity;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/5/16.
13 | */
14 |
15 | public class SimpleErrorEntity extends DefaultMultiHeaderEntity {
16 |
17 | private long id;
18 | private int type;
19 |
20 | public SimpleErrorEntity(int type) {
21 | this.id = UUID.nameUUIDFromBytes(("error_" + type).getBytes()).hashCode();
22 | this.type = type;
23 | }
24 |
25 | public void setId(long id) {
26 | this.id = id;
27 | }
28 |
29 | public void setType(int type) {
30 | this.type = type;
31 | }
32 |
33 | @Override
34 | public int getItemType() {
35 | return type;
36 | }
37 |
38 | @Override
39 | public boolean equals(@Nullable Object obj) {
40 | if (!(obj instanceof SimpleErrorEntity)) {
41 | return false;
42 | }
43 | return id == ((SimpleErrorEntity) obj).id;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/data/ThirdItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.R;
6 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
7 | import com.crazysunj.multityperecyclerviewadapter.sticky.ThirdStickyItem;
8 |
9 | import java.util.UUID;
10 |
11 | /**
12 | * Created by sunjian on 2017/3/28.
13 | */
14 |
15 | public class ThirdItem implements ThirdStickyItem {
16 |
17 | private String name;
18 | private long id;
19 | private int img = R.mipmap.ic_launcher;
20 | private String stickyName = "第三条粘性";
21 |
22 | public ThirdItem(String name) {
23 | this.name = name;
24 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
25 | }
26 |
27 | public ThirdItem(String name, long id) {
28 | this.name = name;
29 | this.id = id;
30 | }
31 |
32 | public int getImg() {
33 | return img;
34 | }
35 |
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | @Override
41 | public boolean equals(@Nullable Object obj) {
42 | if (!(obj instanceof ThirdItem)) {
43 | return false;
44 | }
45 | return id == ((ThirdItem) obj).id;
46 | }
47 |
48 | @Override
49 | public long getHeaderId() {
50 | return 3;
51 | }
52 |
53 | @Override
54 | public int getItemType() {
55 | return SimpleHelper.TYPE_FOUR;
56 | }
57 |
58 | @Override
59 | public void setHeaderId(long headerId) {
60 |
61 | }
62 |
63 | @Override
64 | public void setStickyName(String stickyName) {
65 |
66 | }
67 |
68 | @Override
69 | public String getStickyName() {
70 | return stickyName;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/EmptyOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/7/5.
13 | */
14 |
15 | public class EmptyOCEntity implements OpenCloseItem {
16 |
17 | private long id;
18 |
19 | private String title;
20 | private int type;
21 | private final int FLAG = -3;
22 |
23 | public EmptyOCEntity(int type, String title) {
24 | this.type = type;
25 | this.title = title;
26 | id = UUID.nameUUIDFromBytes((FLAG + title).getBytes()).hashCode();
27 | }
28 |
29 | public void setTitle(String title) {
30 | this.title = title;
31 | }
32 |
33 | @Override
34 | public String getTitle() {
35 | return title;
36 | }
37 |
38 | @Override
39 | public int getFlag() {
40 | return FLAG;
41 | }
42 |
43 | @Override
44 | public int getItemType() {
45 | return type;
46 | }
47 |
48 | @Override
49 | public boolean equals(@Nullable Object obj) {
50 | if (!(obj instanceof EmptyOCEntity)) {
51 | return false;
52 | }
53 | if (id != ((EmptyOCEntity) obj).id) {
54 | return false;
55 | }
56 | if (title == null) {
57 | return false;
58 | }
59 | return title.equals(((EmptyOCEntity) obj).title);
60 | }
61 |
62 | @Override
63 | public long getHeaderId() {
64 | return StickyHeaderDecoration.NO_HEADER_ID;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/ErrorOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/7/5.
13 | */
14 |
15 | public class ErrorOCEntity implements OpenCloseItem {
16 |
17 | private long id;
18 |
19 | private String title;
20 | private int type;
21 | private final int FLAG = -4;
22 |
23 | public ErrorOCEntity(int type, String title) {
24 | this.type = type;
25 | this.title = title;
26 | id = UUID.nameUUIDFromBytes((FLAG + title).getBytes()).hashCode();
27 | }
28 |
29 | public void setTitle(String title) {
30 | this.title = title;
31 | }
32 |
33 | @Override
34 | public String getTitle() {
35 | return title;
36 | }
37 |
38 | @Override
39 | public int getFlag() {
40 | return FLAG;
41 | }
42 |
43 | @Override
44 | public int getItemType() {
45 | return type;
46 | }
47 |
48 | @Override
49 | public boolean equals(@Nullable Object obj) {
50 | if (!(obj instanceof ErrorOCEntity)) {
51 | return false;
52 | }
53 | if (id != ((ErrorOCEntity) obj).id) {
54 | return false;
55 | }
56 | if (title == null) {
57 | return false;
58 | }
59 | return title.equals(((ErrorOCEntity) obj).title);
60 | }
61 |
62 | @Override
63 | public long getHeaderId() {
64 | return StickyHeaderDecoration.NO_HEADER_ID;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/FirstOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/7/5.
13 | */
14 |
15 | public class FirstOCEntity implements OpenCloseItem {
16 |
17 | public static final int OC_FIRST_TYPE = 3;
18 | private long id;
19 |
20 | private String title;
21 | private final int FLAG = 1;
22 |
23 | public FirstOCEntity(String title) {
24 | this.title = title;
25 | id = UUID.nameUUIDFromBytes((FLAG + title).getBytes()).hashCode();
26 | }
27 |
28 | @Override
29 | public String getTitle() {
30 | return title;
31 | }
32 |
33 | @Override
34 | public int getFlag() {
35 | return FLAG;
36 | }
37 |
38 | @Override
39 | public int getItemType() {
40 | return OC_FIRST_TYPE;
41 | }
42 |
43 | @Override
44 | public boolean equals(@Nullable Object obj) {
45 | if (!(obj instanceof FirstOCEntity)) {
46 | return false;
47 | }
48 | if (id != ((FirstOCEntity) obj).id) {
49 | return false;
50 | }
51 | if (title == null) {
52 | return false;
53 | }
54 | return title.equals(((FirstOCEntity) obj).title);
55 | }
56 |
57 | @Override
58 | public long getHeaderId() {
59 | return StickyHeaderDecoration.NO_HEADER_ID;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/FooterOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.helper.RecyclerViewAdapterHelper;
6 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
7 |
8 | import java.util.Locale;
9 |
10 | /**
11 | * description
12 | *
13 | * Created by sunjian on 2017/7/5.
14 | */
15 |
16 | public class FooterOCEntity implements OpenCloseItem {
17 |
18 | private long id;
19 | private String title;
20 | private int type;
21 | private final int FLAG = -2;
22 |
23 | public FooterOCEntity(int type, String title, long id) {
24 | this.type = type;
25 | this.title = title;
26 | this.id = id;
27 | // id = String.format(Locale.getDefault(), "%d_%d_%s", FLAG, type, title).hashCode();
28 | }
29 |
30 | public FooterOCEntity(int type, String title) {
31 | this.type = type;
32 | this.title = title;
33 | id = String.format(Locale.getDefault(), "%d_%d_%s", FLAG, type, title).hashCode();
34 | }
35 |
36 | public void setTitle(String title) {
37 | this.title = title;
38 | }
39 |
40 | @Override
41 | public String getTitle() {
42 | return title;
43 | }
44 |
45 | @Override
46 | public int getFlag() {
47 | return FLAG;
48 | }
49 |
50 | @Override
51 | public int getItemType() {
52 | return type - RecyclerViewAdapterHelper.FOOTER_TYPE_DIFFER;
53 | }
54 |
55 | @Override
56 | public boolean equals(@Nullable Object obj) {
57 | if (!(obj instanceof FooterOCEntity)) {
58 | return false;
59 | }
60 | if (id != ((FooterOCEntity) obj).id) {
61 | return false;
62 | }
63 | if (title == null) {
64 | return false;
65 | }
66 | return title.equals(((FooterOCEntity) obj).title);
67 | }
68 |
69 | @Override
70 | public long getHeaderId() {
71 | return StickyHeaderDecoration.NO_HEADER_ID;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/LoadingOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
6 |
7 | /**
8 | * description
9 | *
10 | * Created by sunjian on 2017/7/5.
11 | */
12 |
13 | public class LoadingOCEntity implements OpenCloseItem {
14 |
15 | private long id;
16 |
17 | private int type;
18 | private final int FLAG = -5;
19 |
20 | public LoadingOCEntity(int type, long id) {
21 | this.type = type;
22 | this.id = id;
23 | }
24 |
25 | @Override
26 | public String getTitle() {
27 | return "";
28 | }
29 |
30 | @Override
31 | public int getFlag() {
32 | return FLAG;
33 | }
34 |
35 | @Override
36 | public int getItemType() {
37 | return type;
38 | }
39 |
40 | @Override
41 | public boolean equals(@Nullable Object obj) {
42 | if (!(obj instanceof LoadingOCEntity)) {
43 | return false;
44 | }
45 | return id == ((LoadingOCEntity) obj).id;
46 | }
47 | @Override
48 | public long getHeaderId() {
49 | return StickyHeaderDecoration.NO_HEADER_ID;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/OpenCloseAdapterHelper.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import com.crazysunj.multitypeadapter.helper.AsynAdapterHelper;
4 | import com.crazysunj.multityperecyclerviewadapter.R;
5 |
6 | /**
7 | * description
8 | *
9 | * Created by sunjian on 2017/7/5.
10 | */
11 |
12 | public class OpenCloseAdapterHelper extends AsynAdapterHelper
8 | * Created by sunjian on 2017/7/5.
9 | */
10 |
11 | public interface OpenCloseItem extends MultiHeaderEntity {
12 | int getFlag();
13 |
14 | String getTitle();
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/SecondOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/7/5.
13 | */
14 |
15 | public class SecondOCEntity implements OpenCloseItem {
16 |
17 | public static final int OC_SECOND_TYPE = 6;
18 | private long id;
19 |
20 | private String title;
21 | private final int FLAG = 2;
22 |
23 | public SecondOCEntity(String title) {
24 | this.title = title;
25 | id = UUID.nameUUIDFromBytes((FLAG + title).getBytes()).hashCode();
26 | }
27 |
28 | @Override
29 | public String getTitle() {
30 | return title;
31 | }
32 |
33 | @Override
34 | public int getFlag() {
35 | return FLAG;
36 | }
37 |
38 | @Override
39 | public int getItemType() {
40 | return OC_SECOND_TYPE;
41 | }
42 |
43 | @Override
44 | public boolean equals(@Nullable Object obj) {
45 | if (!(obj instanceof SecondOCEntity)) {
46 | return false;
47 | }
48 | if (id != ((SecondOCEntity) obj).id) {
49 | return false;
50 | }
51 | if (title == null) {
52 | return false;
53 | }
54 | return title.equals(((SecondOCEntity) obj).title);
55 | }
56 |
57 | @Override
58 | public long getHeaderId() {
59 | return StickyHeaderDecoration.NO_HEADER_ID;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/ThirdOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * description
11 | *
12 | * Created by sunjian on 2017/7/5.
13 | */
14 |
15 | public class ThirdOCEntity implements OpenCloseItem {
16 |
17 | public static final int OC_THIRD_TYPE = 9;
18 | private long id;
19 |
20 | private String title;
21 | private final int FLAG = 3;
22 |
23 | public ThirdOCEntity(String title) {
24 | this.title = title;
25 | id = UUID.nameUUIDFromBytes((FLAG + title).getBytes()).hashCode();
26 | }
27 |
28 | @Override
29 | public String getTitle() {
30 | return title;
31 | }
32 |
33 | @Override
34 | public int getFlag() {
35 | return FLAG;
36 | }
37 |
38 | @Override
39 | public int getItemType() {
40 | return OC_THIRD_TYPE;
41 | }
42 |
43 | @Override
44 | public boolean equals(@Nullable Object obj) {
45 | if (!(obj instanceof ThirdOCEntity)) {
46 | return false;
47 | }
48 | if (id != ((ThirdOCEntity) obj).id) {
49 | return false;
50 | }
51 | if (title == null) {
52 | return false;
53 | }
54 | return title.equals(((ThirdOCEntity) obj).title);
55 | }
56 |
57 | @Override
58 | public long getHeaderId() {
59 | return StickyHeaderDecoration.NO_HEADER_ID;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/TitleOCEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.expand;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.helper.RecyclerViewAdapterHelper;
6 | import com.crazysunj.multitypeadapter.sticky.StickyHeaderDecoration;
7 |
8 | import java.util.UUID;
9 |
10 | /**
11 | * description
12 | *
13 | * Created by sunjian on 2017/7/5.
14 | */
15 |
16 | public class TitleOCEntity implements OpenCloseItem {
17 |
18 | private long id;
19 |
20 | private String title;
21 | private int type;
22 | private final int FLAG = -1;
23 |
24 | public TitleOCEntity(int type, String title) {
25 | this.type = type;
26 | this.title = title;
27 | id = UUID.nameUUIDFromBytes((FLAG + title).getBytes()).hashCode();
28 | }
29 |
30 | @Override
31 | public String getTitle() {
32 | return title;
33 | }
34 |
35 | @Override
36 | public int getFlag() {
37 | return FLAG;
38 | }
39 |
40 | @Override
41 | public int getItemType() {
42 | return type - RecyclerViewAdapterHelper.HEADER_TYPE_DIFFER;
43 | }
44 |
45 | @Override
46 | public boolean equals(@Nullable Object obj) {
47 | if (!(obj instanceof TitleOCEntity)) {
48 | return false;
49 | }
50 | if (id != ((TitleOCEntity) obj).id) {
51 | return false;
52 | }
53 | if (title == null) {
54 | return false;
55 | }
56 | return title.equals(((TitleOCEntity) obj).title);
57 | }
58 |
59 | @Override
60 | public long getHeaderId() {
61 | return StickyHeaderDecoration.NO_HEADER_ID;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/header/HeaderFirstItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.header;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
6 | import com.crazysunj.multityperecyclerviewadapter.sticky.FirstStickyItem;
7 |
8 | import java.util.UUID;
9 |
10 | /**
11 | * Created by sunjian on 2017/3/28.
12 | */
13 |
14 | public class HeaderFirstItem implements FirstStickyItem {
15 |
16 | private String name;
17 | private long id;
18 | private String stickyName = "第一条粘性";
19 |
20 | public HeaderFirstItem(String name) {
21 | this.name = name;
22 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
23 | }
24 |
25 | public HeaderFirstItem(String name, long id) {
26 | this.name = name;
27 | this.id = id;
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | @Override
35 | public boolean equals(@Nullable Object obj) {
36 | if (!(obj instanceof HeaderFirstItem)) {
37 | return false;
38 | }
39 | return id == ((HeaderFirstItem) obj).id;
40 | }
41 |
42 | @Override
43 | public long getHeaderId() {
44 | return 1;
45 | }
46 |
47 | @Override
48 | public int getItemType() {
49 | return SimpleHelper.LEVEL_FIRST - 1000;
50 | }
51 |
52 | @Override
53 | public void setHeaderId(long headerId) {
54 |
55 | }
56 |
57 | @Override
58 | public void setStickyName(String stickyName) {
59 |
60 | }
61 |
62 | @Override
63 | public String getStickyName() {
64 | return stickyName;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/header/HeaderFourthItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.header;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
6 | import com.crazysunj.multityperecyclerviewadapter.sticky.FourthStickyItem;
7 |
8 | import java.util.UUID;
9 |
10 | /**
11 | * Created by sunjian on 2017/3/28.
12 | */
13 |
14 | public class HeaderFourthItem implements FourthStickyItem {
15 |
16 | private String name;
17 | private long id;
18 | private String stickyName = "第四条粘性";
19 |
20 | public HeaderFourthItem(String name) {
21 | this.name = name;
22 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
23 | }
24 |
25 | public HeaderFourthItem(String name, long id) {
26 | this.name = name;
27 | this.id = id;
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | @Override
35 | public boolean equals(@Nullable Object obj) {
36 | if (!(obj instanceof HeaderFourthItem)) {
37 | return false;
38 | }
39 | return id == ((HeaderFourthItem) obj).id;
40 | }
41 |
42 | @Override
43 | public long getHeaderId() {
44 | return 4;
45 | }
46 |
47 |
48 | @Override
49 | public int getItemType() {
50 | return SimpleHelper.LEVEL_FOURTH - 1000;
51 | }
52 |
53 | @Override
54 | public void setHeaderId(long headerId) {
55 |
56 | }
57 |
58 | @Override
59 | public void setStickyName(String stickyName) {
60 |
61 | }
62 |
63 | @Override
64 | public String getStickyName() {
65 | return stickyName;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/header/HeaderSecondItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.header;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
6 | import com.crazysunj.multityperecyclerviewadapter.sticky.SecondStickyItem;
7 |
8 | import java.util.UUID;
9 |
10 | /**
11 | * Created by sunjian on 2017/3/28.
12 | */
13 |
14 | public class HeaderSecondItem implements SecondStickyItem {
15 |
16 | private String name;
17 | private long id;
18 | private String stickyName = "第二条粘性";
19 |
20 | public HeaderSecondItem(String name) {
21 | this.name = name;
22 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
23 | }
24 |
25 | public HeaderSecondItem(String name, long id) {
26 | this.name = name;
27 | this.id = id;
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | @Override
35 | public boolean equals(@Nullable Object obj) {
36 | if (!(obj instanceof HeaderSecondItem)) {
37 | return false;
38 | }
39 | return id == ((HeaderSecondItem) obj).id;
40 | }
41 |
42 | @Override
43 | public long getHeaderId() {
44 | return 2;
45 | }
46 |
47 | @Override
48 | public int getItemType() {
49 | return SimpleHelper.LEVEL_SENCOND - 1000;
50 | }
51 |
52 | @Override
53 | public void setHeaderId(long headerId) {
54 |
55 | }
56 |
57 | @Override
58 | public void setStickyName(String stickyName) {
59 |
60 | }
61 |
62 | @Override
63 | public String getStickyName() {
64 | return stickyName;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/header/HeaderThirdItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.header;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multityperecyclerviewadapter.helper.SimpleHelper;
6 | import com.crazysunj.multityperecyclerviewadapter.sticky.ThirdStickyItem;
7 |
8 | import java.util.UUID;
9 |
10 | /**
11 | * Created by sunjian on 2017/3/28.
12 | */
13 |
14 | public class HeaderThirdItem implements ThirdStickyItem {
15 |
16 | private String name;
17 | private long id;
18 | private String stickyName = "第三条粘性";
19 |
20 | public HeaderThirdItem(String name) {
21 | this.name = name;
22 | id = UUID.nameUUIDFromBytes((name + stickyName).getBytes()).hashCode();
23 | }
24 |
25 | public HeaderThirdItem(String name, long id) {
26 | this.name = name;
27 | this.id = id;
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | @Override
35 | public boolean equals(@Nullable Object obj) {
36 | if (!(obj instanceof HeaderThirdItem)) {
37 | return false;
38 | }
39 | return id == ((HeaderThirdItem) obj).id;
40 | }
41 |
42 | @Override
43 | public long getHeaderId() {
44 | return 3;
45 | }
46 |
47 | @Override
48 | public int getItemType() {
49 | return SimpleHelper.LEVEL_THIRD - 1000;
50 | }
51 |
52 | @Override
53 | public void setHeaderId(long headerId) {
54 |
55 | }
56 |
57 | @Override
58 | public void setStickyName(String stickyName) {
59 |
60 | }
61 |
62 | @Override
63 | public String getStickyName() {
64 | return stickyName;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/helper/DefaultMultiHeaderEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sun Jian
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.crazysunj.multityperecyclerviewadapter.helper;
17 |
18 | /**
19 | * @author sunjian
20 | * @description 默认实现返回StickyHeaderDecoration.NO_HEADER_ID
21 | * android现在还不能很好兼容java8特性,无奈之举,不然使用default method
22 | * @date 2017/5/13
23 | */
24 | public abstract class DefaultMultiHeaderEntity implements MultiHeaderEntity {
25 |
26 | @Override
27 | public long getHeaderId() {
28 | return -1;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/helper/MultiHeaderEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 Sun Jian
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.crazysunj.multityperecyclerviewadapter.helper;
17 |
18 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
19 |
20 | /**
21 | * 多类型实体类接口
22 | * id标志不同数据项(包括头,唯一标识)
23 | * headerId标志粘性头部的类型(拥有相同headerId的数据项公用同一个粘性头部)
24 | * itemType标志数据的类型
25 | * 该类已经过时,希望大家自己实现,讲道理,这跟我们的主题并不符合
26 | * Created by sunjian on 2017/3/28.
27 | */
28 |
29 | public interface MultiHeaderEntity extends MultiTypeEntity {
30 |
31 | long getHeaderId();
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/helper/ShimmerViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.helper;
2 |
3 | import android.view.View;
4 |
5 | import com.facebook.shimmer.ShimmerFrameLayout;
6 |
7 | public class ShimmerViewHolder extends BaseViewHolder {
8 |
9 | public ShimmerViewHolder(View view) {
10 | super(view);
11 | if (view instanceof ShimmerFrameLayout) {
12 | final ShimmerFrameLayout shimmerView = (ShimmerFrameLayout) view;
13 | shimmerView.stopShimmer();
14 | }
15 | }
16 |
17 | public void startAnim() {
18 | if (itemView instanceof ShimmerFrameLayout) {
19 | final ShimmerFrameLayout shimmerView = (ShimmerFrameLayout) itemView;
20 | if (!shimmerView.isShimmerStarted()) {
21 | shimmerView.postDelayed(new Runnable() {
22 | @Override
23 | public void run() {
24 | shimmerView.startShimmer();
25 | }
26 | }, 100);
27 |
28 | }
29 | }
30 | }
31 |
32 | public void stopAnim() {
33 | if (itemView instanceof ShimmerFrameLayout) {
34 | final ShimmerFrameLayout shimmerView = (ShimmerFrameLayout) itemView;
35 | if (shimmerView.isShimmerStarted()) {
36 | shimmerView.stopShimmer();
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/sticky/FirstStickyItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.sticky;
2 |
3 | /**
4 | * Created by sunjian on 2017/3/30.
5 | */
6 |
7 | public interface FirstStickyItem extends StickyItem {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/sticky/FourthStickyItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.sticky;
2 |
3 | /**
4 | * Created by sunjian on 2017/3/30.
5 | */
6 |
7 | public interface FourthStickyItem extends StickyItem {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/sticky/SecondStickyItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.sticky;
2 |
3 | /**
4 | * Created by sunjian on 2017/3/30.
5 | */
6 |
7 | public interface SecondStickyItem extends StickyItem {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/sticky/StickyItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.sticky;
2 |
3 | import com.crazysunj.multityperecyclerviewadapter.helper.MultiHeaderEntity;
4 |
5 | /**
6 | * Created by sunjian on 2017/3/30.
7 | */
8 |
9 | public interface StickyItem extends MultiHeaderEntity {
10 | void setHeaderId(long headerId);
11 |
12 | void setStickyName(String stickyName);
13 |
14 | String getStickyName();
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/sticky/ThirdStickyItem.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.sticky;
2 |
3 | /**
4 | * Created by sunjian on 2017/3/30.
5 | */
6 |
7 | public interface ThirdStickyItem extends StickyItem {
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/switchtype/FirstType.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.switchtype;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
6 |
7 | /**
8 | * @author: sunjian
9 | * created on: 2017/10/19 上午11:16
10 | * description:
11 | */
12 |
13 | public class FirstType implements MultiTypeEntity {
14 |
15 | public static final int TYPE_1 = 0;
16 |
17 | private long id;
18 | private String title;
19 |
20 | public FirstType(long id, String title) {
21 | this.id = id;
22 | this.title = title;
23 | }
24 |
25 | public String getTitle() {
26 | return title;
27 | }
28 |
29 | @Override
30 | public int getItemType() {
31 | return TYPE_1;
32 | }
33 |
34 | @Override
35 | public boolean equals(@Nullable Object obj) {
36 | if (!(obj instanceof FirstType)) {
37 | return false;
38 | }
39 | return id == ((FirstType) obj).id;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/switchtype/FourthType.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.switchtype;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
6 |
7 |
8 | /**
9 | * @author: sunjian
10 | * created on: 2017/10/19 上午11:16
11 | * description:
12 | */
13 |
14 | public class FourthType implements MultiTypeEntity {
15 |
16 | public static final int TYPE_4 = 3;
17 |
18 | private long id;
19 | private String title;
20 |
21 | public FourthType(long id, String title) {
22 | this.id = id;
23 | this.title = title;
24 | }
25 |
26 | public String getTitle() {
27 | return title;
28 | }
29 |
30 | @Override
31 | public int getItemType() {
32 | return TYPE_4;
33 | }
34 | @Override
35 | public boolean equals(@Nullable Object obj) {
36 | if (!(obj instanceof FourthType)) {
37 | return false;
38 | }
39 | return id == ((FourthType) obj).id;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/switchtype/SecondType.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.switchtype;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
6 |
7 |
8 | /**
9 | * @author: sunjian
10 | * created on: 2017/10/19 上午11:16
11 | * description:
12 | */
13 |
14 | public class SecondType implements MultiTypeEntity {
15 |
16 | public static final int TYPE_2 = 1;
17 |
18 | private long id;
19 | private String title;
20 |
21 | public SecondType(long id, String title) {
22 | this.id = id;
23 | this.title = title;
24 | }
25 |
26 | public String getTitle() {
27 | return title;
28 | }
29 |
30 | @Override
31 | public int getItemType() {
32 | return TYPE_2;
33 | }
34 |
35 | @Override
36 | public boolean equals(@Nullable Object obj) {
37 | if (!(obj instanceof SecondType)) {
38 | return false;
39 | }
40 | return id == ((SecondType) obj).id;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/crazysunj/multityperecyclerviewadapter/switchtype/SwitchTypeAdapterHelper.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.multityperecyclerviewadapter.switchtype;
2 |
3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
4 | import com.crazysunj.multitypeadapter.helper.AsynAdapterHelper;
5 | import com.crazysunj.multityperecyclerviewadapter.R;
6 |
7 | /**
8 | * @author: sunjian
9 | * created on: 2017/10/19 上午11:11
10 | * description:
11 | */
12 |
13 | public class SwitchTypeAdapterHelper extends AsynAdapterHelper
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.recycler;
17 |
18 | import androidx.annotation.LayoutRes;
19 |
20 | import java.lang.annotation.ElementType;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.RetentionPolicy;
23 | import java.lang.annotation.Target;
24 |
25 | /**
26 | * @author sunjian
27 | * @date 2019-10-23 09:35
28 | */
29 | @Target(ElementType.TYPE)
30 | @Retention(RetentionPolicy.RUNTIME)
31 | public @interface BindLayout {
32 | @LayoutRes int layoutId() default 0;
33 | }
34 |
--------------------------------------------------------------------------------
/component/src/main/java/com/crazysunj/recycler/CrazyViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Sun Jian
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.recycler;
17 |
18 | import android.view.View;
19 |
20 | import androidx.annotation.NonNull;
21 | import androidx.recyclerview.widget.RecyclerView;
22 |
23 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
24 |
25 | /**
26 | * 基础封装ViewHolder,直接采用ViewHolder有个比较大的缺点是不能直接进到对应layout的xml文件
27 | *
28 | * @author sunjian
29 | * @date 2019-10-18 14:38
30 | */
31 | public class CrazyViewHolder
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.adapter;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/6/29
21 | * description: 空实体类的适配器
22 | */
23 | @FunctionalInterface
24 | public interface EmptyEntityAdapter
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.adapter;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/6/29
21 | * description: 错误实体类的适配器
22 | */
23 | @FunctionalInterface
24 | public interface ErrorEntityAdapter
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.adapter;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/6/29
21 | * description: 加载实体类的适配器
22 | */
23 | public interface LoadingEntityAdapter
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.entity;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | * @author: sunjian
22 | * created on: 2017/3/31
23 | * description: 给异步AdapterHelper封装实体类
24 | */
25 | public final class HandleBase
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.entity;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | /**
22 | * @author: sunjian
23 | * created on: 2017/3/27
24 | * description: 存储单个level数据实体
25 | * 没有读懂源码之前,尽量不要在这里修改数据
26 | */
27 | public final class LevelData
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.entity;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/3/28
21 | * description: 多类型实体类接口
22 | */
23 | public interface MultiTypeEntity {
24 |
25 | /**
26 | * itemType标志数据的类型
27 | * 对应{@link androidx.recyclerview.widget.RecyclerView.Adapter#getItemViewType(int)}
28 | *
29 | * @return int
30 | */
31 | int getItemType();
32 |
33 | /**
34 | * 比较两个数据内容是否相同,完全由用户去自定义,这里不采用系统的equals是因为Java的许多集合操作都会关联这个方法
35 | * @param entity
36 | * @return
37 | */
38 | // boolean areContentsTheSame(MultiTypeEntity entity);
39 | }
40 |
--------------------------------------------------------------------------------
/multitypeadapter/src/main/java/com/crazysunj/multitypeadapter/helper/AdapterBindException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Sun Jian
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.helper;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/5/27
21 | * description: adapter未绑定,空指针异常
22 | */
23 | class AdapterBindException extends RuntimeException {
24 |
25 | AdapterBindException() {
26 | }
27 |
28 | AdapterBindException(String message) {
29 | super(message);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/multitypeadapter/src/main/java/com/crazysunj/multitypeadapter/helper/DataException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Sun Jian
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.helper;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/5/27
21 | * description: 处理数据的时候异常
22 | */
23 | class DataException extends RuntimeException {
24 |
25 | DataException() {
26 | }
27 |
28 | DataException(String message) {
29 | super(message);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/multitypeadapter/src/main/java/com/crazysunj/multitypeadapter/helper/DiffCallBack.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Sun Jian
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.helper;
17 |
18 | import androidx.recyclerview.widget.DiffUtil;
19 |
20 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
21 |
22 | import java.util.List;
23 |
24 | /**
25 | * @author: sunjian
26 | * created on: 2017/3/28
27 | * description: 关于新老数据比较的callback,暂时不提供出去
28 | * 如果你有自己的比较逻辑,实现接口{@link RecyclerViewAdapterHelper#getDiffCallBack(List, List)}
29 | */
30 | class DiffCallBack
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.helper;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/6/9
21 | * description: loading的全局刷新配置实体
22 | * @see LoadingConfig
23 | */
24 | class LoadingConfigEntity {
25 |
26 | /**
27 | * 需要展示多少个
28 | */
29 | int count;
30 | /**
31 | * 是否拥有头部
32 | */
33 | boolean isHaveHeader;
34 |
35 | LoadingConfigEntity(boolean isHaveHeader) {
36 | this(0, isHaveHeader);
37 | }
38 |
39 | LoadingConfigEntity(int count) {
40 | this(count, false);
41 | }
42 |
43 | LoadingConfigEntity(int count, boolean isHaveHeader) {
44 | this.count = count;
45 | this.isHaveHeader = isHaveHeader;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/multitypeadapter/src/main/java/com/crazysunj/multitypeadapter/helper/RefreshException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Sun Jian
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.helper;
17 |
18 | /**
19 | * @author: sunjian
20 | * created on: 2017/5/27
21 | * description: 刷新异常
22 | */
23 | class RefreshException extends RuntimeException {
24 |
25 | RefreshException() {
26 | }
27 |
28 | RefreshException(String message) {
29 | super(message);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/multitypeadapter/src/main/java/com/crazysunj/multitypeadapter/helper/SynAdapterHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 Sun Jian
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.crazysunj.multitypeadapter.helper;
17 |
18 | import com.crazysunj.multitypeadapter.entity.HandleBase;
19 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
20 |
21 | /**
22 | * @author: sunjian
23 | * created on: 2017/4/1
24 | * description:
25 | * 同步适配器,数据量过大可能会卡顿,甚至出现ANR,相对来说比较稳定
26 | * 卡顿的原因主要是计算差异数据量过大以及大量UI更新
27 | * 可以采用异步刷新{@link AsynAdapterHelper}
28 | */
29 | public class SynAdapterHelper
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.crazysunj.sample;
17 |
18 | /**
19 | * author: sunjian
20 | * created on: 2018/7/6 下午2:54
21 | * description: 辅助开发者自定义ID
22 | */
23 | public class IDUtil {
24 | private static final long MIN_ID = Long.MIN_VALUE;
25 | private static final long MAX_ID = Long.MAX_VALUE;
26 | private static long sCurrentId = MIN_ID;
27 |
28 | private IDUtil() {
29 | }
30 |
31 | /**
32 | * 辅助id
33 | * 有特殊要求的同学可以自己设计
34 | *
35 | * @return 返回不重复Id
36 | */
37 | public static long getId() {
38 | if (MAX_ID <= sCurrentId) {
39 | throw new RuntimeException("it's the biggest");
40 | }
41 | return sCurrentId++;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/crazysunj/sample/adapter/FooterVPAdapter.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.sample.adapter;
2 |
3 | import com.crazysunj.sample.FooterItemFragment;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | import androidx.fragment.app.Fragment;
9 | import androidx.fragment.app.FragmentManager;
10 | import androidx.fragment.app.FragmentPagerAdapter;
11 |
12 | /**
13 | * author: sunjian
14 | * created on: 2017/8/13 下午4:20
15 | * description:
16 | */
17 |
18 | public class FooterVPAdapter extends FragmentPagerAdapter {
19 |
20 | private static final String[] sTitle = {"疗养中心", "专科用药", "医疗器械", "营养保健"};
21 |
22 | private List
13 | * Created by sunjian on 2017/6/24.
14 | */
15 |
16 | public class APP extends Application {
17 |
18 | @Override
19 | protected void attachBaseContext(Context base) {
20 | super.attachBaseContext(base);
21 | MultiDex.install(this);
22 | }
23 |
24 | @Override
25 | public void onCreate() {
26 | super.onCreate();
27 | if (LeakCanary.isInAnalyzerProcess(this)) {
28 | return;
29 | }
30 | LeakCanary.install(this);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/crazysunj/sample/base/MutiTypeTitleEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.sample.base;
2 |
3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity;
4 |
5 | /**
6 | * author: sunjian
7 | * created on: 2017/8/12 下午4:06
8 | * description:
9 | */
10 |
11 | public interface MutiTypeTitleEntity extends MultiTypeEntity {
12 | String getTitle();
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/crazysunj/sample/constant/Constants.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.sample.constant;
2 |
3 | /**
4 | * description
5 | *
6 | * Created by sunjian on 2017/7/7.
7 | */
8 |
9 | public interface Constants {
10 | String FOLD = "点击收回";
11 | String EXPAND = "查看更多";
12 | String EMPTY = "";
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/crazysunj/sample/entity/CommonFooterEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.sample.entity;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.helper.RecyclerViewAdapterHelper;
6 | import com.crazysunj.sample.base.MutiTypeTitleEntity;
7 |
8 | /**
9 | * author: sunjian
10 | * created on: 2017/8/6 下午5:08
11 | * description:
12 | */
13 |
14 | public class CommonFooterEntity implements MutiTypeTitleEntity {
15 |
16 | private String title;
17 | private int type;
18 | private long id;
19 |
20 | public CommonFooterEntity(String title, int type) {
21 | this.title = title;
22 | this.type = type - RecyclerViewAdapterHelper.FOOTER_TYPE_DIFFER;
23 | this.id = System.currentTimeMillis();
24 | }
25 |
26 | public void setTitle(String title) {
27 | this.title = title;
28 | }
29 |
30 | @Override
31 | public String getTitle() {
32 | return title;
33 | }
34 |
35 | @Override
36 | public int getItemType() {
37 | return type;
38 | }
39 |
40 | @Override
41 | public boolean equals(@Nullable Object obj) {
42 | if (!(obj instanceof CommonFooterEntity)) {
43 | return false;
44 | }
45 | return id == ((CommonFooterEntity) obj).id;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/crazysunj/sample/entity/CommonHeadEntity.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.sample.entity;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.crazysunj.multitypeadapter.helper.RecyclerViewAdapterHelper;
6 | import com.crazysunj.sample.base.MutiTypeTitleEntity;
7 |
8 | /**
9 | * author: sunjian
10 | * created on: 2017/8/6 下午5:08
11 | * description:
12 | */
13 |
14 | public class CommonHeadEntity implements MutiTypeTitleEntity {
15 |
16 | private String title;
17 | private int type;
18 | private long id;
19 |
20 | public CommonHeadEntity(String title, int type) {
21 | this.title = title;
22 | this.type = type - RecyclerViewAdapterHelper.HEADER_TYPE_DIFFER;
23 | this.id = System.currentTimeMillis();
24 | }
25 |
26 | @Override
27 | public String getTitle() {
28 | return title;
29 | }
30 |
31 | @Override
32 | public int getItemType() {
33 | return type;
34 | }
35 |
36 | @Override
37 | public boolean equals(@Nullable Object obj) {
38 | if (!(obj instanceof CommonHeadEntity)) {
39 | return false;
40 | }
41 | return id == ((CommonHeadEntity) obj).id;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/crazysunj/sample/entity/ItemEntity2.java:
--------------------------------------------------------------------------------
1 | package com.crazysunj.sample.entity;
2 |
3 | import android.text.TextUtils;
4 |
5 | import androidx.annotation.Nullable;
6 |
7 | import com.crazysunj.sample.base.MutiTypeTitleEntity;
8 | import com.crazysunj.sample.util.MD5Util;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * author: sunjian
15 | * created on: 2017/8/8 上午9:42
16 | * description:
17 | */
18 |
19 | public class ItemEntity2 implements MutiTypeTitleEntity {
20 |
21 | private int img;
22 | private String title;
23 | private String content;
24 | private String price;
25 | private List