Skip to content

Commit

Permalink
- Updated Gradle Plugin to 3.4.1
Browse files Browse the repository at this point in the history
- Updated Gradle to 5.4.1
- Using new Sky-UK Gradle maven plugin and dropped dcendents maven plugin
- Implemented "prepareForReuse" in view holders
- Added additional declarative extensions
  • Loading branch information
gotev committed Jul 15, 2019
1 parent 9f434a8 commit 340a770
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 282 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ In this way every item of the recycler view has its own set of files, resulting
## <a name="setup"></a>Setup
In your gradle dependencies add:
```groovy
def recyclerAdapterVersion = "2.7.0" // change it with the version you want to use
def recyclerAdapterVersion = "2.8.0" // change it with the version you want to use
implementation "net.gotev:recycleradapter:$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)
Expand Down Expand Up @@ -91,6 +91,12 @@ open class ExampleItem(private val context: Context, private val text: String)
get() = itemView

internal val titleField: TextView by lazy { title }

override fun prepareForReuse() {
// Here you can perform operations to clear data from the holder
// and free used resources, like bitmaps or other heavy weight
// things
}
}
}
```
Expand Down
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
apply from: '../manifest.gradle'

repositories {
jcenter()
google()
jcenter()
mavenCentral()
}

Expand All @@ -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.github.dcendents:android-maven-gradle-plugin:$maven_gradle_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

Expand All @@ -26,8 +25,8 @@ buildscript {

allprojects {
repositories {
jcenter()
google()
jcenter()
mavenCentral()
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion target_sdk
Expand Down
2 changes: 1 addition & 1 deletion app/demo/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
2 changes: 1 addition & 1 deletion app/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
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.github.dcendents:android-maven-gradle-plugin:$maven_gradle_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_plugin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -24,6 +24,7 @@ allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
22 changes: 11 additions & 11 deletions manifest.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ 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 = '2.7.0'
library_version = '2.8.0'
version_code = 5
min_sdk = 18
target_sdk = 28
demo_app_id = 'net.gotev.recycleradapterdemo'

// Gradle classpath dependencies versions
kotlin_version = '1.3.41'
gradle_version = '3.3.2'
maven_gradle_version = '2.1'
gradle_version = '3.4.1'
gradle_versions_plugin_version = '0.20.0'
bintray_plugin_version = '1.7'

// Library and app testing dependencies versions
junit_version = '4.12'
androidx_test_core_version = '1.1.0'
androidx_test_runner_version = '1.1.1'
androidx_test_rules_version = '1.1.1'
androidx_test_ext_junit_version = '1.1.0'
androidx_test_ext_truth_version = '1.1.0'
truth_version = '0.42'
androidx_test_espresso_version = '3.1.1'
androidx_test_core_version = '1.2.0'
androidx_test_runner_version = '1.2.0'
androidx_test_rules_version = '1.2.0'
androidx_test_ext_junit_version = '1.1.1'
androidx_test_ext_truth_version = '1.2.0'
truth_version = '0.45'
androidx_test_espresso_version = '3.2.0'

// Library and app dependencies versions
androidx_recyclerview_version = '1.0.0'
androidx_appcompat_version = '1.0.2'

// App dependencies
okhttp_version = '3.14.2'
retrofit_version = '2.5.0'
retrofit_version = '2.6.0'
rxjava2_version = '2.2.10'
rxkotlin_version = '2.3.0'
rxandroid_version = '2.1.1'
Expand Down
110 changes: 22 additions & 88 deletions recycleradapter-extensions/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.ben-manes.versions'

// start - do not modify this if your project is on github
def siteUrl = "https://github.com/${github_username}/${github_repository_name}"
def gitUrl = siteUrl + '.git'
def bugTrackerUrl = siteUrl + '/issues/'
def projectName = "recycler-adapter-extensions"
// end - do not modify this if your project is on github
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)]
mavSiteUrl = "https://github.com/${github_username}/${github_repository_name}"
mavGitUrl = mavSiteUrl + '.git'
bugTrackerUrl = mavSiteUrl + '/issues/'
mavProjectName = bintray_project_name
mavLibraryLicenses = ["Apache-2.0": 'http://www.apache.org/licenses/LICENSE-2.0.txt']
mavLibraryDescription = library_description
mavVersion = library_version
}
// end - do not modify this if your project is on github

group = library_project_group
version = library_version

Expand Down Expand Up @@ -73,60 +84,16 @@ dependencies {

}

// add the following information to the file: local.properties situated in the parent directory of
// where this file is:
//
// bintray.user=gotev
// bintray.apikey=api key got from the bintray profile
//
// be sure to add local.properties to the .gitignore!

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

install {
repositories.mavenInstaller {
pom.project {
name projectName
description library_description
packaging 'aar'
groupId library_project_group
version version
url siteUrl
licenses {
license {
name library_licenses[0]
url library_licenses_url
}
}
developers {
developer {
id properties.getProperty("bintray.user")
name maintainer
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl

}
}
}
}

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = projectName
name = mavProjectName
desc = library_description
websiteUrl = siteUrl
vcsUrl = gitUrl
websiteUrl = mavSiteUrl
vcsUrl = mavGitUrl
issueTrackerUrl = bugTrackerUrl
licenses = library_licenses
labels = library_keywords
Expand All @@ -135,37 +102,4 @@ bintray {
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
excludes = ['**/*.kt'] // < ---- Exclude all kotlin files from javadoc file.

title = "$projectName $project.version API"
description "Generates Javadoc"
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
exclude '**/BuildConfig.java', '**/R.java'
options {
windowTitle("$projectName $project.version Reference")
locale = 'en_US'
encoding = 'UTF-8'
charSet = 'UTF-8'
links("http://docs.oracle.com/javase/7/docs/api/");
linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference");
setMemberLevel(JavadocMemberLevel.PUBLIC)
addStringOption('Xdoclint:none', '-quiet')
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
}
apply from: 'https://raw.githubusercontent.com/sky-uk/gradle-maven-plugin/master/gradle-mavenizer.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net.gotev.recycleradapter.ext

import net.gotev.recycleradapter.AdapterItem
import net.gotev.recycleradapter.RecyclerAdapter
import java.util.*

/**
* @author Aleksandar Gotev
Expand Down Expand Up @@ -55,6 +56,14 @@ inline fun <K, V> Map<out K, V>.mapToManyAdapterItems(transform: (Map.Entry<K, V
return map(transform).flatten().toTypedArray()
}

inline fun <T> Array<T>.mapToManyAdapterItems(transform: (T) -> List<AdapterItem<*>>): Array<AdapterItem<*>> {
return map(transform).flatten().toTypedArray()
}

inline fun <T> Iterable<T>.mapToManyAdapterItems(transform: (T) -> List<AdapterItem<*>>): Array<AdapterItem<*>> {
return map(transform).flatten().toTypedArray()
}

inline fun <T> Iterable<T>.createRecyclerAdapterByMapping(transform: (T) -> AdapterItem<*>?): RecyclerAdapter {
return RecyclerAdapter().add(mapToAdapterItems(transform))
}
Expand All @@ -63,6 +72,10 @@ inline fun <T> Iterable<T>.mapToAdapterItems(transform: (T) -> AdapterItem<*>?):
return ArrayList(mapNotNull(transform))
}

inline fun <T> Array<T>.mapToAdapterItems(transform: (T) -> AdapterItem<*>?): AdapterItems {
return ArrayList(mapNotNull(transform))
}

interface RecyclerAdapterProvider {
val recyclerAdapter: RecyclerAdapter

Expand Down
Loading

0 comments on commit 340a770

Please sign in to comment.