diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9eae009 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,5 @@ +# These are supported funding model platforms + +ko_fi: nisrulz +liberapay: nisrulz +custom: https://www.paypal.me/nisrulz/5usd diff --git a/README.md b/README.md index ed6215f..7b93a71 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ where `{latest version}` corresponds to published version in [ ![Download](https Usage Example: ```gradle -def recyclerViewVersion="1.0.0" +def recyclerViewVersion="1.1.0" // Required implementation "androidx.recyclerview:recyclerview:${recyclerViewVersion}" diff --git a/app/build.gradle b/app/build.gradle index 4ad1937..8270606 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,53 +15,28 @@ */ apply plugin: 'com.android.application' -apply from: '../dependencies.gradle' -android { - compileSdkVersion versions.compileSdk +// Configs +apply from: "$rootProject.projectDir/configs/common.gradle" +android { defaultConfig { - minSdkVersion versions.minSdk - targetSdkVersion versions.targetSdk applicationId "github.nisrulz.projectrecyclerviewhelper" - versionCode versions.appVersionCode - versionName versions.appVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - lintOptions { - textOutput "stdout" - textReport true - checkAllWarnings true - warningsAsErrors true - showAll true - explainIssues true - abortOnError false - lintConfig file("$projectDir/lint.xml") + versionCode Versions.appCode + versionName Versions.appName } } dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - - // Testing - testImplementation unitTestLibs - androidTestImplementation androidTestsLibs + // Appcompat + implementation Dependencies.appCompat // Card View - implementation supportDeps.cardView - - // Support Appcompat - implementation "androidx.appcompat:appcompat:$versions.supportAppCompat" + implementation Dependencies.cardview // Required - implementation "androidx.recyclerview:recyclerview:$versions.supportRecyclerView" + implementation Dependencies.recyclerView // ---------- RecyclerViewHelper ---------- // From Maven Repo diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cf4fbf9..e7680d9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,14 +15,14 @@ --> + package="github.nisrulz.projectrecyclerviewhelper"> + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:supportsRtl="true" + android:theme="@style/AppTheme"> diff --git a/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MainActivity.java b/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MainActivity.java index 3397343..ed8d7bc 100644 --- a/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MainActivity.java +++ b/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MainActivity.java @@ -17,17 +17,20 @@ package github.nisrulz.projectrecyclerviewhelper; import android.os.Bundle; -import androidx.appcompat.app.AppCompatActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.recyclerview.widget.ItemTouchHelper; import android.util.Log; import android.view.View; import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.ItemTouchHelper; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; + import github.nisrulz.recyclerviewhelper.RVHItemClickListener; import github.nisrulz.recyclerviewhelper.RVHItemDividerDecoration; import github.nisrulz.recyclerviewhelper.RVHItemTouchHelperCallback; -import java.util.ArrayList; public class MainActivity extends AppCompatActivity { diff --git a/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MyAdapter.java b/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MyAdapter.java index 03bf04a..943c150 100644 --- a/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MyAdapter.java +++ b/app/src/main/java/github/nisrulz/projectrecyclerviewhelper/MyAdapter.java @@ -16,39 +16,22 @@ package github.nisrulz.projectrecyclerviewhelper; -import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import github.nisrulz.recyclerviewhelper.RVHAdapter; -import github.nisrulz.recyclerviewhelper.RVHViewHolder; + +import androidx.recyclerview.widget.RecyclerView; + import java.util.Collections; import java.util.List; +import github.nisrulz.recyclerviewhelper.RVHAdapter; +import github.nisrulz.recyclerviewhelper.RVHViewHolder; + public class MyAdapter extends RecyclerView.Adapter implements RVHAdapter { - public class ItemViewHolder extends RecyclerView.ViewHolder implements RVHViewHolder { - - final TextView txt; - - public ItemViewHolder(View itemView) { - super(itemView); - txt = itemView.findViewById(R.id.txt); - } - - @Override - public void onItemClear() { - System.out.println("Item is unselected"); - } - - @Override - public void onItemSelected(int actionstate) { - System.out.println("Item is selected"); - } - } - private final List dataList; public MyAdapter(List dataList) { @@ -94,4 +77,24 @@ private void swap(int firstPosition, int secondPosition) { Collections.swap(dataList, firstPosition, secondPosition); notifyItemMoved(firstPosition, secondPosition); } + + public class ItemViewHolder extends RecyclerView.ViewHolder implements RVHViewHolder { + + final TextView txt; + + public ItemViewHolder(View itemView) { + super(itemView); + txt = itemView.findViewById(R.id.txt); + } + + @Override + public void onItemClear() { + System.out.println("Item is unselected"); + } + + @Override + public void onItemSelected(int actionstate) { + System.out.println("Item is selected"); + } + } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5409d20..485108e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -15,13 +15,13 @@ --> + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".MainActivity"> + android:id="@+id/rv_fruits" + android:layout_width="match_parent" + android:layout_height="match_parent" /> diff --git a/app/src/main/res/layout/rv_list_item.xml b/app/src/main/res/layout/rv_list_item.xml index 5213d7b..c29ad75 100644 --- a/app/src/main/res/layout/rv_list_item.xml +++ b/app/src/main/res/layout/rv_list_item.xml @@ -15,35 +15,35 @@ --> + android:layout_width="match_parent" + android:layout_height="wrap_content"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:weightSum="3"> + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:contentDescription="Reorder Handle" + android:padding="10dp" + android:src="@drawable/ic_reorder_grey_600_24dp" /> + android:id="@+id/txt" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="3" + android:padding="20dp" + android:textColor="@color/colorAccent" /> + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:contentDescription="Swipe Direction icon" + android:padding="10dp" + android:src="@drawable/ic_compare_arrows_indigo_a400_24dp" /> \ No newline at end of file diff --git a/app/src/test/java/github/nisrulz/projectrecyclerviewhelper/ExampleUnitTest.java b/app/src/test/java/github/nisrulz/projectrecyclerviewhelper/ExampleUnitTest.java index 295888a..f1e1a3a 100644 --- a/app/src/test/java/github/nisrulz/projectrecyclerviewhelper/ExampleUnitTest.java +++ b/app/src/test/java/github/nisrulz/projectrecyclerviewhelper/ExampleUnitTest.java @@ -16,9 +16,9 @@ package github.nisrulz.projectrecyclerviewhelper; -import static org.junit.Assert.*; +import org.junit.Test; -import org.junit.*; +import static org.junit.Assert.assertEquals; /** * To work on unit tests, switch the Test Artifact in the Build Variants view. diff --git a/build.gradle b/build.gradle index 2fff46e..6ba6871 100644 --- a/build.gradle +++ b/build.gradle @@ -17,17 +17,24 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - // Gradle will not find vars defined in an external file when referring to them - // in the buildscript block, unless you link it from the buildscript block, too. - apply from: 'dependencies.gradle' repositories { google() jcenter() } + dependencies { - // See dependencies.gradle for declaration of plugins. - classpath gradlePlugins + classpath Plugins.android + + // Publish to Jcenter/Bintray + classpath Plugins.bintray + classpath Plugins.androidMaven + + // Kotlin Plugin + classpath Plugins.kotlin + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files } } @@ -36,8 +43,4 @@ allprojects { google() jcenter() } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} +} \ No newline at end of file diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100755 index 0000000..72dd20d --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1,5 @@ +*.iml +.gradle +/.idea +/build +gradle.properties \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..445e21f --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +repositories { + jcenter() +} + +plugins { + `kotlin-dsl` +} \ No newline at end of file diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt new file mode 100644 index 0000000..60ec163 --- /dev/null +++ b/buildSrc/src/main/java/Config.kt @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +object Config { + const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" +} \ No newline at end of file diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt new file mode 100644 index 0000000..5425956 --- /dev/null +++ b/buildSrc/src/main/java/Dependencies.kt @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +object Dependencies { + + // Kotlin + const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlin}" + + // Testing + const val junit = "junit:junit:${Versions.junit}" + const val androidJunitExt = "androidx.test.ext:junit:${Versions.junitExt}" + const val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espresso}" + const val testRunner = "androidx.test:runner:${Versions.testRunner}" + const val testRules = "androidx.test:rules:${Versions.testRules}" + const val mockito = "org.mockito:mockito-core:${Versions.mockito}" + const val robolectric = "org.robolectric:robolectric:${Versions.robolectric}" + + // Support Library + const val appCompat = "androidx.appcompat:appcompat:${Versions.appCompat}" + const val cardview = "androidx.cardview:cardview:${Versions.cardview}" + const val annotation = "androidx.annotation:annotation:${Versions.annotation}" + const val recyclerView = "androidx.recyclerview:recyclerview:${Versions.recyclerView}" +} \ No newline at end of file diff --git a/buildSrc/src/main/java/LibraryConfig.kt b/buildSrc/src/main/java/LibraryConfig.kt new file mode 100644 index 0000000..6f92f43 --- /dev/null +++ b/buildSrc/src/main/java/LibraryConfig.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +object LibraryConfig { + const val libPomUrl = "https://github.com/nisrulz/recyclerviewhelper" + const val libGithubRepo = "nisrulz/recyclerviewhelper" + const val libModuleName = "recyclerviewhelper" + const val libModuleDesc = "RecyclerViewHelper provides the most common functions around recycler view like Swipe to dismiss, Drag and Drop, Divider in the ui, events for when item selected and when not selected, on-click listener for items." + const val libBintrayName = "com.github.nisrulz:recyclerviewhelper" +} diff --git a/buildSrc/src/main/java/Plugins.kt b/buildSrc/src/main/java/Plugins.kt new file mode 100644 index 0000000..c26c89a --- /dev/null +++ b/buildSrc/src/main/java/Plugins.kt @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +object Plugins { + // Plugins + const val android = "com.android.tools.build:gradle:${Versions.androidGradlePlugin}" + + // Kotlin + const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" + + + // Publish + const val bintray = "com.jfrog.bintray.gradle:gradle-bintray-plugin:${Versions.bintrayPlugin}" + const val androidMaven = "com.github.dcendents:android-maven-gradle-plugin:${Versions.androidMavenPlugin}" +} \ No newline at end of file diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt new file mode 100644 index 0000000..b5e2d49 --- /dev/null +++ b/buildSrc/src/main/java/Versions.kt @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +object Versions { + + // Build Config + const val minSDK = 14 + const val compileSDK = 29 + const val targetSDK = compileSDK + + // Plugins + const val androidGradlePlugin = "3.6.0-rc03" + const val bintrayPlugin = "1.8.4" + const val androidMavenPlugin = "2.1" + + // Dependencies + const val kotlin = "1.3.61" + const val cardview = "1.0.0" + const val annotation = "1.1.0" + const val appCompat = "1.1.0" + const val recyclerView = "1.1.0" + + // Testing + const val junit = "4.12" + const val junitExt = "1.1.1" + const val espresso = "3.2.0" + const val testRunner = "1.2.0" + const val testRules = "1.2.0" + const val mockito = "2.12.0" + const val robolectric = "4.3" + + // App + const val appCode = 1 + const val appName = "1.0.0" + + // Library + const val libraryCode = 21 + const val libraryName = "x1.1.0" +} \ No newline at end of file diff --git a/configs/common.gradle b/configs/common.gradle new file mode 100644 index 0000000..59672eb --- /dev/null +++ b/configs/common.gradle @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +android { + compileSdkVersion Versions.compileSDK + + defaultConfig { + minSdkVersion Versions.minSDK + targetSdkVersion Versions.targetSDK + + testInstrumentationRunner Config.testInstrumentationRunner + } + buildTypes { + debug { + minifyEnabled false + debuggable true + } + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + lintOptions { + textOutput "stdout" + textReport true + checkAllWarnings true + warningsAsErrors true + showAll true + explainIssues true + abortOnError false + lintConfig file("$projectDir/lint.xml") + } +} + +dependencies { + // Testing + testImplementation Dependencies.junit + androidTestImplementation Dependencies.androidJunitExt + androidTestImplementation Dependencies.testRules + androidTestImplementation Dependencies.espressoCore +} diff --git a/libconfig.gradle b/configs/library.gradle similarity index 52% rename from libconfig.gradle rename to configs/library.gradle index ece02b2..c7a8e7f 100644 --- a/libconfig.gradle +++ b/configs/library.gradle @@ -14,16 +14,23 @@ * limitations under the License. */ +android { + defaultConfig { + versionCode Versions.libraryCode + versionName Versions.libraryName + } +} + ext { libConfig = [ - versionCode : 20, - versionName : 'x1.0.0', - pomUrl : 'https://github.com/nisrulz/recyclerviewhelper', - githubRepo : 'nisrulz/recyclerviewhelper', + versionCode : Versions.libraryCode, + versionName : Versions.libraryName, + pomUrl : LibraryConfig.libPomUrl, + githubRepo : LibraryConfig.libGithubRepo, - moduleName : 'recyclerviewhelper', - moduleDesc : 'RecyclerViewHelper provides the most common functions around recycler view like Swipe to dismiss, Drag and Drop, Divider in the ui, events for when item selected and when not selected, on-click listener for items.', - bintrayName : 'com.github.nisrulz:recyclerviewhelper', + moduleName : LibraryConfig.libModuleName, + moduleDesc : LibraryConfig.libModuleDesc, + bintrayName : LibraryConfig.libBintrayName, publishedGroupId: GROUP, developerId : POM_DEVELOPER_ID, @@ -38,4 +45,19 @@ ext { user : BINTRAY_USER, apikey: BINTRAY_APIKEY ] -} \ No newline at end of file +} + +ext { + // Library Info + libVersionCode = Versions.libraryCode + libVersionName = Versions.libraryName + + libPomUrl = LibraryConfig.libPomUrl + libGithubRepo = LibraryConfig.libGithubRepo + + libModuleName = LibraryConfig.libModuleName + libModuleDesc = LibraryConfig.libModuleDesc + libBintrayName = LibraryConfig.libBintrayName +} + +apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/v2/publish-config.gradle' \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle deleted file mode 100644 index 6cac10e..0000000 --- a/dependencies.gradle +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2016 Nishant Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -ext { - versions = [ - appVersionCode : 1, - appVersionName : '1.0', - - minSdk : 14, - targetSdk : 28, - compileSdk : 28, - - androidGradlePlugin : '3.2.1', - gradleBintrayPlugin : '1.8.0', - androidMavenGradlePlugin: '2.1', - - supportAppCompat : '1.0.2', - support : '1.0.0', - supportRecyclerView : '1.0.0', - - junit : '4.12', - espresso : '3.1.0', - testRunner : '1.1.0', - ] - - junit = [junit: "junit:junit:$versions.junit"] - - supportDeps = [ - appcompatV7 : "androidx.appcompat:appcompat:$versions.support", - supportAnnotation: "androidx.annotation:annotation:$versions.support", - cardView : "androidx.cardview:cardview:$versions.support" - ] - - unitTest = [ - supportAnnotation: "androidx.annotation:annotation:$versions.support", - ] + junit - - androidTests = [ - espressoCore : "androidx.test.espresso:espresso-core:$versions.espresso", - espressoContrib: "androidx.test.espresso:espresso-contrib:$versions.espresso", - espressoIntents: "androidx.test.espresso:espresso-intents:$versions.espresso", - testRunner : "androidx.test:runner:$versions.testRunner", - testRules : "androidx.test:rules:$versions.testRunner", - ] - - gradlePlug = [ - android: "com.android.tools.build:gradle:$versions.androidGradlePlugin", - bintray: "com.jfrog.bintray.gradle:gradle-bintray-plugin:$versions.gradleBintrayPlugin", - maven : "com.github.dcendents:android-maven-gradle-plugin:$versions.androidMavenGradlePlugin" - ] - - gradlePlugins = gradlePlug.values() - - supportLibs = supportDeps.values() - unitTestLibs = unitTest.values() - androidTestsLibs = androidTests.values() + supportLibs -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 01b8bf6..cc4fdc2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b10568f..4e1cc9d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/gradlew b/gradlew index cccdd3d..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d..24467a1 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/recyclerviewhelper/build.gradle b/recyclerviewhelper/build.gradle index b060472..e5e5a53 100644 --- a/recyclerviewhelper/build.gradle +++ b/recyclerviewhelper/build.gradle @@ -15,48 +15,11 @@ */ apply plugin: 'com.android.library' -apply from: '../dependencies.gradle' -apply from: '../libconfig.gradle' -android { - compileSdkVersion versions.compileSdk - - defaultConfig { - minSdkVersion versions.minSdk - targetSdkVersion versions.targetSdk - versionCode libConfig.versionCode - versionName libConfig.versionName - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - lintOptions { - textOutput "stdout" - textReport true - checkAllWarnings true - warningsAsErrors true - showAll true - explainIssues true - abortOnError false - lintConfig file("$projectDir/lint.xml") - } -} +// Configs +apply from: "$rootProject.projectDir/configs/common.gradle" +apply from: "$rootProject.projectDir/configs/library.gradle" dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - - // Testing - testImplementation unitTestLibs - androidTestImplementation androidTestsLibs - - // CompileOnly deps - compileOnly "androidx.recyclerview:recyclerview:$versions.supportRecyclerView" -} - -apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/v2/publish-config.gradle' \ No newline at end of file + compileOnly Dependencies.recyclerView +} \ No newline at end of file diff --git a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHAdapter.java b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHAdapter.java index 879887c..b4ec198 100644 --- a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHAdapter.java +++ b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHAdapter.java @@ -23,7 +23,7 @@ public interface RVHAdapter { /** * Called when an item has been dismissed by a swipe. - * + *

* Implementations should call RecyclerView.Adapter notifyItemRemoved(int) after * adjusting the underlying data to reflect this removal. * @@ -35,7 +35,7 @@ public interface RVHAdapter { /** * Called when an item has been dragged far enough to trigger a move. This is called every time * an item is shifted, and not at the end of a "drop" event. - * + *

* Implementations should call RecyclerView.Adapter notifyItemMoved(int, int) after * adjusting the underlying data to reflect this move. * diff --git a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemClickListener.java b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemClickListener.java index bc65725..d5b68ca 100644 --- a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemClickListener.java +++ b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemClickListener.java @@ -17,11 +17,12 @@ package github.nisrulz.recyclerviewhelper; import android.content.Context; -import android.view.GestureDetector.SimpleOnGestureListener; -import androidx.recyclerview.widget.RecyclerView; import android.view.GestureDetector; +import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; import android.view.View; + +import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener; /** @@ -29,25 +30,10 @@ */ public class RVHItemClickListener implements OnItemTouchListener { - /** - * The interface On item click listener. - */ - public interface OnItemClickListener { - - /** - * On item click. - * - * @param view the view - * @param position the position - */ - void onItemClick(View view, int position); - } - /** * The M gesture detector. */ private final GestureDetector mGestureDetector; - private final RVHItemClickListener.OnItemClickListener mListener; /** @@ -85,4 +71,18 @@ public void onRequestDisallowInterceptTouchEvent(final boolean disallowIntercept public void onTouchEvent(final RecyclerView view, final MotionEvent motionEvent) { // Do nothing } + + /** + * The interface On item click listener. + */ + public interface OnItemClickListener { + + /** + * On item click. + * + * @param view the view + * @param position the position + */ + void onItemClick(View view, int position); + } } diff --git a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemDividerDecoration.java b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemDividerDecoration.java index 1c9f677..4dbd064 100644 --- a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemDividerDecoration.java +++ b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemDividerDecoration.java @@ -23,6 +23,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.view.View; + import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -64,7 +65,7 @@ public RVHItemDividerDecoration(final Context context, final int orientation) { @Override public void getItemOffsets(final Rect outRect, final View view, final RecyclerView parent, - final RecyclerView.State state) { + final RecyclerView.State state) { super.getItemOffsets(outRect, view, parent, state); if (mOrientation == VERTICAL_LIST) { diff --git a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemTouchHelperCallback.java b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemTouchHelperCallback.java index 8f3447f..f8a601a 100644 --- a/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemTouchHelperCallback.java +++ b/recyclerviewhelper/src/main/java/github/nisrulz/recyclerviewhelper/RVHItemTouchHelperCallback.java @@ -17,6 +17,7 @@ package github.nisrulz.recyclerviewhelper; import android.graphics.Canvas; + import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; @@ -42,7 +43,7 @@ public class RVHItemTouchHelperCallback extends ItemTouchHelper.Callback { * @param isItemViewSwipeEnabledRight the is item view swipe enabled right */ public RVHItemTouchHelperCallback(final RVHAdapter adapter, final boolean isLongPressDragEnabled, - final boolean isItemViewSwipeEnabledLeft, final boolean isItemViewSwipeEnabledRight) { + final boolean isItemViewSwipeEnabledLeft, final boolean isItemViewSwipeEnabledRight) { this.mAdapter = adapter; this.isItemViewSwipeEnabledLeft = isItemViewSwipeEnabledLeft; this.isItemViewSwipeEnabledRight = isItemViewSwipeEnabledRight; @@ -51,7 +52,7 @@ public RVHItemTouchHelperCallback(final RVHAdapter adapter, final boolean isLong @Override public boolean canDropOver(final RecyclerView recyclerView, final RecyclerView.ViewHolder current, - final RecyclerView.ViewHolder target) { + final RecyclerView.ViewHolder target) { return current.getItemViewType() == target.getItemViewType(); } @@ -93,7 +94,7 @@ public boolean isLongPressDragEnabled() { @Override public void onChildDraw(final Canvas c, final RecyclerView recyclerView, final RecyclerView.ViewHolder viewHolder, - final float dX, final float dY, final int actionState, final boolean isCurrentlyActive) { + final float dX, final float dY, final int actionState, final boolean isCurrentlyActive) { if (ItemTouchHelper.ACTION_STATE_SWIPE == actionState) { // Fade out the view as it is swiped out of the parent's bounds viewHolder.itemView.setTranslationX(dX); @@ -104,7 +105,7 @@ public void onChildDraw(final Canvas c, final RecyclerView recyclerView, final R @Override public boolean onMove(final RecyclerView recyclerView, final RecyclerView.ViewHolder source, - final RecyclerView.ViewHolder target) { + final RecyclerView.ViewHolder target) { // Notify the adapter of the move this.mAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); return true; diff --git a/recyclerviewhelper/src/test/java/github/nisrulz/recyclerviewhelper/ExampleUnitTest.java b/recyclerviewhelper/src/test/java/github/nisrulz/recyclerviewhelper/ExampleUnitTest.java index d1f135e..73ae360 100644 --- a/recyclerviewhelper/src/test/java/github/nisrulz/recyclerviewhelper/ExampleUnitTest.java +++ b/recyclerviewhelper/src/test/java/github/nisrulz/recyclerviewhelper/ExampleUnitTest.java @@ -16,7 +16,8 @@ package github.nisrulz.recyclerviewhelper; -import org.junit.*; +import org.junit.Assert; +import org.junit.Test; /** * To work on unit tests, switch the Test Artifact in the Build Variants view. diff --git a/settings.gradle b/settings.gradle index 3d73c90..ea98096 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,4 +14,6 @@ * limitations under the License. */ -include ':app', ':recyclerviewhelper' +rootProject.name = 'RecyclerViewHelperProject' +include ':app' +include ':recyclerviewhelper'