Skip to content

Commit

Permalink
Merge pull request #23 from manneohlund/rc-5.0.0
Browse files Browse the repository at this point in the history
Rc 5.0.0
  • Loading branch information
manneohlund authored Oct 6, 2020
2 parents 91e0fb6 + b90c5fe commit 6ffa089
Show file tree
Hide file tree
Showing 70 changed files with 521 additions and 95 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 62 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ This library will make it easy and painless to map your data item with a target
# Features

###### OnViewEventListener
* Smart <b>OnClick</b> / <b>OnLongClickListener</b> <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/SimpleItemOnClickOnLongClickActivity.kt" target="_blank">SimpleItemOnClickOnLongClickActivity</a></sup>
* State holding with <b>OnItemSelectedListener</b> <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/MultipleViewTypesResolverActivity.kt" target="_blank">MultipleViewTypesResolverActivity</a></sup>
* Custom View Events <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/CustomViewEventActivity.kt" target="_blank">CustomViewEventActivity</a></sup>
* Smart <b>OnClick</b> / <b>OnLongClickListener</b> <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/SimpleItemOnClickOnLongClickActivity.kt" target="_blank">SimpleItemOnClickOnLongClickActivity</a></sup>
* State holding with <b>OnItemSelectedListener</b> <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/MultipleViewTypesResolverActivity.kt" target="_blank">MultipleViewTypesResolverActivity</a></sup>
* Custom View Events <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/CustomViewEventActivity.kt" target="_blank">CustomViewEventActivity</a></sup>
###### ItemTouchHelper Swipe, Drag & Drop extensions
* Drag & drop <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/DragAndDropItemActivity.kt" target="_blank">DragAndDropItemActivity</a></sup>
* Drag & drop with handle <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/DragAndDropHandleItemActivity.kt" target="_blank">DragAndDropHandleItemActivity</a></sup>
* Swipe to remove item <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/SwipeRemoveItemActivity.kt" target="_blank">SwipeRemoveItemActivity</a></sup>
* Drag & drop, Swipe, View Events <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/MultipleEventsAndExtensionsActivity.kt" target="_blank">MultipleEventsAndExtensionsActivity</a></sup>
* Grid + Drag & drop <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/GridActivity.kt" target="_blank">GridActivity</a></sup>
* Drag & drop <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/DragAndDropItemActivity.kt" target="_blank">DragAndDropItemActivity</a></sup>
* Drag & drop with handle <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/DragAndDropHandleItemActivity.kt" target="_blank">DragAndDropHandleItemActivity</a></sup>
* Swipe to remove item <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/SwipeRemoveItemActivity.kt" target="_blank">SwipeRemoveItemActivity</a></sup>
* Drag & drop, Swipe, View Events <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/MultipleEventsAndExtensionsActivity.kt" target="_blank">MultipleEventsAndExtensionsActivity</a></sup>
* Grid + Drag & drop <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/GridActivity.kt" target="_blank">GridActivity</a></sup>
###### ViewTypeResolver
* Multiple ViewHolder types resolver <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/MultipleViewTypesResolverActivity.kt" target="_blank">MultipleViewTypesResolverActivity</a></sup>
* Multiple ViewHolder types resolver <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/MultipleViewTypesResolverActivity.kt" target="_blank">MultipleViewTypesResolverActivity</a></sup>
###### SmartStateHolder
* Multiple items select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/MultiSelectItemsActivity.kt" target="_blank">MultiSelectItemsActivity</a></sup>
* Single RadioButton select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/SingleSelectRadioButtonItemActivity.kt" target="_blank">SingleSelectRadioButtonItemActivity</a></sup>
* Multiple CheckBox select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/MultiSelectCheckBoxItemsActivity.kt" target="_blank">MultiSelectCheckBoxItemsActivity</a></sup>
* Multiple Switch select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/MultiSelectSwitchItemsActivity.kt" target="_blank">MultiSelectSwitchItemsActivity</a></sup>
* Multiple Expandable items <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/MultipleExpandableItemActivity.kt" target="_blank">MultipleExpandableItemActivity</a></sup>
* Single Expandable item <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/SingleExpandableItemActivity.kt" target="_blank">SingleExpandableItemActivity</a></sup>
* Multiple items select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/MultiSelectItemsActivity.kt" target="_blank">MultiSelectItemsActivity</a></sup>
* Single RadioButton select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/SingleSelectRadioButtonItemActivity.kt" target="_blank">SingleSelectRadioButtonItemActivity</a></sup>
* Multiple CheckBox select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/MultiSelectCheckBoxItemsActivity.kt" target="_blank">MultiSelectCheckBoxItemsActivity</a></sup>
* Multiple Switch select <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/MultiSelectSwitchItemsActivity.kt" target="_blank">MultiSelectSwitchItemsActivity</a></sup>
* Multiple Expandable items <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/MultipleExpandableItemActivity.kt" target="_blank">MultipleExpandableItemActivity</a></sup>
* Single Expandable item <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/SingleExpandableItemActivity.kt" target="_blank">SingleExpandableItemActivity</a></sup>
###### Nested adapter
* Nested SmartRecyclerAdapter <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/NestedSmartRecyclerAdaptersActivity.kt" target="_blank">NestedSmartRecyclerAdaptersActivity</a></sup>
* Nested SmartRecyclerAdapter <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/NestedSmartRecyclerAdaptersActivity.kt" target="_blank">NestedSmartRecyclerAdaptersActivity</a></sup>
###### Pagination
* Endless scroll <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/EndlessScrollActivity.kt" target="_blank">EndlessScrollActivity</a></sup>
* Endless scroll with load more button <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/EndlessScrollLoadMoreButtonActivity.kt" target="_blank">EndlessScrollLoadMoreButtonActivity</a></sup>
* Endless scroll <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/EndlessScrollActivity.kt" target="_blank">EndlessScrollActivity</a></sup>
* Endless scroll with load more button <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/EndlessScrollLoadMoreButtonActivity.kt" target="_blank">EndlessScrollLoadMoreButtonActivity</a></sup>
###### DiffUtil
* Diff Util extension <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta02/sample/src/main/java/smartrecycleradapter/feature/DiffUtilActivity.kt" target="_blank">DiffUtilActivity</a></sup>
* Diff Util extension <sup><a href="https://github.com/manneohlund/smart-recycler-adapter/blob/5.0.0-beta03/sample/src/main/kotlin/smartrecycleradapter/feature/DiffUtilActivity.kt" target="_blank">DiffUtilActivity</a></sup>

#### Release overview

* Kotlin + AndroidX (jcenter, jitpack) [v5.0.0-beta02](https://github.com/manneohlund/smart-recycler-adapter/tree/5.0.0-beta02)
* Kotlin + AndroidX (jcenter, jitpack) [v5.0.0-beta03](https://github.com/manneohlund/smart-recycler-adapter/tree/5.0.0-beta03)
* Kotlin + AndroidX (jcenter, jitpack) [v4.0.0](https://github.com/manneohlund/smart-recycler-adapter/tree/4.0.0)
* Java + AndroidX (jcenter, jitpack) [v3.0.0](https://github.com/manneohlund/smart-recycler-adapter/tree/3.0.0)
* Java + AppCompat (jitpack) [v2.2.0](https://github.com/manneohlund/smart-recycler-adapter/tree/2.2.0)
Expand All @@ -53,7 +53,7 @@ Add `jcenter()` or `maven { url "https://dl.bintray.com/manneohlund/maven" }` t
```groovy
dependencies {
// Core SmartRecyclerAdapter
implementation 'io.github.manneohlund:smart-recycler-adapter:5.0.0-beta02'
implementation 'io.github.manneohlund:smart-recycler-adapter:5.0.0-beta03'
}
```

Expand All @@ -63,6 +63,18 @@ dependencies {
dependencies {
// ViewEvent click listeners, multi select, swipe dismiss and drag & drop
implementation 'io.github.manneohlund:smart-recycler-adapter-viewevent:1.0.0-alpha02'
// DiffUtil extension library
implementation 'io.github.manneohlund:smart-recycler-adapter-diffutil:1.0.0-alpha01'
}
```

# Proguard

Only known rule is to keep constructor for all ViewHolders.

```proguard
-keepclassmembers class **ViewHolder {
public <init>(**);
}
```

Expand Down Expand Up @@ -232,6 +244,34 @@ SmartRecyclerAdapter

**See sample app section:** [#SmartStateHolder](#smartstateholder)

# smart-recycler-adapter-diffutil

As of `smart-recycler-adapter:v5.0.0` diff util have been removed from `SmartRecyclerAdapter` and is added in this extension library `smart-recycler-adapter-diffutil`.
Essentially the `SmartRecyclerAdapter` will now hold a map of `SmartRecyclerAdapterExtension` that is the basic interface for `SmartRecyclerAdapter` binding extensions.

```kotlin
// If adapter items contains unspecified super type DiffPredicate bust be of type Any, DiffPredicate<Any>
private val predicate = object : DiffUtilExtension.DiffPredicate<Int> {
override fun areItemsTheSame(oldItem: Int, newItem: Int): Boolean {
return oldItem == newItem
}

override fun areContentsTheSame(oldItem: Int, newItem: Int): Boolean {
return oldItem == newItem
}
}

// Add SimpleDiffUtilExtension to the adapter
SmartRecyclerAdapter
.items((0..100).toMutableList())
.map(Integer::class, SimpleItemViewHolder::class)
.add(SimpleDiffUtilExtension(predicate))
.into(recyclerView)

// Add some new random items
smartRecyclerAdapter.diffSwapList((0..100).shuffled().toMutableList())
```

### Adapter creation with ViewTypeResolver

If you want to bind one data type with different view holders depending on some attribute you can set a ViewTypeResolver.<br/>
Expand Down Expand Up @@ -335,7 +375,7 @@ You can also set your custom loading/loadmore view.

# More

For more samples test out the sample app and see the [source code](https://github.com/manneohlund/smart-recycler-adapter/tree/master/sample/src/main/java/com/example/smartrecycleradapter).
For more samples test out the sample app and see the [source code](https://github.com/manneohlund/smart-recycler-adapter/tree/master/sample/src/main/kotlin/com/example/smartrecycleradapter).

### RecyclableViewHolder

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ext {
PROJ_NAME = 'SmartRecyclerAdapter'
PROJ_GROUP_ID = 'io.github.manneohlund'
PROJ_ARTIFACT_ID = 'smart-recycler-adapter'
PROJ_VERSION_CODE = 13
PROJ_VERSION_NAME = '5.0.0-beta02'
PROJ_VERSION_CODE = 14
PROJ_VERSION_NAME = '5.0.0-beta03'

TARGET_SDK_VERSION = 28
BUILD_TOOLS_VERSION = '29.0.2'
Expand Down
83 changes: 83 additions & 0 deletions extensions/diffutil/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Project
upload-keystore.jks

# Built application files
*.apk
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ, Android Studio
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches/
.idea/caches/build_file_checksums.ser
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
.idea/assetWizardSettings.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
lint/reports/

# Mac
*.DS_Store
7 changes: 7 additions & 0 deletions extensions/diffutil/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# v1.0.0-alpha01

### Initial release contains
* `SimpleDiffUtilExtension` basic implementation of `DiffUtilExtension`
* `DiffUtilExtension` defining the basic diff util.
* `SmartRecyclerAdapterExt` helper extension methods getDiffUtil, diffSwapList
* `SmartAdapterBuilderExt` helper extension methods to add extension
62 changes: 62 additions & 0 deletions extensions/diffutil/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

ext {
LIB_ARTIFACT_NAME = 'SmartRecyclerAdapter DiffUtil'
LIB_ARTIFACT_ID = 'smart-recycler-adapter-diffutil'
LIB_VERSION_CODE = 1
LIB_VERSION_NAME = '1.0.0-alpha01'
LIB_DESCRIPTION = 'Diff util extension library for SmartRecyclerAdapter'
}

android {
compileSdkVersion TARGET_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION
versionCode LIB_VERSION_CODE
versionName LIB_VERSION_NAME

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

sourceSets {
main {
java.srcDirs = ['src/main/kotlin']
res.srcDirs = ['src/main/res']
}
release {
java.srcDirs = ['src/main/kotlin']
res.srcDirs = ['src/main/res']
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
// Test
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

// Project
implementation project(path: ':smartadapter')

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

// Androidx
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
}
Empty file.
21 changes: 21 additions & 0 deletions extensions/diffutil/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package smartadapter.diffutil

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("smartadapter.diffutil.test", appContext.packageName)
}
}
1 change: 1 addition & 0 deletions extensions/diffutil/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="io.github.manneohlund.smartrecycleradapter.diffutil" />
Loading

0 comments on commit 6ffa089

Please sign in to comment.