├── .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 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/IDUtil.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; 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 extends CrazyViewHolder { 16 | 17 | protected ComponentSubject mSubject; 18 | 19 | public BaseViewHolder(@NonNull View itemView) { 20 | super(itemView); 21 | } 22 | 23 | @CallSuper 24 | protected void subscribe(@NonNull ComponentSubject subject) { 25 | mSubject = subject; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/ComponentSubject.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.annotation.Nullable; 5 | 6 | /** 7 | * 主容器主题,子组件和主容器之间交互桥梁 8 | * 9 | * @author sunjian 10 | * @date 2019-10-18 20:07 11 | */ 12 | public interface ComponentSubject { 13 | 14 | /** 15 | * @return 主容器上拉加载状态 16 | */ 17 | int loadMoreState(); 18 | 19 | /** 20 | * @return 当前主容器是否可见 21 | */ 22 | boolean isVisible(); 23 | 24 | /** 25 | * 事件交互,通过callback可达到循环依赖 26 | * 27 | * @param event 事件对象 28 | * @param callback 事件回调 29 | */ 30 | void notifyEvent(@NonNull Object event, @Nullable IEvent callback); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/IEvent.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | /** 4 | * @author sunjian 5 | * @date 2019-10-18 20:37 6 | */ 7 | public interface IEvent { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/LoadMore.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | /** 4 | * @author sunjian 5 | * @date 2019-10-21 20:08 6 | */ 7 | class LoadMore { 8 | static int STATE_INIT = 0x100; 9 | static int STATE_LOADING = 0x101; 10 | int state; 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/LoadMoreEvent.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | /** 4 | * @author sunjian 5 | * @date 2019-10-21 20:01 6 | */ 7 | public interface LoadMoreEvent extends IEvent { 8 | void onDefault(); 9 | 10 | void onGone(); 11 | 12 | void onLoading(); 13 | 14 | void onFailed(); 15 | 16 | void onCompleted(); 17 | 18 | void onEnd(); 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/MainAdapter.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 4 | import com.crazysunj.multitypeadapter.helper.AdapterHelper; 5 | import com.crazysunj.multitypeadapter.helper.AsynAdapterHelper; 6 | import com.crazysunj.multitypeadapter.helper.RecyclerViewAdapterHelper; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author sunjian 12 | * @date 2019-10-18 19:12 13 | */ 14 | public class MainAdapter extends BaseAdapter { 15 | 16 | public MainAdapter() { 17 | super(new AsynAdapterHelper(RecyclerViewAdapterHelper.MODE_MIXED) { 18 | @Override 19 | protected boolean isDetectMoves() { 20 | return false; 21 | } 22 | }); 23 | } 24 | 25 | @Override 26 | protected void init() { 27 | super.init(); 28 | register(TypeOne.TYPE, TypeOneViewHolder.class); 29 | register(TypeTwo.TYPE, TypeTwoViewHolder.class); 30 | register(TypeThree.TYPE, TypeThreeViewHolder.class); 31 | } 32 | 33 | public void refresh(List data) { 34 | AdapterHelper.action() 35 | .all(data) 36 | .into(mHelper); 37 | } 38 | 39 | public void refreshDiff(List data) { 40 | AdapterHelper.action() 41 | .allDiff(data) 42 | .into(mHelper); 43 | } 44 | 45 | public void loadMore(List data) { 46 | AdapterHelper.action() 47 | .add(data) 48 | .into(mHelper); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/MainHelper.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 4 | import com.crazysunj.multitypeadapter.helper.AsynAdapterHelper; 5 | 6 | /** 7 | * @author sunjian 8 | * @date 2019-10-18 19:10 9 | */ 10 | public class MainHelper extends AsynAdapterHelper { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/TypeOne.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 4 | 5 | /** 6 | * @author sunjian 7 | * @date 2019-10-18 19:15 8 | */ 9 | public class TypeOne implements MultiTypeEntity { 10 | 11 | public static final int TYPE = 0; 12 | 13 | @Override 14 | public int getItemType() { 15 | return TYPE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/TypeOneViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import android.util.Log; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import androidx.annotation.NonNull; 8 | 9 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 10 | import com.crazysunj.multityperecyclerviewadapter.R; 11 | import com.crazysunj.recycler.BindLayout; 12 | 13 | /** 14 | * @author sunjian 15 | * @date 2019-10-18 19:13 16 | */ 17 | @BindLayout(layoutId = R.layout.item_type_one) 18 | public class TypeOneViewHolder extends BaseViewHolder { 19 | 20 | public TypeOneViewHolder(@NonNull View itemView) { 21 | super(itemView); 22 | } 23 | 24 | @Override 25 | protected void showData(MultiTypeEntity data, int position) { 26 | super.showData(data, position); 27 | ((TextView) itemView).setText("type:" + data.getItemType() + " isVisible:" + mSubject.isVisible()); 28 | } 29 | 30 | @Override 31 | protected void onViewAttachedToWindow() { 32 | super.onViewAttachedToWindow(); 33 | Log.d("TypeOneViewHolder", "onViewAttachedToWindow"); 34 | } 35 | 36 | @Override 37 | protected void onViewDetachedFromWindow() { 38 | super.onViewDetachedFromWindow(); 39 | Log.d("TypeOneViewHolder", "onViewDetachedFromWindow"); 40 | } 41 | 42 | @Override 43 | protected void onViewRecycled() { 44 | super.onViewRecycled(); 45 | Log.d("TypeOneViewHolder", "onViewRecycled"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/TypeThree.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 4 | 5 | /** 6 | * @author sunjian 7 | * @date 2019-10-18 19:15 8 | */ 9 | public class TypeThree implements MultiTypeEntity { 10 | 11 | public static final int TYPE = 2; 12 | 13 | @Override 14 | public int getItemType() { 15 | return TYPE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/TypeThreeViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import android.view.View; 4 | import android.widget.TextView; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 9 | import com.crazysunj.multityperecyclerviewadapter.R; 10 | import com.crazysunj.recycler.BindLayout; 11 | 12 | /** 13 | * @author sunjian 14 | * @date 2019-10-18 19:13 15 | */ 16 | @BindLayout(layoutId = R.layout.item_type_three) 17 | public class TypeThreeViewHolder extends BaseViewHolder { 18 | 19 | public TypeThreeViewHolder(@NonNull View itemView) { 20 | super(itemView); 21 | } 22 | 23 | @Override 24 | protected void showData(MultiTypeEntity data, int position) { 25 | super.showData(data, position); 26 | ((TextView) itemView).setText("type:" + data.getItemType()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/TypeTwo.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 4 | 5 | /** 6 | * @author sunjian 7 | * @date 2019-10-18 19:15 8 | */ 9 | public class TypeTwo implements MultiTypeEntity { 10 | 11 | public static final int TYPE = 1; 12 | 13 | @Override 14 | public int getItemType() { 15 | return TYPE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/component/TypeTwoViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.component; 2 | 3 | import android.view.View; 4 | import android.widget.TextView; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 9 | import com.crazysunj.multityperecyclerviewadapter.R; 10 | import com.crazysunj.recycler.BindLayout; 11 | 12 | /** 13 | * @author sunjian 14 | * @date 2019-10-18 19:13 15 | */ 16 | @BindLayout(layoutId = R.layout.item_type_two) 17 | public class TypeTwoViewHolder extends BaseViewHolder { 18 | 19 | public TypeTwoViewHolder(@NonNull View itemView) { 20 | super(itemView); 21 | } 22 | 23 | @Override 24 | protected void showData(MultiTypeEntity data, int position) { 25 | super.showData(data, position); 26 | ((TextView) itemView).setText("type:" + data.getItemType()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/constant/Constants.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.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 | } 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 { 13 | 14 | public static final int LEVEL_FIRST = 0; 15 | public static final int LEVEL_SECOND = 1; 16 | public static final int LEVEL_THIRD = 2; 17 | 18 | public OpenCloseAdapterHelper() { 19 | super(); 20 | registerModule(); 21 | } 22 | 23 | private void registerModule() { 24 | 25 | registerModule(LEVEL_FIRST) 26 | .type(FirstOCEntity.OC_FIRST_TYPE) 27 | .layoutResId(R.layout.item_first) 28 | .headerResId(R.layout.item_header) 29 | .footerResId(R.layout.item_footer) 30 | .isFolded(true) 31 | .minSize(3) 32 | .loading() 33 | .loadingHeaderResId(R.layout.layout_default_shimmer_header_view) 34 | .loadingLayoutResId(R.layout.layout_default_shimmer_view) 35 | .error() 36 | .errorLayoutResId(R.layout.layout_error_two) 37 | .empty() 38 | .emptyLayoutResId(R.layout.layout_empty) 39 | .register(); 40 | 41 | registerModule(LEVEL_SECOND) 42 | .type(SecondOCEntity.OC_SECOND_TYPE) 43 | .layoutResId(R.layout.item_second) 44 | .headerResId(R.layout.item_header) 45 | .footerResId(R.layout.item_footer) 46 | .minSize(2) 47 | .register(); 48 | 49 | registerModule(LEVEL_THIRD) 50 | .type(ThirdOCEntity.OC_THIRD_TYPE) 51 | .layoutResId(R.layout.item_third) 52 | .headerResId(R.layout.item_header) 53 | .footerResId(R.layout.item_footer) 54 | .minSize(4) 55 | .register(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/expand/OpenCloseItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.expand; 2 | 3 | import com.crazysunj.multityperecyclerviewadapter.helper.MultiHeaderEntity; 4 | 5 | /** 6 | * description 7 | *

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 { 14 | 15 | public static final int LEVEL_FIRST = 0; 16 | public static final int LEVEL_SECOND = 1; 17 | public static final int LEVEL_THIRD = 2; 18 | public static final int LEVEL_FOURTH = 3; 19 | public static final int LEVEL_SWITCH = 4; 20 | 21 | public SwitchTypeAdapterHelper() { 22 | super(); 23 | registerModule(); 24 | } 25 | 26 | private void registerModule() { 27 | registerModule(LEVEL_FIRST) 28 | .type(FirstType.TYPE_1) 29 | .layoutResId(R.layout.item_first) 30 | .register(); 31 | 32 | registerModule(LEVEL_SECOND) 33 | .type(SecondType.TYPE_2) 34 | .layoutResId(R.layout.item_second) 35 | .register(); 36 | 37 | registerModule(LEVEL_THIRD) 38 | .type(ThirdType.TYPE_3) 39 | .layoutResId(R.layout.item_third) 40 | .register(); 41 | 42 | registerModule(LEVEL_FOURTH) 43 | .type(FourthType.TYPE_4) 44 | .layoutResId(R.layout.item_fourth) 45 | .register(); 46 | 47 | registerModule(LEVEL_SWITCH) 48 | .type(SwtichType.TYPE_A) 49 | .layoutResId(R.layout.item_switch_type) 50 | .type(SwtichType.TYPE_B) 51 | .layoutResId(R.layout.item_switch_type) 52 | .type(SwtichType.TYPE_C) 53 | .layoutResId(R.layout.item_switch_type) 54 | .type(SwtichType.TYPE_D) 55 | .layoutResId(R.layout.item_switch_type) 56 | .register(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/switchtype/SwtichType.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 SwtichType implements MultiTypeEntity { 14 | 15 | public static final int TYPE_A = 4; 16 | public static final int TYPE_B = 5; 17 | public static final int TYPE_C = 6; 18 | public static final int TYPE_D = 7; 19 | 20 | private int type; 21 | private String title; 22 | 23 | public SwtichType(int type, String title) { 24 | this.type = type; 25 | this.title = title; 26 | } 27 | 28 | public String getTitle() { 29 | return title; 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 SwtichType)) { 40 | return false; 41 | } 42 | return type == ((SwtichType) obj).type; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/switchtype/ThirdType.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 ThirdType implements MultiTypeEntity { 15 | 16 | public static final int TYPE_3 = 2; 17 | 18 | private long id; 19 | private String title; 20 | 21 | public ThirdType(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_3; 33 | } 34 | @Override 35 | public boolean equals(@Nullable Object obj) { 36 | if (!(obj instanceof ThirdType)) { 37 | return false; 38 | } 39 | return id == ((ThirdType) obj).id; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/ItemConvert.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | 4 | import com.crazysunj.multityperecyclerviewadapter.helper.BaseViewHolder; 5 | 6 | /** 7 | * author: sunjian 8 | * created on: 2018/4/3 下午1:32 9 | * description: 10 | */ 11 | 12 | public interface ItemConvert { 13 | void convert(K helper, T item); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelFirstEmptyItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import static com.crazysunj.multityperecyclerviewadapter.testlevel.TestLevelAdapter.TYPE_LEVEL_FIRST_EMPTY; 6 | 7 | /** 8 | * @author: sunjian 9 | * created on: 2019/1/7 上午10:21 10 | * description: 11 | */ 12 | public class LevelFirstEmptyItem implements MultiTypeTitleEntity { 13 | 14 | private String msg; 15 | 16 | public LevelFirstEmptyItem(String msg) { 17 | this.msg = msg; 18 | } 19 | 20 | @Override 21 | public String getMsg() { 22 | return msg; 23 | } 24 | 25 | @Override 26 | public int getItemType() { 27 | return TYPE_LEVEL_FIRST_EMPTY; 28 | } 29 | 30 | @Override 31 | public boolean equals(@Nullable Object obj) { 32 | if (!(obj instanceof LevelFirstEmptyItem)) { 33 | return false; 34 | } 35 | if (msg == null) { 36 | return false; 37 | } 38 | return msg.equals(((LevelFirstEmptyItem) obj).msg); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelFirstItemConvert.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import com.crazysunj.multityperecyclerviewadapter.R; 4 | import com.crazysunj.multityperecyclerviewadapter.helper.BaseViewHolder; 5 | 6 | /** 7 | * author: sunjian 8 | * created on: 2018/4/3 下午1:34 9 | * description: 10 | */ 11 | 12 | public class LevelFirstItemConvert implements ItemConvert { 13 | 14 | @Override 15 | public void convert(BaseViewHolder helper, MultiTypeTitleEntity item) { 16 | final int itemType = item.getItemType(); 17 | switch (itemType) { 18 | case TypeOneItem.TYPE_ONE: 19 | renderTypeOne(helper, (TypeOneItem) item); 20 | break; 21 | case TypeTwoItem.TYPE_TWO: 22 | renderTypeTwo(helper, (TypeTwoItem) item); 23 | break; 24 | case TestLevelAdapter.TYPE_LEVEL_FIRST_HEADER: 25 | renderLevelFirstHeader(helper, (LevelTitleItem) item); 26 | break; 27 | case TestLevelAdapter.TYPE_LEVEL_FIRST_FOOTER: 28 | renderLevelFirstFooter(helper, (LevelFooterItem) item); 29 | break; 30 | case TestLevelAdapter.TYPE_LEVEL_FIRST_EMPTY: 31 | renderLevelFirstEmpty(helper, item); 32 | break; 33 | default: 34 | break; 35 | } 36 | } 37 | 38 | private void renderLevelFirstEmpty(BaseViewHolder helper, MultiTypeTitleEntity item) { 39 | helper.getTextView(R.id.empty_title).setText(item.getMsg()); 40 | } 41 | 42 | private void renderLevelFirstFooter(BaseViewHolder helper, LevelFooterItem item) { 43 | helper.setText(R.id.item_footer, item.getMsg()); 44 | } 45 | 46 | private void renderLevelFirstHeader(BaseViewHolder helper, LevelTitleItem item) { 47 | helper.setText(R.id.item_header, item.getMsg()); 48 | } 49 | 50 | private void renderTypeTwo(BaseViewHolder helper, TypeTwoItem item) { 51 | helper.setText(R.id.item_name, item.getMsg()); 52 | } 53 | 54 | private void renderTypeOne(BaseViewHolder helper, TypeOneItem item) { 55 | helper.setText(R.id.item_name, item.getMsg()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelFooterItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * author: sunjian 9 | * created on: 2018/4/3 上午11:11 10 | * description: 11 | */ 12 | 13 | public class LevelFooterItem implements MultiTypeTitleEntity { 14 | 15 | private long id; 16 | private int type; 17 | private String msg; 18 | 19 | public LevelFooterItem(int type, String msg) { 20 | this.id = UUID.nameUUIDFromBytes(msg.getBytes()).hashCode(); 21 | this.type = type; 22 | this.msg = msg; 23 | } 24 | 25 | public void setMsg(String msg) { 26 | this.msg = msg; 27 | } 28 | 29 | @Override 30 | public String getMsg() { 31 | return msg; 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 LevelFooterItem)) { 42 | return false; 43 | } 44 | if (msg == null) { 45 | return false; 46 | } 47 | return msg.equals(((LevelFooterItem) obj).msg); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelLoadingItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * author: sunjian 9 | * created on: 2018/4/3 上午11:11 10 | * description: 11 | */ 12 | 13 | public class LevelLoadingItem implements MultiTypeTitleEntity { 14 | 15 | private long id; 16 | private int type; 17 | 18 | public LevelLoadingItem(int type) { 19 | this.id = UUID.nameUUIDFromBytes(String.valueOf(type).getBytes()).hashCode(); 20 | this.type = type; 21 | } 22 | 23 | @Override 24 | public int getItemType() { 25 | return type; 26 | } 27 | 28 | @Override 29 | public boolean equals(@Nullable Object obj) { 30 | if (!(obj instanceof LevelLoadingItem)) { 31 | return false; 32 | } 33 | return id == ((LevelLoadingItem) obj).id; 34 | } 35 | 36 | @Override 37 | public String getMsg() { 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelSecondErrorItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import static com.crazysunj.multityperecyclerviewadapter.testlevel.TestLevelAdapter.TYPE_LEVEL_SECOND_ERROR; 6 | 7 | /** 8 | * @author: sunjian 9 | * created on: 2019/1/7 上午10:21 10 | * description: 11 | */ 12 | public class LevelSecondErrorItem implements MultiTypeTitleEntity { 13 | 14 | private String msg; 15 | 16 | public LevelSecondErrorItem(String msg) { 17 | this.msg = msg; 18 | } 19 | 20 | @Override 21 | public String getMsg() { 22 | return msg; 23 | } 24 | 25 | @Override 26 | public int getItemType() { 27 | return TYPE_LEVEL_SECOND_ERROR; 28 | } 29 | 30 | @Override 31 | public boolean equals(@Nullable Object obj) { 32 | if (!(obj instanceof LevelSecondErrorItem)) { 33 | return false; 34 | } 35 | if (msg == null) { 36 | return false; 37 | } 38 | return msg.equals(((LevelSecondErrorItem) obj).msg); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelSecondItemConvert.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import android.content.Context; 4 | 5 | import com.crazysunj.multityperecyclerviewadapter.R; 6 | import com.crazysunj.multityperecyclerviewadapter.Refresh240Activity; 7 | import com.crazysunj.multityperecyclerviewadapter.helper.BaseViewHolder; 8 | 9 | /** 10 | * author: sunjian 11 | * created on: 2018/4/3 下午1:34 12 | * description: 13 | */ 14 | 15 | public class LevelSecondItemConvert implements ItemConvert { 16 | 17 | @Override 18 | public void convert(BaseViewHolder helper, MultiTypeTitleEntity item) { 19 | final int itemType = item.getItemType(); 20 | switch (itemType) { 21 | case TypeThreeItem.TYPE_THREE: 22 | renderTypeThree(helper, (TypeThreeItem) item); 23 | break; 24 | case TestLevelAdapter.TYPE_LEVEL_SECOND_HEADER: 25 | renderLevelSecondHeader(helper, (LevelTitleItem) item); 26 | break; 27 | case TestLevelAdapter.TYPE_LEVEL_SECOND_ERROR: 28 | renderLevelSecondError(helper, item); 29 | break; 30 | default: 31 | break; 32 | } 33 | } 34 | 35 | private void renderLevelSecondError(BaseViewHolder helper, MultiTypeTitleEntity item) { 36 | helper.getTextView(R.id.error_text).setText(item.getMsg()); 37 | helper.getView(R.id.retry).setOnClickListener(v -> { 38 | Context context = v.getContext(); 39 | if (context instanceof Refresh240Activity) { 40 | ((Refresh240Activity) context).click1(v); 41 | } 42 | }); 43 | } 44 | 45 | private void renderLevelSecondHeader(BaseViewHolder helper, LevelTitleItem item) { 46 | helper.setText(R.id.item_header, item.getMsg()); 47 | } 48 | 49 | private void renderTypeThree(BaseViewHolder helper, TypeThreeItem item) { 50 | helper.setText(R.id.item_name, item.getMsg()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelThirdItemConvert.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import com.crazysunj.multityperecyclerviewadapter.R; 4 | import com.crazysunj.multityperecyclerviewadapter.helper.BaseViewHolder; 5 | 6 | /** 7 | * author: sunjian 8 | * created on: 2018/4/3 下午1:34 9 | * description: 10 | */ 11 | 12 | public class LevelThirdItemConvert implements ItemConvert { 13 | 14 | @Override 15 | public void convert(BaseViewHolder helper, MultiTypeTitleEntity item) { 16 | final int itemType = item.getItemType(); 17 | switch (itemType) { 18 | case TypeFourItem.TYPE_FOUR: 19 | renderTypeFour(helper, (TypeFourItem) item); 20 | break; 21 | case TypeFiveItem.TYPE_FIVE: 22 | renderTypeFive(helper, (TypeFiveItem) item); 23 | break; 24 | case TestLevelAdapter.TYPE_LEVEL_THIRD_HEADER: 25 | renderLevelThirdHeader(helper, (LevelTitleItem) item); 26 | break; 27 | case TestLevelAdapter.TYPE_LEVEL_THIRD_FOOTER: 28 | renderLevelThirdFooter(helper, (LevelFooterItem) item); 29 | break; 30 | default: 31 | break; 32 | } 33 | } 34 | 35 | private void renderLevelThirdFooter(BaseViewHolder helper, LevelFooterItem item) { 36 | helper.setText(R.id.item_footer, item.getMsg()); 37 | } 38 | 39 | private void renderLevelThirdHeader(BaseViewHolder helper, LevelTitleItem item) { 40 | helper.setText(R.id.item_header, item.getMsg()); 41 | } 42 | 43 | private void renderTypeFive(BaseViewHolder helper, TypeFiveItem item) { 44 | helper.setText(R.id.item_name, item.getMsg()); 45 | } 46 | 47 | private void renderTypeFour(BaseViewHolder helper, TypeFourItem item) { 48 | helper.setText(R.id.item_name, item.getMsg()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/LevelTitleItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import java.util.UUID; 6 | 7 | /** 8 | * author: sunjian 9 | * created on: 2018/4/3 上午11:11 10 | * description: 11 | */ 12 | 13 | public class LevelTitleItem implements MultiTypeTitleEntity { 14 | 15 | private long id; 16 | private int type; 17 | private String msg; 18 | 19 | public LevelTitleItem(int type, String msg) { 20 | this.id = UUID.nameUUIDFromBytes(msg.getBytes()).hashCode(); 21 | this.type = type; 22 | this.msg = msg; 23 | } 24 | 25 | public void setMsg(String msg) { 26 | this.msg = msg; 27 | } 28 | 29 | @Override 30 | public String getMsg() { 31 | return msg; 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 LevelTitleItem)) { 42 | return false; 43 | } 44 | if (id != ((LevelTitleItem) obj).id) { 45 | return false; 46 | } 47 | if (msg == null) { 48 | return false; 49 | } 50 | return msg.equals(((LevelTitleItem) obj).msg); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/MultiTypeTitleEntity.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import com.crazysunj.multitypeadapter.entity.MultiTypeEntity; 4 | 5 | /** 6 | * author: sunjian 7 | * created on: 2018/4/3 下午4:31 8 | * description: 9 | */ 10 | 11 | public interface MultiTypeTitleEntity extends MultiTypeEntity { 12 | String getMsg(); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/TypeEmptyAllItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | /** 6 | * author: sunjian 7 | * created on: 2018/4/3 上午11:11 8 | * description: 9 | */ 10 | 11 | public class TypeEmptyAllItem implements MultiTypeTitleEntity { 12 | 13 | public static final int TYPE_EMPTY = 6; 14 | private String msg; 15 | 16 | public TypeEmptyAllItem( String msg) { 17 | this.msg = msg; 18 | } 19 | 20 | public void setMsg(String msg) { 21 | this.msg = msg; 22 | } 23 | 24 | @Override 25 | public String getMsg() { 26 | return msg; 27 | } 28 | 29 | @Override 30 | public int getItemType() { 31 | return TYPE_EMPTY; 32 | } 33 | 34 | @Override 35 | public boolean equals(@Nullable Object obj) { 36 | if (!(obj instanceof TypeEmptyAllItem)) { 37 | return false; 38 | } 39 | if (msg == null) { 40 | return false; 41 | } 42 | return msg.equals(((TypeEmptyAllItem) obj).msg); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/TypeFiveItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | /** 6 | * author: sunjian 7 | * created on: 2018/4/3 上午11:11 8 | * description: 9 | */ 10 | 11 | public class TypeFiveItem implements MultiTypeTitleEntity { 12 | 13 | public static final int TYPE_FIVE = 5; 14 | private long id; 15 | private String msg; 16 | 17 | public TypeFiveItem(long id, String msg) { 18 | this.id = id; 19 | this.msg = msg; 20 | } 21 | 22 | public void setMsg(String msg) { 23 | this.msg = msg; 24 | } 25 | 26 | @Override 27 | public String getMsg() { 28 | return msg; 29 | } 30 | 31 | @Override 32 | public int getItemType() { 33 | return TYPE_FIVE; 34 | } 35 | 36 | @Override 37 | public boolean equals(@Nullable Object obj) { 38 | if (!(obj instanceof TypeFiveItem)) { 39 | return false; 40 | } 41 | if (id != ((TypeFiveItem) obj).id) { 42 | return false; 43 | } 44 | if (msg == null) { 45 | return false; 46 | } 47 | return msg.equals(((TypeFiveItem) obj).msg); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/TypeFourItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | /** 6 | * author: sunjian 7 | * created on: 2018/4/3 上午11:11 8 | * description: 9 | */ 10 | 11 | public class TypeFourItem implements MultiTypeTitleEntity { 12 | 13 | public static final int TYPE_FOUR = 4; 14 | private long id; 15 | private String msg; 16 | 17 | public TypeFourItem(long id, String msg) { 18 | this.id = id; 19 | this.msg = msg; 20 | } 21 | 22 | public void setMsg(String msg) { 23 | this.msg = msg; 24 | } 25 | 26 | @Override 27 | public String getMsg() { 28 | return msg; 29 | } 30 | 31 | @Override 32 | public int getItemType() { 33 | return TYPE_FOUR; 34 | } 35 | 36 | @Override 37 | public boolean equals(@Nullable Object obj) { 38 | if (!(obj instanceof TypeFourItem)) { 39 | return false; 40 | } 41 | if (id != ((TypeFourItem) obj).id) { 42 | return false; 43 | } 44 | if (msg == null) { 45 | return false; 46 | } 47 | return msg.equals(((TypeFourItem) obj).msg); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/TypeOneItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | /** 6 | * author: sunjian 7 | * created on: 2018/4/3 上午11:11 8 | * description: 9 | */ 10 | 11 | public class TypeOneItem implements MultiTypeTitleEntity { 12 | 13 | public static final int TYPE_ONE = 1; 14 | private long id; 15 | private String msg; 16 | 17 | public TypeOneItem(long id, String msg) { 18 | this.id = id; 19 | this.msg = msg; 20 | } 21 | 22 | public void setMsg(String msg) { 23 | this.msg = msg; 24 | } 25 | 26 | @Override 27 | public String getMsg() { 28 | return msg; 29 | } 30 | 31 | @Override 32 | public int getItemType() { 33 | return TYPE_ONE; 34 | } 35 | 36 | @Override 37 | public boolean equals(@Nullable Object obj) { 38 | if (!(obj instanceof TypeOneItem)) { 39 | return false; 40 | } 41 | if (id != ((TypeOneItem) obj).id) { 42 | return false; 43 | } 44 | if (msg == null) { 45 | return false; 46 | } 47 | return msg.equals(((TypeOneItem) obj).msg); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/TypeThreeItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | /** 6 | * author: sunjian 7 | * created on: 2018/4/3 上午11:11 8 | * description: 9 | */ 10 | 11 | public class TypeThreeItem implements MultiTypeTitleEntity { 12 | 13 | public static final int TYPE_THREE = 3; 14 | private long id; 15 | private String msg; 16 | 17 | public TypeThreeItem(long id, String msg) { 18 | this.id = id; 19 | this.msg = msg; 20 | } 21 | 22 | public void setMsg(String msg) { 23 | this.msg = msg; 24 | } 25 | 26 | @Override 27 | public String getMsg() { 28 | return msg; 29 | } 30 | 31 | @Override 32 | public int getItemType() { 33 | return TYPE_THREE; 34 | } 35 | 36 | @Override 37 | public boolean equals(@Nullable Object obj) { 38 | if (!(obj instanceof TypeThreeItem)) { 39 | return false; 40 | } 41 | if (id != ((TypeThreeItem) obj).id) { 42 | return false; 43 | } 44 | if (msg == null) { 45 | return false; 46 | } 47 | return msg.equals(((TypeThreeItem) obj).msg); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/crazysunj/multityperecyclerviewadapter/testlevel/TypeTwoItem.java: -------------------------------------------------------------------------------- 1 | package com.crazysunj.multityperecyclerviewadapter.testlevel; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | /** 6 | * author: sunjian 7 | * created on: 2018/4/3 上午11:11 8 | * description: 9 | */ 10 | 11 | public class TypeTwoItem implements MultiTypeTitleEntity { 12 | 13 | public static final int TYPE_TWO = 2; 14 | private long id; 15 | private String msg; 16 | 17 | public TypeTwoItem(long id, String msg) { 18 | this.id = id; 19 | this.msg = msg; 20 | } 21 | 22 | public void setMsg(String msg) { 23 | this.msg = msg; 24 | } 25 | 26 | @Override 27 | public String getMsg() { 28 | return msg; 29 | } 30 | 31 | @Override 32 | public int getItemType() { 33 | return TYPE_TWO; 34 | } 35 | 36 | @Override 37 | public boolean equals(@Nullable Object obj) { 38 | if (!(obj instanceof TypeTwoItem)) { 39 | return false; 40 | } 41 | if (id != ((TypeTwoItem) obj).id) { 42 | return false; 43 | } 44 | if (msg == null) { 45 | return false; 46 | } 47 | return msg.equals(((TypeTwoItem) obj).msg); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_fifth_bottom_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_first_bottom_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_fourth_bottom_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_second_bottom_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_third_bottom_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_apt_default.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |