├── paging ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── hannesdorfmann │ │ │ └── adapterdelegates4 │ │ │ └── paging │ │ │ └── PagedListDelegationAdapter.java │ └── test │ │ └── java │ │ └── com │ │ └── hannesdorfmann │ │ └── adapterdelegates4 │ │ └── paging │ │ ├── SpyableAdapterDelegate.java │ │ └── PagedListDelegationAdapterTest.java ├── gradle.properties ├── proguard-rules.pro └── build.gradle ├── kotlin-dsl ├── .gitignore ├── src │ ├── main │ │ └── AndroidManifest.xml │ └── test │ │ └── java │ │ └── com │ │ └── hannesdorfmann │ │ └── adapterdelegates4 │ │ └── ListAdapterDelegateDslTest.kt ├── gradle.properties ├── proguard-rules.pro └── build.gradle ├── kotlin-dsl-viewbinding ├── consumer-rules.pro ├── .gitignore ├── src │ └── main │ │ └── AndroidManifest.xml ├── gradle.properties ├── proguard-rules.pro └── build.gradle ├── kotlin-dsl-layoutcontainer ├── .gitignore ├── src │ └── main │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ └── AndroidManifest.xml ├── gradle.properties ├── proguard-rules.pro └── build.gradle ├── library ├── src │ ├── test │ │ ├── resources │ │ │ └── mockito-extensions │ │ │ │ └── org.mockito.plugins.MockMaker │ │ └── java │ │ │ └── com │ │ │ └── hannesdorfmann │ │ │ └── adapterdelegates4 │ │ │ ├── ListDelegationAdapterTest.java │ │ │ ├── AbsListItemAdapterDelegateTest.java │ │ │ ├── SpyableAdapterDelegate.java │ │ │ ├── AbsDelegationAdapterTest.java │ │ │ └── AsyncListDifferDelegationAdapterTest.java │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── hannesdorfmann │ │ └── adapterdelegates4 │ │ ├── AbsFallbackAdapterDelegate.java │ │ ├── ListDelegationAdapter.java │ │ ├── AbsListItemAdapterDelegate.java │ │ ├── AbsDelegationAdapter.java │ │ ├── AsyncListDifferDelegationAdapter.java │ │ └── AdapterDelegate.java ├── proguard-rules.pro ├── gradle.properties ├── .gitignore └── build.gradle ├── settings.gradle ├── app ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ ├── cat.png │ │ │ ├── dog.png │ │ │ ├── geko.png │ │ │ └── snake.png │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── styles.xml │ │ │ └── dimens.xml │ │ ├── layout │ │ │ ├── item_unknown_reptile.xml │ │ │ ├── item_animation.xml │ │ │ ├── loading.xml │ │ │ ├── activity_pagination.xml │ │ │ ├── item_diff_cat.xml │ │ │ ├── activity_reptiels.xml │ │ │ ├── item_diff_dog.xml │ │ │ ├── item_dog.xml │ │ │ ├── item_cat.xml │ │ │ ├── activity_diff.xml │ │ │ ├── item_advertisement.xml │ │ │ ├── item_gecko.xml │ │ │ ├── item_snake.xml │ │ │ ├── activity_main.xml │ │ │ └── activity_animation_diff_utils.xml │ │ └── values-w820dp │ │ │ └── dimens.xml │ │ ├── java │ │ └── com │ │ │ └── hannesdorfmann │ │ │ └── adapterdelegates4 │ │ │ └── sample │ │ │ ├── model │ │ │ ├── DiffItem.java │ │ │ ├── UnknownReptile.java │ │ │ ├── DisplayableItem.java │ │ │ ├── Advertisement.java │ │ │ ├── Cat.java │ │ │ ├── Dog.java │ │ │ ├── Gecko.java │ │ │ ├── Snake.java │ │ │ ├── Animal.java │ │ │ ├── DiffCat.java │ │ │ └── DiffDog.java │ │ │ ├── animations │ │ │ ├── Item.java │ │ │ ├── ItemAdapterDelegate.java │ │ │ ├── AnimationDiffUtilsActivity.java │ │ │ └── ItemProvider.java │ │ │ ├── MainListAdapter.kt │ │ │ ├── dsl │ │ │ └── DslSample.kt │ │ │ ├── AsyncListDifferAdapter.java │ │ │ ├── pagination │ │ │ ├── LoadingAdapterDelegate.java │ │ │ ├── SampleDataSource.java │ │ │ └── PaginationActivity.java │ │ │ ├── adapterdelegates │ │ │ ├── ReptilesFallbackDelegate.java │ │ │ ├── DiffCatAdapterDelegate.java │ │ │ ├── DiffDogAdapterDelegate.java │ │ │ ├── SnakeListItemAdapterDelegate.java │ │ │ ├── AdvertisementAdapterDelegate.java │ │ │ ├── DogAdapterDelegate.java │ │ │ ├── CatAdapterDelegate.java │ │ │ └── GeckoAdapterDelegate.java │ │ │ ├── ReptilesAdapter.java │ │ │ ├── ReptilesActivity.java │ │ │ ├── MainActivity.java │ │ │ └── DiffActivity.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro ├── .gitignore └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .github └── workflows │ ├── build.yml │ ├── publish_snapshot.yml │ └── publish_release.yml ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── LICENSE /paging/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlin-dsl/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlin-dsl-viewbinding/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /kotlin-dsl-layoutcontainer/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kotlin-dsl-viewbinding/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':library', ':paging', ':kotlin-dsl', ':kotlin-dsl-layoutcontainer', ':kotlin-dsl-viewbinding' 2 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/drawable/cat.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/dog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/drawable/dog.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/geko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/drawable/geko.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/snake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/drawable/snake.png -------------------------------------------------------------------------------- /kotlin-dsl-viewbinding/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sockeqwe/AdapterDelegates/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /kotlin-dsl-layoutcontainer/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | kotlindsllayoutcontainer 3 | 4 | -------------------------------------------------------------------------------- /kotlin-dsl-viewbinding/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME = AdapterDelegates-Kotlin-Dsl 2 | POM_ARTIFACT_ID = adapterdelegates4-kotlin-dsl-viewbinding 3 | POM_PACKAGING = aar -------------------------------------------------------------------------------- /paging/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /kotlin-dsl/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /kotlin-dsl-layoutcontainer/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AdapterDelegates 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Feb 04 08:47:41 SAMT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/DiffItem.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample.model; 2 | 3 | /** 4 | * @author Sergey Opivalov 5 | */ 6 | 7 | public interface DiffItem { 8 | long getItemId(); 9 | 10 | int getItemHash(); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/UnknownReptile.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample.model; 2 | 3 | /** 4 | * @author Hannes Dorfmann 5 | */ 6 | public class UnknownReptile extends Animal { 7 | 8 | public UnknownReptile() { 9 | super("Unknown Reptile"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_unknown_reptile.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v2 13 | 14 | - name: Install JDK 11 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: 11 18 | 19 | - name: Build 20 | run: ./gradlew build --stacktrace 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/animations/Item.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample.animations; 2 | 3 | /** 4 | * @author Hannes Dorfmann 5 | */ 6 | public class Item { 7 | public int id; 8 | public String text; 9 | public int color; 10 | 11 | public Item(int id, String text, int color) { 12 | this.id = id; 13 | this.text = text; 14 | this.color = color; 15 | } 16 | 17 | public Item copy() { 18 | return new Item(id, text, color); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_pagination.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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/hannes/android-sdks/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 | -------------------------------------------------------------------------------- /library/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/hannes/android-sdks/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 | -------------------------------------------------------------------------------- /library/gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2015 Hannes Dorfmann. 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 | POM_NAME = AdapterDelegates 17 | POM_ARTIFACT_ID = adapterdelegates4 18 | POM_PACKAGING = aar 19 | -------------------------------------------------------------------------------- /paging/gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2015 Hannes Dorfmann. 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 | POM_NAME = AdapterDelegates 17 | POM_ARTIFACT_ID = adapterdelegates4-pagination 18 | POM_PACKAGING = aar 19 | -------------------------------------------------------------------------------- /kotlin-dsl/gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2015 Hannes Dorfmann. 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 | POM_NAME = AdapterDelegates-Kotlin-Dsl 17 | POM_ARTIFACT_ID = adapterdelegates4-kotlin-dsl 18 | POM_PACKAGING = aar 19 | -------------------------------------------------------------------------------- /kotlin-dsl-layoutcontainer/gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2015 Hannes Dorfmann. 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 | POM_NAME = AdapterDelegates-Kotlin-Dsl 17 | POM_ARTIFACT_ID = adapterdelegates4-kotlin-dsl-layoutcontainer 18 | POM_PACKAGING = aar 19 | -------------------------------------------------------------------------------- /paging/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /kotlin-dsl/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/hannesdorfmann/adapterdelegates4/AbsFallbackAdapterDelegate.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4; 2 | 3 | 4 | import androidx.annotation.NonNull; 5 | 6 | /** 7 | * This class can be used as base class for a fallback delegate {@link 8 | * AdapterDelegatesManager#setFallbackDelegate(AdapterDelegate)}. 9 | * 10 | * @author Hannes Dorfmann 11 | * @since 1.1.0 12 | */ 13 | public abstract class AbsFallbackAdapterDelegate extends AdapterDelegate { 14 | 15 | /** 16 | * Not needed, because never called for fallback adapter delegates. 17 | * 18 | * @param items The data source of the Adapter 19 | * @param position The position in the datasource 20 | * @return true 21 | */ 22 | @Override final protected boolean isForViewType(@NonNull Object items, int position) { 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /kotlin-dsl-viewbinding/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /kotlin-dsl-layoutcontainer/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/DisplayableItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Hannes Dorfmann. 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 | 17 | package com.hannesdorfmann.adapterdelegates4.sample.model; 18 | 19 | /** 20 | * @author Hannes Dorfmann 21 | */ 22 | public interface DisplayableItem { 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/Advertisement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Hannes Dorfmann. 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 | 17 | package com.hannesdorfmann.adapterdelegates4.sample.model; 18 | 19 | /** 20 | * @author Hannes Dorfmann 21 | */ 22 | public class Advertisement implements DisplayableItem { 23 | } 24 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | bin/ 5 | gen/ 6 | classes/ 7 | gen-external-apklibs/ 8 | 9 | # Eclipse project files 10 | .classpath 11 | .project 12 | .metadata 13 | .settings 14 | 15 | # IntelliJ files 16 | .idea 17 | *.iml 18 | 19 | # OSX files 20 | .DS_Store 21 | 22 | # Windows files 23 | Thumbs.db 24 | 25 | # vi swap files 26 | *.swp 27 | 28 | # backup files 29 | *.bak 30 | 31 | 32 | # Files for the Dalvik VM 33 | *.dex 34 | 35 | # Java class files 36 | *.class 37 | 38 | # Generated files 39 | bin/ 40 | gen/ 41 | 42 | # Gradle files 43 | .gradle/ 44 | build/ 45 | .gradle 46 | 47 | #maven files 48 | target/ 49 | /null 50 | 51 | # Local configuration file (sdk path, etc) 52 | 53 | local.properties 54 | 55 | # Proguard folder generated by Eclipse 56 | proguard/ 57 | 58 | #Log Files 59 | *.log 60 | 61 | 62 | #crashlytics 63 | app/src/main/res/values/com_crashlytics_export_strings.xml 64 | 65 | #infer 66 | infer-out/ -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | bin/ 5 | gen/ 6 | classes/ 7 | gen-external-apklibs/ 8 | 9 | # Eclipse project files 10 | .classpath 11 | .project 12 | .metadata 13 | .settings 14 | 15 | # IntelliJ files 16 | .idea 17 | *.iml 18 | 19 | # OSX files 20 | .DS_Store 21 | 22 | # Windows files 23 | Thumbs.db 24 | 25 | # vi swap files 26 | *.swp 27 | 28 | # backup files 29 | *.bak 30 | 31 | 32 | # Files for the Dalvik VM 33 | *.dex 34 | 35 | # Java class files 36 | *.class 37 | 38 | # Generated files 39 | bin/ 40 | gen/ 41 | 42 | # Gradle files 43 | .gradle/ 44 | build/ 45 | .gradle 46 | 47 | #maven files 48 | target/ 49 | /null 50 | 51 | # Local configuration file (sdk path, etc) 52 | 53 | local.properties 54 | 55 | # Proguard folder generated by Eclipse 56 | proguard/ 57 | 58 | #Log Files 59 | *.log 60 | 61 | 62 | #crashlytics 63 | app/src/main/res/values/com_crashlytics_export_strings.xml 64 | 65 | #infer 66 | infer-out/ -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/Cat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Hannes Dorfmann. 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 | 17 | package com.hannesdorfmann.adapterdelegates4.sample.model; 18 | 19 | /** 20 | * @author Hannes Dorfmann 21 | */ 22 | public class Cat extends Animal { 23 | 24 | public Cat(String name) { 25 | super(name); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/Dog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Hannes Dorfmann. 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 | 17 | package com.hannesdorfmann.adapterdelegates4.sample.model; 18 | 19 | /** 20 | * @author Hannes Dorfmann 21 | */ 22 | public class Dog extends Animal { 23 | 24 | public Dog(String name) { 25 | super(name); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /paging/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: "com.vanniktech.maven.publish" 3 | 4 | android { 5 | compileSdkVersion rootProject.ext.compileSdk 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.minSdk 9 | targetSdkVersion rootProject.ext.targetSdk 10 | } 11 | buildTypes { 12 | release { 13 | minifyEnabled false 14 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 15 | } 16 | } 17 | 18 | compileOptions { 19 | sourceCompatibility rootProject.ext.javaSourceCompatibility 20 | targetCompatibility rootProject.ext.javaTargetCompatibility 21 | } 22 | 23 | libraryVariants.all { 24 | it.generateBuildConfig.enabled = false 25 | } 26 | 27 | } 28 | 29 | dependencies { 30 | implementation project(":library") 31 | api rootProject.ext.paging 32 | 33 | testImplementation rootProject.ext.junit 34 | testImplementation rootProject.ext.mockito 35 | } 36 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: "com.vanniktech.maven.publish" 3 | 4 | android { 5 | compileSdkVersion rootProject.ext.compileSdk 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.minSdk 9 | targetSdkVersion rootProject.ext.targetSdk 10 | } 11 | buildTypes { 12 | release { 13 | minifyEnabled false 14 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 15 | } 16 | } 17 | 18 | compileOptions { 19 | sourceCompatibility rootProject.ext.javaSourceCompatibility 20 | targetCompatibility rootProject.ext.javaTargetCompatibility 21 | } 22 | 23 | libraryVariants.all { 24 | it.generateBuildConfig.enabled = false 25 | } 26 | } 27 | 28 | dependencies { 29 | api rootProject.ext.recyclerView 30 | api rootProject.ext.androidAnnotations 31 | 32 | testImplementation rootProject.ext.junit 33 | testImplementation rootProject.ext.mockito 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/MainListAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample 2 | 3 | import android.app.Activity 4 | import com.hannesdorfmann.adapterdelegates4.ListDelegationAdapter 5 | import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.AdvertisementAdapterDelegate 6 | import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.DogAdapterDelegate 7 | import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.GeckoAdapterDelegate 8 | import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.SnakeListItemAdapterDelegate 9 | import com.hannesdorfmann.adapterdelegates4.sample.dsl.cat2AdapterDelegate 10 | import com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem 11 | 12 | class MainListAdapter(activity: Activity) : ListDelegationAdapter>( 13 | AdvertisementAdapterDelegate(activity), 14 | cat2AdapterDelegate(), 15 | DogAdapterDelegate(activity), 16 | GeckoAdapterDelegate(activity), 17 | SnakeListItemAdapterDelegate(activity) 18 | ) -------------------------------------------------------------------------------- /kotlin-dsl/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: "com.vanniktech.maven.publish" 4 | 5 | 6 | android { 7 | compileSdkVersion rootProject.ext.compileSdk 8 | 9 | defaultConfig { 10 | minSdkVersion rootProject.ext.minSdk 11 | targetSdkVersion rootProject.ext.targetSdk 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility rootProject.ext.javaSourceCompatibility 22 | targetCompatibility rootProject.ext.javaTargetCompatibility 23 | } 24 | 25 | libraryVariants.all { 26 | it.generateBuildConfig.enabled = false 27 | } 28 | } 29 | 30 | dependencies { 31 | api project(":library") 32 | implementation rootProject.ext.kotlinStdLib 33 | 34 | testImplementation rootProject.ext.junit 35 | testImplementation rootProject.ext.mockito 36 | } 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | 9 | # Built application files 10 | *.apk 11 | *.ap_ 12 | bin/ 13 | gen/ 14 | classes/ 15 | gen-external-apklibs/ 16 | 17 | # Eclipse project files 18 | .classpath 19 | .project 20 | .metadata 21 | .settings 22 | 23 | # IntelliJ files 24 | .idea 25 | *.iml 26 | 27 | # OSX files 28 | .DS_Store 29 | 30 | # Windows files 31 | Thumbs.db 32 | 33 | # vi swap files 34 | *.swp 35 | 36 | # backup files 37 | *.bak 38 | 39 | 40 | # Files for the Dalvik VM 41 | *.dex 42 | 43 | # Java class files 44 | *.class 45 | 46 | # Generated files 47 | bin/ 48 | gen/ 49 | 50 | # Gradle files 51 | .gradle/ 52 | build/ 53 | .gradle 54 | 55 | #maven files 56 | target/ 57 | /null 58 | 59 | # Local configuration file (sdk path, etc) 60 | 61 | local.properties 62 | 63 | # Proguard folder generated by Eclipse 64 | proguard/ 65 | 66 | #Log Files 67 | *.log 68 | 69 | 70 | #crashlytics 71 | app/src/main/res/values/com_crashlytics_export_strings.xml 72 | 73 | #infer 74 | infer-out/ -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/Gecko.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Hannes Dorfmann. 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 | 17 | package com.hannesdorfmann.adapterdelegates4.sample.model; 18 | 19 | /** 20 | * @author Hannes Dorfmann 21 | */ 22 | public class Gecko extends Animal { 23 | 24 | private String race; 25 | 26 | public Gecko(String name, String race) { 27 | super(name); 28 | this.race = race; 29 | } 30 | 31 | public String getRace() { 32 | return race; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/Snake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Hannes Dorfmann. 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 | 17 | package com.hannesdorfmann.adapterdelegates4.sample.model; 18 | 19 | /** 20 | * @author Hannes Dorfmann 21 | */ 22 | public class Snake extends Animal { 23 | 24 | private String race; 25 | 26 | public Snake(String name, String race) { 27 | super(name); 28 | this.race = race; 29 | } 30 | 31 | public String getRace() { 32 | return race; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_diff_cat.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 19 | 20 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.github/workflows/publish_snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Publish Snapshot 2 | 3 | on: 4 | workflow_run: 5 | workflows: ["Build"] 6 | types: [completed] 7 | branches: 8 | - master 9 | 10 | jobs: 11 | publish: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v2 18 | 19 | - name: Install JDK 11 20 | uses: actions/setup-java@v1 21 | with: 22 | java-version: 11 23 | 24 | - name: Retrieve version 25 | run: | 26 | echo "VERSION_NAME=$(cat gradle.properties | grep -w "VERSION_NAME" | cut -d'=' -f2)" >> $GITHUB_ENV 27 | - name: Publish snapshot 28 | run: ./gradlew publish --no-daemon --no-parallel 29 | if: endsWith(env.VERSION_NAME, '-SNAPSHOT') 30 | env: 31 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} 32 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} 33 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_SIGNING_PRIVATE_KEY }} 34 | ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_SIGNING_PASSWORD }} -------------------------------------------------------------------------------- /kotlin-dsl-layoutcontainer/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply plugin: "com.vanniktech.maven.publish" 5 | 6 | androidExtensions { 7 | experimental = true 8 | } 9 | 10 | 11 | android { 12 | compileSdkVersion rootProject.ext.compileSdk 13 | 14 | defaultConfig { 15 | minSdkVersion rootProject.ext.minSdk 16 | targetSdkVersion rootProject.ext.targetSdk 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | compileOptions { 26 | sourceCompatibility rootProject.ext.javaSourceCompatibility 27 | targetCompatibility rootProject.ext.javaTargetCompatibility 28 | } 29 | 30 | libraryVariants.all { 31 | it.generateBuildConfig.enabled = false 32 | } 33 | } 34 | 35 | dependencies { 36 | api project(":library") 37 | implementation rootProject.ext.kotlinStdLib 38 | 39 | testImplementation rootProject.ext.junit 40 | testImplementation rootProject.ext.mockito 41 | } 42 | -------------------------------------------------------------------------------- /.github/workflows/publish_release.yml: -------------------------------------------------------------------------------- 1 | name: Publish Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | publish: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v2 16 | 17 | - name: Install JDK 11 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 11 21 | 22 | - name: Build 23 | run: ./gradlew build 24 | 25 | - name: Upload release 26 | run: ./gradlew publish --no-daemon --no-parallel 27 | env: 28 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} 29 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} 30 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_SIGNING_PRIVATE_KEY }} 31 | ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_SIGNING_PASSWORD }} 32 | 33 | - name: Publish release 34 | run: ./gradlew closeAndReleaseRepository --no-daemon --no-parallel 35 | env: 36 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} 37 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} -------------------------------------------------------------------------------- /kotlin-dsl-viewbinding/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply plugin: "com.vanniktech.maven.publish" 5 | 6 | 7 | androidExtensions { 8 | experimental = true 9 | } 10 | 11 | 12 | android { 13 | compileSdkVersion rootProject.ext.compileSdk 14 | 15 | defaultConfig { 16 | minSdkVersion rootProject.ext.minSdk 17 | targetSdkVersion rootProject.ext.targetSdk 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | compileOptions { 27 | sourceCompatibility rootProject.ext.javaSourceCompatibility 28 | targetCompatibility rootProject.ext.javaTargetCompatibility 29 | } 30 | 31 | libraryVariants.all { 32 | it.generateBuildConfig.enabled = false 33 | } 34 | 35 | viewBinding { 36 | enabled = true 37 | } 38 | } 39 | 40 | dependencies { 41 | api project(":library") 42 | implementation rootProject.ext.kotlinStdLib 43 | 44 | testImplementation rootProject.ext.junit 45 | testImplementation rootProject.ext.mockito 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/Animal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Hannes Dorfmann. 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 | 17 | package com.hannesdorfmann.adapterdelegates4.sample.model; 18 | 19 | import androidx.annotation.NonNull; 20 | 21 | /** 22 | * @author Hannes Dorfmann 23 | */ 24 | public class Animal implements DisplayableItem { 25 | 26 | private String name; 27 | 28 | public Animal(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | @NonNull 37 | @Override 38 | public String toString() { 39 | return name + " " + super.toString(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/dsl/DslSample.kt: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample.dsl 2 | 3 | import android.util.Log 4 | import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateLayoutContainer 5 | import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding 6 | import com.hannesdorfmann.adapterdelegates4.sample.R 7 | import com.hannesdorfmann.adapterdelegates4.sample.databinding.ItemCatBinding 8 | import com.hannesdorfmann.adapterdelegates4.sample.model.Cat 9 | import com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem 10 | import kotlinx.android.synthetic.main.item_cat.name 11 | 12 | // Example 13 | fun catAdapterDelegate() = adapterDelegateLayoutContainer(R.layout.item_cat) { 15 | 16 | name.setOnClickListener { 17 | Log.d("Click", "Click on $item") 18 | } 19 | 20 | bind { 21 | name.text = item.name 22 | } 23 | } 24 | 25 | fun cat2AdapterDelegate() = adapterDelegateViewBinding( 26 | { layoutInflater, root -> ItemCatBinding.inflate(layoutInflater, root, false) } 27 | ) { 28 | binding.name.setOnClickListener { 29 | Log.d("Click", "Click on $item") 30 | } 31 | bind { 32 | binding.name.text = item.name 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/DiffCat.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample.model; 2 | 3 | /** 4 | * @author Sergey Opivalov 5 | */ 6 | 7 | public class DiffCat implements DiffItem { 8 | 9 | private int id; 10 | 11 | private String name; 12 | 13 | public DiffCat(int id, String name) { 14 | this.id = id; 15 | this.name = name; 16 | } 17 | 18 | public int getId() { 19 | return id; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | @Override 27 | public long getItemId() { 28 | return id; 29 | } 30 | 31 | @Override 32 | public int getItemHash() { 33 | return hashCode(); 34 | } 35 | 36 | @Override 37 | public boolean equals(Object o) { 38 | if (this == o) return true; 39 | if (o == null || getClass() != o.getClass()) return false; 40 | 41 | DiffCat diffCat = (DiffCat) o; 42 | 43 | if (id != diffCat.id) return false; 44 | return name != null ? name.equals(diffCat.name) : diffCat.name == null; 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | int result = id; 50 | result = 31 * result + (name != null ? name.hashCode() : 0); 51 | return result; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_reptiels.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | 25 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_diff_dog.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 27 | 28 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/AsyncListDifferAdapter.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample; 2 | 3 | 4 | import com.hannesdorfmann.adapterdelegates4.AsyncListDifferDelegationAdapter; 5 | import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.DiffCatAdapterDelegate; 6 | import com.hannesdorfmann.adapterdelegates4.sample.adapterdelegates.DiffDogAdapterDelegate; 7 | import com.hannesdorfmann.adapterdelegates4.sample.model.DiffItem; 8 | 9 | import androidx.recyclerview.widget.DiffUtil; 10 | 11 | /** 12 | * @author Sergey Opivalov 13 | */ 14 | public class AsyncListDifferAdapter extends AsyncListDifferDelegationAdapter { 15 | 16 | public AsyncListDifferAdapter() { 17 | super(DIFF_CALLBACK); 18 | delegatesManager 19 | .addDelegate(new DiffDogAdapterDelegate()) 20 | .addDelegate(new DiffCatAdapterDelegate()); 21 | } 22 | 23 | private static final DiffUtil.ItemCallback DIFF_CALLBACK 24 | = new DiffUtil.ItemCallback() { 25 | 26 | @Override 27 | public boolean areItemsTheSame(DiffItem oldItem, DiffItem newItem) { 28 | return oldItem.getItemId() == newItem.getItemId(); 29 | } 30 | 31 | @Override 32 | public boolean areContentsTheSame(DiffItem oldItem, DiffItem newItem) { 33 | return oldItem.getItemHash() == newItem.getItemHash(); 34 | } 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/model/DiffDog.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample.model; 2 | 3 | /** 4 | * @author Sergey Opivalov 5 | */ 6 | 7 | public class DiffDog implements DiffItem { 8 | 9 | private int id; 10 | 11 | private String name; 12 | 13 | private int age; 14 | 15 | public DiffDog(int id, String name, int age) { 16 | this.id = id; 17 | this.name = name; 18 | this.age = age; 19 | } 20 | 21 | public int getId() { 22 | return id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public int getAge() { 30 | return age; 31 | } 32 | 33 | @Override 34 | public long getItemId() { 35 | return id; 36 | } 37 | 38 | @Override 39 | public int getItemHash() { 40 | return hashCode(); 41 | } 42 | 43 | @Override 44 | public boolean equals(Object o) { 45 | if (this == o) return true; 46 | if (o == null || getClass() != o.getClass()) return false; 47 | 48 | DiffDog diffDog = (DiffDog) o; 49 | 50 | if (id != diffDog.id) return false; 51 | if (age != diffDog.age) return false; 52 | return name != null ? name.equals(diffDog.name) : diffDog.name == null; 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | int result = id; 58 | result = 31 * result + (name != null ? name.hashCode() : 0); 59 | result = 31 * result + age; 60 | return result; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_dog.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 27 | 28 | 34 | 35 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/hannesdorfmann/adapterdelegates4/sample/pagination/LoadingAdapterDelegate.java: -------------------------------------------------------------------------------- 1 | package com.hannesdorfmann.adapterdelegates4.sample.pagination; 2 | 3 | import android.app.Activity; 4 | import android.util.Log; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.hannesdorfmann.adapterdelegates4.AbsFallbackAdapterDelegate; 10 | import com.hannesdorfmann.adapterdelegates4.sample.R; 11 | import com.hannesdorfmann.adapterdelegates4.sample.model.DisplayableItem; 12 | 13 | import java.util.List; 14 | 15 | import androidx.annotation.NonNull; 16 | import androidx.recyclerview.widget.RecyclerView; 17 | 18 | public class LoadingAdapterDelegate extends AbsFallbackAdapterDelegate> { 19 | 20 | private final LayoutInflater inflater; 21 | 22 | public LoadingAdapterDelegate(Activity activity) { 23 | this.inflater = activity.getLayoutInflater(); 24 | } 25 | 26 | @NonNull 27 | @Override 28 | protected RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent) { 29 | return new LoadingViewHolder(inflater.inflate(R.layout.loading, parent, false)); 30 | } 31 | 32 | @Override 33 | protected void onBindViewHolder(@NonNull List items, int position, @NonNull RecyclerView.ViewHolder holder, @NonNull List payloads) { 34 | Log.d("Tes", "test"); 35 | } 36 | 37 | static class LoadingViewHolder extends RecyclerView.ViewHolder { 38 | LoadingViewHolder(@NonNull View itemView) { 39 | super(itemView); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_cat.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 28 | 29 | 36 | 37 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_diff.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 16 | 17 |