diff --git a/README.md b/README.md
index 18af036c..373a598b 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,6 @@ This RecyclerView extension library provides Google's Inbox app like swiping, Pl
[ ![Download](https://api.bintray.com/packages/h6ah4i/maven/android-advancedrecyclerview/images/download.svg) ](https://bintray.com/h6ah4i/maven/android-advancedrecyclerview/_latestVersion)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Advanced%20RecyclerView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1432)
-[![Method Count](https://img.shields.io/badge/Methods%20and%20size-core:%201718%20%7C%20deps:%2018297%20%7C%20233%20KB-e91e63.svg) ](http://www.methodscount.com/?lib=com.h6ah4i.android.widget.advrecyclerview%3Aadvrecyclerview%3A0.11.0)
---
@@ -36,18 +35,23 @@ Target platforms
Latest version
---
-- Version 0.11.0 (October 29, 2017) ([RELEASE NOTES](./RELEASE-NOTES.md))
+- Version 1.0.0 (December 16, 2018) ([RELEASE NOTES](./RELEASE-NOTES.md))
**Recent Breaking Change Info**
-- **v0.11.0:**
- - Since official support libraries have dropped support older API levels than v14, this library does also dropped support them since v0.11.0. If you still need to support API level v9, please continue to use v0.10.6.
- - A new callback `onItemSwipeStarted()` is added to `SwipeableItemAdapter`. Users must invoke appropriate `notify*()` method in this method.
- - A new callback `onItemDragStarted()` is added to `DraggableItemAdapter`. Users must invoke appropriate `notify*()` method in this method.
- - A new callback `onItemDragFinished()` is added to `DraggableItemAdapter`. Users must invoke appropriate `notify*()` method in this method.
+- **v1.0.0:**
+ - Migrated to AndroidX (Use **v0.11.0** instead if your project uses support libraries)
+ - `BaseWrapperAdapter`
+ - Removed some deprecated features
+ - `SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH`
+ - `SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH`
+ - `SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_WITH_RUBBER_BAND_EFFECT`
+ - New `DraggableItemState getDragState()` method added to the `DraggableItemViewHolder` interface
+ - New `SwipeableItemState getSwipeState()` method added to the `SwipeableItemViewHolder` interface
+ - New `ExpandableItemState getExpandState()` method added to the `ExpandableItemViewHolder` interface
-- **v0.10.4:** `OnGroupExpandListener` and `OnGroupCollapseListener` takes `payload` parameter. (related: [issue #350](https://github.com/h6ah4i/android-advancedrecyclerview/issues/350))
+:point_right: [Migration guide from v0.11.0 to v1.0.0](https://advancedrecyclerview.h6ah4i.com/migration/)
Getting started
@@ -57,9 +61,7 @@ This library is published on jCenter. Just add these lines to `build.gradle`.
```gradle
dependencies {
- implementation ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar'){
- transitive=true
- }
+ implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0'
}
```
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index b540a231..9efd689f 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -1,3 +1,23 @@
+## 1.0.0
+[Breaking changes]
+- Migrated to AndroidX
+- Removed some deprecated features
+ - `BaseWrapperAdapter`
+ - `SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH`
+ - `SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH`
+ - `SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_WITH_RUBBER_BAND_EFFECT`
+- New `DraggableItemState getDragState()` method added to the `DraggableItemViewHolder` interface
+- New `SwipeableItemState getSwipeState()` method added to the `SwipeableItemViewHolder` interface
+- New `ExpandableItemState getExpandState()` method added to the `ExpandableItemViewHolder` interface
+
+[New features & improvements]
+- Introduced `DraggableItemState`, no more `DraggableItemConstants.STATE_FLAG_**` bit operations required anymore in user code
+- Introduced `SwipeableItemState`, no more `SwipeableItemConstants.STATE_FLAG_**` bit operations required anymore in user code
+- Introduced `ExpandableItemState`, no more `ExpandableItemConstants.STATE_FLAG_**` bit operations required anymore in user code
+- Annotated many public method with `@NonNull` or `@Nullable`
+
+
+
## 0.11.0
[Breaking changes]
- Changed minimum SDK level to v14
diff --git a/build.gradle b/build.gradle
index 2f8362dc..2512afba 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,13 +4,9 @@ buildscript {
repositories {
jcenter()
google()
- maven {
- url "http://dl.bintray.com/vigidroid/maven"
- }
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0'
- classpath 'me.vigi:fat-aar-plugin:0.2.8'
+ classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -23,3 +19,12 @@ allprojects {
google()
}
}
+
+project.ext {
+ compileSdkVersion = 28
+ buildToolsVersion = '28.0.3'
+ minSdkVersion = 14
+ targetSdkVersion = 28
+
+ recyclerViewVersion = '1.0.0'
+}
\ No newline at end of file
diff --git a/common/android-maven-publish.gradle b/common/android-maven-publish.gradle
index c01ab8a1..e6bbb4ab 100644
--- a/common/android-maven-publish.gradle
+++ b/common/android-maven-publish.gradle
@@ -26,7 +26,6 @@ def repoDir = project.mavenPublishDestDir
def dataProps = new Properties()
dataProps.load(project.file(project.mavenPublishDataFile).newDataInputStream())
-def doclavaProjPath = project.path + ':doclava'
def optUseDoclava = project.useDoclava
task cleanDocsOutDir(type: Delete) {
diff --git a/common/android-set-common-properties.gradle b/common/android-set-common-properties.gradle
deleted file mode 100644
index b71d9f74..00000000
--- a/common/android-set-common-properties.gradle
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2015 Haruki Hasegawa
- *
- * 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 27
-
- if (System.getenv("JITPACK") == "true") {
- buildToolsVersion '27.0.0'
- } else {
- buildToolsVersion '27.0.0'
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_7
- targetCompatibility JavaVersion.VERSION_1_7
- }
-}
diff --git a/common/android-signing-utils.gradle b/common/android-signing-utils.gradle
index cf2d22b3..bbc84319 100644
--- a/common/android-signing-utils.gradle
+++ b/common/android-signing-utils.gradle
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-def loadSigningConfigFromPropertiesFile(project, signingConfig, propFileName) {
+static def loadSigningConfigFromPropertiesFile(project, signingConfig, propFileName) {
def props = new Properties()
def propFile = project.file(propFileName)
diff --git a/example/build.gradle b/example/build.gradle
index b0060eed..cdb4ae77 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -16,20 +16,26 @@
apply plugin: 'com.android.application'
-// Common configurations
-apply from: '../common/android-set-common-properties.gradle'
apply from: '../common/android-signing-utils.gradle'
android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+
defaultConfig {
applicationId "com.h6ah4i.android.example.advrecyclerview"
- minSdkVersion 14
- targetSdkVersion 27
- versionCode 29
- versionName "0.11.0"
+ minSdkVersion rootProject.ext.minSdkVersion
+ targetSdkVersion rootProject.ext.targetSdkVersion
+ versionCode 30
+ versionName "1.0.0"
vectorDrawables.useSupportLibrary = true
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
signingConfigs {
release
}
@@ -64,6 +70,6 @@ if (loadSigningConfigFromPropertiesFile(
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':library')
- implementation 'com.android.support:design:27.0.0'
- implementation ('com.h6ah4i.android.tablayouthelper:tablayouthelper:0.9.0')
+ implementation 'com.google.android.material:material:1.0.0'
+ implementation ('com.h6ah4i.android.tablayouthelper:tablayouthelper:1.0.0')
}
diff --git a/example/src/androidTest/java/com/h6ah4i/android/example/advrecyclerview/ApplicationTest.java b/example/src/androidTest/java/com/h6ah4i/android/example/advrecyclerview/ApplicationTest.java
deleted file mode 100644
index 5d5dbcd3..00000000
--- a/example/src/androidTest/java/com/h6ah4i/android/example/advrecyclerview/ApplicationTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2015 Haruki Hasegawa
- *
- * 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.
- */
-
-package com.h6ah4i.android.example.advrecyclerview;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/example/src/main/assets/oss/1_android_support_design/LINK b/example/src/main/assets/oss/1_android_support_design/LINK
deleted file mode 100644
index fe7651cc..00000000
--- a/example/src/main/assets/oss/1_android_support_design/LINK
+++ /dev/null
@@ -1 +0,0 @@
-http://developer.android.com/tools/support-library/features.html#design
diff --git a/example/src/main/assets/oss/1_android_support_design/NAME b/example/src/main/assets/oss/1_android_support_design/NAME
deleted file mode 100644
index 758ebd2e..00000000
--- a/example/src/main/assets/oss/1_android_support_design/NAME
+++ /dev/null
@@ -1 +0,0 @@
-Design Support Library
diff --git a/example/src/main/assets/oss/1_android_support_design/NOTICE b/example/src/main/assets/oss/1_android_support_design/NOTICE
deleted file mode 100644
index f111b31e..00000000
--- a/example/src/main/assets/oss/1_android_support_design/NOTICE
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright (c) 2005-2013, The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-
-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.
diff --git a/example/src/main/assets/oss/5_material_design_icons/LINK b/example/src/main/assets/oss/1_material_design_icons/LINK
similarity index 100%
rename from example/src/main/assets/oss/5_material_design_icons/LINK
rename to example/src/main/assets/oss/1_material_design_icons/LINK
diff --git a/example/src/main/assets/oss/5_material_design_icons/NAME b/example/src/main/assets/oss/1_material_design_icons/NAME
similarity index 100%
rename from example/src/main/assets/oss/5_material_design_icons/NAME
rename to example/src/main/assets/oss/1_material_design_icons/NAME
diff --git a/example/src/main/assets/oss/5_material_design_icons/NOTICE b/example/src/main/assets/oss/1_material_design_icons/NOTICE
similarity index 100%
rename from example/src/main/assets/oss/5_material_design_icons/NOTICE
rename to example/src/main/assets/oss/1_material_design_icons/NOTICE
diff --git a/example/src/main/assets/oss/2_android_support_v4/LINK b/example/src/main/assets/oss/2_android_support_v4/LINK
deleted file mode 100644
index e06aa4c1..00000000
--- a/example/src/main/assets/oss/2_android_support_v4/LINK
+++ /dev/null
@@ -1 +0,0 @@
-http://developer.android.com/tools/support-library/features.html#v4
diff --git a/example/src/main/assets/oss/2_android_support_v4/NAME b/example/src/main/assets/oss/2_android_support_v4/NAME
deleted file mode 100644
index 8e4c2194..00000000
--- a/example/src/main/assets/oss/2_android_support_v4/NAME
+++ /dev/null
@@ -1 +0,0 @@
-Android v4 Support Library
diff --git a/example/src/main/assets/oss/2_android_support_v4/NOTICE b/example/src/main/assets/oss/2_android_support_v4/NOTICE
deleted file mode 100644
index f111b31e..00000000
--- a/example/src/main/assets/oss/2_android_support_v4/NOTICE
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright (c) 2005-2013, The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-
-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.
diff --git a/example/src/main/assets/oss/6_tablayouthelper/LINK b/example/src/main/assets/oss/2_tablayouthelper/LINK
similarity index 100%
rename from example/src/main/assets/oss/6_tablayouthelper/LINK
rename to example/src/main/assets/oss/2_tablayouthelper/LINK
diff --git a/example/src/main/assets/oss/6_tablayouthelper/NAME b/example/src/main/assets/oss/2_tablayouthelper/NAME
similarity index 100%
rename from example/src/main/assets/oss/6_tablayouthelper/NAME
rename to example/src/main/assets/oss/2_tablayouthelper/NAME
diff --git a/example/src/main/assets/oss/6_tablayouthelper/NOTICE b/example/src/main/assets/oss/2_tablayouthelper/NOTICE
similarity index 100%
rename from example/src/main/assets/oss/6_tablayouthelper/NOTICE
rename to example/src/main/assets/oss/2_tablayouthelper/NOTICE
diff --git a/example/src/main/assets/oss/3_android_support_v7_appcompat/LINK b/example/src/main/assets/oss/3_android_support_v7_appcompat/LINK
deleted file mode 100644
index 69fa3309..00000000
--- a/example/src/main/assets/oss/3_android_support_v7_appcompat/LINK
+++ /dev/null
@@ -1 +0,0 @@
-http://developer.android.com/tools/support-library/features.html#v7-appcompat
diff --git a/example/src/main/assets/oss/3_android_support_v7_appcompat/NAME b/example/src/main/assets/oss/3_android_support_v7_appcompat/NAME
deleted file mode 100644
index b29a0078..00000000
--- a/example/src/main/assets/oss/3_android_support_v7_appcompat/NAME
+++ /dev/null
@@ -1 +0,0 @@
-Android v7 Support Library (v7 apcompat library)
diff --git a/example/src/main/assets/oss/3_android_support_v7_appcompat/NOTICE b/example/src/main/assets/oss/3_android_support_v7_appcompat/NOTICE
deleted file mode 100644
index f111b31e..00000000
--- a/example/src/main/assets/oss/3_android_support_v7_appcompat/NOTICE
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright (c) 2005-2013, The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-
-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.
diff --git a/example/src/main/assets/oss/4_android_support_v7_recyclerview/LINK b/example/src/main/assets/oss/4_android_support_v7_recyclerview/LINK
deleted file mode 100644
index da0e31d4..00000000
--- a/example/src/main/assets/oss/4_android_support_v7_recyclerview/LINK
+++ /dev/null
@@ -1 +0,0 @@
-http://developer.android.com/tools/support-library/features.html#v7-recyclerview
diff --git a/example/src/main/assets/oss/4_android_support_v7_recyclerview/NAME b/example/src/main/assets/oss/4_android_support_v7_recyclerview/NAME
deleted file mode 100644
index db0aae80..00000000
--- a/example/src/main/assets/oss/4_android_support_v7_recyclerview/NAME
+++ /dev/null
@@ -1 +0,0 @@
-Android v7 Support Library (v7 recyclerview library)
diff --git a/example/src/main/assets/oss/4_android_support_v7_recyclerview/NOTICE b/example/src/main/assets/oss/4_android_support_v7_recyclerview/NOTICE
deleted file mode 100644
index f111b31e..00000000
--- a/example/src/main/assets/oss/4_android_support_v7_recyclerview/NOTICE
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright (c) 2005-2013, The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-
-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.
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AboutActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AboutActivity.java
index b0cfd1f0..6291aebc 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AboutActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AboutActivity.java
@@ -18,8 +18,6 @@
import android.content.Context;
import android.os.Bundle;
-import android.support.v4.app.ListFragment;
-import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
@@ -32,6 +30,9 @@
import java.util.List;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.ListFragment;
+
public class AboutActivity extends AppCompatActivity {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AssetFileLibraryLicenseDataCollector.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AssetFileLibraryLicenseDataCollector.java
index 0206c0f0..f3b2402b 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AssetFileLibraryLicenseDataCollector.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/about/AssetFileLibraryLicenseDataCollector.java
@@ -25,7 +25,6 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Comparator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -56,26 +55,24 @@ public List collect() {
// sort numerically
final Pattern p = Pattern.compile("^([0-9]+).*$");
- Arrays.sort(dirs, new Comparator() {
- public int compare(String s1, String s2) {
- try {
- Matcher m1 = p.matcher(s1);
- Matcher m2 = p.matcher(s2);
- if (m1.find() && m2.find()) {
- int n1 = Integer.parseInt(m1.group(1));
- int n2 = Integer.parseInt(m2.group(1));
-
- if (n1 == n2) {
- return s1.compareTo(s2);
- }
-
- return n1 - n2;
- } else {
+ Arrays.sort(dirs, (s1, s2) -> {
+ try {
+ Matcher m1 = p.matcher(s1);
+ Matcher m2 = p.matcher(s2);
+ if (m1.find() && m2.find()) {
+ int n1 = Integer.parseInt(m1.group(1));
+ int n2 = Integer.parseInt(m2.group(1));
+
+ if (n1 == n2) {
return s1.compareTo(s2);
}
- } catch (RuntimeException e) {
+
+ return n1 - n2;
+ } else {
return s1.compareTo(s2);
}
+ } catch (RuntimeException e) {
+ return s1.compareTo(s2);
}
});
@@ -131,20 +128,11 @@ private static Uri safeParseLinkUri(String s) {
// http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string
private static String loadTextFile(AssetManager assets, String path) {
- InputStream stream = null;
- try {
- stream = assets.open(path, AssetManager.ACCESS_STREAMING);
+ try (InputStream stream = assets.open(path, AssetManager.ACCESS_STREAMING)) {
java.util.Scanner s = new java.util.Scanner(stream).useDelimiter("\\A");
return s.hasNext() ? s.next().trim() : "";
} catch (IOException e) {
// just ignore
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException ignored) {
- }
- }
}
return null;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/DemoHeaderFooterAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/DemoHeaderFooterAdapter.java
index 77082346..23838804 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/DemoHeaderFooterAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/DemoHeaderFooterAdapter.java
@@ -15,9 +15,6 @@
*/
package com.h6ah4i.android.example.advrecyclerview.common.adapter;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -27,6 +24,11 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.StaggeredGridLayoutManager;
+
public class DemoHeaderFooterAdapter
extends AbstractHeaderFooterWrapperAdapter
implements View.OnClickListener {
@@ -63,8 +65,9 @@ public int getFooterItemCount() {
return 1;
}
+ @NonNull
@Override
- public HeaderViewHolder onCreateHeaderItemViewHolder(ViewGroup parent, int viewType) {
+ public HeaderViewHolder onCreateHeaderItemViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.header_item, parent, false);
HeaderViewHolder vh = new HeaderViewHolder(v);
if (mOnItemClickListener != null) {
@@ -73,8 +76,9 @@ public HeaderViewHolder onCreateHeaderItemViewHolder(ViewGroup parent, int viewT
return vh;
}
+ @NonNull
@Override
- public FooterViewHolder onCreateFooterItemViewHolder(ViewGroup parent, int viewType) {
+ public FooterViewHolder onCreateFooterItemViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.footer_item, parent, false);
FooterViewHolder vh = new FooterViewHolder(v);
if (mOnItemClickListener != null) {
@@ -84,7 +88,7 @@ public FooterViewHolder onCreateFooterItemViewHolder(ViewGroup parent, int viewT
}
@Override
- public void onClick(View v) {
+ public void onClick(@NonNull View v) {
RecyclerView rv = RecyclerViewAdapterUtils.getParentRecyclerView(v);
RecyclerView.ViewHolder vh = rv.findContainingViewHolder(v);
@@ -120,19 +124,19 @@ public void onClick(View v) {
// Set full-span for Grid layout and Staggered Grid layout
@Override
- public void onAttachedToRecyclerView(RecyclerView recyclerView) {
+ public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
setupFullSpanForGridLayoutManager(recyclerView);
}
@Override
- public void onBindHeaderItemViewHolder(HeaderViewHolder holder, int localPosition) {
+ public void onBindHeaderItemViewHolder(@NonNull HeaderViewHolder holder, int localPosition) {
applyFullSpanForStaggeredGridLayoutManager(holder);
}
@Override
- public void onBindFooterItemViewHolder(FooterViewHolder holder, int localPosition) {
+ public void onBindFooterItemViewHolder(@NonNull FooterViewHolder holder, int localPosition) {
applyFullSpanForStaggeredGridLayoutManager(holder);
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoExpandableItemAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoExpandableItemAdapter.java
index 2c08e0f7..f96c6e27 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoExpandableItemAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoExpandableItemAdapter.java
@@ -15,7 +15,6 @@
*/
package com.h6ah4i.android.example.advrecyclerview.common.adapter;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -31,6 +30,9 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public class SimpleDemoExpandableItemAdapter extends AbstractExpandableItemAdapter implements View.OnClickListener {
RecyclerViewExpandableItemManager mExpandableItemManager;
List mItems;
@@ -121,7 +123,8 @@ public long getChildId(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_group_item_for_expandable_minimal, parent, false);
MyGroupViewHolder vh = new MyGroupViewHolder(v);
vh.itemView.setOnClickListener(this);
@@ -129,7 +132,8 @@ public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType)
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_child_item_for_expandable_minimal, parent, false);
MyChildViewHolder vh = new MyChildViewHolder(v);
vh.itemView.setOnClickListener(this);
@@ -137,19 +141,19 @@ public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType)
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
MyGroupItem group = mItems.get(groupPosition);
holder.textView.setText(group.text);
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
MyChildItem child = mItems.get(groupPosition).children.get(childPosition);
holder.textView.setText(child.text);
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
// handles click event manually (to show Snackbar message)
return false;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoItemAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoItemAdapter.java
index 29b6dce4..fadf9414 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoItemAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/adapter/SimpleDemoItemAdapter.java
@@ -15,7 +15,6 @@
*/
package com.h6ah4i.android.example.advrecyclerview.common.adapter;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -25,6 +24,9 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public class SimpleDemoItemAdapter extends RecyclerView.Adapter implements View.OnClickListener {
static class MyViewHolder extends RecyclerView.ViewHolder {
TextView textView;
@@ -41,8 +43,9 @@ public SimpleDemoItemAdapter(OnListItemClickMessageListener clickListener) {
mOnItemClickListener = clickListener;
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_minimal, parent, false);
MyViewHolder vh = new MyViewHolder(v);
vh.itemView.setOnClickListener(this);
@@ -50,7 +53,7 @@ public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.textView.setText("Item " + position);
}
@@ -60,7 +63,7 @@ public int getItemCount() {
}
@Override
- public void onClick(View v) {
+ public void onClick(@NonNull View v) {
RecyclerView rv = RecyclerViewAdapterUtils.getParentRecyclerView(v);
RecyclerView.ViewHolder vh = rv.findContainingViewHolder(v);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleDataProvider.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleDataProvider.java
index 93bb792f..a89c7c92 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleDataProvider.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleDataProvider.java
@@ -22,6 +22,8 @@
import java.util.LinkedList;
import java.util.List;
+import androidx.annotation.NonNull;
+
public class ExampleDataProvider extends AbstractDataProvider {
private List mData;
private ConcreteData mLastRemovedData;
@@ -112,24 +114,19 @@ public void removeItem(int position) {
public static final class ConcreteData extends Data {
private final long mId;
+ @NonNull
private final String mText;
private final int mViewType;
private boolean mPinned;
- ConcreteData(long id, int viewType, String text, int swipeReaction) {
+ ConcreteData(long id, int viewType, @NonNull String text, int swipeReaction) {
mId = id;
mViewType = viewType;
mText = makeText(id, text, swipeReaction);
}
private static String makeText(long id, String text, int swipeReaction) {
- final StringBuilder sb = new StringBuilder();
-
- sb.append(id);
- sb.append(" - ");
- sb.append(text);
-
- return sb.toString();
+ return String.valueOf(id) + " - " + text;
}
@Override
@@ -147,6 +144,7 @@ public long getId() {
return mId;
}
+ @NonNull
@Override
public String toString() {
return mText;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleExpandableDataProvider.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleExpandableDataProvider.java
index 3204d4f3..ee633c8f 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleExpandableDataProvider.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleExpandableDataProvider.java
@@ -17,14 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.common.data;
-import android.support.v4.util.Pair;
-
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import androidx.core.util.Pair;
+
public class ExampleExpandableDataProvider extends AbstractExpandableDataProvider {
private List>> mData;
@@ -57,7 +57,7 @@ public ExampleExpandableDataProvider() {
children.add(new ConcreteChildData(childId, childText));
}
- mData.add(new Pair>(group, children));
+ mData.add(new Pair<>(group, children));
}
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionDataProvider.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionDataProvider.java
index a08ea3c4..3e635287 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionDataProvider.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionDataProvider.java
@@ -20,6 +20,8 @@
import java.util.LinkedList;
import java.util.List;
+import androidx.annotation.NonNull;
+
public class ExampleSectionDataProvider extends AbstractDataProvider {
private List mData;
private ConcreteData mLastRemovedData;
@@ -123,11 +125,12 @@ public static final class ConcreteData extends Data {
private final long mId;
private final boolean mIsSectionHeader;
+ @NonNull
private final String mText;
private final int mViewType;
private boolean mPinned;
- ConcreteData(long id, boolean isSectionHeader, int viewType, String text) {
+ ConcreteData(long id, boolean isSectionHeader, int viewType, @NonNull String text) {
mId = id;
mIsSectionHeader = isSectionHeader;
mViewType = viewType;
@@ -149,6 +152,7 @@ public long getId() {
return mId;
}
+ @NonNull
@Override
public String toString() {
return mText;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionExpandableDataProvider.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionExpandableDataProvider.java
index 5d9e7598..68a874c4 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionExpandableDataProvider.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/data/ExampleSectionExpandableDataProvider.java
@@ -17,14 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.common.data;
-import android.support.v4.util.Pair;
-
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import androidx.core.util.Pair;
+
public class ExampleSectionExpandableDataProvider extends AbstractExpandableDataProvider {
private List>> mData;
@@ -64,7 +64,7 @@ public ExampleSectionExpandableDataProvider() {
}
}
- mData.add(new Pair>(group, children));
+ mData.add(new Pair<>(group, children));
}
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleAddRemoveExpandableDataProviderFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleAddRemoveExpandableDataProviderFragment.java
index 9f263567..1ac6ffc6 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleAddRemoveExpandableDataProviderFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleAddRemoveExpandableDataProviderFragment.java
@@ -18,11 +18,12 @@
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractAddRemoveExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.data.ExampleAddRemoveExpandableDataProvider;
+import androidx.fragment.app.Fragment;
+
public class ExampleAddRemoveExpandableDataProviderFragment extends Fragment {
private ExampleAddRemoveExpandableDataProvider mDataProvider;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleDataProviderFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleDataProviderFragment.java
index a924d70a..f1aaab9e 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleDataProviderFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleDataProviderFragment.java
@@ -18,11 +18,12 @@
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.data.ExampleDataProvider;
+import androidx.fragment.app.Fragment;
+
public class ExampleDataProviderFragment extends Fragment {
private AbstractDataProvider mDataProvider;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleExpandableDataProviderFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleExpandableDataProviderFragment.java
index d299dbb1..4275deb7 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleExpandableDataProviderFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleExpandableDataProviderFragment.java
@@ -18,11 +18,12 @@
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.data.ExampleExpandableDataProvider;
+import androidx.fragment.app.Fragment;
+
public class ExampleExpandableDataProviderFragment extends Fragment {
private ExampleExpandableDataProvider mDataProvider;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionDataProviderFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionDataProviderFragment.java
index a720985a..cc695bef 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionDataProviderFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionDataProviderFragment.java
@@ -18,11 +18,12 @@
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.data.ExampleSectionDataProvider;
+import androidx.fragment.app.Fragment;
+
public class ExampleSectionDataProviderFragment extends Fragment {
private ExampleSectionDataProvider mDataProvider;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionExpandableDataProviderFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionExpandableDataProviderFragment.java
index 27901775..59941e65 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionExpandableDataProviderFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExampleSectionExpandableDataProviderFragment.java
@@ -18,11 +18,12 @@
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.data.ExampleSectionExpandableDataProvider;
+import androidx.fragment.app.Fragment;
+
public class ExampleSectionExpandableDataProviderFragment extends Fragment {
private ExampleSectionExpandableDataProvider mDataProvider;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExpandableItemPinnedMessageDialogFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExpandableItemPinnedMessageDialogFragment.java
index 45556617..5d2d6659 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExpandableItemPinnedMessageDialogFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ExpandableItemPinnedMessageDialogFragment.java
@@ -20,13 +20,14 @@
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.app.DialogFragment;
-import android.support.v7.widget.RecyclerView;
import com.h6ah4i.android.example.advrecyclerview.R;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+import androidx.recyclerview.widget.RecyclerView;
+
public class ExpandableItemPinnedMessageDialogFragment extends DialogFragment {
private static final String KEY_GROUP_ITEM_POSITION = "group_position";
private static final String KEY_CHILD_ITEM_POSITION = "child_position";
@@ -64,18 +65,8 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
} else {
builder.setMessage(getString(R.string.dialog_message_child_item_pinned, groupPosition, childPosition));
}
- builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- notifyItemPinnedDialogDismissed(true);
- }
- });
- builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
+ builder.setPositiveButton(android.R.string.ok, (dialog, which) -> notifyItemPinnedDialogDismissed(true));
+ builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel());
builder.setCancelable(true);
return builder.create();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ItemPinnedMessageDialogFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ItemPinnedMessageDialogFragment.java
index 12eb77e5..315f35f5 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ItemPinnedMessageDialogFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/fragment/ItemPinnedMessageDialogFragment.java
@@ -20,12 +20,13 @@
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.app.DialogFragment;
import com.h6ah4i.android.example.advrecyclerview.R;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+
public class ItemPinnedMessageDialogFragment extends DialogFragment {
private static final String KEY_ITEM_POSITION = "position";
@@ -55,18 +56,8 @@ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final int itemPosition = getArguments().getInt(KEY_ITEM_POSITION, Integer.MIN_VALUE);
builder.setMessage(getString(R.string.dialog_message_item_pinned, itemPosition));
- builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- notifyItemPinnedDialogDismissed(true);
- }
- });
- builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
+ builder.setPositiveButton(android.R.string.ok, (dialog, which) -> notifyItemPinnedDialogDismissed(true));
+ builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.cancel());
builder.setCancelable(true);
return builder.create();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplAnim.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplAnim.java
index 1b98d03c..20c56318 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplAnim.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplAnim.java
@@ -20,14 +20,15 @@
import android.content.Context;
import android.graphics.drawable.Animatable;
import android.os.Build;
-import android.support.annotation.DrawableRes;
-import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import com.h6ah4i.android.example.advrecyclerview.R;
+import androidx.annotation.DrawableRes;
+import androidx.appcompat.widget.AppCompatImageView;
+
// NOTE: AnimatedVectorDrawableCompat works on API level 11+
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
class ExpandableItemIndicatorImplAnim extends ExpandableItemIndicator.Impl {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplNoAnim.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplNoAnim.java
index dd98f17a..d8a7a893 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplNoAnim.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/common/widget/ExpandableItemIndicatorImplNoAnim.java
@@ -17,14 +17,15 @@
package com.h6ah4i.android.example.advrecyclerview.common.widget;
import android.content.Context;
-import android.support.annotation.DrawableRes;
-import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import com.h6ah4i.android.example.advrecyclerview.R;
+import androidx.annotation.DrawableRes;
+import androidx.appcompat.widget.AppCompatImageView;
+
class ExpandableItemIndicatorImplNoAnim extends ExpandableItemIndicator.Impl {
private AppCompatImageView mImageView;
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/CompositionAllExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/CompositionAllExampleActivity.java
index 6eff306c..2578e4f1 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/CompositionAllExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/CompositionAllExampleActivity.java
@@ -18,14 +18,9 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.SimpleItemAnimator;
import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener;
@@ -34,6 +29,12 @@
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.SimpleItemAnimator;
+
public class CompositionAllExampleActivity extends AppCompatActivity {
@Override
@@ -44,12 +45,9 @@ public void onCreate(Bundle savedInstanceState) {
RecyclerView recyclerView = findViewById(R.id.recycler_view);
- OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {
- @Override
- public void onItemClicked(String message) {
- View container = findViewById(R.id.container);
- Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
- }
+ OnListItemClickMessageListener clickListener = message -> {
+ View container = findViewById(R.id.container);
+ Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
};
recyclerView.setLayoutManager(new LinearLayoutManager(this));
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyDraggableAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyDraggableAdapter.java
index 2786b408..76d03481 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyDraggableAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyDraggableAdapter.java
@@ -15,7 +15,6 @@
*/
package com.h6ah4i.android.example.advrecyclerview.demo_composition_all;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -33,6 +32,9 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class MyDraggableAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter, View.OnClickListener {
@@ -79,8 +81,9 @@ public long getItemId(int position) {
return mItems.get(position).id; // need to return stable (= not change even after reordered) value
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_draggable, parent, false);
MyViewHolder vh = new MyViewHolder(v);
vh.containerView.setOnClickListener(this);
@@ -88,7 +91,7 @@ public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
MyItem item = mItems.get(position);
holder.textView.setText(item.text);
}
@@ -105,12 +108,12 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
return ViewUtils.hitTest(holder.dragHandle, x, y);
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
return null;
}
@@ -130,7 +133,7 @@ public void onItemDragFinished(int fromPosition, int toPosition, boolean result)
}
@Override
- public void onClick(View v) {
+ public void onClick(@NonNull View v) {
RecyclerView rv = RecyclerViewAdapterUtils.getParentRecyclerView(v);
RecyclerView.ViewHolder vh = rv.findContainingViewHolder(v);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyExpandableAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyExpandableAdapter.java
index 0c198227..96ccb266 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyExpandableAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MyExpandableAdapter.java
@@ -15,7 +15,6 @@
*/
package com.h6ah4i.android.example.advrecyclerview.demo_composition_all;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -24,7 +23,7 @@
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener;
import com.h6ah4i.android.example.advrecyclerview.common.widget.ExpandableItemIndicator;
-import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemState;
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemViewHolder;
@@ -34,6 +33,9 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class MyExpandableAdapter
extends AbstractExpandableItemAdapter
implements View.OnClickListener {
@@ -131,7 +133,8 @@ public long getChildId(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_group_item, parent, false);
MyGroupViewHolder vh = new MyGroupViewHolder(v);
vh.containerView.setOnClickListener(this);
@@ -139,7 +142,8 @@ public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType)
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
MyChildViewHolder vh = new MyChildViewHolder(v);
vh.containerView.setOnClickListener(this);
@@ -147,34 +151,33 @@ public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType)
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
MyGroupItem group = mItems.get(groupPosition);
holder.textView.setText(group.text);
- final int expandState = holder.getExpandStateFlags();
+ final ExpandableItemState expandState = holder.getExpandState();
- if ((expandState & ExpandableItemConstants.STATE_FLAG_IS_UPDATED) != 0) {
- boolean isExpanded = ((expandState & ExpandableItemConstants.STATE_FLAG_IS_EXPANDED) != 0);
- boolean animateIndicator = ((expandState & ExpandableItemConstants.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED) != 0);
+ if (expandState.isUpdated()) {
+ boolean animateIndicator = expandState.hasExpandedStateChanged();
- holder.indicator.setExpandedState(isExpanded, animateIndicator);
+ holder.indicator.setExpandedState(expandState.isExpanded(), animateIndicator);
}
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
MyChildItem child = mItems.get(groupPosition).children.get(childPosition);
holder.textView.setText(child.text);
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
// handles click event manually (to show Snackbar message)
return false;
}
@Override
- public void onClick(View v) {
+ public void onClick(@NonNull View v) {
RecyclerView rv = RecyclerViewAdapterUtils.getParentRecyclerView(v);
RecyclerView.ViewHolder vh = rv.findContainingViewHolder(v);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySectionHeaderAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySectionHeaderAdapter.java
index d513cfd1..693f6a1d 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySectionHeaderAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySectionHeaderAdapter.java
@@ -15,7 +15,6 @@
*/
package com.h6ah4i.android.example.advrecyclerview.demo_composition_all;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -23,6 +22,9 @@
import com.h6ah4i.android.example.advrecyclerview.R;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class MySectionHeaderAdapter extends RecyclerView.Adapter {
static class MyViewHolder extends RecyclerView.ViewHolder {
public TextView textView;
@@ -44,14 +46,15 @@ public int getItemCount() {
return 1;
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_section_header, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.textView.setText(mSectionTitle);
}
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySwipeableAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySwipeableAdapter.java
index 40986a2c..9faa7902 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySwipeableAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_composition_all/MySwipeableAdapter.java
@@ -15,8 +15,6 @@
*/
package com.h6ah4i.android.example.advrecyclerview.demo_composition_all;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,6 +37,10 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
class MySwipeableAdapter
extends RecyclerView.Adapter
implements SwipeableItemAdapter, View.OnClickListener {
@@ -64,6 +66,7 @@ public MyViewHolder(View itemView) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return containerView;
}
@@ -90,8 +93,9 @@ public long getItemId(int position) {
return mItems.get(position).id; // need to return stable (= not change even after position changed) value
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
MyViewHolder vh = new MyViewHolder(v);
vh.containerView.setOnClickListener(this);
@@ -99,7 +103,7 @@ public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
MyItem item = mItems.get(position);
holder.textView.setText(item.text);
}
@@ -110,12 +114,12 @@ public int getItemCount() {
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, int position, @SwipeableItemResults int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, int position, @SwipeableItemResults int result) {
if (result == Swipeable.RESULT_CANCELED) {
return new SwipeResultActionDefault();
} else {
@@ -124,18 +128,18 @@ public SwipeResultAction onSwipeItem(MyViewHolder holder, int position, @Swipeab
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
return Swipeable.REACTION_CAN_SWIPE_BOTH_H;
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, @SwipeableItemDrawableTypes int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, @SwipeableItemDrawableTypes int type) {
int bgColor = ContextCompat.getColor(holder.itemView.getContext(), R.color.bg_swipe_item_gray);
holder.itemView.setBackgroundColor(bgColor);
}
@Override
- public void onClick(View v) {
+ public void onClick(@NonNull View v) {
RecyclerView rv = RecyclerViewAdapterUtils.getParentRecyclerView(v);
RecyclerView.ViewHolder vh = rv.findContainingViewHolder(v);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleActivity.java
index 8adfc10e..43ed9f98 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_basic;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class DraggableExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleFragment.java
index be52bc0e..3648cff8 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -37,6 +32,13 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class DraggableExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -49,22 +51,22 @@ public DraggableExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
+ mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
//adapter
final DraggableExampleItemAdapter myItemAdapter = new DraggableExampleItemAdapter(getDataProvider());
@@ -83,9 +85,9 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleItemAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleItemAdapter.java
index 88ce44ee..82a242ce 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleItemAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_basic/DraggableExampleItemAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_basic;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,19 +28,18 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class DraggableExampleItemAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter {
private static final String TAG = "MyDraggableItemAdapter";
- // NOTE: Make accessible with short name
- private interface Draggable extends DraggableItemConstants {
- }
-
private AbstractDataProvider mProvider;
public static class MyViewHolder extends AbstractDraggableItemViewHolder {
@@ -75,32 +73,33 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate((viewType == 0) ? R.layout.list_item_draggable : R.layout.list_item2_draggable, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set text
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_item_dragging_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -123,7 +122,7 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
// x, y --- relative from the itemView's top-left
final View containerView = holder.mContainer;
final View dragHandleView = holder.mDragHandle;
@@ -135,7 +134,7 @@ public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
// no drag-sortable range specified
return null;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleActivity.java
index 926abe73..8cebbd41 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_check_can_drop;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class DraggableCheckCanDropExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleFragment.java
index 620b5d83..86dd6a20 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -37,6 +32,13 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class DraggableCheckCanDropExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -49,22 +51,22 @@ public DraggableCheckCanDropExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
+ mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
mRecyclerViewDragDropManager.setCheckCanDropEnabled(true); // !!! this method is required to use onCheckCanDrop()
//adapter
@@ -84,9 +86,9 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleItemAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleItemAdapter.java
index 7a5c86e8..8f98d86c 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleItemAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_check_can_drop/DraggableCheckCanDropExampleItemAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_check_can_drop;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,19 +28,18 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class DraggableCheckCanDropExampleItemAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter {
private static final String TAG = "MyDraggableItemAdapter";
- // NOTE: Make accessible with short name
- private interface Draggable extends DraggableItemConstants {
- }
-
private AbstractDataProvider mProvider;
public static class MyViewHolder extends AbstractDraggableItemViewHolder {
@@ -75,32 +73,33 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate((viewType == 0) ? R.layout.list_item_draggable : R.layout.list_item2_draggable, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set text
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_item_dragging_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -123,7 +122,7 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
// x, y --- relative from the itemView's top-left
final View containerView = holder.mContainer;
final View dragHandleView = holder.mDragHandle;
@@ -135,7 +134,7 @@ public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
// no drag-sortable range specified
return null;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleActivity.java
index a8c8dd5d..537f904f 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_grid;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class DraggableGridExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleAdapter.java
index 186820f9..152a1198 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_grid;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -28,21 +27,20 @@
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class DraggableGridExampleAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter {
private static final String TAG = "MyDraggableItemAdapter";
private int mItemMoveMode = RecyclerViewDragDropManager.ITEM_MOVE_MODE_DEFAULT;
- // NOTE: Make accessible with short name
- private interface Draggable extends DraggableItemConstants {
- }
-
private AbstractDataProvider mProvider;
public static class MyViewHolder extends AbstractDraggableItemViewHolder {
@@ -80,32 +78,33 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_grid_item, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set text
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_item_dragging_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -132,12 +131,12 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
return true;
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
// no drag-sortable range specified
return null;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleFragment.java
index 27daa8a6..d3d7db0f 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_grid/DraggableGridExampleFragment.java
@@ -19,13 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v4.view.MenuItemCompat;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -34,6 +27,7 @@
import android.view.ViewGroup;
import android.widget.CompoundButton;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator;
@@ -42,6 +36,13 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class DraggableGridExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -60,22 +61,22 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new GridLayoutManager(getContext(), 3, GridLayoutManager.VERTICAL, false);
+ mLayoutManager = new GridLayoutManager(requireContext(), 3, RecyclerView.VERTICAL, false);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
@@ -104,7 +105,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
@@ -149,14 +150,9 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// setting up the item move mode selection switch
MenuItem menuSwitchItem = menu.findItem(R.id.menu_switch_swap_mode);
- CompoundButton actionView = MenuItemCompat.getActionView(menuSwitchItem).findViewById(R.id.switch_view);
-
- actionView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- updateItemMoveMode(isChecked);
- }
- });
+ CompoundButton actionView = menuSwitchItem.getActionView().findViewById(R.id.switch_view);
+
+ actionView.setOnCheckedChangeListener((buttonView, isChecked) -> updateItemMoveMode(isChecked));
}
private void updateItemMoveMode(boolean swapMode) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_minimal/MinimalDraggableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_minimal/MinimalDraggableExampleActivity.java
index a90e2756..f4610902 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_minimal/MinimalDraggableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_minimal/MinimalDraggableExampleActivity.java
@@ -17,15 +17,12 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_minimal;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
@@ -35,6 +32,11 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
/*
* This example shows very very minimal implementation of draggable feature.
* Please refer to other examples for more advanced usages. Thanks!
@@ -99,14 +101,15 @@ public long getItemId(int position) {
return mItems.get(position).id; // need to return stable (= not change even after reordered) value
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_minimal, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
MyItem item = mItems.get(position);
holder.textView.setText(item.text);
}
@@ -123,12 +126,12 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
return true;
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
return null;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleActivity.java
index 5d49681f..6c9c131b 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_on_longpress;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class DragOnLongPressExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleAdapter.java
index 517cf8ba..679f98bb 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_on_longpress;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,19 +28,18 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class DragOnLongPressExampleAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter {
private static final String TAG = "MyDraggableItemAdapter";
- // NOTE: Make accessible with short name
- private interface Draggable extends DraggableItemConstants {
- }
-
private AbstractDataProvider mProvider;
public static class MyViewHolder extends AbstractDraggableItemViewHolder {
@@ -75,32 +73,33 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate((viewType == 0) ? R.layout.list_item_draggable : R.layout.list_item2_draggable, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set text
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isUpdated()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_item_dragging_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -123,7 +122,7 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
// x, y --- relative from the itemView's top-left
final View containerView = holder.mContainer;
final View dragHandleView = holder.mDragHandle;
@@ -135,7 +134,7 @@ public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
// no drag-sortable range specified
return null;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleFragment.java
index df19c78e..d4b6a127 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_on_longpress/DragOnLongPressExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -37,6 +32,13 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class DragOnLongPressExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -49,22 +51,22 @@ public DragOnLongPressExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
@@ -86,9 +88,9 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleActivity.java
index a5156b0a..06fe4b54 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_staggered_grid;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class DraggableStaggeredGridExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleAdapter.java
index e0db312c..62e91a38 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleAdapter.java
@@ -17,8 +17,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_staggered_grid;
import android.content.Context;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,10 +28,15 @@
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.StaggeredGridLayoutManager;
+
class DraggableStaggeredGridExampleAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter {
@@ -44,10 +47,6 @@ class DraggableStaggeredGridExampleAdapter
private static final boolean USE_DUMMY_HEADER = true;
private static final boolean RANDOMIZE_ITEM_SIZE = true;
- // NOTE: Make accessible with short name
- private interface Draggable extends DraggableItemConstants {
- }
-
private AbstractDataProvider mProvider;
public static class BaseViewHolder extends AbstractDraggableItemViewHolder {
@@ -101,8 +100,9 @@ public int getItemViewType(int position) {
}
}
+ @NonNull
@Override
- public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
switch (viewType) {
case ITEM_VIEW_TYPE_HEADER: {
@@ -124,7 +124,7 @@ public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(BaseViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
if (isHeader(position)) {
onBindHeaderViewHolder((HeaderItemViewHolder) holder, position);
} else {
@@ -154,17 +154,17 @@ private void onBindNormalItemViewHolder(NormalItemViewHolder holder, int positio
}
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_item_dragging_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -192,12 +192,13 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(BaseViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull BaseViewHolder holder, int position, int x, int y) {
return !isHeader(position);
}
+ @Nullable
@Override
- public ItemDraggableRange onGetItemDraggableRange(BaseViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull BaseViewHolder holder, int position) {
int headerCount = getHeaderItemCount();
return new ItemDraggableRange(headerCount, getItemCount() - 1);
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleFragment.java
index 903d4aeb..e224882c 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_staggered_grid/DraggableStaggeredGridExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -36,6 +31,13 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.StaggeredGridLayoutManager;
+
public class DraggableStaggeredGridExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private StaggeredGridLayoutManager mLayoutManager;
@@ -48,12 +50,12 @@ public DraggableStaggeredGridExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
@@ -63,7 +65,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
@@ -87,7 +89,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleActivity.java
index 2a992fbd..5201dc9b 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_with_section;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleSectionDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class DraggableWithSectionExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleAdapter.java
index 833d421a..bbd9cd11 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_d_with_section;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -30,19 +29,18 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class DraggableWithSectionExampleAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter {
private static final String TAG = "MyDragSectionAdapter";
- // NOTE: Make accessible with short name
- private interface Draggable extends DraggableItemConstants {
- }
-
private static final int ITEM_VIEW_TYPE_SECTION_HEADER = ExampleSectionDataProvider.ITEM_VIEW_TYPE_SECTION_HEADER;
private static final int ITEM_VIEW_TYPE_SECTION_ITEM = ExampleSectionDataProvider.ITEM_VIEW_TYPE_SECTION_ITEM;
@@ -79,8 +77,9 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v;
@@ -99,7 +98,7 @@ public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case ITEM_VIEW_TYPE_SECTION_HEADER:
onBindSectionHeaderViewHolder(holder, position);
@@ -124,19 +123,17 @@ private void onBindSectionItemViewHolder(MyViewHolder holder, int position) {
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isUpdated()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if (
- ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) &&
- ((dragState & Draggable.STATE_FLAG_IS_IN_RANGE) != 0)) {
+ } else if (dragState.isDragging() && dragState.isInRange()) {
bgResId = R.drawable.bg_item_dragging_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -159,7 +156,7 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
// x, y --- relative from the itemView's top-left
// return false if the item is a section header
@@ -177,7 +174,7 @@ public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
final int start = findFirstSectionItem(position);
final int end = findLastSectionItem(position);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleFragment.java
index f38391ba..582f3ece 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d_with_section/DraggableWithSectionExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -37,6 +32,13 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class DraggableWithSectionExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -49,22 +51,22 @@ public DraggableWithSectionExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
//adapter
final DraggableWithSectionExampleAdapter myItemAdapter = new DraggableWithSectionExampleAdapter(getDataProvider());
@@ -83,9 +85,9 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleActivity.java
index 5ea8a6c6..7a3c6e6f 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleActivity.java
@@ -17,18 +17,18 @@
package com.h6ah4i.android.example.advrecyclerview.demo_ds;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ItemPinnedMessageDialogFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+
public class DraggableSwipeableExampleActivity extends AppCompatActivity implements ItemPinnedMessageDialogFragment.EventListener {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
@@ -60,12 +60,7 @@ public void onItemRemoved(int position) {
R.string.snack_bar_text_item_removed,
Snackbar.LENGTH_LONG);
- snackbar.setAction(R.string.snack_bar_action_undo, new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemUndoActionClicked();
- }
- });
+ snackbar.setAction(R.string.snack_bar_action_undo, v -> onItemUndoActionClicked());
snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.snackbar_action_color_done));
snackbar.show();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleAdapter.java
index 2c99017f..6d540fa2 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_ds;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,10 +28,11 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemState;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionDefault;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionMoveToSwipedDirection;
@@ -40,6 +40,9 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class DraggableSwipeableExampleAdapter
extends RecyclerView.Adapter
implements DraggableItemAdapter,
@@ -47,8 +50,6 @@ class DraggableSwipeableExampleAdapter
private static final String TAG = "MyDSItemAdapter";
// NOTE: Make accessible with short name
- private interface Draggable extends DraggableItemConstants {
- }
private interface Swipeable extends SwipeableItemConstants {
}
@@ -78,6 +79,7 @@ public MyViewHolder(View v) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return mContainer;
}
@@ -85,18 +87,8 @@ public View getSwipeableContainerView() {
public DraggableSwipeableExampleAdapter(AbstractDataProvider dataProvider) {
mProvider = dataProvider;
- mItemViewOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemViewClick(v);
- }
- };
- mSwipeableViewContainerOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onSwipeableViewContainerClick(v);
- }
- };
+ mItemViewOnClickListener = v -> onItemViewClick(v);
+ mSwipeableViewContainerOnClickListener = v -> onSwipeableViewContainerClick(v);
// DraggableItemAdapter and SwipeableItemAdapter require stable ID, and also
// have to implement the getItemId() method appropriately.
@@ -125,15 +117,16 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate((viewType == 0) ? R.layout.list_item_draggable : R.layout.list_item2_draggable, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set listeners
@@ -146,23 +139,22 @@ public void onBindViewHolder(MyViewHolder holder, int position) {
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
- final int swipeState = holder.getSwipeStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
+ final SwipeableItemState swipeState = holder.getSwipeState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0) ||
- ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated() || swipeState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_item_dragging_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) {
+ } else if (swipeState.isActive()) {
bgResId = R.drawable.bg_item_swiping_active_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) {
+ } else if (swipeState.isSwiping()) {
bgResId = R.drawable.bg_item_swiping_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -189,7 +181,7 @@ public void onMoveItem(int fromPosition, int toPosition) {
}
@Override
- public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull MyViewHolder holder, int position, int x, int y) {
// x, y --- relative from the itemView's top-left
final View containerView = holder.mContainer;
final View dragHandleView = holder.mDragHandle;
@@ -201,7 +193,7 @@ public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int
}
@Override
- public ItemDraggableRange onGetItemDraggableRange(MyViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull MyViewHolder holder, int position) {
// no drag-sortable range specified
return null;
}
@@ -222,7 +214,7 @@ public void onItemDragFinished(int fromPosition, int toPosition, boolean result)
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
if (onCheckCanStartDrag(holder, position, x, y)) {
return Swipeable.REACTION_CAN_NOT_SWIPE_BOTH_H;
} else {
@@ -231,12 +223,12 @@ public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, int type) {
int bgRes = 0;
switch (type) {
case Swipeable.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND:
@@ -254,7 +246,7 @@ public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
}
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, final int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, final int position, int result) {
Log.d(TAG, "onSwipeItem(position = " + position + ", result = " + result + ")");
switch (result) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleFragment.java
index 1ad11468..37e5e29c 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ds/DraggableSwipeableExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,6 +34,13 @@
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class DraggableSwipeableExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -53,17 +55,17 @@ public DraggableSwipeableExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
@@ -73,7 +75,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
@@ -117,9 +119,9 @@ public void onItemViewClicked(View v, boolean pinned) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleActivity.java
index 40c7baca..f0c1056e 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_e_add_remove;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractAddRemoveExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleAddRemoveExpandableDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class AddRemoveExpandableExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleAdapter.java
index d50ebc25..90920a32 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_e_add_remove;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -26,28 +25,22 @@
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractAddRemoveExpandableDataProvider;
-import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemState;
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class AddRemoveExpandableExampleAdapter
extends AbstractExpandableItemAdapter {
private static final String TAG = "MyExpandableItemAdapter";
- // NOTE: Make accessible with short name
- private interface Expandable extends ExpandableItemConstants {
- }
-
private RecyclerViewExpandableItemManager mExpandableItemManager;
private AbstractAddRemoveExpandableDataProvider mProvider;
- private View.OnClickListener mItemOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onClickItemView(v);
- }
- };
+ private View.OnClickListener mItemOnClickListener = v -> onClickItemView(v);
public static abstract class MyBaseViewHolder extends AbstractExpandableItemViewHolder {
public FrameLayout mContainer;
@@ -161,21 +154,23 @@ public int getChildItemViewType(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_group_item_with_add_remove_buttons, parent, false);
return new MyGroupViewHolder(v, mItemOnClickListener);
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item_with_add_remove_buttons, parent, false);
return new MyChildViewHolder(v, mItemOnClickListener);
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
// child item
final AbstractAddRemoveExpandableDataProvider.BaseData item = mProvider.getGroupItem(groupPosition);
@@ -186,12 +181,12 @@ public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, i
holder.itemView.setClickable(true);
// set background resource (target view ID: container)
- final int expandState = holder.getExpandStateFlags();
+ final ExpandableItemState expandState = holder.getExpandState();
- if ((expandState & Expandable.STATE_FLAG_IS_UPDATED) != 0) {
+ if (expandState.isUpdated()) {
int bgResId;
- if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) {
+ if (expandState.isExpanded()) {
bgResId = R.drawable.bg_group_item_expanded_state;
} else {
bgResId = R.drawable.bg_group_item_normal_state;
@@ -202,7 +197,7 @@ public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, i
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
// group item
final AbstractAddRemoveExpandableDataProvider.ChildData item = mProvider.getChildItem(groupPosition, childPosition);
@@ -216,7 +211,7 @@ public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, i
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
// NOTE: Handles all click events manually
return false;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleFragment.java
index 67dca3c2..d2ae00fe 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_add_remove/AddRemoveExpandableExampleFragment.java
@@ -20,11 +20,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -41,6 +36,13 @@
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class AddRemoveExpandableExampleFragment
extends Fragment
implements RecyclerViewExpandableItemManager.OnGroupCollapseListener,
@@ -59,17 +61,17 @@ public AddRemoveExpandableExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
@@ -99,15 +101,15 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// save current state to support screen rotation, etc...
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleActivity.java
index 3d710d9c..8deee89d 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_e_already_expanded;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractAddRemoveExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleAddRemoveExpandableDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class AlreadyExpandedGroupsExpandableExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleAdapter.java
index 7d51f292..408884d1 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_e_already_expanded;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -26,11 +25,13 @@
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractAddRemoveExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.widget.ExpandableItemIndicator;
-import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemState;
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemViewHolder;
+import androidx.annotation.NonNull;
+
class AlreadyExpandedGroupsExpandableExampleAdapter
extends AbstractExpandableItemAdapter {
private static final String TAG = "MyExpandableItemAdapter";
@@ -38,10 +39,6 @@ class AlreadyExpandedGroupsExpandableExampleAdapter
private AbstractAddRemoveExpandableDataProvider mProvider;
private RecyclerViewExpandableItemManager mExpandableItemManager;
- // NOTE: Make accessible with short name
- private interface Expandable extends ExpandableItemConstants {
- }
-
public static abstract class MyBaseViewHolder extends AbstractExpandableItemViewHolder {
public FrameLayout mContainer;
public TextView mTextView;
@@ -111,21 +108,23 @@ public int getChildItemViewType(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_group_item, parent, false);
return new MyGroupViewHolder(v);
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item, parent, false);
return new MyChildViewHolder(v);
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
// child item
final AbstractAddRemoveExpandableDataProvider.BaseData item = mProvider.getGroupItem(groupPosition);
@@ -136,30 +135,25 @@ public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, i
holder.itemView.setClickable(true);
// set background resource (target view ID: container)
- final int expandState = holder.getExpandStateFlags();
+ final ExpandableItemState expandState = holder.getExpandState();
- if ((expandState & Expandable.STATE_FLAG_IS_UPDATED) != 0) {
+ if (expandState.isUpdated()) {
int bgResId;
- boolean isExpanded;
- boolean animateIndicator = ((expandState & Expandable.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED) != 0);
+ boolean animateIndicator = expandState.hasExpandedStateChanged();
- if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) {
+ if (expandState.isExpanded()) {
bgResId = R.drawable.bg_group_item_expanded_state;
- isExpanded = true;
} else {
bgResId = R.drawable.bg_group_item_normal_state;
- isExpanded = false;
}
holder.mContainer.setBackgroundResource(bgResId);
- holder.mIndicator.setExpandedState(isExpanded, animateIndicator);
- } else {
- Log.d("TAG", "teste");
+ holder.mIndicator.setExpandedState(expandState.isExpanded(), animateIndicator);
}
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
// group item
final AbstractAddRemoveExpandableDataProvider.ChildData item = mProvider.getChildItem(groupPosition, childPosition);
@@ -173,7 +167,7 @@ public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, i
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
// check is enabled
return holder.itemView.isEnabled() && holder.itemView.isClickable();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleFragment.java
index 847d0326..f382548b 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_already_expanded/AlreadyExpandedGroupsExpandableExampleFragment.java
@@ -20,11 +20,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -41,6 +36,13 @@
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class AlreadyExpandedGroupsExpandableExampleFragment extends Fragment {
private static final String SAVED_STATE_EXPANDABLE_ITEM_MANAGER = "RecyclerViewExpandableItemManager";
@@ -56,17 +58,17 @@ public AlreadyExpandedGroupsExpandableExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
@@ -99,15 +101,15 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// save current state to support screen rotation, etc...
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleActivity.java
index 8c9ca956..a68b3b31 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_e_basic;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleExpandableDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class ExpandableExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleAdapter.java
index 49885be1..19ed0daf 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleAdapter.java
@@ -25,18 +25,17 @@
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.widget.ExpandableItemIndicator;
-import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemState;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemViewHolder;
+import androidx.annotation.NonNull;
+
class ExpandableExampleAdapter
extends AbstractExpandableItemAdapter {
private static final String TAG = "MyExpandableItemAdapter";
// NOTE: Make accessible with short name
- private interface Expandable extends ExpandableItemConstants {
- }
-
private AbstractExpandableDataProvider mProvider;
public static abstract class MyBaseViewHolder extends AbstractExpandableItemViewHolder {
@@ -104,21 +103,23 @@ public int getChildItemViewType(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_group_item, parent, false);
return new MyGroupViewHolder(v);
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item, parent, false);
return new MyChildViewHolder(v);
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
// child item
final AbstractExpandableDataProvider.BaseData item = mProvider.getGroupItem(groupPosition);
@@ -129,28 +130,25 @@ public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, i
holder.itemView.setClickable(true);
// set background resource (target view ID: container)
- final int expandState = holder.getExpandStateFlags();
+ final ExpandableItemState expandState = holder.getExpandState();
- if ((expandState & ExpandableItemConstants.STATE_FLAG_IS_UPDATED) != 0) {
+ if (expandState.isUpdated()) {
int bgResId;
- boolean isExpanded;
- boolean animateIndicator = ((expandState & Expandable.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED) != 0);
+ boolean animateIndicator = expandState.hasExpandedStateChanged();
- if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) {
+ if (expandState.isExpanded()) {
bgResId = R.drawable.bg_group_item_expanded_state;
- isExpanded = true;
} else {
bgResId = R.drawable.bg_group_item_normal_state;
- isExpanded = false;
}
holder.mContainer.setBackgroundResource(bgResId);
- holder.mIndicator.setExpandedState(isExpanded, animateIndicator);
+ holder.mIndicator.setExpandedState(expandState.isExpanded(), animateIndicator);
}
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
// group item
final AbstractExpandableDataProvider.ChildData item = mProvider.getChildItem(groupPosition, childPosition);
@@ -164,7 +162,7 @@ public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, i
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
// check the item is *not* pinned
if (mProvider.getGroupItem(groupPosition).isPinned()) {
// return false to raise View.OnClickListener#onClick() event
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleFragment.java
index f18c3e9a..ed6e7105 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_basic/ExpandableExampleFragment.java
@@ -20,11 +20,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,6 +33,13 @@
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class ExpandableExampleFragment
extends Fragment
implements RecyclerViewExpandableItemManager.OnGroupCollapseListener,
@@ -54,17 +56,17 @@ public ExpandableExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
@@ -92,15 +94,15 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// save current state to support screen rotation, etc...
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_minimal/MinimalExpandableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_minimal/MinimalExpandableExampleActivity.java
index 63667cb0..3f49875e 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_minimal/MinimalExpandableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e_minimal/MinimalExpandableExampleActivity.java
@@ -17,10 +17,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_e_minimal;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.SimpleItemAnimator;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -34,6 +30,12 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.SimpleItemAnimator;
+
/*
* This example shows very very minimal implementation of expandable feature.
* Please refer to other examples for more advanced usages. Thanks!
@@ -145,31 +147,33 @@ public long getChildId(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_group_item_for_expandable_minimal, parent, false);
return new MyGroupViewHolder(v);
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_child_item_for_expandable_minimal, parent, false);
return new MyChildViewHolder(v);
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
MyGroupItem group = mItems.get(groupPosition);
holder.textView.setText(group.text);
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
MyChildItem child = mItems.get(groupPosition).children.get(childPosition);
holder.textView.setText(child.text);
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
return true;
}
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleActivity.java
index 33f7c942..e930f2a8 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.demo_ed_with_section;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleSectionExpandableDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class ExpandableDraggableWithSectionExampleActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleAdapter.java
index 944c9be0..652b05fa 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleAdapter.java
@@ -27,16 +27,18 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.example.advrecyclerview.common.widget.ExpandableItemIndicator;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableDraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemState;
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.expandable.GroupPositionItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemAdapter;
+import androidx.annotation.NonNull;
+
class ExpandableDraggableWithSectionExampleAdapter
extends AbstractExpandableItemAdapter
implements ExpandableDraggableItemAdapter {
@@ -47,20 +49,13 @@ class ExpandableDraggableWithSectionExampleAdapter
private boolean mAllowItemsMoveAcrossSections;
- // NOTE: Make accessible with short name
- private interface Expandable extends ExpandableItemConstants {
- }
-
- private interface Draggable extends DraggableItemConstants {
- }
-
private AbstractExpandableDataProvider mProvider;
public static abstract class MyBaseViewHolder extends AbstractDraggableItemViewHolder implements ExpandableItemViewHolder {
public FrameLayout mContainer;
public View mDragHandle;
public TextView mTextView;
- private int mExpandStateFlags;
+ private final ExpandableItemState mExpandState = new ExpandableItemState();
public MyBaseViewHolder(View v) {
super(v);
@@ -71,12 +66,18 @@ public MyBaseViewHolder(View v) {
@Override
public int getExpandStateFlags() {
- return mExpandStateFlags;
+ return mExpandState.getFlags();
}
@Override
- public void setExpandStateFlags(int flag) {
- mExpandStateFlags = flag;
+ public void setExpandStateFlags(int flags) {
+ mExpandState.setFlags(flags);
+ }
+
+ @NonNull
+ @Override
+ public ExpandableItemState getExpandState() {
+ return mExpandState;
}
}
@@ -140,7 +141,8 @@ public int getChildItemViewType(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v;
@@ -159,14 +161,15 @@ public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType)
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item_draggable, parent, false);
return new MyChildViewHolder(v);
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
switch (viewType) {
case GROUP_ITEM_VIEW_TYPE_SECTION_HEADER:
onbBindSectionHeaderGroupViewHolder(holder, groupPosition);
@@ -177,7 +180,7 @@ public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, i
}
}
- private void onbBindSectionHeaderGroupViewHolder(MyGroupViewHolder holder, int groupPosition) {
+ private void onbBindSectionHeaderGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition) {
// group item
final AbstractExpandableDataProvider.GroupData item = mProvider.getGroupItem(groupPosition);
@@ -185,7 +188,7 @@ private void onbBindSectionHeaderGroupViewHolder(MyGroupViewHolder holder, int g
holder.mTextView.setText(item.getText());
}
- private void onBindItemGroupViewHolder(MyGroupViewHolder holder, int groupPosition) {
+ private void onBindItemGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition) {
// group item
final AbstractExpandableDataProvider.GroupData item = mProvider.getGroupItem(groupPosition);
@@ -193,56 +196,50 @@ private void onBindItemGroupViewHolder(MyGroupViewHolder holder, int groupPositi
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
- final int expandState = holder.getExpandStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
+ final ExpandableItemState expandState = holder.getExpandState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0) ||
- ((expandState & Expandable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated() || expandState.isUpdated()) {
int bgResId;
- boolean isExpanded;
- boolean animateIndicator = ((expandState & Expandable.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED) != 0);
+ boolean animateIndicator = expandState.hasExpandedStateChanged();
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_group_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if (((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) &&
- ((dragState & Draggable.STATE_FLAG_IS_IN_RANGE) != 0)) {
+ } else if (dragState.isDragging() && dragState.isInRange()) {
bgResId = R.drawable.bg_group_item_dragging_state;
- } else if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) {
+ } else if (expandState.isExpanded()) {
bgResId = R.drawable.bg_group_item_expanded_state;
} else {
bgResId = R.drawable.bg_group_item_normal_state;
}
- isExpanded = (expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0;
-
holder.mContainer.setBackgroundResource(bgResId);
- holder.mIndicator.setExpandedState(isExpanded, animateIndicator);
+ holder.mIndicator.setExpandedState(expandState.isExpanded(), animateIndicator);
}
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
// child item
final AbstractExpandableDataProvider.ChildData item = mProvider.getChildItem(groupPosition, childPosition);
// set text
holder.mTextView.setText(item.getText());
- final int dragState = holder.getDragStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if (((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) &&
- ((dragState & Draggable.STATE_FLAG_IS_IN_RANGE) != 0)) {
+ } else if (dragState.isDragging() && dragState.isInRange()) {
bgResId = R.drawable.bg_item_dragging_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -253,7 +250,7 @@ public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, i
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
// check is normal item
if (!isSectionHeader(holder)) {
return false;
@@ -274,7 +271,7 @@ public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int gro
}
@Override
- public boolean onCheckGroupCanStartDrag(MyGroupViewHolder holder, int groupPosition, int x, int y) {
+ public boolean onCheckGroupCanStartDrag(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y) {
// check is normal item
if (!isSectionHeader(holder)) {
return false;
@@ -291,7 +288,7 @@ public boolean onCheckGroupCanStartDrag(MyGroupViewHolder holder, int groupPosit
}
@Override
- public boolean onCheckChildCanStartDrag(MyChildViewHolder holder, int groupPosition, int childPosition, int x, int y) {
+ public boolean onCheckChildCanStartDrag(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int x, int y) {
// x, y --- relative from the itemView's top-left
final View containerView = holder.mContainer;
final View dragHandleView = holder.mDragHandle;
@@ -303,7 +300,7 @@ public boolean onCheckChildCanStartDrag(MyChildViewHolder holder, int groupPosit
}
@Override
- public ItemDraggableRange onGetGroupItemDraggableRange(MyGroupViewHolder holder, int groupPosition) {
+ public ItemDraggableRange onGetGroupItemDraggableRange(@NonNull MyGroupViewHolder holder, int groupPosition) {
if (mAllowItemsMoveAcrossSections) {
return null;
} else {
@@ -316,7 +313,7 @@ public ItemDraggableRange onGetGroupItemDraggableRange(MyGroupViewHolder holder,
}
@Override
- public ItemDraggableRange onGetChildItemDraggableRange(MyChildViewHolder holder, int groupPosition, int childPosition) {
+ public ItemDraggableRange onGetChildItemDraggableRange(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition) {
if (mAllowItemsMoveAcrossSections) {
return null;
} else {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleFragment.java
index d579206f..7d1f833a 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_ed_with_section/ExpandableDraggableWithSectionExampleFragment.java
@@ -20,11 +20,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,6 +34,13 @@
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class ExpandableDraggableWithSectionExampleFragment extends Fragment
implements RecyclerViewExpandableItemManager.OnGroupCollapseListener,
RecyclerViewExpandableItemManager.OnGroupExpandListener {
@@ -57,17 +59,17 @@ public ExpandableDraggableWithSectionExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
@@ -77,7 +79,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
//adapter
final ExpandableDraggableWithSectionExampleAdapter myItemAdapter = new ExpandableDraggableWithSectionExampleAdapter(getDataProvider());
@@ -106,9 +108,9 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
// NOTE:
@@ -120,7 +122,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// save current state to support screen rotation, etc...
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleActivity.java
index b8f35f06..21d2ec16 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleActivity.java
@@ -17,20 +17,20 @@
package com.h6ah4i.android.example.advrecyclerview.demo_eds;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.RecyclerView;
-import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractExpandableDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleExpandableDataProviderFragment;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExpandableItemPinnedMessageDialogFragment;
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.RecyclerView;
+
public class ExpandableDraggableSwipeableExampleActivity extends AppCompatActivity implements ExpandableItemPinnedMessageDialogFragment.EventListener {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
private static final String FRAGMENT_LIST_VIEW = "list view";
@@ -62,12 +62,7 @@ public void onGroupItemRemoved(int groupPosition) {
R.string.snack_bar_text_group_item_removed,
Snackbar.LENGTH_LONG);
- snackbar.setAction(R.string.snack_bar_action_undo, new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemUndoActionClicked();
- }
- });
+ snackbar.setAction(R.string.snack_bar_action_undo, v -> onItemUndoActionClicked());
snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.snackbar_action_color_done));
snackbar.show();
}
@@ -84,12 +79,7 @@ public void onChildItemRemoved(int groupPosition, int childPosition) {
R.string.snack_bar_text_child_item_removed,
Snackbar.LENGTH_LONG);
- snackbar.setAction(R.string.snack_bar_action_undo, new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemUndoActionClicked();
- }
- });
+ snackbar.setAction(R.string.snack_bar_action_undo, v -> onItemUndoActionClicked());
snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.snackbar_action_color_done));
snackbar.show();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleAdapter.java
index de347f2c..b477311f 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_eds;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -29,14 +28,15 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.DrawableUtils;
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.example.advrecyclerview.common.widget.ExpandableItemIndicator;
-import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableDraggableItemAdapter;
-import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemState;
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableSwipeableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemState;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionDefault;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionMoveToSwipedDirection;
@@ -45,6 +45,9 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractExpandableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class ExpandableDraggableSwipeableExampleAdapter
extends AbstractExpandableItemAdapter
implements ExpandableDraggableItemAdapter,
@@ -52,12 +55,6 @@ class ExpandableDraggableSwipeableExampleAdapter
private static final String TAG = "MyEDSItemAdapter";
// NOTE: Make accessible with short name
- private interface Expandable extends ExpandableItemConstants {
- }
-
- private interface Draggable extends DraggableItemConstants {
- }
-
private interface Swipeable extends SwipeableItemConstants {
}
@@ -83,7 +80,7 @@ public static abstract class MyBaseViewHolder extends AbstractDraggableSwipeable
public FrameLayout mContainer;
public View mDragHandle;
public TextView mTextView;
- private int mExpandStateFlags;
+ private final ExpandableItemState mExpandState = new ExpandableItemState();
public MyBaseViewHolder(View v) {
super(v);
@@ -92,19 +89,26 @@ public MyBaseViewHolder(View v) {
mTextView = v.findViewById(android.R.id.text1);
}
+ @Override
+ @NonNull
+ public View getSwipeableContainerView() {
+ return mContainer;
+ }
+
@Override
public int getExpandStateFlags() {
- return mExpandStateFlags;
+ return mExpandState.getFlags();
}
@Override
- public void setExpandStateFlags(int flag) {
- mExpandStateFlags = flag;
+ public void setExpandStateFlags(int flags) {
+ mExpandState.setFlags(flags);
}
+ @NonNull
@Override
- public View getSwipeableContainerView() {
- return mContainer;
+ public ExpandableItemState getExpandState() {
+ return mExpandState;
}
}
@@ -128,18 +132,8 @@ public ExpandableDraggableSwipeableExampleAdapter(
AbstractExpandableDataProvider dataProvider) {
mExpandableItemManager = expandableItemManager;
mProvider = dataProvider;
- mItemViewOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemViewClick(v);
- }
- };
- mSwipeableViewContainerOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onSwipeableViewContainerClick(v);
- }
- };
+ mItemViewOnClickListener = v -> onItemViewClick(v);
+ mSwipeableViewContainerOnClickListener = v -> onSwipeableViewContainerClick(v);
// ExpandableItemAdapter, ExpandableDraggableItemAdapter and ExpandableSwipeableItemAdapter
// require stable ID, and also have to implement the getGroupItemId()/getChildItemId() methods appropriately.
@@ -189,21 +183,23 @@ public int getChildItemViewType(int groupPosition, int childPosition) {
}
@Override
- public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyGroupViewHolder onCreateGroupViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_group_item_draggable, parent, false);
return new MyGroupViewHolder(v);
}
@Override
- public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
+ @NonNull
+ public MyChildViewHolder onCreateChildViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item_draggable, parent, false);
return new MyChildViewHolder(v);
}
@Override
- public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) {
+ public void onBindGroupViewHolder(@NonNull MyGroupViewHolder holder, int groupPosition, int viewType) {
// group item
final AbstractExpandableDataProvider.GroupData item = mProvider.getGroupItem(groupPosition);
@@ -214,38 +210,33 @@ public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, i
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int dragState = holder.getDragStateFlags();
- final int expandState = holder.getExpandStateFlags();
- final int swipeState = holder.getSwipeStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
+ final ExpandableItemState expandState = holder.getExpandState();
+ final SwipeableItemState swipeState = holder.getSwipeState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0) ||
- ((expandState & Expandable.STATE_FLAG_IS_UPDATED) != 0) ||
- ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated() || expandState.isUpdated() || swipeState.isUpdated()) {
int bgResId;
- boolean isExpanded;
- boolean animateIndicator = ((expandState & Expandable.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED) != 0);
+ boolean animateIndicator = expandState.hasExpandedStateChanged();
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_group_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_group_item_dragging_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) {
+ } else if (swipeState.isActive()) {
bgResId = R.drawable.bg_group_item_swiping_active_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) {
+ } else if (swipeState.isSwiping()) {
bgResId = R.drawable.bg_group_item_swiping_state;
- } else if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) {
+ } else if (expandState.isExpanded()) {
bgResId = R.drawable.bg_group_item_expanded_state;
} else {
bgResId = R.drawable.bg_group_item_normal_state;
}
- isExpanded = (expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0;
-
holder.mContainer.setBackgroundResource(bgResId);
- holder.mIndicator.setExpandedState(isExpanded, animateIndicator);
+ holder.mIndicator.setExpandedState(expandState.isExpanded(), animateIndicator);
}
// set swiping properties
@@ -254,7 +245,7 @@ public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, i
}
@Override
- public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
+ public void onBindChildViewHolder(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) {
// child item
final AbstractExpandableDataProvider.ChildData item = mProvider.getChildItem(groupPosition, childPosition);
@@ -267,23 +258,22 @@ public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, i
// set text
holder.mTextView.setText(item.getText());
- final int dragState = holder.getDragStateFlags();
- final int swipeState = holder.getSwipeStateFlags();
+ final DraggableItemState dragState = holder.getDragState();
+ final SwipeableItemState swipeState = holder.getSwipeState();
- if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0) ||
- ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0)) {
+ if (dragState.isUpdated() || swipeState.isUpdated()) {
int bgResId;
- if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (dragState.isActive()) {
bgResId = R.drawable.bg_item_dragging_active_state;
// need to clear drawable state here to get correct appearance of the dragging item.
DrawableUtils.clearState(holder.mContainer.getForeground());
- } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
+ } else if (dragState.isDragging()) {
bgResId = R.drawable.bg_item_dragging_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) {
+ } else if (swipeState.isActive()) {
bgResId = R.drawable.bg_item_swiping_active_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) {
+ } else if (swipeState.isSwiping()) {
bgResId = R.drawable.bg_item_swiping_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -298,7 +288,7 @@ public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, i
}
@Override
- public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
+ public boolean onCheckCanExpandOrCollapseGroup(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) {
// check the item is *not* pinned
if (mProvider.getGroupItem(groupPosition).isPinned()) {
// return false to raise View.OnClickListener#onClick() event
@@ -320,7 +310,7 @@ public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int gro
}
@Override
- public boolean onCheckGroupCanStartDrag(MyGroupViewHolder holder, int groupPosition, int x, int y) {
+ public boolean onCheckGroupCanStartDrag(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y) {
// x, y --- relative from the itemView's top-left
final View containerView = holder.mContainer;
final View dragHandleView = holder.mDragHandle;
@@ -332,7 +322,7 @@ public boolean onCheckGroupCanStartDrag(MyGroupViewHolder holder, int groupPosit
}
@Override
- public boolean onCheckChildCanStartDrag(MyChildViewHolder holder, int groupPosition, int childPosition, int x, int y) {
+ public boolean onCheckChildCanStartDrag(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int x, int y) {
// x, y --- relative from the itemView's top-left
final View containerView = holder.mContainer;
final View dragHandleView = holder.mDragHandle;
@@ -344,13 +334,13 @@ public boolean onCheckChildCanStartDrag(MyChildViewHolder holder, int groupPosit
}
@Override
- public ItemDraggableRange onGetGroupItemDraggableRange(MyGroupViewHolder holder, int groupPosition) {
+ public ItemDraggableRange onGetGroupItemDraggableRange(@NonNull MyGroupViewHolder holder, int groupPosition) {
// no drag-sortable range specified
return null;
}
@Override
- public ItemDraggableRange onGetChildItemDraggableRange(MyChildViewHolder holder, int groupPosition, int childPosition) {
+ public ItemDraggableRange onGetChildItemDraggableRange(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition) {
// no drag-sortable range specified
return null;
}
@@ -396,7 +386,7 @@ public void onChildDragFinished(int fromGroupPosition, int fromChildPosition, in
}
@Override
- public int onGetGroupItemSwipeReactionType(MyGroupViewHolder holder, int groupPosition, int x, int y) {
+ public int onGetGroupItemSwipeReactionType(@NonNull MyGroupViewHolder holder, int groupPosition, int x, int y) {
if (onCheckGroupCanStartDrag(holder, groupPosition, x, y)) {
return Swipeable.REACTION_CAN_NOT_SWIPE_BOTH_H;
}
@@ -405,7 +395,7 @@ public int onGetGroupItemSwipeReactionType(MyGroupViewHolder holder, int groupPo
}
@Override
- public int onGetChildItemSwipeReactionType(MyChildViewHolder holder, int groupPosition, int childPosition, int x, int y) {
+ public int onGetChildItemSwipeReactionType(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int x, int y) {
if (onCheckChildCanStartDrag(holder, groupPosition, childPosition, x, y)) {
return Swipeable.REACTION_CAN_NOT_SWIPE_BOTH_H;
}
@@ -414,17 +404,17 @@ public int onGetChildItemSwipeReactionType(MyChildViewHolder holder, int groupPo
}
@Override
- public void onSwipeGroupItemStarted(MyGroupViewHolder holder, int groupPosition) {
+ public void onSwipeGroupItemStarted(@NonNull MyGroupViewHolder holder, int groupPosition) {
notifyDataSetChanged();
}
@Override
- public void onSwipeChildItemStarted(MyChildViewHolder holder, int groupPosition, int childPosition) {
+ public void onSwipeChildItemStarted(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition) {
notifyDataSetChanged();
}
@Override
- public void onSetGroupItemSwipeBackground(MyGroupViewHolder holder, int groupPosition, int type) {
+ public void onSetGroupItemSwipeBackground(@NonNull MyGroupViewHolder holder, int groupPosition, int type) {
int bgResId = 0;
switch (type) {
case Swipeable.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND:
@@ -442,7 +432,7 @@ public void onSetGroupItemSwipeBackground(MyGroupViewHolder holder, int groupPos
}
@Override
- public void onSetChildItemSwipeBackground(MyChildViewHolder holder, int groupPosition, int childPosition, int type) {
+ public void onSetChildItemSwipeBackground(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int type) {
int bgResId = 0;
switch (type) {
case Swipeable.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND:
@@ -460,7 +450,7 @@ public void onSetChildItemSwipeBackground(MyChildViewHolder holder, int groupPos
}
@Override
- public SwipeResultAction onSwipeGroupItem(MyGroupViewHolder holder, int groupPosition, int result) {
+ public SwipeResultAction onSwipeGroupItem(@NonNull MyGroupViewHolder holder, int groupPosition, int result) {
Log.d(TAG, "onSwipeGroupItem(groupPosition = " + groupPosition + ", result = " + result + ")");
switch (result) {
@@ -488,7 +478,7 @@ public SwipeResultAction onSwipeGroupItem(MyGroupViewHolder holder, int groupPos
}
@Override
- public SwipeResultAction onSwipeChildItem(MyChildViewHolder holder, int groupPosition, int childPosition, int result) {
+ public SwipeResultAction onSwipeChildItem(@NonNull MyChildViewHolder holder, int groupPosition, int childPosition, int result) {
Log.d(TAG, "onSwipeChildItem(groupPosition = " + groupPosition + ", childPosition = " + childPosition + ", result = " + result + ")");
switch (result) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleFragment.java
index 26033c39..eab04dad 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_eds/ExpandableDraggableSwipeableExampleFragment.java
@@ -20,11 +20,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -41,6 +36,13 @@
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class ExpandableDraggableSwipeableExampleFragment extends Fragment
implements RecyclerViewExpandableItemManager.OnGroupCollapseListener,
RecyclerViewExpandableItemManager.OnGroupExpandListener {
@@ -60,17 +62,17 @@ public ExpandableDraggableSwipeableExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
@@ -85,7 +87,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable(
- (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
+ (NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z3));
// swipe manager
mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
@@ -145,9 +147,9 @@ public void onItemViewClicked(View v, boolean pinned) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
// NOTE:
@@ -161,7 +163,7 @@ public void onItemViewClicked(View v, boolean pinned) {
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
// save current state to support screen rotation, etc...
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/AddRemoveHeaderFooterExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/AddRemoveHeaderFooterExampleActivity.java
index 04e0c38e..750d11c6 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/AddRemoveHeaderFooterExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/AddRemoveHeaderFooterExampleActivity.java
@@ -17,18 +17,19 @@
package com.h6ah4i.android.example.advrecyclerview.demo_hf_add_remove;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoItemAdapter;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
/*
* This example shows very very minimal implementation of header and footer feature.
* Please refer to other examples for more advanced usages. Thanks!
@@ -43,12 +44,9 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_demo_minimal);
- OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {
- @Override
- public void onItemClicked(String message) {
- View container = findViewById(R.id.container);
- Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
- }
+ OnListItemClickMessageListener clickListener = message -> {
+ View container = findViewById(R.id.container);
+ Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
};
RecyclerView recyclerView = findViewById(R.id.recycler_view);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/MyHeaderFooterAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/MyHeaderFooterAdapter.java
index d088a1ef..1b103823 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/MyHeaderFooterAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_add_remove/MyHeaderFooterAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_hf_add_remove;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -31,6 +30,9 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class MyHeaderFooterAdapter
extends AbstractHeaderFooterWrapperAdapter
implements View.OnClickListener {
@@ -119,16 +121,18 @@ public int getFooterItemViewType(int localPosition) {
return mFooterItems.get(localPosition).viewType;
}
+ @NonNull
@Override
- public HeaderViewHolder onCreateHeaderItemViewHolder(ViewGroup parent, int viewType) {
+ public HeaderViewHolder onCreateHeaderItemViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.header_item, parent, false);
HeaderViewHolder vh = new HeaderViewHolder(v);
vh.itemView.setOnClickListener(this);
return vh;
}
+ @NonNull
@Override
- public FooterViewHolder onCreateFooterItemViewHolder(ViewGroup parent, int viewType) {
+ public FooterViewHolder onCreateFooterItemViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.footer_item, parent, false);
FooterViewHolder vh = new FooterViewHolder(v);
vh.itemView.setOnClickListener(this);
@@ -136,14 +140,14 @@ public FooterViewHolder onCreateFooterItemViewHolder(ViewGroup parent, int viewT
}
@Override
- public void onBindHeaderItemViewHolder(HeaderViewHolder holder, int localPosition) {
+ public void onBindHeaderItemViewHolder(@NonNull HeaderViewHolder holder, int localPosition) {
HeaderFooterItem item = mHeaderItems.get(localPosition);
holder.textView.setText(item.text);
holder.itemView.setBackgroundColor(item.bgColor);
}
@Override
- public void onBindFooterItemViewHolder(FooterViewHolder holder, int localPosition) {
+ public void onBindFooterItemViewHolder(@NonNull FooterViewHolder holder, int localPosition) {
HeaderFooterItem item = mFooterItems.get(localPosition);
holder.textView.setText(item.text);
holder.itemView.setBackgroundColor(item.bgColor);
@@ -184,7 +188,7 @@ public void removeFooterItem() {
}
@Override
- public void onClick(View v) {
+ public void onClick(@NonNull View v) {
RecyclerView rv = RecyclerViewAdapterUtils.getParentRecyclerView(v);
RecyclerView.ViewHolder vh = rv.findContainingViewHolder(v);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_e/ExpandableWithHeaderFooterExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_e/ExpandableWithHeaderFooterExampleActivity.java
index c167b6ba..9e48d48e 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_e/ExpandableWithHeaderFooterExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_e/ExpandableWithHeaderFooterExampleActivity.java
@@ -17,19 +17,20 @@
package com.h6ah4i.android.example.advrecyclerview.demo_hf_e;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.SimpleItemAnimator;
import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoExpandableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.SimpleItemAnimator;
+
/*
* This example shows very very minimal implementation of expandable feature with header and footer.
* Please refer to other examples for more advanced usages. Thanks!
@@ -42,12 +43,9 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_demo_minimal);
- OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {
- @Override
- public void onItemClicked(String message) {
- View container = findViewById(R.id.container);
- Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
- }
+ OnListItemClickMessageListener clickListener = message -> {
+ View container = findViewById(R.id.container);
+ Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
};
RecyclerView recyclerView = findViewById(R.id.recycler_view);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_minimal/MinimalHeaderFooterExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_minimal/MinimalHeaderFooterExampleActivity.java
index 4d2c9082..cd2bfe78 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_minimal/MinimalHeaderFooterExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_hf_minimal/MinimalHeaderFooterExampleActivity.java
@@ -17,17 +17,18 @@
package com.h6ah4i.android.example.advrecyclerview.demo_hf_minimal;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoItemAdapter;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
/*
* This example shows very very minimal implementation of header and footer feature.
* Please refer to other examples for more advanced usages. Thanks!
@@ -40,12 +41,9 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_demo_minimal);
- OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {
- @Override
- public void onItemClicked(String message) {
- View container = findViewById(R.id.container);
- Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
- }
+ OnListItemClickMessageListener clickListener = message -> {
+ View container = findViewById(R.id.container);
+ Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
};
RecyclerView recyclerView = findViewById(R.id.recycler_view);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleActivity.java
index e5e46800..8266ae3f 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleActivity.java
@@ -17,18 +17,18 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_basic;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ItemPinnedMessageDialogFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+
public class SwipeableExampleActivity extends AppCompatActivity implements ItemPinnedMessageDialogFragment.EventListener {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
@@ -61,12 +61,7 @@ public void onItemRemoved(int position) {
R.string.snack_bar_text_item_removed,
Snackbar.LENGTH_LONG);
- snackbar.setAction(R.string.snack_bar_action_undo, new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemUndoActionClicked();
- }
- });
+ snackbar.setAction(R.string.snack_bar_action_undo, v -> onItemUndoActionClicked());
snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.snackbar_action_color_done));
snackbar.show();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleAdapter.java
index 05a7d5e3..c475e972 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_basic;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -28,6 +27,7 @@
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemState;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionDefault;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionMoveToSwipedDirection;
@@ -35,6 +35,9 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class SwipeableExampleAdapter
extends RecyclerView.Adapter
implements SwipeableItemAdapter {
@@ -68,6 +71,7 @@ public MyViewHolder(View v) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return mContainer;
}
@@ -75,18 +79,8 @@ public View getSwipeableContainerView() {
public SwipeableExampleAdapter(AbstractDataProvider dataProvider) {
mProvider = dataProvider;
- mItemViewOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemViewClick(v);
- }
- };
- mSwipeableViewContainerOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onSwipeableViewContainerClick(v);
- }
- };
+ mItemViewOnClickListener = v -> onItemViewClick(v);
+ mSwipeableViewContainerOnClickListener = v -> onSwipeableViewContainerClick(v);
// SwipeableItemAdapter requires stable ID, and also
// have to implement the getItemId() method appropriately.
@@ -115,15 +109,16 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set listeners
@@ -136,14 +131,14 @@ public void onBindViewHolder(MyViewHolder holder, int position) {
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int swipeState = holder.getSwipeStateFlags();
+ final SwipeableItemState swipeState = holder.getSwipeState();
- if ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0) {
+ if (swipeState.isUpdated()) {
int bgResId;
- if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (swipeState.isActive()) {
bgResId = R.drawable.bg_item_swiping_active_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) {
+ } else if (swipeState.isSwiping()) {
bgResId = R.drawable.bg_item_swiping_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -163,17 +158,17 @@ public int getItemCount() {
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
return Swipeable.REACTION_CAN_SWIPE_BOTH_H;
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, int type) {
int bgRes = 0;
switch (type) {
case Swipeable.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND:
@@ -191,7 +186,7 @@ public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
}
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, final int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, final int position, int result) {
Log.d(TAG, "onSwipeItem(position = " + position + ", result = " + result + ")");
switch (result) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleFragment.java
index 578b6301..7c752ef1 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_basic/SwipeableExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,6 +33,13 @@
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class SwipeableExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -50,18 +52,19 @@ public SwipeableExampleFragment() {
super();
}
+ @NonNull
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
+ mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
@@ -109,9 +112,9 @@ public void onItemViewClicked(View v, boolean pinned) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleActivity.java
index 30178c2a..43df8bd5 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleActivity.java
@@ -17,15 +17,16 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_button;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.Fragment;
-import android.support.v7.app.AppCompatActivity;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ItemPinnedMessageDialogFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
public class SwipeableWithButtonExampleActivity extends AppCompatActivity implements ItemPinnedMessageDialogFragment.EventListener {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleAdapter.java
index ef279d87..1b54c148 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_button;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -31,12 +30,17 @@
import com.h6ah4i.android.example.advrecyclerview.common.utils.ViewUtils;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemState;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionDefault;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionMoveToSwipedDirection;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
class SwipeableWithButtonExampleAdapter
extends RecyclerView.Adapter
implements SwipeableItemAdapter {
@@ -74,6 +78,7 @@ public MyViewHolder(View v) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return mContainer;
}
@@ -82,18 +87,8 @@ public View getSwipeableContainerView() {
public SwipeableWithButtonExampleAdapter(AbstractDataProvider dataProvider) {
mProvider = dataProvider;
- mSwipeableViewContainerOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onSwipeableViewContainerClick(v);
- }
- };
- mUnderSwipeableViewButtonOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onUnderSwipeableViewButtonClick(v);
- }
- };
+ mSwipeableViewContainerOnClickListener = v -> onSwipeableViewContainerClick(v);
+ mUnderSwipeableViewButtonOnClickListener = v -> onUnderSwipeableViewButtonClick(v);
// SwipeableItemAdapter requires stable ID, and also
// have to implement the getItemId() method appropriately.
@@ -124,15 +119,16 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item_with_leave_behind_button, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set listeners
@@ -144,14 +140,14 @@ public void onBindViewHolder(MyViewHolder holder, int position) {
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int swipeState = holder.getSwipeStateFlags();
+ final SwipeableItemState swipeState = holder.getSwipeState();
- if ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0) {
+ if (swipeState.isUpdated()) {
int bgResId;
- if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (swipeState.isActive()) {
bgResId = R.drawable.bg_item_swiping_active_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) {
+ } else if (swipeState.isSwiping()) {
bgResId = R.drawable.bg_item_swiping_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -181,7 +177,7 @@ public int getItemCount() {
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
if (ViewUtils.hitTest(holder.getSwipeableContainerView(), x, y)) {
return Swipeable.REACTION_CAN_SWIPE_BOTH_H;
} else {
@@ -190,12 +186,12 @@ public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, int type) {
if (type == Swipeable.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND) {
holder.mBehindViews.setVisibility(View.GONE);
} else {
@@ -203,8 +199,9 @@ public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
}
}
+ @Nullable
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, int position, int result) {
Log.d(TAG, "onSwipeItem(position = " + position + ", result = " + result + ")");
switch (result) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleFragment.java
index 0891b060..37981294 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_button/SwipeableWithButtonExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,6 +33,13 @@
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class SwipeableWithButtonExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -51,17 +53,17 @@ public SwipeableWithButtonExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext());
+ mLayoutManager = new LinearLayoutManager(requireContext());
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
@@ -109,9 +111,9 @@ public void onUnderSwipeableViewButtonClicked(View v) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleActivity.java
index 3ab31ed9..e259c9e4 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleActivity.java
@@ -17,18 +17,18 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_longpress;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ItemPinnedMessageDialogFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+
public class SwipeOnLongPressExampleActivity extends AppCompatActivity implements ItemPinnedMessageDialogFragment.EventListener {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
@@ -61,12 +61,7 @@ public void onItemRemoved(int position) {
R.string.snack_bar_text_item_removed,
Snackbar.LENGTH_LONG);
- snackbar.setAction(R.string.snack_bar_action_undo, new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemUndoActionClicked();
- }
- });
+ snackbar.setAction(R.string.snack_bar_action_undo, v -> onItemUndoActionClicked());
snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.snackbar_action_color_done));
snackbar.show();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleAdapter.java
index 6de56ede..fce86dcb 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_longpress;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -28,6 +27,7 @@
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemState;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionDefault;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionMoveToSwipedDirection;
@@ -35,6 +35,9 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class SwipeOnLongPressExampleAdapter
extends RecyclerView.Adapter
implements SwipeableItemAdapter {
@@ -68,6 +71,7 @@ public MyViewHolder(View v) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return mContainer;
}
@@ -75,18 +79,8 @@ public View getSwipeableContainerView() {
public SwipeOnLongPressExampleAdapter(AbstractDataProvider dataProvider) {
mProvider = dataProvider;
- mItemViewOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemViewClick(v);
- }
- };
- mSwipeableViewContainerOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onSwipeableViewContainerClick(v);
- }
- };
+ mItemViewOnClickListener = v -> onItemViewClick(v);
+ mSwipeableViewContainerOnClickListener = v -> onSwipeableViewContainerClick(v);
// SwipeableItemAdapter requires stable ID, and also
// have to implement the getItemId() method appropriately.
@@ -115,15 +109,16 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set listeners
@@ -136,14 +131,14 @@ public void onBindViewHolder(MyViewHolder holder, int position) {
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int swipeState = holder.getSwipeStateFlags();
+ final SwipeableItemState swipeState = holder.getSwipeState();
- if ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0) {
+ if (swipeState.isUpdated()) {
int bgResId;
- if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (swipeState.isActive()) {
bgResId = R.drawable.bg_item_swiping_active_state;
- } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) {
+ } else if (swipeState.isSwiping()) {
bgResId = R.drawable.bg_item_swiping_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -163,19 +158,19 @@ public int getItemCount() {
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
return Swipeable.REACTION_CAN_SWIPE_LEFT | Swipeable.REACTION_MASK_START_SWIPE_LEFT |
Swipeable.REACTION_CAN_SWIPE_RIGHT | Swipeable.REACTION_MASK_START_SWIPE_RIGHT |
Swipeable.REACTION_START_SWIPE_ON_LONG_PRESS;
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, int type) {
int bgRes = 0;
switch (type) {
case Swipeable.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND:
@@ -193,7 +188,7 @@ public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
}
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, final int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, final int position, int result) {
Log.d(TAG, "onSwipeItem(position = " + position + ", result = " + result + ")");
switch (result) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleFragment.java
index 69f72f13..ee061a0f 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_longpress/SwipeOnLongPressExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,6 +33,13 @@
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class SwipeOnLongPressExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -51,17 +53,17 @@ public SwipeOnLongPressExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
+ mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
@@ -109,9 +111,9 @@ public void onItemViewClicked(View v, boolean pinned) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_minimal/MinimalSwipeableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_minimal/MinimalSwipeableExampleActivity.java
index c0dae664..f40129ff 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_minimal/MinimalSwipeableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_minimal/MinimalSwipeableExampleActivity.java
@@ -17,9 +17,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_minimal;
import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -40,6 +37,11 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
/*
* This example shows very very minimal implementation of swiping feature.
* Please refer to other examples for more advanced usages. Thanks!
@@ -84,6 +86,7 @@ public MyViewHolder(View itemView) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return containerView;
}
@@ -109,14 +112,15 @@ public long getItemId(int position) {
return mItems.get(position).id; // need to return stable (= not change even after position changed) value
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_for_swipe_minimal, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
MyItem item = mItems.get(position);
holder.textView.setText(item.text);
}
@@ -127,12 +131,12 @@ public int getItemCount() {
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, int position, @SwipeableItemResults int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, int position, @SwipeableItemResults int result) {
if (result == Swipeable.RESULT_CANCELED) {
return new SwipeResultActionDefault();
} else {
@@ -141,12 +145,12 @@ public SwipeResultAction onSwipeItem(MyViewHolder holder, int position, @Swipeab
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
return Swipeable.REACTION_CAN_SWIPE_BOTH_H;
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, @SwipeableItemDrawableTypes int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, @SwipeableItemDrawableTypes int type) {
}
static class MySwipeResultActionRemoveItem extends SwipeResultActionRemoveItem {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleActivity.java
index d7392ec8..b58358c5 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleActivity.java
@@ -17,18 +17,18 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_vertical;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ItemPinnedMessageDialogFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+
public class VerticalSwipeableExampleActivity extends AppCompatActivity implements ItemPinnedMessageDialogFragment.EventListener {
private static final String FRAGMENT_TAG_DATA_PROVIDER = "data provider";
@@ -61,12 +61,7 @@ public void onItemRemoved(int position) {
R.string.snack_bar_text_item_removed,
Snackbar.LENGTH_LONG);
- snackbar.setAction(R.string.snack_bar_action_undo, new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemUndoActionClicked();
- }
- });
+ snackbar.setAction(R.string.snack_bar_action_undo, v -> onItemUndoActionClicked());
snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.snackbar_action_color_done));
snackbar.show();
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleAdapter.java
index 08542a2d..99dbdcca 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_vertical;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -28,6 +27,7 @@
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemAdapter;
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemState;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionDefault;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionMoveToSwipedDirection;
@@ -35,6 +35,9 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.utils.RecyclerViewAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class VerticalSwipeableExampleAdapter
extends RecyclerView.Adapter
implements SwipeableItemAdapter {
@@ -64,6 +67,7 @@ public MyViewHolder(View v) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return mContainer;
}
@@ -71,18 +75,8 @@ public View getSwipeableContainerView() {
public VerticalSwipeableExampleAdapter(AbstractDataProvider dataProvider) {
mProvider = dataProvider;
- mItemViewOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onItemViewClick(v);
- }
- };
- mSwipeableViewContainerOnClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onSwipeableViewContainerClick(v);
- }
- };
+ mItemViewOnClickListener = v -> onItemViewClick(v);
+ mSwipeableViewContainerOnClickListener = v -> onSwipeableViewContainerClick(v);
// SwipeableItemAdapter requires stable ID, and also
// have to implement the getItemId() method appropriately.
@@ -111,15 +105,16 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item_v, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
// set listeners
@@ -132,14 +127,14 @@ public void onBindViewHolder(MyViewHolder holder, int position) {
holder.mTextView.setText(item.getText());
// set background resource (target view ID: container)
- final int swipeState = holder.getSwipeStateFlags();
+ final SwipeableItemState swipeState = holder.getSwipeState();
- if ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_IS_UPDATED) != 0) {
+ if (swipeState.isUpdated()) {
int bgResId;
- if ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_IS_ACTIVE) != 0) {
+ if (swipeState.isActive()) {
bgResId = R.drawable.bg_item_swiping_active_state;
- } else if ((swipeState & RecyclerViewSwipeManager.STATE_FLAG_SWIPING) != 0) {
+ } else if (swipeState.isSwiping()) {
bgResId = R.drawable.bg_item_swiping_state;
} else {
bgResId = R.drawable.bg_item_normal_state;
@@ -159,17 +154,17 @@ public int getItemCount() {
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
return RecyclerViewSwipeManager.REACTION_CAN_SWIPE_BOTH_V;
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, int type) {
int bgRes = 0;
switch (type) {
case RecyclerViewSwipeManager.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND:
@@ -187,7 +182,7 @@ public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
}
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, final int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, final int position, int result) {
Log.d(TAG, "onSwipeItem(position = " + position + ", result = " + result + ")");
switch (result) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleFragment.java
index e315e03a..98a842ca 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_vertical/VerticalSwipeableExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,6 +33,13 @@
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class VerticalSwipeableExampleFragment extends Fragment {
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
@@ -51,17 +53,17 @@ public VerticalSwipeableExampleFragment() {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
+ mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
@@ -109,9 +111,9 @@ public void onItemViewClicked(View v, boolean pinned) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(null, ContextCompat.getDrawable(getContext(), R.drawable.list_divider_v), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(null, ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_v), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleActivity.java
index 8a469ccc..a05b1c5b 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleActivity.java
@@ -17,15 +17,16 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_viewpager;
import android.os.Bundle;
-import android.support.design.widget.TabLayout;
-import android.support.v4.app.Fragment;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.AppCompatActivity;
+import com.google.android.material.tabs.TabLayout;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.data.AbstractDataProvider;
import com.h6ah4i.android.example.advrecyclerview.common.fragment.ExampleDataProviderFragment;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+import androidx.viewpager.widget.ViewPager;
+
public class ViewPagerSwipeableExampleActivity extends AppCompatActivity {
public static final String FRAGMENT_TAG_DATA_PROVIDER_1 = "data provider 1";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleAdapter.java
index bbeddf3f..a4243b68 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleAdapter.java
@@ -17,8 +17,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_viewpager;
import android.graphics.Color;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -34,6 +32,11 @@
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionRemoveItem;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractSwipeableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
class ViewPagerSwipeableExampleAdapter
extends RecyclerView.Adapter
implements SwipeableItemAdapter {
@@ -57,6 +60,7 @@ public MyViewHolder(View v) {
}
@Override
+ @NonNull
public View getSwipeableContainerView() {
return mContainer;
}
@@ -87,15 +91,16 @@ public int getItemViewType(int position) {
return mProvider.getItem(position).getViewType();
}
+ @NonNull
@Override
- public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View v = inflater.inflate(R.layout.list_item_view_pager, parent, false);
return new MyViewHolder(v);
}
@Override
- public void onBindViewHolder(MyViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = mProvider.getItem(position);
holder.mContainer.setCanSwipeLeft(mCanSwipeLeft);
@@ -105,7 +110,7 @@ public void onBindViewHolder(MyViewHolder holder, int position) {
}
@Override
- public void onViewRecycled(MyViewHolder holder) {
+ public void onViewRecycled(@NonNull MyViewHolder holder) {
super.onViewRecycled(holder);
holder.mContainer.setAlpha(1.0f);
}
@@ -116,7 +121,7 @@ public int getItemCount() {
}
@Override
- public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull MyViewHolder holder, int position, int x, int y) {
// NOTE: Need to specify REACTION_MASK_START_xxx flags to make ViewPager can handle touch event.
if (mCanSwipeLeft) {
return Swipeable.REACTION_CAN_SWIPE_LEFT |
@@ -130,12 +135,12 @@ public int onGetSwipeReactionType(MyViewHolder holder, int position, int x, int
}
@Override
- public void onSwipeItemStarted(MyViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull MyViewHolder holder, int position) {
notifyDataSetChanged();
}
@Override
- public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull MyViewHolder holder, int position, int type) {
if (type == Swipeable.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND) {
holder.itemView.setBackgroundColor(Color.TRANSPARENT);
} else {
@@ -143,8 +148,9 @@ public void onSetSwipeBackground(MyViewHolder holder, int position, int type) {
}
}
+ @Nullable
@Override
- public SwipeResultAction onSwipeItem(MyViewHolder holder, final int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull MyViewHolder holder, final int position, int result) {
Log.d(TAG, "onSwipeItem(position = " + position + ", result = " + result + ")");
if (position == RecyclerView.NO_POSITION) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleFragment.java
index d8e799a7..9c39e456 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExampleFragment.java
@@ -19,11 +19,6 @@
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,6 +33,13 @@
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class ViewPagerSwipeableExampleFragment extends Fragment {
private static final String ARG_DATA_PROVIDER = "data provider";
private static final String ARG_CAN_SWIPE_LEFT = "can swipe left";
@@ -74,17 +76,17 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
- mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
+ mLayoutManager = new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false);
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
@@ -116,9 +118,9 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
- mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
+ mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(requireContext(), R.drawable.material_shadow_z1)));
}
- mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
+ mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.list_divider_h), true));
// NOTE:
// The initialization order is very important! This order determines the priority of touch event handling.
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExamplePagerAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExamplePagerAdapter.java
index 2ec89a9e..3fc2d28a 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExamplePagerAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s_viewpager/ViewPagerSwipeableExamplePagerAdapter.java
@@ -16,9 +16,10 @@
package com.h6ah4i.android.example.advrecyclerview.demo_s_viewpager;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
+
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentPagerAdapter;
public class ViewPagerSwipeableExamplePagerAdapter extends FragmentPagerAdapter {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/CustomFilteringWrapperAdapterExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/CustomFilteringWrapperAdapterExampleActivity.java
index daa3b05f..062cce47 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/CustomFilteringWrapperAdapterExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/CustomFilteringWrapperAdapterExampleActivity.java
@@ -17,22 +17,22 @@
package com.h6ah4i.android.example.advrecyclerview.demo_wa_filtering;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.view.MenuItemCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CompoundButton;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.BuildConfig;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.DebugWrapperAdapter;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class CustomFilteringWrapperAdapterExampleActivity extends AppCompatActivity {
private MyItemFilteringAdapter mFilteringAdapter;
@@ -43,12 +43,9 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_demo_minimal);
- OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {
- @Override
- public void onItemClicked(String message) {
- View container = findViewById(R.id.container);
- Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
- }
+ OnListItemClickMessageListener clickListener = message -> {
+ View container = findViewById(R.id.container);
+ Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
};
RecyclerView recyclerView = findViewById(R.id.recycler_view);
@@ -73,16 +70,11 @@ public boolean onCreateOptionsMenu(Menu menu) {
// setting up the filtering on/off switch
MenuItem menuSwitchItem = menu.findItem(R.id.menu_switch_on_off);
- CompoundButton actionView = MenuItemCompat.getActionView(menuSwitchItem).findViewById(R.id.switch_view);
+ CompoundButton actionView = menuSwitchItem.getActionView().findViewById(R.id.switch_view);
actionView.setChecked(mFilteringAdapter.isFilteringEnabled());
- actionView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mFilteringAdapter.setFilteringEnabled(!mFilteringAdapter.isFilteringEnabled());
- }
- });
+ actionView.setOnCheckedChangeListener((buttonView, isChecked) -> mFilteringAdapter.setFilteringEnabled(!mFilteringAdapter.isFilteringEnabled()));
return true;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/MyItemFilteringAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/MyItemFilteringAdapter.java
index 94d5e992..2411289e 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/MyItemFilteringAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_filtering/MyItemFilteringAdapter.java
@@ -16,8 +16,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_wa_filtering;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPathSegment;
@@ -26,6 +24,9 @@
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class MyItemFilteringAdapter extends SimpleWrapperAdapter {
private boolean mFilteringEnabled = true;
@@ -60,13 +61,14 @@ public long getItemId(int position) {
}
}
+ @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return super.onCreateViewHolder(parent, viewType);
}
@Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
if (isFilteringEnabled()) {
super.onBindViewHolder(holder, position * 2, payloads);
} else {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/CustomInsertionWrapperAdapterExampleActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/CustomInsertionWrapperAdapterExampleActivity.java
index a35d7a94..9cc7d11c 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/CustomInsertionWrapperAdapterExampleActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/CustomInsertionWrapperAdapterExampleActivity.java
@@ -17,22 +17,22 @@
package com.h6ah4i.android.example.advrecyclerview.demo_wa_insertion;
import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.support.v4.view.MenuItemCompat;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CompoundButton;
+import com.google.android.material.snackbar.Snackbar;
import com.h6ah4i.android.example.advrecyclerview.BuildConfig;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener;
import com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoItemAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.DebugWrapperAdapter;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class CustomInsertionWrapperAdapterExampleActivity extends AppCompatActivity {
private MyItemInsertionAdapter mInsertionAdapter;
@@ -43,12 +43,9 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_demo_minimal);
- OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {
- @Override
- public void onItemClicked(String message) {
- View container = findViewById(R.id.container);
- Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
- }
+ OnListItemClickMessageListener clickListener = message -> {
+ View container = findViewById(R.id.container);
+ Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
};
RecyclerView recyclerView = findViewById(R.id.recycler_view);
@@ -74,16 +71,11 @@ public boolean onCreateOptionsMenu(Menu menu) {
// setting up the insertion on/off switch
MenuItem menuSwitchItem = menu.findItem(R.id.menu_switch_on_off);
- CompoundButton actionView = MenuItemCompat.getActionView(menuSwitchItem).findViewById(R.id.switch_view);
+ CompoundButton actionView = menuSwitchItem.getActionView().findViewById(R.id.switch_view);
actionView.setChecked(mInsertionAdapter.isInsertionEnabled());
- actionView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- mInsertionAdapter.setInsertionEnabled(!mInsertionAdapter.isInsertionEnabled());
- }
- });
+ actionView.setOnCheckedChangeListener((buttonView, isChecked) -> mInsertionAdapter.setInsertionEnabled(!mInsertionAdapter.isInsertionEnabled()));
return true;
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/MyItemInsertionAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/MyItemInsertionAdapter.java
index 35c08575..668a6724 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/MyItemInsertionAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_wa_insertion/MyItemInsertionAdapter.java
@@ -17,8 +17,6 @@
package com.h6ah4i.android.example.advrecyclerview.demo_wa_insertion;
import android.graphics.Color;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -34,6 +32,9 @@
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Created by hasegawa on 9/11/16.
*/
@@ -91,8 +92,9 @@ public long getItemId(int position) {
}
}
+ @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (isInsertionEnabled()) {
if (viewType != ODD_POS_ITEM_VIEW_TYPE) {
return super.onCreateViewHolder(parent, viewType);
@@ -108,7 +110,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
}
@Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
if (isInsertionEnabled()) {
if ((position % 2) == 0) {
super.onBindViewHolder(holder, position / 2, payloads);
@@ -123,7 +125,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List
}
@Override
- public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
+ public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
if (isInsertionEnabled()) {
if (!(holder instanceof OddPosItemViewHolder)) {
super.onViewAttachedToWindow(holder);
@@ -134,7 +136,7 @@ public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
}
@Override
- public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
+ public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) {
if (isInsertionEnabled()) {
if (!(holder instanceof OddPosItemViewHolder)) {
super.onViewDetachedFromWindow(holder);
@@ -145,7 +147,7 @@ public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
}
@Override
- public void onViewRecycled(RecyclerView.ViewHolder holder) {
+ public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (isInsertionEnabled()) {
if (!(holder instanceof OddPosItemViewHolder)) {
super.onViewRecycled(holder);
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherButtonsAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherButtonsAdapter.java
index e3fbef02..7726785e 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherButtonsAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherButtonsAdapter.java
@@ -18,9 +18,6 @@
import android.app.Activity;
import android.content.Intent;
-import android.support.annotation.StringRes;
-import android.support.v4.app.Fragment;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -32,6 +29,11 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.StringRes;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.RecyclerView;
+
public class LauncherButtonsAdapter
extends RecyclerView.Adapter
implements View.OnClickListener {
@@ -59,8 +61,9 @@ public void put(Class extends Activity> activityClass, @StringRes int textRes)
mItems.add(new LauncherItem(activityClass, textRes));
}
+ @NonNull
@Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_item_launcher_button, parent, false);
ViewHolder holder = new ViewHolder(v);
holder.mButton.setOnClickListener(this);
@@ -68,7 +71,7 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(ViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
LauncherItem item = mItems.get(position);
holder.mButton.setText(item.mTextRes);
}
@@ -79,7 +82,7 @@ public int getItemCount() {
}
@Override
- public void onClick(View v) {
+ public void onClick(@NonNull View v) {
ViewHolder viewHolder = (ViewHolder) RecyclerViewAdapterUtils.getViewHolder(v);
int position = viewHolder.getAdapterPosition();
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPageFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPageFragment.java
index 7ca88889..bb1ab924 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPageFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPageFragment.java
@@ -17,10 +17,6 @@
package com.h6ah4i.android.example.advrecyclerview.launcher;
import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -53,6 +49,12 @@
import com.h6ah4i.android.example.advrecyclerview.demo_wa_filtering.CustomFilteringWrapperAdapterExampleActivity;
import com.h6ah4i.android.example.advrecyclerview.demo_wa_insertion.CustomInsertionWrapperAdapterExampleActivity;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class LauncherPageFragment extends Fragment {
private static final String ARG_PAGE_NO = "page no";
@@ -79,12 +81,12 @@ public LauncherPageFragment() {
@Nullable
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recycler_list_view, container, false);
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
@@ -93,7 +95,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
LauncherButtonsAdapter adapter = createAdapter(pageNo);
RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
- recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false));
+ recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext(), RecyclerView.VERTICAL, false));
recyclerView.setAdapter(adapter);
}
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPagerAdapter.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPagerAdapter.java
index 5c402f7e..e34e6d28 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPagerAdapter.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/LauncherPagerAdapter.java
@@ -16,9 +16,9 @@
package com.h6ah4i.android.example.advrecyclerview.launcher;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentPagerAdapter;
public class LauncherPagerAdapter extends FragmentPagerAdapter {
public LauncherPagerAdapter(FragmentManager fm) {
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/MainActivity.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/MainActivity.java
index 7ffe9f66..826d5994 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/MainActivity.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/MainActivity.java
@@ -17,13 +17,14 @@
package com.h6ah4i.android.example.advrecyclerview.launcher;
import android.os.Bundle;
-import android.support.design.widget.TabLayout;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.AppCompatActivity;
+import com.google.android.material.tabs.TabLayout;
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.tablayouthelper.TabLayoutHelper;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.viewpager.widget.ViewPager;
+
public class MainActivity extends AppCompatActivity {
private static final String FRAGMENT_TAG_OPTIONS_MENU = "options menu";
diff --git a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/OptionsMenuFragment.java b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/OptionsMenuFragment.java
index b666e287..dd3d6727 100644
--- a/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/OptionsMenuFragment.java
+++ b/example/src/main/java/com/h6ah4i/android/example/advrecyclerview/launcher/OptionsMenuFragment.java
@@ -19,7 +19,6 @@
import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -27,6 +26,8 @@
import com.h6ah4i.android.example.advrecyclerview.R;
import com.h6ah4i.android.example.advrecyclerview.about.AboutActivity;
+import androidx.fragment.app.Fragment;
+
public class OptionsMenuFragment extends Fragment {
@Override
diff --git a/example/src/main/res/drawable/ic_expand_less.xml b/example/src/main/res/drawable-nodpi/ic_expand_less.xml
similarity index 100%
rename from example/src/main/res/drawable/ic_expand_less.xml
rename to example/src/main/res/drawable-nodpi/ic_expand_less.xml
diff --git a/example/src/main/res/drawable-v11/ic_expand_less_to_expand_more.xml b/example/src/main/res/drawable-nodpi/ic_expand_less_to_expand_more.xml
similarity index 100%
rename from example/src/main/res/drawable-v11/ic_expand_less_to_expand_more.xml
rename to example/src/main/res/drawable-nodpi/ic_expand_less_to_expand_more.xml
diff --git a/example/src/main/res/drawable/ic_expand_more.xml b/example/src/main/res/drawable-nodpi/ic_expand_more.xml
similarity index 100%
rename from example/src/main/res/drawable/ic_expand_more.xml
rename to example/src/main/res/drawable-nodpi/ic_expand_more.xml
diff --git a/example/src/main/res/drawable-v11/ic_expand_more_to_expand_less.xml b/example/src/main/res/drawable-nodpi/ic_expand_more_to_expand_less.xml
similarity index 100%
rename from example/src/main/res/drawable-v11/ic_expand_more_to_expand_less.xml
rename to example/src/main/res/drawable-nodpi/ic_expand_more_to_expand_less.xml
diff --git a/example/src/main/res/layout/activity_demo_minimal.xml b/example/src/main/res/layout/activity_demo_minimal.xml
index 74a4b449..f50243dc 100644
--- a/example/src/main/res/layout/activity_demo_minimal.xml
+++ b/example/src/main/res/layout/activity_demo_minimal.xml
@@ -21,7 +21,7 @@
android:layout_height="match_parent"
>
-
-
-
-
-
-
diff --git a/example/src/main/res/layout/fragment_oss_license_info.xml b/example/src/main/res/layout/fragment_oss_license_info.xml
index a6b1c18e..3494711b 100644
--- a/example/src/main/res/layout/fragment_oss_license_info.xml
+++ b/example/src/main/res/layout/fragment_oss_license_info.xml
@@ -19,7 +19,7 @@
android:layout_height="match_parent">
-
-
-
- /dev/null
-
-# assemble fat-aar and copy dependencies
-USE_METHOD_COUNT=1 ./gradlew :methodscount:assembleRelease > /dev/null
-
-BUILD_TOOOLS_VERSION=$(ls $ANDROID_HOME/build-tools/ | sort -n -r | head -n 1)
-BUILD_TOOOLS_DIR="$ANDROID_HOME/build-tools/$BUILD_TOOOLS_VERSION"
-export BUILD_TOOOLS_DIR
-
-function aar-method-counts() {
- local aar_file=$1
- local aar_basename=$(basename $aar_file '.aar')
- local aar_unzip_dest="/tmp/aar-method-counts/$aar_basename"
-
- rm -rf "$aar_unzip_dest"
- mkdir -p "$aar_unzip_dest"
-
- unzip "$aar_file" -d "$aar_unzip_dest" > /dev/null
- jar-method-counts "$aar_unzip_dest/classes.jar"
-}
-
-function aar-deps-method-counts() {
- local aar_file=$1
- local aar_basename=$(basename $aar_file '.aar')
- local aar_unzip_dest="/tmp/aar-deps-method-counts/$aar_basename"
-
- rm -rf "$aar_unzip_dest"
- mkdir -p "$aar_unzip_dest"
-
- unzip "$aar_file" -d "$aar_unzip_dest" > /dev/null
-
- DEPS_JARS=$(find "$aar_unzip_dest/libs" -type f -name '*.jar' | grep -v 'library-unspecified.jar')
- deps_method_counts=0
-
- IFS=$'\n'
- for dep_jar in $(echo "$DEPS_JARS"); do
- count=$(jar-method-counts "$dep_jar")
- deps_method_counts=$(($deps_method_counts + $count))
- # echo "$(basename $dep_jar) $deps_method_counts $count"
- done
- unset IFS
-
- echo "$deps_method_counts"
-}
-
-function jar-method-counts() {
- local jar_file=$1
- local jar_basename=$(basename $jar_file '.jar')
- local jar_dir_dest="/tmp/jar-method-counts/$jar_basename"
-
- rm -rf "$jar_dir_dest"
- mkdir -p "$jar_dir_dest"
-
- "$BUILD_TOOOLS_DIR/dx"\
- --dex --no-optimize \
- --output="$jar_dir_dest/classes.dex" \
- "$jar_file"
-
- dex-method-counts "$jar_dir_dest/classes.dex" | grep 'Overall method count:' | sed -E 's/Overall method count: ([0-9]+)/\1/g'
-}
-
-function file_size() {
- echo $(
- ${DU:-du} --apparent-size --block-size=1 "$1" 2>/dev/null ||
- ${GDU:-gdu} --apparent-size --block-size=1 "$1" 2>/dev/null ||
- ${FIND:-find} "$1" -printf "%s" 2>/dev/null ||
- ${GFIND:-gfind} "$1" -printf "%s" 2>/dev/null ||
- ${STAT:-stat} --printf="%s" "$1" 2>/dev/null ||
- ${STAT:-stat} -f%z "$1" 2>/dev/null ||
- ${WC:-wc} -c <"$1" 2>/dev/null
- ) | awk '{print $1}'
-}
-
-LIBRARY_AAR="./library/build/outputs/aar/library-release.aar"
-DEPS_LIBRARY_AAR="./methodscount/build/outputs/aar/methodscount-release.aar"
-
-#
-# count library's method counts
-#
-lib_method_counts=$(aar-method-counts "$LIBRARY_AAR")
-
-#
-# count dependencies' method counts
-#
-deps_method_counts=$(aar-deps-method-counts "$DEPS_LIBRARY_AAR")
-
-#
-# library version
-#
-lib_version=$(cat library/library-data.properties | grep 'VERSION_NAME' | sed -E 's/VERSION_NAME=(.*)/\1/g')
-
-#
-# library (AAR) file size
-#
-lib_file_size=$(file_size "$LIBRARY_AAR")
-lib_file_size_kb=$(( ($lib_file_size + 999) / 1000 ))
-
-methodscount_site_url="http://www.methodscount.com/?lib=com.h6ah4i.android.widget.advrecyclerview%3Aadvrecyclerview%3A$lib_version"
-methodscount_badge_url="https://img.shields.io/badge/Methods and size-core: $lib_method_counts | deps: $deps_method_counts | $lib_file_size_kb KB-e91e63.svg"
-methodscount_badge_url=$(echo "$methodscount_badge_url" | sed -E 's/ /%20/g' | sed 's/|/%7C/g')
-
-# echo " "
-echo "[![Method Count]($methodscount_badge_url) ]($methodscount_site_url)"
-
diff --git a/gradle.properties b/gradle.properties
index 3f5c2505..ac968af7 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,4 +17,9 @@ 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
-android.enableBuildCache=false
+
+android.useAndroidX=true
+android.enableJetifier=true
+
+# for Roboelectric (TODO no longer necessary with Android Studio 3.3+)
+android.enableUnitTestBinaryResources=true
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f16d2666..9f287626 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
+#Tue Jul 10 12:18:06 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/library/build.gradle b/library/build.gradle
index 74f28916..89af8da0 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -25,13 +25,18 @@ ext {
useDoclava = true
}
-// Common configurations
-apply from: '../common/android-set-common-properties.gradle'
-
android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_7
+ targetCompatibility JavaVersion.VERSION_1_7
+ }
+
defaultConfig {
- minSdkVersion 14
- targetSdkVersion 27
+ minSdkVersion rootProject.ext.minSdkVersion
+ targetSdkVersion rootProject.ext.targetSdkVersion
def dataProps = new Properties()
dataProps.load(project.file(project.mavenPublishDataFile).newDataInputStream())
@@ -39,7 +44,10 @@ android {
//noinspection GroovyAssignabilityCheck
versionCode dataProps.VERSION_CODE.toInteger()
versionName dataProps.VERSION_NAME
+
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
+
buildTypes {
release {
minifyEnabled false
@@ -52,15 +60,33 @@ android {
consumerProguardFiles 'proguard-rules.pro'
}
}
+
+ testOptions {
+ unitTests {
+ includeAndroidResources = true
+ }
+ }
}
dependencies {
- implementation 'com.android.support:appcompat-v7:27.0.0'
- implementation 'com.android.support:recyclerview-v7:27.0.0'
+ implementation "androidx.recyclerview:recyclerview:${rootProject.ext.recyclerViewVersion}"
testImplementation 'junit:junit:4.12'
+ testImplementation 'androidx.test:rules:1.1.0'
+ testImplementation 'androidx.test:runner:1.1.0'
+ testImplementation ('androidx.test.ext:junit:1.0.0') {
+ exclude group: 'org.junit', module: 'junit' // is this a bug???
+ }
testImplementation 'org.hamcrest:hamcrest-library:1.3'
- testImplementation "org.robolectric:robolectric:3.1.2"
+ testImplementation 'org.robolectric:robolectric:4.0.2'
+
+ androidTestImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:rules:1.1.0'
+ androidTestImplementation 'androidx.test:runner:1.1.0'
+ androidTestImplementation ('androidx.test.ext:junit:1.0.0') {
+ exclude group: 'org.junit', module: 'junit' // is this a bug???
+ }
+ androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
}
tasks.withType(JavaCompile) {
diff --git a/library/library-data.properties b/library/library-data.properties
index 2e98e341..fea5822b 100644
--- a/library/library-data.properties
+++ b/library/library-data.properties
@@ -1,7 +1,7 @@
# suppress inspection "UnusedProperty" for whole file
# common
-VERSION_NAME=0.11.0
-VERSION_CODE=29
+VERSION_NAME=1.0.0
+VERSION_CODE=30
# for maven-publish
POM_GROUP_ID=com.h6ah4i.android.widget.advrecyclerview
diff --git a/library/src/androidTest/AndroidManifest.xml b/library/src/androidTest/AndroidManifest.xml
index 80ca8cdd..8a7be335 100644
--- a/library/src/androidTest/AndroidManifest.xml
+++ b/library/src/androidTest/AndroidManifest.xml
@@ -17,6 +17,8 @@
package="com.h6ah4i.android.widget.advrecyclerview">
+
+
diff --git a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/ApplicationTest.java b/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/ApplicationTest.java
deleted file mode 100644
index 213b4ee2..00000000
--- a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/ApplicationTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2015 Haruki Hasegawa
- *
- * 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.
- */
-
-package com.h6ah4i.android.widget.advrecyclerview;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/GeneralItemAnimatorTest.java b/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/GeneralItemAnimatorTest.java
index 2f79cd0f..0d87148c 100644
--- a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/GeneralItemAnimatorTest.java
+++ b/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/GeneralItemAnimatorTest.java
@@ -19,8 +19,6 @@
package com.h6ah4i.android.widget.advrecyclerview;
-import android.support.v7.widget.RecyclerView;
-import android.test.ActivityInstrumentationTestCase2;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -28,6 +26,11 @@
import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -35,7 +38,19 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-public abstract class GeneralItemAnimatorTest extends ActivityInstrumentationTestCase2 {
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.LargeTest;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.rule.ActivityTestRule;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public abstract class GeneralItemAnimatorTest {
GeneralItemAnimator mAnimator;
Adapter mAdapter;
@@ -47,38 +62,36 @@ public abstract class GeneralItemAnimatorTest extends ActivityInstrumentationTes
final Set mMoveFinished = new HashSet<>();
final Set mChangeFinished = new HashSet<>();
- public GeneralItemAnimatorTest() {
- super(TestActivity.class);
- }
+ @Rule
+ public ActivityTestRule mActivityRule = new ActivityTestRule(TestActivity.class);
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() {
mAnimator = onCreateTestTargetItemAnimator();
mAnimator.setDebug(true);
mAdapter = new Adapter(20);
mDummyParent = getActivity().mContainer;
mAnimator.setListener(new BaseItemAnimator.ItemAnimatorListener() {
@Override
- public void onRemoveFinished(RecyclerView.ViewHolder item) {
+ public void onRemoveFinished(@NonNull RecyclerView.ViewHolder item) {
assertTrue(mRemoveFinished.add(item));
onFinished();
}
@Override
- public void onAddFinished(RecyclerView.ViewHolder item) {
+ public void onAddFinished(@NonNull RecyclerView.ViewHolder item) {
assertTrue(mAddFinished.add(item));
onFinished();
}
@Override
- public void onMoveFinished(RecyclerView.ViewHolder item) {
+ public void onMoveFinished(@NonNull RecyclerView.ViewHolder item) {
assertTrue(mMoveFinished.add(item));
onFinished();
}
@Override
- public void onChangeFinished(RecyclerView.ViewHolder item) {
+ public void onChangeFinished(@NonNull RecyclerView.ViewHolder item) {
assertTrue(mChangeFinished.add(item));
onFinished();
}
@@ -93,12 +106,12 @@ private void onFinished() {
protected abstract GeneralItemAnimator onCreateTestTargetItemAnimator();
- void expectItems(int count) {
+ private void expectItems(int count) {
mExpectedItems = new CountDownLatch(count);
}
- void runAndWait(int seconds) throws Throwable {
- runTestOnUiThread(new Runnable() {
+ private void runAndWait(int seconds) throws Throwable {
+ runOnMainSync(new Runnable() {
@Override
public void run() {
mAnimator.runPendingAnimations();
@@ -107,11 +120,12 @@ public void run() {
waitForItems(seconds);
}
- void waitForItems(int seconds) throws InterruptedException {
+ private void waitForItems(int seconds) throws InterruptedException {
mExpectedItems.await(seconds, TimeUnit.SECONDS);
assertEquals("all expected finish events should happen", 0, mExpectedItems.getCount());
}
+ @Test
public void testAnimateAdd() throws Throwable {
ViewHolder vh = createViewHolder(1);
expectItems(1);
@@ -120,6 +134,7 @@ public void testAnimateAdd() throws Throwable {
runAndWait(1);
}
+ @Test
public void testAnimateRemove() throws Throwable {
ViewHolder vh = createViewHolder(1);
expectItems(1);
@@ -128,6 +143,7 @@ public void testAnimateRemove() throws Throwable {
runAndWait(1);
}
+ @Test
public void testAnimateMove() throws Throwable {
ViewHolder vh = createViewHolder(1);
expectItems(1);
@@ -136,6 +152,7 @@ public void testAnimateMove() throws Throwable {
runAndWait(1);
}
+ @Test
public void testAnimateChange() throws Throwable {
ViewHolder vh = createViewHolder(1);
ViewHolder vh2 = createViewHolder(2);
@@ -145,9 +162,9 @@ public void testAnimateChange() throws Throwable {
runAndWait(1);
}
- boolean animateAdd(final RecyclerView.ViewHolder vh) throws Throwable {
+ private boolean animateAdd(final RecyclerView.ViewHolder vh) throws Throwable {
final boolean[] result = new boolean[1];
- runTestOnUiThread(new Runnable() {
+ runOnMainSync(new Runnable() {
@Override
public void run() {
result[0] = mAnimator.animateAdd(vh);
@@ -156,9 +173,9 @@ public void run() {
return result[0];
}
- boolean animateRemove(final RecyclerView.ViewHolder vh) throws Throwable {
+ private boolean animateRemove(final RecyclerView.ViewHolder vh) throws Throwable {
final boolean[] result = new boolean[1];
- runTestOnUiThread(new Runnable() {
+ runOnMainSync(new Runnable() {
@Override
public void run() {
result[0] = mAnimator.animateRemove(vh);
@@ -167,10 +184,10 @@ public void run() {
return result[0];
}
- boolean animateMove(final RecyclerView.ViewHolder vh, final int fromX, final int fromY,
+ private boolean animateMove(final RecyclerView.ViewHolder vh, final int fromX, final int fromY,
final int toX, final int toY) throws Throwable {
final boolean[] result = new boolean[1];
- runTestOnUiThread(new Runnable() {
+ runOnMainSync(new Runnable() {
@Override
public void run() {
result[0] = mAnimator.animateMove(vh, fromX, fromY, toX, toY);
@@ -179,11 +196,11 @@ public void run() {
return result[0];
}
- boolean animateChange(final RecyclerView.ViewHolder oldHolder,
+ private boolean animateChange(final RecyclerView.ViewHolder oldHolder,
final RecyclerView.ViewHolder newHolder,
final int fromX, final int fromY, final int toX, final int toY) throws Throwable {
final boolean[] result = new boolean[1];
- runTestOnUiThread(new Runnable() {
+ runOnMainSync(new Runnable() {
@Override
public void run() {
result[0] = mAnimator.animateChange(oldHolder, newHolder, fromX, fromY, toX, toY);
@@ -194,7 +211,7 @@ public void run() {
private ViewHolder createViewHolder(final int pos) throws Throwable {
final ViewHolder vh = mAdapter.createViewHolder(mDummyParent, 1);
- runTestOnUiThread(new Runnable() {
+ runOnMainSync(new Runnable() {
@Override
public void run() {
mAdapter.bindViewHolder(vh, pos);
@@ -205,6 +222,13 @@ public void run() {
return vh;
}
+ private TestActivity getActivity() {
+ return mActivityRule.getActivity();
+ }
+
+ public final void runOnMainSync(Runnable action) {
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(action);
+ }
private class Adapter extends RecyclerView.Adapter {
@@ -217,13 +241,14 @@ private class Adapter extends RecyclerView.Adapter {
}
}
+ @NonNull
@Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(new TextView(parent.getContext()));
}
@Override
- public void onBindViewHolder(ViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.bind(mItems.get(position));
}
diff --git a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/RefactoredDefaultItemAnimatorTest.java b/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/RefactoredDefaultItemAnimatorTest.java
index 35a4f93d..80c317de 100644
--- a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/RefactoredDefaultItemAnimatorTest.java
+++ b/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/RefactoredDefaultItemAnimatorTest.java
@@ -19,6 +19,13 @@
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator;
+import org.junit.runner.RunWith;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.LargeTest;
+
+@RunWith(AndroidJUnit4.class)
+@LargeTest
public class RefactoredDefaultItemAnimatorTest extends GeneralItemAnimatorTest {
@Override
protected GeneralItemAnimator onCreateTestTargetItemAnimator() {
diff --git a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/SwipeDismissItemAnimatorTest.java b/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/SwipeDismissItemAnimatorTest.java
index 98de6d14..5c6f17c3 100644
--- a/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/SwipeDismissItemAnimatorTest.java
+++ b/library/src/androidTest/java/com/h6ah4i/android/widget/advrecyclerview/SwipeDismissItemAnimatorTest.java
@@ -19,6 +19,13 @@
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator;
+import org.junit.runner.RunWith;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.LargeTest;
+
+@RunWith(AndroidJUnit4.class)
+@LargeTest
public class SwipeDismissItemAnimatorTest extends GeneralItemAnimatorTest {
@Override
protected GeneralItemAnimator onCreateTestTargetItemAnimator() {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPath.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPath.java
index 88ad2d68..3ad031a8 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPath.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPath.java
@@ -15,18 +15,19 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.RecyclerView;
-
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Adapter path. This class represents how nested {@link WrapperAdapter}s route items.
*/
public class AdapterPath {
- private List mSegments = new ArrayList<>();
+ @NonNull
+ private final List mSegments = new ArrayList<>();
/**
* Constructor.
@@ -40,6 +41,7 @@ public AdapterPath() {
* @param wrapResult The result object returned by {@link WrapperAdapter#wrapPosition(AdapterPathSegment, int)}.
* @return {@link AdapterPath} instance itself.
*/
+ @NonNull
public AdapterPath append(@NonNull UnwrapPositionResult wrapResult) {
return append(wrapResult.adapter, wrapResult.tag);
}
@@ -51,6 +53,7 @@ public AdapterPath append(@NonNull UnwrapPositionResult wrapResult) {
* @param tag The tag object
* @return {@link AdapterPath} instance itself.
*/
+ @NonNull
public AdapterPath append(@NonNull RecyclerView.Adapter adapter, @Nullable Object tag) {
return append(new AdapterPathSegment(adapter, tag));
}
@@ -61,6 +64,7 @@ public AdapterPath append(@NonNull RecyclerView.Adapter adapter, @Nullable Objec
* @param segment The path segment
* @return {@link AdapterPath} instance itself.
*/
+ @NonNull
public AdapterPath append(@NonNull AdapterPathSegment segment) {
mSegments.add(segment);
return this;
@@ -71,6 +75,7 @@ public AdapterPath append(@NonNull AdapterPathSegment segment) {
*
* @return {@link AdapterPath} instance itself.
*/
+ @NonNull
public AdapterPath clear() {
mSegments.clear();
return this;
@@ -90,6 +95,7 @@ public boolean isEmpty() {
*
* @return The collection of path segments.
*/
+ @NonNull
public List segments() {
return mSegments;
}
@@ -99,6 +105,7 @@ public List segments() {
*
* @return The first path segment.
*/
+ @Nullable
public AdapterPathSegment firstSegment() {
return (!mSegments.isEmpty()) ? (mSegments.get(0)) : null;
}
@@ -108,6 +115,7 @@ public AdapterPathSegment firstSegment() {
*
* @return THe last path segment.
*/
+ @Nullable
public AdapterPathSegment lastSegment() {
return (!mSegments.isEmpty()) ? (mSegments.get(mSegments.size() - 1)) : null;
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPathSegment.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPathSegment.java
index bf499ce5..e8ccba94 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPathSegment.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/AdapterPathSegment.java
@@ -15,9 +15,9 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
/**
* Adapter path segment
@@ -26,11 +26,13 @@ public class AdapterPathSegment {
/**
* Adapter
*/
+ @NonNull
public final RecyclerView.Adapter adapter;
/**
* Tag object
*/
+ @Nullable
public final Object tag;
/**
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/BridgeAdapterDataObserver.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/BridgeAdapterDataObserver.java
index b8bf28f2..a73cdc24 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/BridgeAdapterDataObserver.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/BridgeAdapterDataObserver.java
@@ -15,12 +15,12 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.RecyclerView;
-
import java.lang.ref.WeakReference;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* This class behaves like a "proxy" which bridges
* {@link RecyclerView.AdapterDataObserver} events to another subscriber object.
@@ -36,9 +36,9 @@ public interface Subscriber {
*
* @param source The source adapter
* @param tag The tag object
- * @see {@link RecyclerView.AdapterDataObserver#onChanged()}
+ * @see RecyclerView.AdapterDataObserver#onChanged()
*/
- void onBridgedAdapterChanged(RecyclerView.Adapter source, Object tag);
+ void onBridgedAdapterChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag);
/**
* Routed {@link RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int)} event.
@@ -47,9 +47,9 @@ public interface Subscriber {
* @param tag The tag object
* @param positionStart Position of the first item that has changed
* @param itemCount Number of items that have changed
- * @see {@link RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int)}
+ * @see RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int)
*/
- void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount);
+ void onBridgedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount);
/**
* Routed {@link RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int, Object)} event.
@@ -59,9 +59,9 @@ public interface Subscriber {
* @param positionStart Position of the first item that has changed
* @param itemCount Number of items that have changed
* @param payload Optional parameter, use null to identify a "full" update
- * @see {@link RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int, Object)}
+ * @see RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int, Object)
*/
- void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount, Object payload);
+ void onBridgedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount, @Nullable Object payload);
/**
* Routed {@link RecyclerView.AdapterDataObserver#onItemRangeInserted(int, int)} event.
@@ -70,9 +70,9 @@ public interface Subscriber {
* @param tag The tag object
* @param positionStart Position of the first item that was inserted
* @param itemCount Number of items inserted
- * @see {@link RecyclerView.AdapterDataObserver#onItemRangeInserted(int, int)}
+ * @see RecyclerView.AdapterDataObserver#onItemRangeInserted(int, int)
*/
- void onBridgedAdapterItemRangeInserted(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount);
+ void onBridgedAdapterItemRangeInserted(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount);
/**
* Routed {@link RecyclerView.AdapterDataObserver#onItemRangeRemoved(int, int)} event.
@@ -81,9 +81,9 @@ public interface Subscriber {
* @param tag The tag object
* @param positionStart Previous position of the first item that was removed
* @param itemCount Number of items removed from the data set
- * @see {@link RecyclerView.AdapterDataObserver#onItemRangeRemoved(int, int)}}
+ * @see RecyclerView.AdapterDataObserver#onItemRangeRemoved(int, int)
*/
- void onBridgedAdapterItemRangeRemoved(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount);
+ void onBridgedAdapterItemRangeRemoved(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount);
/**
* Routed {@link RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int, Object)} event.
@@ -93,9 +93,9 @@ public interface Subscriber {
* @param fromPosition Previous position of the item.
* @param toPosition New position of the item.
* @param itemCount Number of items moved (NOTE: this parameter is not actually used, always 1.)
- * @see {@link RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int, Object)}
+ * @see RecyclerView.AdapterDataObserver#onItemRangeChanged(int, int, Object)
*/
- void onBridgedAdapterRangeMoved(RecyclerView.Adapter source, Object tag, int fromPosition, int toPosition, int itemCount);
+ void onBridgedAdapterRangeMoved(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int fromPosition, int toPosition, int itemCount);
}
private final WeakReference mRefSubscriber;
@@ -120,6 +120,7 @@ public BridgeAdapterDataObserver(@NonNull Subscriber subscriber, @NonNull Recycl
*
* @return The tag object
*/
+ @Nullable
public Object getTag() {
return mTag;
}
@@ -155,7 +156,7 @@ public void onItemRangeChanged(int positionStart, int itemCount) {
* {@inheritDoc}
*/
@Override
- public void onItemRangeChanged(int positionStart, int itemCount, Object payload) {
+ public void onItemRangeChanged(int positionStart, int itemCount, @Nullable Object payload) {
final Subscriber subscriber = mRefSubscriber.get();
final RecyclerView.Adapter source = mRefSourceHolder.get();
if (subscriber != null && source != null) {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposer.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposer.java
index 91bd5ae0..0c03bd6c 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposer.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposer.java
@@ -16,8 +16,8 @@
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.annotation.IntRange;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.IntRange;
+import androidx.recyclerview.widget.RecyclerView;
/**
* Utility class providing "Composed item ID" related definitions and methods.
@@ -80,6 +80,7 @@ public class ItemIdComposer {
/**
* Bit mask of the reserved sign flag part.
*/
+ @SuppressWarnings("NumericOverflow")
public static final long BIT_MASK_RESERVED_SIGN_FLAG = ((1L << BIT_WIDTH_RESERVED_SIGN_FLAG) - 1) << BIT_OFFSET_RESERVED_SIGN_FLAG;
/**
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposer.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposer.java
index 5a9656ef..6470e624 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposer.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposer.java
@@ -17,7 +17,7 @@
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.annotation.IntRange;
+import androidx.annotation.IntRange;
/**
* Utility class providing "Composed item view type" related definitions and methods.
@@ -67,6 +67,7 @@ public class ItemViewTypeComposer {
/**
* Bit mask of the expandable flag part.
*/
+ @SuppressWarnings("NumericOverflow")
public static final int BIT_MASK_EXPANDABLE_FLAG = (1 << (BIT_WIDTH_EXPANDABLE_FLAG - 1)) << BIT_OFFSET_EXPANDABLE_FLAG;
// ---
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/SimpleWrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/SimpleWrapperAdapter.java
index 0b1ca2fe..e9a92d13 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/SimpleWrapperAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/SimpleWrapperAdapter.java
@@ -15,9 +15,6 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.annotation.CallSuper;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.ViewGroup;
@@ -26,6 +23,11 @@
import java.util.Collections;
import java.util.List;
+import androidx.annotation.CallSuper;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* A simple wrapper class. It just bypasses all methods and events to the wrapped adapter.
* Use this class as a default implementation of {@link WrapperAdapter}, so extend it
@@ -66,6 +68,7 @@ public boolean isWrappedAdapterAlive() {
* Returns underlying adapter.
* @return The underlying adapter instance
*/
+ @Nullable
public RecyclerView.Adapter getWrappedAdapter() {
return mWrappedAdapter;
}
@@ -99,7 +102,7 @@ public void release() {
* {@inheritDoc}
*/
@Override
- public void onAttachedToRecyclerView(RecyclerView recyclerView) {
+ public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
if (isWrappedAdapterAlive())
mWrappedAdapter.onAttachedToRecyclerView(recyclerView);
}
@@ -108,7 +111,7 @@ public void onAttachedToRecyclerView(RecyclerView recyclerView) {
* {@inheritDoc}
*/
@Override
- public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
+ public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
if (isWrappedAdapterAlive())
mWrappedAdapter.onDetachedFromRecyclerView(recyclerView);
}
@@ -117,7 +120,7 @@ public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
* {@inheritDoc}
*/
@Override
- public void onViewAttachedToWindow(VH holder) {
+ public void onViewAttachedToWindow(@NonNull VH holder) {
onViewAttachedToWindow(holder, holder.getItemViewType());
}
@@ -125,7 +128,7 @@ public void onViewAttachedToWindow(VH holder) {
* {@inheritDoc}
*/
@Override
- public void onViewAttachedToWindow(VH holder, int viewType) {
+ public void onViewAttachedToWindow(@NonNull VH holder, int viewType) {
if (isWrappedAdapterAlive()) {
WrappedAdapterUtils.invokeOnViewAttachedToWindow(mWrappedAdapter, holder, viewType);
}
@@ -135,7 +138,7 @@ public void onViewAttachedToWindow(VH holder, int viewType) {
* {@inheritDoc}
*/
@Override
- public void onViewDetachedFromWindow(VH holder) {
+ public void onViewDetachedFromWindow(@NonNull VH holder) {
onViewDetachedFromWindow(holder, holder.getItemViewType());
}
@@ -143,7 +146,7 @@ public void onViewDetachedFromWindow(VH holder) {
* {@inheritDoc}
*/
@Override
- public void onViewDetachedFromWindow(VH holder, int viewType) {
+ public void onViewDetachedFromWindow(@NonNull VH holder, int viewType) {
if (isWrappedAdapterAlive()) {
WrappedAdapterUtils.invokeOnViewDetachedFromWindow(mWrappedAdapter, holder, viewType);
}
@@ -153,7 +156,7 @@ public void onViewDetachedFromWindow(VH holder, int viewType) {
* {@inheritDoc}
*/
@Override
- public void onViewRecycled(VH holder) {
+ public void onViewRecycled(@NonNull VH holder) {
onViewRecycled(holder, holder.getItemViewType());
}
@@ -161,7 +164,7 @@ public void onViewRecycled(VH holder) {
* {@inheritDoc}
*/
@Override
- public void onViewRecycled(VH holder, int viewType) {
+ public void onViewRecycled(@NonNull VH holder, int viewType) {
if (isWrappedAdapterAlive()) {
WrappedAdapterUtils.invokeOnViewRecycled(mWrappedAdapter, holder, viewType);
}
@@ -171,7 +174,7 @@ public void onViewRecycled(VH holder, int viewType) {
* {@inheritDoc}
*/
@Override
- public boolean onFailedToRecycleView(VH holder) {
+ public boolean onFailedToRecycleView(@NonNull VH holder) {
return onFailedToRecycleView(holder, holder.getItemViewType());
}
@@ -179,7 +182,7 @@ public boolean onFailedToRecycleView(VH holder) {
* {@inheritDoc}
*/
@Override
- public boolean onFailedToRecycleView(VH holder, int viewType) {
+ public boolean onFailedToRecycleView(@NonNull VH holder, int viewType) {
boolean shouldBeRecycled = false;
if (isWrappedAdapterAlive()) {
@@ -207,8 +210,9 @@ public void setHasStableIds(boolean hasStableIds) {
/**
* {@inheritDoc}
*/
+ @NonNull
@Override
- public VH onCreateViewHolder(ViewGroup parent, int viewType) {
+ public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return mWrappedAdapter.onCreateViewHolder(parent, viewType);
}
@@ -216,7 +220,7 @@ public VH onCreateViewHolder(ViewGroup parent, int viewType) {
* {@inheritDoc}
*/
@Override
- public void onBindViewHolder(VH holder, int position) {
+ public void onBindViewHolder(@NonNull VH holder, int position) {
onBindViewHolder(holder, position, FULL_UPDATE_PAYLOADS);
}
@@ -224,7 +228,7 @@ public void onBindViewHolder(VH holder, int position) {
* {@inheritDoc}
*/
@Override
- public void onBindViewHolder(VH holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull VH holder, int position, @NonNull List payloads) {
if (isWrappedAdapterAlive())
mWrappedAdapter.onBindViewHolder(holder, position, payloads);
}
@@ -308,7 +312,7 @@ protected void onHandleWrappedAdapterRangeMoved(int fromPosition, int toPosition
}
@Override
- public final void onBridgedAdapterChanged(RecyclerView.Adapter source, Object tag) {
+ public final void onBridgedAdapterChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag) {
if (LOCAL_LOGD) {
Log.d(TAG, "onBridgedAdapterChanged");
}
@@ -317,7 +321,7 @@ public final void onBridgedAdapterChanged(RecyclerView.Adapter source, Object ta
}
@Override
- public final void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount) {
+ public final void onBridgedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount) {
if (LOCAL_LOGD) {
Log.d(TAG, "onBridgedAdapterItemRangeChanged(positionStart = " + positionStart + ", itemCount = " + itemCount + ")");
}
@@ -326,7 +330,7 @@ public final void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source,
}
@Override
- public final void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter sourceAdapter, Object tag, int positionStart, int itemCount, Object payload) {
+ public final void onBridgedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter sourceAdapter, @Nullable Object tag, int positionStart, int itemCount, Object payload) {
if (LOCAL_LOGD) {
Log.d(TAG, "onBridgedAdapterItemRangeChanged(positionStart = " + positionStart + ", itemCount = " + itemCount + ", payload = " + payload + ")");
}
@@ -335,7 +339,7 @@ public final void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter sourceAd
}
@Override
- public final void onBridgedAdapterItemRangeInserted(RecyclerView.Adapter sourceAdapter, Object tag, int positionStart, int itemCount) {
+ public final void onBridgedAdapterItemRangeInserted(@NonNull RecyclerView.Adapter sourceAdapter, @Nullable Object tag, int positionStart, int itemCount) {
if (LOCAL_LOGD) {
Log.d(TAG, "onBridgedAdapterItemRangeInserted(positionStart = " + positionStart + ", itemCount = " + itemCount + ")");
}
@@ -344,7 +348,7 @@ public final void onBridgedAdapterItemRangeInserted(RecyclerView.Adapter sourceA
}
@Override
- public final void onBridgedAdapterItemRangeRemoved(RecyclerView.Adapter sourceAdapter, Object tag, int positionStart, int itemCount) {
+ public final void onBridgedAdapterItemRangeRemoved(@NonNull RecyclerView.Adapter sourceAdapter, @Nullable Object tag, int positionStart, int itemCount) {
if (LOCAL_LOGD) {
Log.d(TAG, "onBridgedAdapterItemRangeRemoved(positionStart = " + positionStart + ", itemCount = " + itemCount + ")");
}
@@ -353,7 +357,7 @@ public final void onBridgedAdapterItemRangeRemoved(RecyclerView.Adapter sourceAd
}
@Override
- public final void onBridgedAdapterRangeMoved(RecyclerView.Adapter sourceAdapter, Object tag, int fromPosition, int toPosition, int itemCount) {
+ public final void onBridgedAdapterRangeMoved(@NonNull RecyclerView.Adapter sourceAdapter, @Nullable Object tag, int fromPosition, int toPosition, int itemCount) {
if (LOCAL_LOGD) {
Log.d(TAG, "onBridgedAdapterRangeMoved(fromPosition = " + fromPosition + ", toPosition = " + toPosition + ", itemCount = " + itemCount + ")");
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/UnwrapPositionResult.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/UnwrapPositionResult.java
index bd66c417..a1215193 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/UnwrapPositionResult.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/UnwrapPositionResult.java
@@ -16,7 +16,8 @@
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
/**
* The result object of {@link WrapperAdapter#unwrapPosition(UnwrapPositionResult, int)}.
@@ -26,6 +27,7 @@ public class UnwrapPositionResult {
/**
* Adapter
*/
+ @Nullable
public RecyclerView.Adapter adapter;
/**
@@ -34,6 +36,7 @@ public class UnwrapPositionResult {
* The tag object can be used to identify the path.
* (e.g.: wrapper adapter can use a same child adapter multiple times)
*/
+ @Nullable
public Object tag;
/**
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrappedAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrappedAdapter.java
index a3495a8f..f01b01ba 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrappedAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrappedAdapter.java
@@ -15,7 +15,8 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
/**
* An interface provides better methods for wrapped adapters.
@@ -26,27 +27,27 @@ public interface WrappedAdapter {
*
* @param holder Holder of the view being attached
* @param viewType Unwrapped view type. Use this instead of #{{@link RecyclerView.ViewHolder#getItemViewType()}}.
- * @see {@link android.support.v7.widget.RecyclerView.Adapter#onViewAttachedToWindow(RecyclerView.ViewHolder)}
+ * @see androidx.recyclerview.widget.RecyclerView.Adapter#onViewAttachedToWindow(RecyclerView.ViewHolder)
*/
- void onViewAttachedToWindow(VH holder, int viewType);
+ void onViewAttachedToWindow(@NonNull VH holder, int viewType);
/**
* onViewDetachedFromWindow() with unwrapped item view type parameter.
*
* @param holder Holder of the view being detached
* @param viewType Unwrapped view type. Use this instead of #{{@link RecyclerView.ViewHolder#getItemViewType()}}.
- * @see {@link android.support.v7.widget.RecyclerView.Adapter#onViewDetachedFromWindow(RecyclerView.ViewHolder)}
+ * @see androidx.recyclerview.widget.RecyclerView.Adapter#onViewDetachedFromWindow(RecyclerView.ViewHolder)
*/
- void onViewDetachedFromWindow(VH holder, int viewType);
+ void onViewDetachedFromWindow(@NonNull VH holder, int viewType);
/**
* onViewRecycled() with unwrapped item view type parameter.
*
* @param holder The ViewHolder for the view being recycled
* @param viewType Unwrapped view type. Use this instead of #{{@link RecyclerView.ViewHolder#getItemViewType()}}.
- * @see {@link android.support.v7.widget.RecyclerView.Adapter#onViewRecycled(RecyclerView.ViewHolder)}
+ * @see androidx.recyclerview.widget.RecyclerView.Adapter#onViewRecycled(RecyclerView.ViewHolder)
*/
- void onViewRecycled(VH holder, int viewType);
+ void onViewRecycled(@NonNull VH holder, int viewType);
/**
@@ -60,7 +61,7 @@ public interface WrappedAdapter {
* the View and recycle it regardless. If this method returns false
,
* RecyclerView will check the View's transient state again before giving a final decision.
* Default implementation returns false.
- * @see {@link android.support.v7.widget.RecyclerView.Adapter#onFailedToRecycleView(RecyclerView.ViewHolder)}
+ * @see androidx.recyclerview.widget.RecyclerView.Adapter#onFailedToRecycleView(RecyclerView.ViewHolder)
*/
- boolean onFailedToRecycleView(VH holder, int viewType);
+ boolean onFailedToRecycleView(@NonNull VH holder, int viewType);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrapperAdapter.java
index c1d51397..be0f333f 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrapperAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/adapter/WrapperAdapter.java
@@ -15,11 +15,11 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
-
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* An RecyclerView adapter which wraps another adapter(s).
*/
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/BaseItemAnimator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/BaseItemAnimator.java
index b191143c..5189b9f8 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/BaseItemAnimator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/BaseItemAnimator.java
@@ -16,8 +16,10 @@
package com.h6ah4i.android.widget.advrecyclerview.animator;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.SimpleItemAnimator;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.SimpleItemAnimator;
public abstract class BaseItemAnimator extends SimpleItemAnimator {
private ItemAnimatorListener mListener;
@@ -28,13 +30,13 @@ public abstract class BaseItemAnimator extends SimpleItemAnimator {
* create directly.
*/
public interface ItemAnimatorListener {
- void onRemoveFinished(RecyclerView.ViewHolder item);
+ void onRemoveFinished(@NonNull RecyclerView.ViewHolder item);
- void onAddFinished(RecyclerView.ViewHolder item);
+ void onAddFinished(@NonNull RecyclerView.ViewHolder item);
- void onMoveFinished(RecyclerView.ViewHolder item);
+ void onMoveFinished(@NonNull RecyclerView.ViewHolder item);
- void onChangeFinished(RecyclerView.ViewHolder item);
+ void onChangeFinished(@NonNull RecyclerView.ViewHolder item);
}
/**
@@ -45,7 +47,7 @@ public interface ItemAnimatorListener {
*
* @param listener The listener that must be called.
*/
- public void setListener(ItemAnimatorListener listener) {
+ public void setListener(@Nullable ItemAnimatorListener listener) {
mListener = listener;
}
@@ -106,35 +108,35 @@ public final void onRemoveFinished(RecyclerView.ViewHolder item) {
}
@SuppressWarnings("EmptyMethod")
- protected void onAddStartingImpl(RecyclerView.ViewHolder item) {
+ protected void onAddStartingImpl(@NonNull RecyclerView.ViewHolder item) {
}
@SuppressWarnings("EmptyMethod")
- protected void onAddFinishedImpl(RecyclerView.ViewHolder item) {
+ protected void onAddFinishedImpl(@NonNull RecyclerView.ViewHolder item) {
}
@SuppressWarnings("EmptyMethod")
- protected void onChangeStartingItem(RecyclerView.ViewHolder item, boolean oldItem) {
+ protected void onChangeStartingItem(@NonNull RecyclerView.ViewHolder item, boolean oldItem) {
}
@SuppressWarnings("EmptyMethod")
- protected void onChangeFinishedImpl(RecyclerView.ViewHolder item, boolean oldItem) {
+ protected void onChangeFinishedImpl(@NonNull RecyclerView.ViewHolder item, boolean oldItem) {
}
@SuppressWarnings("EmptyMethod")
- protected void onMoveStartingImpl(RecyclerView.ViewHolder item) {
+ protected void onMoveStartingImpl(@NonNull RecyclerView.ViewHolder item) {
}
@SuppressWarnings("EmptyMethod")
- protected void onMoveFinishedImpl(RecyclerView.ViewHolder item) {
+ protected void onMoveFinishedImpl(@NonNull RecyclerView.ViewHolder item) {
}
@SuppressWarnings("EmptyMethod")
- protected void onRemoveStartingImpl(RecyclerView.ViewHolder item) {
+ protected void onRemoveStartingImpl(@NonNull RecyclerView.ViewHolder item) {
}
@SuppressWarnings("EmptyMethod")
- protected void onRemoveFinishedImpl(RecyclerView.ViewHolder item) {
+ protected void onRemoveFinishedImpl(@NonNull RecyclerView.ViewHolder item) {
}
public boolean dispatchFinishedWhenDone() {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/DraggableItemAnimator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/DraggableItemAnimator.java
index c8577d77..052d71f5 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/DraggableItemAnimator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/DraggableItemAnimator.java
@@ -15,7 +15,7 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.animator;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
/**
* ItemAnimator for Draggable item. This animator is required to work animations properly on drop an item.
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/GeneralItemAnimator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/GeneralItemAnimator.java
index 3c594b1f..4cffa7b5 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/GeneralItemAnimator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/GeneralItemAnimator.java
@@ -16,8 +16,6 @@
package com.h6ah4i.android.widget.advrecyclerview.animator;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.h6ah4i.android.widget.advrecyclerview.animator.impl.ItemAddAnimationManager;
@@ -25,6 +23,10 @@
import com.h6ah4i.android.widget.advrecyclerview.animator.impl.ItemMoveAnimationManager;
import com.h6ah4i.android.widget.advrecyclerview.animator.impl.ItemRemoveAnimationManager;
+import androidx.annotation.NonNull;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class GeneralItemAnimator extends BaseItemAnimator {
private static final String TAG = "ARVGeneralItemAnimator";
@@ -116,7 +118,7 @@ protected void cancelAnimations(RecyclerView.ViewHolder item) {
}
@Override
- public void endAnimation(RecyclerView.ViewHolder item) {
+ public void endAnimation(@NonNull RecyclerView.ViewHolder item) {
// this will trigger end callback which should set properties to their target values.
cancelAnimations(item);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/RefactoredDefaultItemAnimator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/RefactoredDefaultItemAnimator.java
index 5d8cd39c..542df1ff 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/RefactoredDefaultItemAnimator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/RefactoredDefaultItemAnimator.java
@@ -16,10 +16,6 @@
package com.h6ah4i.android.widget.advrecyclerview.animator;
-import android.support.annotation.NonNull;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.h6ah4i.android.widget.advrecyclerview.animator.impl.AddAnimationInfo;
@@ -33,6 +29,12 @@
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.ViewPropertyAnimatorCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
public class RefactoredDefaultItemAnimator extends GeneralItemAnimator {
@Override
@@ -74,12 +76,12 @@ public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHo
*/
protected static class DefaultItemAddAnimationManager extends ItemAddAnimationManager {
- public DefaultItemAddAnimationManager(BaseItemAnimator itemAnimator) {
+ public DefaultItemAddAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
super(itemAnimator);
}
@Override
- protected void onCreateAnimation(AddAnimationInfo info) {
+ protected void onCreateAnimation(@NonNull AddAnimationInfo info) {
final ViewPropertyAnimatorCompat animator = ViewCompat.animate(info.holder.itemView);
animator.alpha(1);
@@ -89,21 +91,21 @@ protected void onCreateAnimation(AddAnimationInfo info) {
}
@Override
- protected void onAnimationEndedSuccessfully(AddAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedSuccessfully(@NonNull AddAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
}
@Override
- protected void onAnimationEndedBeforeStarted(AddAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedBeforeStarted(@NonNull AddAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
item.itemView.setAlpha(1);
}
@Override
- protected void onAnimationCancel(AddAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationCancel(@NonNull AddAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
item.itemView.setAlpha(1);
}
@Override
- public boolean addPendingAnimation(RecyclerView.ViewHolder item) {
+ public boolean addPendingAnimation(@NonNull RecyclerView.ViewHolder item) {
resetAnimation(item);
item.itemView.setAlpha(0);
@@ -119,12 +121,12 @@ public boolean addPendingAnimation(RecyclerView.ViewHolder item) {
*/
protected static class DefaultItemRemoveAnimationManager extends ItemRemoveAnimationManager {
- public DefaultItemRemoveAnimationManager(BaseItemAnimator itemAnimator) {
+ public DefaultItemRemoveAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
super(itemAnimator);
}
@Override
- protected void onCreateAnimation(RemoveAnimationInfo info) {
+ protected void onCreateAnimation(@NonNull RemoveAnimationInfo info) {
final ViewPropertyAnimatorCompat animator = ViewCompat.animate(info.holder.itemView);
animator.setDuration(getDuration());
@@ -134,23 +136,23 @@ protected void onCreateAnimation(RemoveAnimationInfo info) {
}
@Override
- protected void onAnimationEndedSuccessfully(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedSuccessfully(@NonNull RemoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
final View view = item.itemView;
view.setAlpha(1);
}
@Override
- protected void onAnimationEndedBeforeStarted(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedBeforeStarted(@NonNull RemoveAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
final View view = item.itemView;
view.setAlpha(1);
}
@Override
- protected void onAnimationCancel(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationCancel(@NonNull RemoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
}
@Override
- public boolean addPendingAnimation(RecyclerView.ViewHolder holder) {
+ public boolean addPendingAnimation(@NonNull RecyclerView.ViewHolder holder) {
resetAnimation(holder);
enqueuePendingAnimationInfo(new RemoveAnimationInfo(holder));
@@ -162,12 +164,12 @@ public boolean addPendingAnimation(RecyclerView.ViewHolder holder) {
* Item Animation manager for CHANGE operation (Same behavior as DefaultItemAnimator class)
*/
protected static class DefaultItemChangeAnimationManager extends ItemChangeAnimationManager {
- public DefaultItemChangeAnimationManager(BaseItemAnimator itemAnimator) {
+ public DefaultItemChangeAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
super(itemAnimator);
}
@Override
- protected void onCreateChangeAnimationForOldItem(ChangeAnimationInfo info) {
+ protected void onCreateChangeAnimationForOldItem(@NonNull ChangeAnimationInfo info) {
final ViewPropertyAnimatorCompat animator = ViewCompat.animate(info.oldHolder.itemView);
animator.setDuration(getDuration());
@@ -180,7 +182,7 @@ protected void onCreateChangeAnimationForOldItem(ChangeAnimationInfo info) {
@Override
- protected void onCreateChangeAnimationForNewItem(ChangeAnimationInfo info) {
+ protected void onCreateChangeAnimationForNewItem(@NonNull ChangeAnimationInfo info) {
final ViewPropertyAnimatorCompat animator = ViewCompat.animate(info.newHolder.itemView);
animator.translationX(0);
@@ -192,7 +194,7 @@ protected void onCreateChangeAnimationForNewItem(ChangeAnimationInfo info) {
}
@Override
- protected void onAnimationEndedSuccessfully(ChangeAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedSuccessfully(@NonNull ChangeAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
final View view = item.itemView;
view.setAlpha(1);
view.setTranslationX(0);
@@ -200,7 +202,7 @@ protected void onAnimationEndedSuccessfully(ChangeAnimationInfo info, RecyclerVi
}
@Override
- protected void onAnimationEndedBeforeStarted(ChangeAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedBeforeStarted(@NonNull ChangeAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
final View view = item.itemView;
view.setAlpha(1);
view.setTranslationX(0);
@@ -208,11 +210,11 @@ protected void onAnimationEndedBeforeStarted(ChangeAnimationInfo info, RecyclerV
}
@Override
- protected void onAnimationCancel(ChangeAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationCancel(@NonNull ChangeAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
}
@Override
- public boolean addPendingAnimation(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
+ public boolean addPendingAnimation(@NonNull RecyclerView.ViewHolder oldHolder, @Nullable RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
final float prevTranslationX = oldHolder.itemView.getTranslationX();
final float prevTranslationY = oldHolder.itemView.getTranslationY();
final float prevAlpha = oldHolder.itemView.getAlpha();
@@ -246,12 +248,12 @@ public boolean addPendingAnimation(RecyclerView.ViewHolder oldHolder, RecyclerVi
*/
protected static class DefaultItemMoveAnimationManager extends ItemMoveAnimationManager {
- public DefaultItemMoveAnimationManager(BaseItemAnimator itemAnimator) {
+ public DefaultItemMoveAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
super(itemAnimator);
}
@Override
- protected void onCreateAnimation(MoveAnimationInfo info) {
+ protected void onCreateAnimation(@NonNull MoveAnimationInfo info) {
final View view = info.holder.itemView;
final int deltaX = info.toX - info.fromX;
final int deltaY = info.toY - info.fromY;
@@ -271,18 +273,18 @@ protected void onCreateAnimation(MoveAnimationInfo info) {
}
@Override
- protected void onAnimationEndedSuccessfully(MoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedSuccessfully(@NonNull MoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
}
@Override
- protected void onAnimationEndedBeforeStarted(MoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedBeforeStarted(@NonNull MoveAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
final View view = item.itemView;
view.setTranslationY(0);
view.setTranslationX(0);
}
@Override
- protected void onAnimationCancel(MoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationCancel(@NonNull MoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
final View view = item.itemView;
final int deltaX = info.toX - info.fromX;
final int deltaY = info.toY - info.fromY;
@@ -303,7 +305,7 @@ protected void onAnimationCancel(MoveAnimationInfo info, RecyclerView.ViewHolder
}
@Override
- public boolean addPendingAnimation(RecyclerView.ViewHolder item, int fromX, int fromY, int toX, int toY) {
+ public boolean addPendingAnimation(@NonNull RecyclerView.ViewHolder item, int fromX, int fromY, int toX, int toY) {
final View view = item.itemView;
fromX += item.itemView.getTranslationX();
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/SwipeDismissItemAnimator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/SwipeDismissItemAnimator.java
index 915d3299..5e21dc21 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/SwipeDismissItemAnimator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/SwipeDismissItemAnimator.java
@@ -16,9 +16,6 @@
package com.h6ah4i.android.widget.advrecyclerview.animator;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
@@ -28,6 +25,12 @@
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemViewHolder;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.ViewPropertyAnimatorCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
public class SwipeDismissItemAnimator extends DraggableItemAnimator {
public static final Interpolator MOVE_INTERPOLATOR = new AccelerateDecelerateInterpolator();
@@ -49,12 +52,12 @@ protected void onSetup() {
protected static class SwipeDismissItemRemoveAnimationManager extends ItemRemoveAnimationManager {
protected static final Interpolator DEFAULT_INTERPOLATOR = new AccelerateDecelerateInterpolator();
- public SwipeDismissItemRemoveAnimationManager(BaseItemAnimator itemAnimator) {
+ public SwipeDismissItemRemoveAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
super(itemAnimator);
}
@Override
- protected void onCreateAnimation(RemoveAnimationInfo info) {
+ protected void onCreateAnimation(@NonNull RemoveAnimationInfo info) {
final ViewPropertyAnimatorCompat animator;
if (isSwipeDismissed(info.holder)) {
@@ -93,7 +96,7 @@ protected static boolean isSwipeDismissed(RemoveAnimationInfo info) {
}
@Override
- protected void onAnimationEndedSuccessfully(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedSuccessfully(@NonNull RemoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
final View view = item.itemView;
if (isSwipeDismissed(info)) {
@@ -105,7 +108,7 @@ protected void onAnimationEndedSuccessfully(RemoveAnimationInfo info, RecyclerVi
}
@Override
- protected void onAnimationEndedBeforeStarted(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationEndedBeforeStarted(@NonNull RemoveAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
final View view = item.itemView;
if (isSwipeDismissed(info)) {
@@ -117,11 +120,11 @@ protected void onAnimationEndedBeforeStarted(RemoveAnimationInfo info, RecyclerV
}
@Override
- protected void onAnimationCancel(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected void onAnimationCancel(@NonNull RemoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
}
@Override
- public boolean addPendingAnimation(RecyclerView.ViewHolder holder) {
+ public boolean addPendingAnimation(@NonNull RecyclerView.ViewHolder holder) {
if (isSwipeDismissed(holder)) {
final View itemView = holder.itemView;
final int prevItemX = (int) (itemView.getTranslationX() + 0.5f);
@@ -146,7 +149,7 @@ public boolean addPendingAnimation(RecyclerView.ViewHolder holder) {
}
protected static class SwipeDismissRemoveAnimationInfo extends RemoveAnimationInfo {
- public SwipeDismissRemoveAnimationInfo(RecyclerView.ViewHolder holder) {
+ public SwipeDismissRemoveAnimationInfo(@NonNull RecyclerView.ViewHolder holder) {
super(holder);
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/AddAnimationInfo.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/AddAnimationInfo.java
index faf644a0..e1b3b1a0 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/AddAnimationInfo.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/AddAnimationInfo.java
@@ -16,27 +16,31 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
public class AddAnimationInfo extends ItemAnimationInfo {
public RecyclerView.ViewHolder holder;
- public AddAnimationInfo(RecyclerView.ViewHolder holder) {
+ public AddAnimationInfo(@NonNull RecyclerView.ViewHolder holder) {
this.holder = holder;
}
@Override
+ @Nullable
public RecyclerView.ViewHolder getAvailableViewHolder() {
return holder;
}
@Override
- public void clear(RecyclerView.ViewHolder item) {
- if (holder == null) {
+ public void clear(@NonNull RecyclerView.ViewHolder item) {
+ if (holder == item) {
holder = null;
}
}
+ @NonNull
@Override
public String toString() {
return "AddAnimationInfo{" +
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/BaseItemAnimationManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/BaseItemAnimationManager.java
index 512b19b2..ea47e127 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/BaseItemAnimationManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/BaseItemAnimationManager.java
@@ -18,10 +18,6 @@
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v4.view.ViewPropertyAnimatorListener;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator;
@@ -29,6 +25,13 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.ViewPropertyAnimatorCompat;
+import androidx.core.view.ViewPropertyAnimatorListener;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class BaseItemAnimationManager {
private static TimeInterpolator sDefaultInterpolator;
@@ -37,7 +40,7 @@ public abstract class BaseItemAnimationManager {
protected final List> mDeferredReadySets;
protected final List mActive;
- public BaseItemAnimationManager(BaseItemAnimator itemAnimator) {
+ public BaseItemAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
mItemAnimator = itemAnimator;
mPending = new ArrayList<>();
mActive = new ArrayList<>();
@@ -56,7 +59,7 @@ public boolean isRunning() {
return !mPending.isEmpty() || !mActive.isEmpty() || !mDeferredReadySets.isEmpty();
}
- public boolean removeFromActive(RecyclerView.ViewHolder item) {
+ public boolean removeFromActive(@NonNull RecyclerView.ViewHolder item) {
return mActive.remove(item);
}
@@ -69,9 +72,7 @@ public void cancelAllStartedAnimations() {
}
public void runPendingAnimations(boolean deferred, long deferredDelay) {
- final List ready = new ArrayList<>();
-
- ready.addAll(mPending);
+ final List ready = new ArrayList<>(mPending);
mPending.clear();
if (deferred) {
@@ -98,15 +99,15 @@ public void run() {
}
}
- public abstract void dispatchStarting(T info, RecyclerView.ViewHolder item);
+ public abstract void dispatchStarting(@NonNull T info, @NonNull RecyclerView.ViewHolder item);
- public abstract void dispatchFinished(T info, RecyclerView.ViewHolder item);
+ public abstract void dispatchFinished(@NonNull T info, @NonNull RecyclerView.ViewHolder item);
public abstract long getDuration();
public abstract void setDuration(long duration);
- public void endPendingAnimations(RecyclerView.ViewHolder item) {
+ public void endPendingAnimations(@Nullable RecyclerView.ViewHolder item) {
final List pending = mPending;
for (int i = pending.size() - 1; i >= 0; i--) {
@@ -126,7 +127,7 @@ public void endAllPendingAnimations() {
endPendingAnimations(null);
}
- public void endDeferredReadyAnimations(RecyclerView.ViewHolder item) {
+ public void endDeferredReadyAnimations(@Nullable RecyclerView.ViewHolder item) {
for (int i = mDeferredReadySets.size() - 1; i >= 0; i--) {
final List ready = mDeferredReadySets.get(i);
@@ -152,15 +153,15 @@ public void endAllDeferredReadyAnimations() {
endDeferredReadyAnimations(null);
}
- /*package*/ void createAnimation(T info) {
+ /*package*/ void createAnimation(@NonNull T info) {
onCreateAnimation(info);
}
- protected void endAnimation(RecyclerView.ViewHolder holder) {
+ protected void endAnimation(@NonNull RecyclerView.ViewHolder holder) {
mItemAnimator.endAnimation(holder);
}
- protected void resetAnimation(RecyclerView.ViewHolder holder) {
+ protected void resetAnimation(@NonNull RecyclerView.ViewHolder holder) {
if (sDefaultInterpolator == null) {
sDefaultInterpolator = new ValueAnimator().getInterpolator();
}
@@ -172,15 +173,12 @@ protected void dispatchFinishedWhenDone() {
mItemAnimator.dispatchFinishedWhenDone();
}
- protected void enqueuePendingAnimationInfo(T info) {
- if (info == null) {
- throw new IllegalStateException("info is null");
- }
+ protected void enqueuePendingAnimationInfo(@NonNull T info) {
mPending.add(info);
}
- protected void startActiveItemAnimation(T info, RecyclerView.ViewHolder holder,
- ViewPropertyAnimatorCompat animator) {
+ protected void startActiveItemAnimation(@NonNull T info, @NonNull RecyclerView.ViewHolder holder,
+ @NonNull ViewPropertyAnimatorCompat animator) {
animator.setListener(new BaseAnimatorListener(this, info, holder, animator));
addActiveAnimationTarget(holder);
animator.start();
@@ -193,15 +191,15 @@ private void addActiveAnimationTarget(RecyclerView.ViewHolder item) {
mActive.add(item);
}
- protected abstract void onCreateAnimation(final T info);
+ protected abstract void onCreateAnimation(@NonNull T info);
- protected abstract void onAnimationEndedSuccessfully(T info, RecyclerView.ViewHolder item);
+ protected abstract void onAnimationEndedSuccessfully(@NonNull T info, @NonNull RecyclerView.ViewHolder item);
- protected abstract void onAnimationEndedBeforeStarted(T info, RecyclerView.ViewHolder item);
+ protected abstract void onAnimationEndedBeforeStarted(@NonNull T info, @NonNull RecyclerView.ViewHolder item);
- protected abstract void onAnimationCancel(T info, RecyclerView.ViewHolder item);
+ protected abstract void onAnimationCancel(@NonNull T info, @NonNull RecyclerView.ViewHolder item);
- protected abstract boolean endNotStartedAnimation(T info, RecyclerView.ViewHolder item);
+ protected abstract boolean endNotStartedAnimation(@NonNull T info, @NonNull RecyclerView.ViewHolder item);
protected static class BaseAnimatorListener implements ViewPropertyAnimatorListener {
private BaseItemAnimationManager mManager;
@@ -219,13 +217,13 @@ public BaseAnimatorListener(BaseItemAnimationManager manager, ItemAnimationInfo
@SuppressWarnings("unchecked")
@Override
- public void onAnimationStart(View view) {
+ public void onAnimationStart(@NonNull View view) {
mManager.dispatchStarting(mAnimationInfo, mHolder);
}
@SuppressWarnings("unchecked")
@Override
- public void onAnimationEnd(View view) {
+ public void onAnimationEnd(@NonNull View view) {
final BaseItemAnimationManager manager = mManager;
final ItemAnimationInfo info = mAnimationInfo;
final RecyclerView.ViewHolder holder = mHolder;
@@ -245,7 +243,7 @@ public void onAnimationEnd(View view) {
@SuppressWarnings("unchecked")
@Override
- public void onAnimationCancel(View view) {
+ public void onAnimationCancel(@NonNull View view) {
mManager.onAnimationCancel(mAnimationInfo, mHolder);
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ChangeAnimationInfo.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ChangeAnimationInfo.java
index dd8931a5..f41790fc 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ChangeAnimationInfo.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ChangeAnimationInfo.java
@@ -16,7 +16,8 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
public class ChangeAnimationInfo extends ItemAnimationInfo {
public RecyclerView.ViewHolder newHolder, oldHolder;
@@ -38,7 +39,7 @@ public RecyclerView.ViewHolder getAvailableViewHolder() {
}
@Override
- public void clear(RecyclerView.ViewHolder item) {
+ public void clear(@NonNull RecyclerView.ViewHolder item) {
if (oldHolder == item) {
oldHolder = null;
}
@@ -53,6 +54,7 @@ public void clear(RecyclerView.ViewHolder item) {
}
}
+ @NonNull
@Override
public String toString() {
return "ChangeInfo{" +
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAddAnimationManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAddAnimationManager.java
index 8e514f07..e9ba2215 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAddAnimationManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAddAnimationManager.java
@@ -16,11 +16,14 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class ItemAddAnimationManager extends BaseItemAnimationManager {
private static final String TAG = "ARVItemAddAnimMgr";
@@ -39,7 +42,7 @@ public void setDuration(long duration) {
}
@Override
- public void dispatchStarting(AddAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchStarting(@NonNull AddAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchAddStarting(" + item + ")");
}
@@ -47,7 +50,7 @@ public void dispatchStarting(AddAnimationInfo info, RecyclerView.ViewHolder item
}
@Override
- public void dispatchFinished(AddAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchFinished(@NonNull AddAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchAddFinished(" + item + ")");
}
@@ -55,7 +58,7 @@ public void dispatchFinished(AddAnimationInfo info, RecyclerView.ViewHolder item
}
@Override
- protected boolean endNotStartedAnimation(AddAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected boolean endNotStartedAnimation(@NonNull AddAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
if ((info.holder != null) && ((item == null) || (info.holder == item))) {
onAnimationEndedBeforeStarted(info, info.holder);
dispatchFinished(info, info.holder);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAnimationInfo.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAnimationInfo.java
index a85e1582..70688f7e 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAnimationInfo.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAnimationInfo.java
@@ -16,11 +16,14 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
public abstract class ItemAnimationInfo {
+ @Nullable
public abstract RecyclerView.ViewHolder getAvailableViewHolder();
- public abstract void clear(RecyclerView.ViewHolder holder);
+ public abstract void clear(@NonNull RecyclerView.ViewHolder holder);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemChangeAnimationManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemChangeAnimationManager.java
index 62620ee9..0fb98c7b 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemChangeAnimationManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemChangeAnimationManager.java
@@ -16,20 +16,23 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class ItemChangeAnimationManager extends BaseItemAnimationManager {
private static final String TAG = "ARVItemChangeAnimMgr";
- public ItemChangeAnimationManager(BaseItemAnimator itemAnimator) {
+ public ItemChangeAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
super(itemAnimator);
}
@Override
- public void dispatchStarting(ChangeAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchStarting(@NonNull ChangeAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchChangeStarting(" + item + ")");
}
@@ -37,7 +40,7 @@ public void dispatchStarting(ChangeAnimationInfo info, RecyclerView.ViewHolder i
}
@Override
- public void dispatchFinished(ChangeAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchFinished(@NonNull ChangeAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchChangeFinished(" + item + ")");
}
@@ -55,18 +58,18 @@ public void setDuration(long duration) {
}
@Override
- protected void onCreateAnimation(ChangeAnimationInfo info) {
- if (info.oldHolder != null && info.oldHolder.itemView != null) {
+ protected void onCreateAnimation(@NonNull ChangeAnimationInfo info) {
+ if (info.oldHolder != null) {
onCreateChangeAnimationForOldItem(info);
}
- if (info.newHolder != null && info.newHolder.itemView != null) {
+ if (info.newHolder != null) {
onCreateChangeAnimationForNewItem(info);
}
}
@Override
- protected boolean endNotStartedAnimation(ChangeAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected boolean endNotStartedAnimation(@NonNull ChangeAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
if ((info.oldHolder != null) && ((item == null) || (info.oldHolder == item))) {
onAnimationEndedBeforeStarted(info, info.oldHolder);
dispatchFinished(info, info.oldHolder);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemMoveAnimationManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemMoveAnimationManager.java
index 1ba2bd33..5bef16da 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemMoveAnimationManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemMoveAnimationManager.java
@@ -16,15 +16,18 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class ItemMoveAnimationManager extends BaseItemAnimationManager {
public static final String TAG = "ARVItemMoveAnimMgr";
- public ItemMoveAnimationManager(BaseItemAnimator itemAnimator) {
+ public ItemMoveAnimationManager(@NonNull BaseItemAnimator itemAnimator) {
super(itemAnimator);
}
@@ -39,7 +42,7 @@ public void setDuration(long duration) {
}
@Override
- public void dispatchStarting(MoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchStarting(@NonNull MoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchMoveStarting(" + item + ")");
}
@@ -47,7 +50,7 @@ public void dispatchStarting(MoveAnimationInfo info, RecyclerView.ViewHolder ite
}
@Override
- public void dispatchFinished(MoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchFinished(@NonNull MoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchMoveFinished(" + item + ")");
}
@@ -55,7 +58,7 @@ public void dispatchFinished(MoveAnimationInfo info, RecyclerView.ViewHolder ite
}
@Override
- protected boolean endNotStartedAnimation(MoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected boolean endNotStartedAnimation(@NonNull MoveAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
if ((info.holder != null) && ((item == null) || (info.holder == item))) {
onAnimationEndedBeforeStarted(info, info.holder);
dispatchFinished(info, info.holder);
@@ -66,5 +69,5 @@ protected boolean endNotStartedAnimation(MoveAnimationInfo info, RecyclerView.Vi
}
}
- public abstract boolean addPendingAnimation(RecyclerView.ViewHolder item, int fromX, int fromY, int toX, int toY);
+ public abstract boolean addPendingAnimation(@NonNull RecyclerView.ViewHolder item, int fromX, int fromY, int toX, int toY);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemRemoveAnimationManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemRemoveAnimationManager.java
index c5c3117b..b2a4f760 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemRemoveAnimationManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemRemoveAnimationManager.java
@@ -16,11 +16,14 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class ItemRemoveAnimationManager extends BaseItemAnimationManager {
private static final String TAG = "ARVItemRemoveAnimMgr";
@@ -39,7 +42,7 @@ public void setDuration(long duration) {
}
@Override
- public void dispatchStarting(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchStarting(@NonNull RemoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchRemoveStarting(" + item + ")");
}
@@ -47,7 +50,7 @@ public void dispatchStarting(RemoveAnimationInfo info, RecyclerView.ViewHolder i
}
@Override
- public void dispatchFinished(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ public void dispatchFinished(@NonNull RemoveAnimationInfo info, @NonNull RecyclerView.ViewHolder item) {
if (debugLogEnabled()) {
Log.d(TAG, "dispatchRemoveFinished(" + item + ")");
}
@@ -55,7 +58,7 @@ public void dispatchFinished(RemoveAnimationInfo info, RecyclerView.ViewHolder i
}
@Override
- protected boolean endNotStartedAnimation(RemoveAnimationInfo info, RecyclerView.ViewHolder item) {
+ protected boolean endNotStartedAnimation(@NonNull RemoveAnimationInfo info, @Nullable RecyclerView.ViewHolder item) {
if ((info.holder != null) && ((item == null) || (info.holder == item))) {
onAnimationEndedBeforeStarted(info, info.holder);
dispatchFinished(info, info.holder);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/MoveAnimationInfo.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/MoveAnimationInfo.java
index f1d07edb..ef3a6677 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/MoveAnimationInfo.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/MoveAnimationInfo.java
@@ -16,7 +16,9 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
public class MoveAnimationInfo extends ItemAnimationInfo {
public RecyclerView.ViewHolder holder;
@@ -25,7 +27,7 @@ public class MoveAnimationInfo extends ItemAnimationInfo {
public final int toX;
public final int toY;
- public MoveAnimationInfo(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
+ public MoveAnimationInfo(@NonNull RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) {
this.holder = holder;
this.fromX = fromX;
this.fromY = fromY;
@@ -34,17 +36,19 @@ public MoveAnimationInfo(RecyclerView.ViewHolder holder, int fromX, int fromY, i
}
@Override
+ @Nullable
public RecyclerView.ViewHolder getAvailableViewHolder() {
return holder;
}
@Override
- public void clear(RecyclerView.ViewHolder item) {
+ public void clear(@NonNull RecyclerView.ViewHolder item) {
if (holder == item) {
holder = null;
}
}
+ @NonNull
@Override
public String toString() {
return "MoveAnimationInfo{" +
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/RemoveAnimationInfo.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/RemoveAnimationInfo.java
index 131b6fcf..70b3bde7 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/RemoveAnimationInfo.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/RemoveAnimationInfo.java
@@ -16,7 +16,8 @@
package com.h6ah4i.android.widget.advrecyclerview.animator.impl;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
public class RemoveAnimationInfo extends ItemAnimationInfo {
public RecyclerView.ViewHolder holder;
@@ -31,12 +32,13 @@ public RecyclerView.ViewHolder getAvailableViewHolder() {
}
@Override
- public void clear(RecyclerView.ViewHolder item) {
+ public void clear(@NonNull RecyclerView.ViewHolder item) {
if (holder == item) {
holder = null;
}
}
+ @NonNull
@Override
public String toString() {
return "RemoveAnimationInfo{" +
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/AdaptersSet.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/AdaptersSet.java
index 86a3e520..2baae0ef 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/AdaptersSet.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/AdaptersSet.java
@@ -15,14 +15,15 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.composedadapter;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.adapter.BridgeAdapterDataObserver;
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
class AdaptersSet {
public static long NO_SEGMENTED_POSITION = -1L;
@@ -33,7 +34,7 @@ class AdaptersSet {
private List mUniqueAdapters;
private List mObservers;
- public AdaptersSet(BridgeAdapterDataObserver.Subscriber bridgeSubscriber) {
+ public AdaptersSet(@NonNull BridgeAdapterDataObserver.Subscriber bridgeSubscriber) {
mSubscriber = bridgeSubscriber;
mAdapterTags = new ArrayList<>();
mAdapters = new ArrayList<>();
@@ -41,6 +42,7 @@ public AdaptersSet(BridgeAdapterDataObserver.Subscriber bridgeSubscriber) {
mObservers = new ArrayList<>();
}
+ @NonNull
public ComposedChildAdapterTag addAdapter(@NonNull RecyclerView.Adapter adapter, int position) {
final ComposedChildAdapterTag tag = new ComposedChildAdapterTag();
@@ -66,6 +68,7 @@ public ComposedChildAdapterTag addAdapter(@NonNull RecyclerView.Adapter adapter,
return tag;
}
+ @Nullable
public RecyclerView.Adapter removeAdapter(@NonNull ComposedChildAdapterTag tag) {
final int segment = getAdapterSegment(tag);
@@ -94,7 +97,7 @@ public RecyclerView.Adapter removeAdapter(@NonNull ComposedChildAdapterTag tag)
return adapter;
}
- public int getAdapterSegment(ComposedChildAdapterTag tag) {
+ public int getAdapterSegment(@NonNull ComposedChildAdapterTag tag) {
return mAdapterTags.indexOf(tag);
}
@@ -102,10 +105,12 @@ public int getSegmentCount() {
return mAdapters.size();
}
+ @NonNull
public RecyclerView.Adapter getAdapter(int segment) {
return mAdapters.get(segment);
}
+ @NonNull
public ComposedChildAdapterTag getTag(int segment) {
return mAdapterTags.get(segment);
}
@@ -137,6 +142,7 @@ public void release() {
mObservers.clear();
}
+ @NonNull
public List getUniqueAdaptersList() {
return mUniqueAdapters;
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedAdapter.java
index 45616c64..9d1cda67 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedAdapter.java
@@ -15,9 +15,6 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.composedadapter;
-import android.support.annotation.CallSuper;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPathSegment;
@@ -30,6 +27,11 @@
import java.util.List;
+import androidx.annotation.CallSuper;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* A wrapper adapter which can compose and manage several children adapters.
*/
@@ -108,8 +110,9 @@ public int getChildAdapterCount() {
*
* @param adapter The adapter which to be managed by the ComposedAdapter
* @return An instance of {@link ComposedChildAdapterTag}
- * @see {@link #addAdapter(RecyclerView.Adapter, int)}
+ * @see #addAdapter(RecyclerView.Adapter, int)
*/
+ @NonNull
public ComposedChildAdapterTag addAdapter(@NonNull RecyclerView.Adapter adapter) {
return addAdapter(adapter, getChildAdapterCount());
}
@@ -120,8 +123,9 @@ public ComposedChildAdapterTag addAdapter(@NonNull RecyclerView.Adapter adapter)
* @param adapter The adapter which to be managed by the ComposedAdapter
* @param position The position inserting a child adapter
* @return An instance of {@link ComposedChildAdapterTag}
- * @see {@link #addAdapter(RecyclerView.Adapter)}
+ * @see #addAdapter(RecyclerView.Adapter)
*/
+ @NonNull
public ComposedChildAdapterTag addAdapter(@NonNull RecyclerView.Adapter adapter, int position) {
if (hasObservers() && hasStableIds()) {
if (!adapter.hasStableIds()) {
@@ -179,8 +183,8 @@ public int getSegment(@NonNull ComposedChildAdapterTag tag) {
*
* @param flatPosition The normal flat position to be converted
* @return Segmented Position
- * @see {@link #extractSegmentPart(long)}
- * @see {@link #extractSegmentOffsetPart(long)}
+ * @see #extractSegmentPart(long)
+ * @see #extractSegmentOffsetPart(long)
*/
public long getSegmentedPosition(int flatPosition) {
return mSegmentedPositionTranslator.getSegmentedPosition(flatPosition);
@@ -264,8 +268,9 @@ public int getItemViewType(int position) {
/**
* {@inheritDoc}
*/
+ @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final long packedViewType = mViewTypeTranslator.unwrapViewType(viewType);
final int segment = SegmentedViewTypeTranslator.extractWrapperSegment(packedViewType);
final int origViewType = SegmentedViewTypeTranslator.extractWrappedViewType(packedViewType);
@@ -279,7 +284,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
*/
@Override
@SuppressWarnings("unchecked")
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
final long segmentedPosition = getSegmentedPosition(position);
final int segment = AdaptersSet.extractSegment(segmentedPosition);
final int offset = AdaptersSet.extractSegmentOffset(segmentedPosition);
@@ -293,7 +298,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
*/
@Override
@SuppressWarnings("unchecked")
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
final long segmentedPosition = getSegmentedPosition(position);
final int segment = AdaptersSet.extractSegment(segmentedPosition);
final int offset = AdaptersSet.extractSegmentOffset(segmentedPosition);
@@ -306,7 +311,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<
* {@inheritDoc}
*/
@Override
- public void onAttachedToRecyclerView(RecyclerView recyclerView) {
+ public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
final List adapters = mAdaptersSet.getUniqueAdaptersList();
for (int i = 0; i < adapters.size(); i++) {
adapters.get(i).onAttachedToRecyclerView(recyclerView);
@@ -317,7 +322,7 @@ public void onAttachedToRecyclerView(RecyclerView recyclerView) {
* {@inheritDoc}
*/
@Override
- public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
+ public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
final List adapters = mAdaptersSet.getUniqueAdaptersList();
for (int i = 0; i < adapters.size(); i++) {
adapters.get(i).onDetachedFromRecyclerView(recyclerView);
@@ -328,7 +333,7 @@ public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
* {@inheritDoc}
*/
@Override
- public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
+ public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
onViewAttachedToWindow(holder, holder.getItemViewType());
}
@@ -336,7 +341,7 @@ public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
* {@inheritDoc}
*/
@Override
- public void onViewAttachedToWindow(RecyclerView.ViewHolder holder, int viewType) {
+ public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder, int viewType) {
final long packedViewType = mViewTypeTranslator.unwrapViewType(viewType);
final int segment = SegmentedViewTypeTranslator.extractWrapperSegment(packedViewType);
final int wrappedViewType = SegmentedViewTypeTranslator.extractWrappedViewType(packedViewType);
@@ -349,7 +354,7 @@ public void onViewAttachedToWindow(RecyclerView.ViewHolder holder, int viewType)
* {@inheritDoc}
*/
@Override
- public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
+ public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) {
onViewDetachedFromWindow(holder, holder.getItemViewType());
}
@@ -357,7 +362,7 @@ public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
* {@inheritDoc}
*/
@Override
- public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder, int viewType) {
+ public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder, int viewType) {
final long packedViewType = mViewTypeTranslator.unwrapViewType(viewType);
final int segment = SegmentedViewTypeTranslator.extractWrapperSegment(packedViewType);
final int wrappedViewType = SegmentedViewTypeTranslator.extractWrappedViewType(packedViewType);
@@ -370,7 +375,7 @@ public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder, int viewTyp
* {@inheritDoc}
*/
@Override
- public void onViewRecycled(RecyclerView.ViewHolder holder) {
+ public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
onViewRecycled(holder, holder.getItemViewType());
}
@@ -378,7 +383,7 @@ public void onViewRecycled(RecyclerView.ViewHolder holder) {
* {@inheritDoc}
*/
@Override
- public void onViewRecycled(RecyclerView.ViewHolder holder, int viewType) {
+ public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder, int viewType) {
final long packedViewType = mViewTypeTranslator.unwrapViewType(viewType);
final int segment = SegmentedViewTypeTranslator.extractWrapperSegment(packedViewType);
final int wrappedViewType = SegmentedViewTypeTranslator.extractWrappedViewType(packedViewType);
@@ -391,7 +396,7 @@ public void onViewRecycled(RecyclerView.ViewHolder holder, int viewType) {
* {@inheritDoc}
*/
@Override
- public boolean onFailedToRecycleView(RecyclerView.ViewHolder holder) {
+ public boolean onFailedToRecycleView(@NonNull RecyclerView.ViewHolder holder) {
return onFailedToRecycleView(holder, holder.getItemViewType());
}
@@ -399,7 +404,7 @@ public boolean onFailedToRecycleView(RecyclerView.ViewHolder holder) {
* {@inheritDoc}
*/
@Override
- public boolean onFailedToRecycleView(RecyclerView.ViewHolder holder, int viewType) {
+ public boolean onFailedToRecycleView(@NonNull RecyclerView.ViewHolder holder, int viewType) {
final long packedViewType = mViewTypeTranslator.unwrapViewType(viewType);
final int segment = SegmentedViewTypeTranslator.extractWrapperSegment(packedViewType);
final int wrappedViewType = SegmentedViewTypeTranslator.extractWrappedViewType(packedViewType);
@@ -453,7 +458,7 @@ public int wrapPosition(@NonNull AdapterPathSegment pathSegment, int position) {
*/
@Override
@SuppressWarnings("unchecked")
- public void onBridgedAdapterChanged(RecyclerView.Adapter source, Object tag) {
+ public void onBridgedAdapterChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag) {
onHandleWrappedAdapterChanged(source, (List) tag);
}
@@ -462,7 +467,7 @@ public void onBridgedAdapterChanged(RecyclerView.Adapter source, Object tag) {
*/
@Override
@SuppressWarnings("unchecked")
- public void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount) {
+ public void onBridgedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount) {
onHandleWrappedAdapterItemRangeChanged(source, (List) tag, positionStart, itemCount);
}
@@ -471,7 +476,7 @@ public void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source, Object
*/
@Override
@SuppressWarnings("unchecked")
- public void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount, Object payload) {
+ public void onBridgedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount, Object payload) {
onHandleWrappedAdapterItemRangeChanged(source, (List) tag, positionStart, itemCount, payload);
}
@@ -480,7 +485,7 @@ public void onBridgedAdapterItemRangeChanged(RecyclerView.Adapter source, Object
*/
@Override
@SuppressWarnings("unchecked")
- public void onBridgedAdapterItemRangeInserted(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount) {
+ public void onBridgedAdapterItemRangeInserted(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount) {
onHandleWrappedAdapterItemRangeInserted(source, (List) tag, positionStart, itemCount);
}
@@ -489,7 +494,7 @@ public void onBridgedAdapterItemRangeInserted(RecyclerView.Adapter source, Objec
*/
@Override
@SuppressWarnings("unchecked")
- public void onBridgedAdapterItemRangeRemoved(RecyclerView.Adapter source, Object tag, int positionStart, int itemCount) {
+ public void onBridgedAdapterItemRangeRemoved(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int positionStart, int itemCount) {
onHandleWrappedAdapterItemRangeRemoved(source, (List) tag, positionStart, itemCount);
}
@@ -498,16 +503,16 @@ public void onBridgedAdapterItemRangeRemoved(RecyclerView.Adapter source, Object
*/
@Override
@SuppressWarnings("unchecked")
- public void onBridgedAdapterRangeMoved(RecyclerView.Adapter source, Object tag, int fromPosition, int toPosition, int itemCount) {
+ public void onBridgedAdapterRangeMoved(@NonNull RecyclerView.Adapter source, @Nullable Object tag, int fromPosition, int toPosition, int itemCount) {
onHandleWrappedAdapterRangeMoved(source, (List) tag, fromPosition, toPosition, itemCount);
}
- protected void onHandleWrappedAdapterChanged(RecyclerView.Adapter sourceAdapter, List sourceTags) {
+ protected void onHandleWrappedAdapterChanged(@NonNull RecyclerView.Adapter sourceAdapter, @NonNull List sourceTags) {
mSegmentedPositionTranslator.invalidateAll();
notifyDataSetChanged();
}
- protected void onHandleWrappedAdapterItemRangeChanged(RecyclerView.Adapter sourceAdapter, List sourceTags, int localPositionStart, int itemCount) {
+ protected void onHandleWrappedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter sourceAdapter, @NonNull List sourceTags, int localPositionStart, int itemCount) {
final int nTags = sourceTags.size();
for (int i = 0; i < nTags; i++) {
final int adapterSegment = mAdaptersSet.getAdapterSegment(sourceTags.get(i));
@@ -517,7 +522,7 @@ protected void onHandleWrappedAdapterItemRangeChanged(RecyclerView.Adapter sourc
}
}
- protected void onHandleWrappedAdapterItemRangeChanged(RecyclerView.Adapter sourceAdapter, List sourceTags, int localPositionStart, int itemCount, Object payload) {
+ protected void onHandleWrappedAdapterItemRangeChanged(@NonNull RecyclerView.Adapter sourceAdapter, @NonNull List sourceTags, int localPositionStart, int itemCount, Object payload) {
final int nTags = sourceTags.size();
for (int i = 0; i < nTags; i++) {
final int adapterSegment = mAdaptersSet.getAdapterSegment(sourceTags.get(i));
@@ -527,7 +532,7 @@ protected void onHandleWrappedAdapterItemRangeChanged(RecyclerView.Adapter sourc
}
}
- protected void onHandleWrappedAdapterItemRangeInserted(RecyclerView.Adapter sourceAdapter, List sourceTags, int localPositionStart, int itemCount) {
+ protected void onHandleWrappedAdapterItemRangeInserted(@NonNull RecyclerView.Adapter sourceAdapter, @NonNull List sourceTags, int localPositionStart, int itemCount) {
if (itemCount <= 0) {
return;
}
@@ -552,7 +557,7 @@ protected void onHandleWrappedAdapterItemRangeInserted(RecyclerView.Adapter sour
}
}
- protected void onHandleWrappedAdapterItemRangeRemoved(RecyclerView.Adapter sourceAdapter, List sourceTags, int localPositionStart, int itemCount) {
+ protected void onHandleWrappedAdapterItemRangeRemoved(@NonNull RecyclerView.Adapter sourceAdapter, @NonNull List sourceTags, int localPositionStart, int itemCount) {
if (itemCount <= 0) {
return;
}
@@ -577,7 +582,7 @@ protected void onHandleWrappedAdapterItemRangeRemoved(RecyclerView.Adapter sourc
}
}
- protected void onHandleWrappedAdapterRangeMoved(RecyclerView.Adapter sourceAdapter, List sourceTags, int localFromPosition, int localToPosition, int itemCount) {
+ protected void onHandleWrappedAdapterRangeMoved(@NonNull RecyclerView.Adapter sourceAdapter, @NonNull List sourceTags, int localFromPosition, int localToPosition, int itemCount) {
if (itemCount != 1) {
throw new IllegalStateException("itemCount should be always 1 (actual: " + itemCount + ")");
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterDataObserver.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterDataObserver.java
index a4b58004..e867bacc 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterDataObserver.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterDataObserver.java
@@ -15,28 +15,30 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.composedadapter;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.adapter.BridgeAdapterDataObserver;
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class ComposedChildAdapterDataObserver extends BridgeAdapterDataObserver {
- public ComposedChildAdapterDataObserver(Subscriber subscriber, RecyclerView.Adapter sourceAdapter) {
+ public ComposedChildAdapterDataObserver(@NonNull Subscriber subscriber, @NonNull RecyclerView.Adapter sourceAdapter) {
super(subscriber, sourceAdapter, new ArrayList());
}
@SuppressWarnings("unchecked")
+ @NonNull
private List getChildAdapterTags() {
return (List) getTag();
}
- public void registerChildAdapterTag(ComposedChildAdapterTag tag) {
+ public void registerChildAdapterTag(@NonNull ComposedChildAdapterTag tag) {
getChildAdapterTags().add(tag);
}
- public void unregisterChildAdapterTag(ComposedChildAdapterTag tag) {
+ public void unregisterChildAdapterTag(@NonNull ComposedChildAdapterTag tag) {
getChildAdapterTags().remove(tag);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterTag.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterTag.java
index 511f344d..3c598b2f 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterTag.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/ComposedChildAdapterTag.java
@@ -15,14 +15,14 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.composedadapter;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
/**
* Returned value of the {@link ComposedAdapter#addAdapter(RecyclerView.Adapter)} method.
*
- * @see {@link ComposedAdapter#addAdapter(RecyclerView.Adapter)}
- * @see {@link ComposedAdapter#addAdapter(RecyclerView.Adapter, int)}
- * @see {@link ComposedAdapter#removeAdapter(ComposedChildAdapterTag)}
+ * @see ComposedAdapter#addAdapter(RecyclerView.Adapter)
+ * @see ComposedAdapter#addAdapter(RecyclerView.Adapter, int)
+ * @see ComposedAdapter#removeAdapter(ComposedChildAdapterTag)
*/
public class ComposedChildAdapterTag {
ComposedChildAdapterTag() {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedPositionTranslator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedPositionTranslator.java
index 01c2a574..361d51af 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedPositionTranslator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedPositionTranslator.java
@@ -15,12 +15,12 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.composedadapter;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.adapter.ItemViewTypeComposer;
import java.util.Arrays;
+import androidx.recyclerview.widget.RecyclerView;
+
class SegmentedPositionTranslator {
private static final int NO_CACHED_SEGMENT = 0;
private static final int NO_CACHED_ITEM_COUNT = -1;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedViewTypeTranslator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedViewTypeTranslator.java
index 4502ddab..362fcfbd 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedViewTypeTranslator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/composedadapter/SegmentedViewTypeTranslator.java
@@ -57,6 +57,7 @@ public long unwrapViewType(int viewType) {
}
final int packedSegments = mUnwrapSegmentMap.valueAt(index);
+ //noinspection BooleanMethodIsAlwaysInverted
final long packedViewType = (((long) packedSegments) << 32) | (((long) viewType) & 0xFFFFFFFFL);
return packedViewType;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/ItemShadowDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/ItemShadowDecorator.java
index 5f7d3907..d3caf74c 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/ItemShadowDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/ItemShadowDecorator.java
@@ -21,10 +21,11 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Item decoration which draws drop shadow of each item views.
*/
@@ -55,7 +56,7 @@ public ItemShadowDecorator(@NonNull NinePatchDrawable shadow, boolean castShadow
}
@Override
- public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
+ public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
final int childCount = parent.getChildCount();
if (childCount == 0) {
@@ -96,7 +97,7 @@ private boolean shouldDrawDropShadow(View child) {
}
if (!mCastShadowForTransparentBackgroundItem && (background instanceof ColorDrawable)) {
- //noinspection RedundantCast
+ //noinspection RedundantCast,RedundantIfStatement
if (((ColorDrawable) background).getAlpha() == 0) {
return false;
}
@@ -106,7 +107,7 @@ private boolean shouldDrawDropShadow(View child) {
}
@Override
- public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
+ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
outRect.set(0, 0, 0, 0);
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/SimpleListDividerDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/SimpleListDividerDecorator.java
index d6865264..0085aa20 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/SimpleListDividerDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/SimpleListDividerDecorator.java
@@ -19,11 +19,13 @@
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
-import android.support.annotation.Nullable;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Item decoration which draws item divider between each items.
*/
@@ -60,7 +62,7 @@ public SimpleListDividerDecorator(@Nullable Drawable horizontalDivider, @Nullabl
}
@Override
- public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
+ public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
final int childCount = parent.getChildCount();
@@ -131,7 +133,7 @@ public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state)
}
@Override
- public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
+ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
if (mOverlap) {
outRect.set(0, 0, 0, 0);
} else {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseDraggableItemDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseDraggableItemDecorator.java
index 4cce802d..2000566a 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseDraggableItemDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseDraggableItemDecorator.java
@@ -16,13 +16,14 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v4.view.ViewPropertyAnimatorListener;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.Interpolator;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.ViewPropertyAnimatorCompat;
+import androidx.core.view.ViewPropertyAnimatorListener;
+import androidx.recyclerview.widget.RecyclerView;
+
abstract class BaseDraggableItemDecorator extends RecyclerView.ItemDecoration {
private static final int RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_DP = 2;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseEdgeEffectDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseEdgeEffectDecorator.java
index 566370c7..70572151 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseEdgeEffectDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BaseEdgeEffectDecorator.java
@@ -17,11 +17,13 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
import android.graphics.Canvas;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.widget.EdgeEffectCompat;
-import android.support.v7.widget.RecyclerView;
import android.widget.EdgeEffect;
+import androidx.annotation.NonNull;
+import androidx.core.view.ViewCompat;
+import androidx.core.widget.EdgeEffectCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
abstract class BaseEdgeEffectDecorator extends RecyclerView.ItemDecoration {
private RecyclerView mRecyclerView;
private EdgeEffect mGlow1;
@@ -35,7 +37,7 @@ abstract class BaseEdgeEffectDecorator extends RecyclerView.ItemDecoration {
protected static final int EDGE_RIGHT = 2;
protected static final int EDGE_BOTTOM = 3;
- public BaseEdgeEffectDecorator(RecyclerView recyclerView) {
+ public BaseEdgeEffectDecorator(@NonNull RecyclerView recyclerView) {
mRecyclerView = recyclerView;
}
@@ -43,7 +45,7 @@ public BaseEdgeEffectDecorator(RecyclerView recyclerView) {
@SuppressWarnings("ConstantConditions")
@Override
- public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
+ public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
boolean needsInvalidate = false;
if (mGlow1 != null) {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemAdapter.java
index f87c37ea..892d1f4f 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemAdapter.java
@@ -16,7 +16,9 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
public interface DraggableItemAdapter {
@@ -30,10 +32,10 @@ public interface DraggableItemAdapter {
* @return Whether can start dragging.
*/
- boolean onCheckCanStartDrag(T holder, int position, int x, int y);
+ boolean onCheckCanStartDrag(@NonNull T holder, int position, int x, int y);
/**
- * Called after the {@link #onCheckCanStartDrag(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method returned true.
+ * Called after the {@link #onCheckCanStartDrag(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method returned true.
*
* @param holder The ViewHolder which is associated to item user is attempt to start dragging.
* @param position The position of the item within the adapter's data set.
@@ -41,7 +43,8 @@ public interface DraggableItemAdapter {
* @return null: no constraints (= new ItemDraggableRange(0, getItemCount() - 1)),
* otherwise: the range specified item can be drag-sortable.
*/
- ItemDraggableRange onGetItemDraggableRange(T holder, int position);
+ @Nullable
+ ItemDraggableRange onGetItemDraggableRange(@NonNull T holder, int position);
/**
* Called when item is moved. Should apply the move operation result to data set.
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemConstants.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemConstants.java
index ed1920be..d1bb1ba6 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemConstants.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemConstants.java
@@ -40,6 +40,7 @@ public interface DraggableItemConstants {
* State flag for the {@link DraggableItemViewHolder#setDragStateFlags(int)} and {@link DraggableItemViewHolder#getDragStateFlags()} methods.
* If this flag is set, some other flags are changed and require to apply.
*/
+ @SuppressWarnings("NumericOverflow")
int STATE_FLAG_IS_UPDATED = (1 << 31);
// ---
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemState.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemState.java
new file mode 100644
index 00000000..ae202b50
--- /dev/null
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemState.java
@@ -0,0 +1,55 @@
+package com.h6ah4i.android.widget.advrecyclerview.draggable;
+
+import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags;
+
+/**
+ * Helper class for decoding {@link DraggableItemViewHolder#getDragStateFlags()} flag values.
+ */
+public class DraggableItemState {
+ private int mFlags;
+
+ @DraggableItemStateFlags
+ public int getFlags() {
+ return mFlags;
+ }
+
+ public void setFlags(@DraggableItemStateFlags int flags) {
+ mFlags = flags;
+ }
+
+ /**
+ * Checks whether the dragging is currently performed.
+ *
+ * @return True if the user is dragging an item, otherwise else.
+ */
+ public boolean isDragging() {
+ return (mFlags & DraggableItemConstants.STATE_FLAG_DRAGGING) != 0;
+ }
+
+ /**
+ * Checks whether the item is being dragged.
+ *
+ * @return True if the associated item is being dragged, otherwise false.
+ */
+ public boolean isActive() {
+ return (mFlags & DraggableItemConstants.STATE_FLAG_IS_ACTIVE) != 0;
+ }
+
+ /**
+ * Checks whether the item is in range of drag-sortable items.
+ *
+ * @return True if the associated item is in range, otherwise false.
+ */
+ public boolean isInRange() {
+ return (mFlags & DraggableItemConstants.STATE_FLAG_IS_IN_RANGE) != 0;
+ }
+
+ /**
+ * Checks whether state flags are changed or not.
+ *
+ * @return True if flags are updated, otherwise false.
+ */
+ public boolean isUpdated() {
+ return (mFlags & DraggableItemConstants.STATE_FLAG_IS_UPDATED) != 0;
+ }
+}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemViewHolder.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemViewHolder.java
index 4ca57bc7..87de1e35 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemViewHolder.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemViewHolder.java
@@ -18,10 +18,13 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Interface which provides required information for dragging item.
*
- * Implement this interface on your sub-class of the {@link android.support.v7.widget.RecyclerView.ViewHolder}.
+ * Implement this interface on your sub-class of the {@link androidx.recyclerview.widget.RecyclerView.ViewHolder}.
*/
public interface DraggableItemViewHolder {
/**
@@ -32,18 +35,29 @@ public interface DraggableItemViewHolder {
* - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_ACTIVE}
* - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_IN_RANGE}
* - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_UPDATED}
+ * @see #getDragState()
*/
void setDragStateFlags(@DraggableItemStateFlags int flags);
/**
- * Gets the state flags value for dragging item
+ * Gets the state flags value for dragging item. You can access these flags more human friendly way through {@link #getDragState()}.
*
* @return Bitwise OR of these flags;
* - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_DRAGGING}
* - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_ACTIVE}
* - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_IN_RANGE}
* - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_UPDATED}
+ * @see #getDragState()
*/
@DraggableItemStateFlags
int getDragStateFlags();
+
+ /**
+ * Gets the state object for dragging item.
+ * This method can be used inside of the {@link androidx.recyclerview.widget.RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}.
+ *
+ * @return {@link DraggableItemState} object
+ */
+ @NonNull
+ DraggableItemState getDragState();
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemWrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemWrapperAdapter.java
index 76262eef..04b60de5 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemWrapperAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemWrapperAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.ViewGroup;
@@ -30,6 +29,9 @@
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class DraggableItemWrapperAdapter extends SimpleWrapperAdapter implements SwipeableItemAdapter {
private static final String TAG = "ARVDraggableWrapper";
@@ -71,8 +73,9 @@ protected void onRelease() {
mDragDropManager = null;
}
+ @NonNull
@Override
- public VH onCreateViewHolder(ViewGroup parent, int viewType) {
+ public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final VH holder = super.onCreateViewHolder(parent, viewType);
if (holder instanceof DraggableItemViewHolder) {
@@ -83,7 +86,7 @@ public VH onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(VH holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull VH holder, int position, @NonNull List payloads) {
if (isDragging()) {
final long draggingItemId = mDraggingItemInfo.id;
final long itemId = holder.getItemId();
@@ -297,7 +300,7 @@ private void cancelDrag() {
}
@Override
- public void onViewRecycled(VH holder, int viewType) {
+ public void onViewRecycled(@NonNull VH holder, int viewType) {
if (isDragging()) {
mDragDropManager.onItemViewRecycled(holder);
mDraggingItemViewHolder = mDragDropManager.getDraggingItemViewHolder();
@@ -435,7 +438,7 @@ private int getOriginalPosition(int position) {
//
@SuppressWarnings("unchecked")
@Override
- public int onGetSwipeReactionType(VH holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull VH holder, int position, int x, int y) {
RecyclerView.Adapter adapter = getWrappedAdapter();
if (!(adapter instanceof SwipeableItemAdapter)) {
return RecyclerViewSwipeManager.REACTION_CAN_NOT_SWIPE_ANY;
@@ -449,7 +452,7 @@ public int onGetSwipeReactionType(VH holder, int position, int x, int y) {
@SuppressWarnings("unchecked")
@Override
- public void onSwipeItemStarted(VH holder, int position) {
+ public void onSwipeItemStarted(@NonNull VH holder, int position) {
RecyclerView.Adapter adapter = getWrappedAdapter();
if (!(adapter instanceof SwipeableItemAdapter)) {
return;
@@ -462,7 +465,7 @@ public void onSwipeItemStarted(VH holder, int position) {
@SuppressWarnings("unchecked")
@Override
- public void onSetSwipeBackground(VH holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull VH holder, int position, int type) {
RecyclerView.Adapter adapter = getWrappedAdapter();
if (!(adapter instanceof SwipeableItemAdapter)) {
return;
@@ -476,7 +479,7 @@ public void onSetSwipeBackground(VH holder, int position, int type) {
@SuppressWarnings("unchecked")
@Override
- public SwipeResultAction onSwipeItem(VH holder, int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull VH holder, int position, int result) {
RecyclerView.Adapter adapter = getWrappedAdapter();
if (!(adapter instanceof SwipeableItemAdapter)) {
return new SwipeResultActionDefault();
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemDecorator.java
index 652007c6..4aabfc0a 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemDecorator.java
@@ -21,13 +21,15 @@
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.NinePatchDrawable;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.Interpolator;
import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils;
+import androidx.annotation.NonNull;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
class DraggingItemDecorator extends BaseDraggableItemDecorator {
@SuppressWarnings("unused")
private static final String TAG = "DraggingItemDecorator";
@@ -133,7 +135,7 @@ private static View findRangeLastItem(RecyclerView rv, ItemDraggableRange range,
}
@Override
- public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
+ public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
if (mDraggingItemImage == null) {
return;
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemInfo.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemInfo.java
index 05671b3f..39c5226a 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemInfo.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemInfo.java
@@ -17,10 +17,11 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
import android.graphics.Rect;
-import android.support.v7.widget.RecyclerView;
import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils;
+import androidx.recyclerview.widget.RecyclerView;
+
public class DraggingItemInfo {
public final int width;
public final int height;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/ItemDraggableRange.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/ItemDraggableRange.java
index e5bbde8b..d1bc2d00 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/ItemDraggableRange.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/ItemDraggableRange.java
@@ -16,6 +16,8 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
+import androidx.annotation.NonNull;
+
public class ItemDraggableRange {
private final int mStart;
private final int mEnd;
@@ -41,10 +43,12 @@ public boolean checkInRange(int position) {
return ((position >= mStart) && (position <= mEnd));
}
+ @NonNull
protected String getClassName() {
return "ItemDraggableRange";
}
+ @NonNull
@Override
public String toString() {
return getClassName() + "{" +
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/LeftRightEdgeEffectDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/LeftRightEdgeEffectDecorator.java
index eb485421..18e203a0 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/LeftRightEdgeEffectDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/LeftRightEdgeEffectDecorator.java
@@ -16,10 +16,11 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
class LeftRightEdgeEffectDecorator extends BaseEdgeEffectDecorator {
- public LeftRightEdgeEffectDecorator(RecyclerView recyclerView) {
+ public LeftRightEdgeEffectDecorator(@NonNull RecyclerView recyclerView) {
super(recyclerView);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/RecyclerViewDragDropManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/RecyclerViewDragDropManager.java
index 57d5b153..fc8568c3 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/RecyclerViewDragDropManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/RecyclerViewDragDropManager.java
@@ -21,13 +21,6 @@
import android.os.Build;
import android.os.Handler;
import android.os.Message;
-import android.support.annotation.FloatRange;
-import android.support.annotation.IntDef;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.widget.NestedScrollView;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
@@ -46,8 +39,16 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
+import androidx.annotation.FloatRange;
+import androidx.annotation.IntDef;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.view.ViewCompat;
+import androidx.core.widget.NestedScrollView;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
- * Provides item drag & drop operation for {@link android.support.v7.widget.RecyclerView}
+ * Provides item drag & drop operation for {@link androidx.recyclerview.widget.RecyclerView}
*/
@SuppressWarnings("PointlessBitwiseExpression")
public class RecyclerViewDragDropManager implements DraggableItemConstants {
@@ -270,12 +271,12 @@ public void clear() {
public RecyclerViewDragDropManager() {
mInternalUseOnItemTouchListener = new RecyclerView.OnItemTouchListener() {
@Override
- public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
+ public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
return RecyclerViewDragDropManager.this.onInterceptTouchEvent(rv, e);
}
@Override
- public void onTouchEvent(RecyclerView rv, MotionEvent e) {
+ public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
RecyclerViewDragDropManager.this.onTouchEvent(rv, e);
}
@@ -287,12 +288,12 @@ public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
mInternalUseOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
- public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
RecyclerViewDragDropManager.this.onScrollStateChanged(recyclerView, newState);
}
@Override
- public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
RecyclerViewDragDropManager.this.onScrolled(recyclerView, dx, dy);
}
};
@@ -309,6 +310,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
* @return Wrapped adapter which is associated to this {@link RecyclerViewDragDropManager} instance.
*/
@SuppressWarnings("unchecked")
+ @NonNull
public RecyclerView.Adapter createWrappedAdapter(@NonNull RecyclerView.Adapter adapter) {
if (!adapter.hasStableIds()) {
throw new IllegalArgumentException("The passed adapter does not support stable IDs");
@@ -333,12 +335,12 @@ public boolean isReleased() {
}
/**
- * Attaches {@link android.support.v7.widget.RecyclerView} instance.
- * Before calling this method, the target {@link android.support.v7.widget.RecyclerView} must set
+ *
Attaches {@link androidx.recyclerview.widget.RecyclerView} instance.
+ * Before calling this method, the target {@link androidx.recyclerview.widget.RecyclerView} must set
* the wrapped adapter instance which is returned by the
- * {@link #createWrappedAdapter(android.support.v7.widget.RecyclerView.Adapter)} method.
+ * {@link #createWrappedAdapter(androidx.recyclerview.widget.RecyclerView.Adapter)} method.
*
- * @param rv The {@link android.support.v7.widget.RecyclerView} instance
+ * @param rv The {@link androidx.recyclerview.widget.RecyclerView} instance
*/
public void attachRecyclerView(@NonNull RecyclerView rv) {
if (isReleased()) {
@@ -376,7 +378,7 @@ public void attachRecyclerView(@NonNull RecyclerView rv) {
}
/**
- * Detach the {@link android.support.v7.widget.RecyclerView} instance and release internal field references.
+ * Detach the {@link androidx.recyclerview.widget.RecyclerView} instance and release internal field references.
* This method should be called in order to avoid memory leaks.
*/
public void release() {
@@ -1021,6 +1023,7 @@ private boolean checkConditionAndStartDragging(RecyclerView rv, MotionEvent e, b
return true;
}
+ @SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean canStartDrag(RecyclerView.ViewHolder holder, int touchX, int touchY) {
final int origRootPosition = holder.getAdapterPosition();
final int wrappedItemPosition = WrapperAdapterUtils.unwrapPosition(mRecyclerView.getAdapter(), mWrapperAdapter, null, origRootPosition);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/SwapTargetItemOperator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/SwapTargetItemOperator.java
index c1f6a7b4..57774174 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/SwapTargetItemOperator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/SwapTargetItemOperator.java
@@ -18,15 +18,17 @@
import android.graphics.Canvas;
import android.graphics.Rect;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v4.view.ViewPropertyAnimatorListener;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.Interpolator;
import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils;
+import androidx.annotation.NonNull;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.ViewPropertyAnimatorCompat;
+import androidx.core.view.ViewPropertyAnimatorListener;
+import androidx.recyclerview.widget.RecyclerView;
+
class SwapTargetItemOperator extends BaseDraggableItemDecorator {
@SuppressWarnings("unused")
private static final String TAG = "SwapTargetItemOperator";
@@ -111,7 +113,7 @@ public void setSwapTargetItem(RecyclerView.ViewHolder swapTargetItem) {
}
@Override
- public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
+ public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
final RecyclerView.ViewHolder draggingItem = mDraggingItemViewHolder;
final RecyclerView.ViewHolder swapTargetItem = mSwapTargetItem;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/TopBottomEdgeEffectDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/TopBottomEdgeEffectDecorator.java
index 64d8a40c..3b20c21d 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/TopBottomEdgeEffectDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/TopBottomEdgeEffectDecorator.java
@@ -16,10 +16,11 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
class TopBottomEdgeEffectDecorator extends BaseEdgeEffectDecorator {
- public TopBottomEdgeEffectDecorator(RecyclerView recyclerView) {
+ public TopBottomEdgeEffectDecorator(@NonNull RecyclerView recyclerView) {
super(recyclerView);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/annotation/DraggableItemStateFlags.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/annotation/DraggableItemStateFlags.java
index 56e968c3..d12b52c9 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/annotation/DraggableItemStateFlags.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/annotation/DraggableItemStateFlags.java
@@ -16,13 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.draggable.annotation;
-import android.support.annotation.IntDef;
-
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
@IntDef(flag = true, value = {
DraggableItemConstants.STATE_FLAG_DRAGGING,
DraggableItemConstants.STATE_FLAG_IS_ACTIVE,
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/BaseRecyclerViewEventDistributor.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/BaseRecyclerViewEventDistributor.java
index ce32cf0d..1832ec9f 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/BaseRecyclerViewEventDistributor.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/BaseRecyclerViewEventDistributor.java
@@ -16,12 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.event;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
-
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class BaseRecyclerViewEventDistributor {
protected boolean mReleased;
protected RecyclerView mRecyclerView;
@@ -32,10 +33,11 @@ public BaseRecyclerViewEventDistributor() {
}
/**
- * Gets attached {@link android.support.v7.widget.RecyclerView}
+ * Gets attached {@link androidx.recyclerview.widget.RecyclerView}
*
- * @return The {@link android.support.v7.widget.RecyclerView} instance
+ * @return The {@link androidx.recyclerview.widget.RecyclerView} instance
*/
+ @Nullable
public RecyclerView getRecyclerView() {
return mRecyclerView;
}
@@ -63,17 +65,13 @@ public boolean isReleased() {
}
/**
- * Attaches {@link android.support.v7.widget.RecyclerView} instance.
+ * Attaches {@link androidx.recyclerview.widget.RecyclerView} instance.
*
- * @param rv The {@link android.support.v7.widget.RecyclerView} instance
+ * @param rv The {@link androidx.recyclerview.widget.RecyclerView} instance
*/
- public void attachRecyclerView(RecyclerView rv) {
+ public void attachRecyclerView(@NonNull RecyclerView rv) {
final String METHOD_NAME = "attachRecyclerView()";
- if (rv == null) {
- throw new IllegalArgumentException("RecyclerView cannot be null");
- }
-
verifyIsNotReleased(METHOD_NAME);
verifyIsNotPerformingClearMethod(METHOD_NAME);
@@ -87,7 +85,7 @@ public void attachRecyclerView(RecyclerView rv) {
*
* @return True if the listener object successfully added, otherwise false. Also returns true if have already been added.
*/
- public boolean add(T listener) {
+ public boolean add(@NonNull T listener) {
return add(listener, -1);
}
@@ -227,17 +225,17 @@ protected void onRelease() {
mPerformingClearMethod = false;
}
- protected void onRecyclerViewAttached(RecyclerView rv) {
+ protected void onRecyclerViewAttached(@NonNull RecyclerView rv) {
mRecyclerView = rv;
}
- protected void verifyIsNotPerformingClearMethod(String methodName) {
+ protected void verifyIsNotPerformingClearMethod(@NonNull String methodName) {
if (mPerformingClearMethod) {
throw new IllegalStateException(methodName + " can not be called while performing the clear() method");
}
}
- protected void verifyIsNotReleased(String methodName) {
+ protected void verifyIsNotReleased(@NonNull String methodName) {
if (mReleased) {
throw new IllegalStateException(methodName + " can not be called after release() method called");
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewEventDistributorListener.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewEventDistributorListener.java
index 437b7dc0..3cfa157c 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewEventDistributorListener.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewEventDistributorListener.java
@@ -16,7 +16,9 @@
package com.h6ah4i.android.widget.advrecyclerview.event;
+import androidx.annotation.NonNull;
+
public interface RecyclerViewEventDistributorListener {
- void onAddedToEventDistributor(BaseRecyclerViewEventDistributor distributor);
- void onRemovedFromEventDistributor(BaseRecyclerViewEventDistributor distributor);
+ void onAddedToEventDistributor(@NonNull BaseRecyclerViewEventDistributor distributor);
+ void onRemovedFromEventDistributor(@NonNull BaseRecyclerViewEventDistributor distributor);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewRecyclerEventDistributor.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewRecyclerEventDistributor.java
index 56e493b9..90d916c7 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewRecyclerEventDistributor.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewRecyclerEventDistributor.java
@@ -16,10 +16,11 @@
package com.h6ah4i.android.widget.advrecyclerview.event;
-import android.support.v7.widget.RecyclerView;
-
import java.lang.ref.WeakReference;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public class RecyclerViewRecyclerEventDistributor extends BaseRecyclerViewEventDistributor {
private InternalRecyclerListener mInternalRecyclerListener;
@@ -31,7 +32,7 @@ public RecyclerViewRecyclerEventDistributor() {
}
@Override
- protected void onRecyclerViewAttached(RecyclerView rv) {
+ protected void onRecyclerViewAttached(@NonNull RecyclerView rv) {
super.onRecyclerViewAttached(rv);
rv.setRecyclerListener(mInternalRecyclerListener);
@@ -47,7 +48,7 @@ protected void onRelease() {
}
}
- /*package*/ void handleOnViewRecycled(RecyclerView.ViewHolder holder) {
+ /*package*/ void handleOnViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (mListeners == null) {
return;
}
@@ -60,13 +61,13 @@ protected void onRelease() {
private static class InternalRecyclerListener implements RecyclerView.RecyclerListener {
private final WeakReference mRefDistributor;
- public InternalRecyclerListener(RecyclerViewRecyclerEventDistributor distributor) {
+ public InternalRecyclerListener(@NonNull RecyclerViewRecyclerEventDistributor distributor) {
super();
mRefDistributor = new WeakReference<>(distributor);
}
@Override
- public void onViewRecycled(RecyclerView.ViewHolder holder) {
+ public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
final RecyclerViewRecyclerEventDistributor distributor = mRefDistributor.get();
if (distributor != null) {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/BaseExpandableSwipeableItemAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/BaseExpandableSwipeableItemAdapter.java
index e55d26c0..38dc93a6 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/BaseExpandableSwipeableItemAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/BaseExpandableSwipeableItemAdapter.java
@@ -16,11 +16,12 @@
package com.h6ah4i.android.widget.advrecyclerview.expandable;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemDrawableTypes;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemReactions;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public interface BaseExpandableSwipeableItemAdapter {
/**
* Called when user is attempt to swipe the group item.
@@ -45,7 +46,7 @@ public interface BaseExpandableSwipeableItemAdapter {
/**
* Called when user is attempt to drag the group item.
@@ -32,7 +33,7 @@ public interface ExpandableDraggableItemAdapter {
/**
@@ -92,6 +95,7 @@ public interface ExpandableItemAdapter payloads);
+ void onBindGroupViewHolder(@NonNull GVH holder, int groupPosition, @IntRange(from = ItemViewTypeComposer.MIN_WRAPPED_VIEW_TYPE, to = ItemViewTypeComposer.MAX_WRAPPED_VIEW_TYPE) int viewType, List payloads);
/**
* Called by RecyclerView to display the child data at the specified position.
- * This method should update the contents of the {@link android.support.v7.widget.RecyclerView.ViewHolder#itemView}
+ * This method should update the contents of the {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#itemView}
* to reflect the item at the given position.
*
* @param holder The ViewHolder which should be updated to represent the contents of the item at the given position in the data set
@@ -137,11 +142,11 @@ public interface ExpandableItemAdapter payloads);
+ void onBindChildViewHolder(@NonNull CVH holder, int groupPosition, int childPosition, @IntRange(from = ItemViewTypeComposer.MIN_WRAPPED_VIEW_TYPE, to = ItemViewTypeComposer.MAX_WRAPPED_VIEW_TYPE) int viewType, List payloads);
/**
* Called by RecyclerView to display the child data at the specified position.
- * This method should update the contents of the {@link android.support.v7.widget.RecyclerView.ViewHolder#itemView}
+ * This method should update the contents of the {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#itemView}
* to reflect the item at the given position.
*
* @param holder The ViewHolder which should be updated to represent the contents of the item at the given position in the data set
@@ -149,7 +154,7 @@ public interface ExpandableItemAdapterCalled when a user attempt to expand/collapse a group item by tapping.
@@ -163,7 +168,7 @@ public interface ExpandableItemAdapterInterface which provides required information for expanding item.
- * Implement this interface on your sub-class of the {@link android.support.v7.widget.RecyclerView.ViewHolder}.
+ * Implement this interface on your sub-class of the {@link androidx.recyclerview.widget.RecyclerView.ViewHolder}.
*/
public interface ExpandableItemViewHolder {
/**
@@ -31,18 +34,29 @@ public interface ExpandableItemViewHolder {
* - {@link ExpandableItemConstants#STATE_FLAG_IS_CHILD}
* - {@link ExpandableItemConstants#STATE_FLAG_IS_EXPANDED}
* - {@link ExpandableItemConstants#STATE_FLAG_IS_UPDATED}
+ * @see #getExpandState()
*/
void setExpandStateFlags(@ExpandableItemStateFlags int flags);
/**
- * Gets the state flags value for expanding item
+ * Gets the state flags value for expanding item. You can access these flags more human friendly way through {@link #getExpandState()}.
*
* @return Bitwise OR of these flags;
* - {@link ExpandableItemConstants#STATE_FLAG_IS_GROUP}
* - {@link ExpandableItemConstants#STATE_FLAG_IS_CHILD}
* - {@link ExpandableItemConstants#STATE_FLAG_IS_EXPANDED}
* - {@link ExpandableItemConstants#STATE_FLAG_IS_UPDATED}
+ * @see #getExpandState()
*/
@ExpandableItemStateFlags
int getExpandStateFlags();
+
+ /**
+ * Gets the state object for expandable item.
+ * This method can be used inside of the {@link androidx.recyclerview.widget.RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}.
+ *
+ * @return {@link ExpandableItemState} object
+ */
+ @NonNull
+ ExpandableItemState getExpandState();
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandablePositionTranslator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandablePositionTranslator.java
index 70986017..b40aa5fc 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandablePositionTranslator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandablePositionTranslator.java
@@ -16,10 +16,10 @@
package com.h6ah4i.android.widget.advrecyclerview.expandable;
-import android.support.v7.widget.RecyclerView;
-
import java.util.Arrays;
+import androidx.recyclerview.widget.RecyclerView;
+
class ExpandablePositionTranslator {
public static final int BUILD_OPTION_DEFAULT = 0;
public static final int BUILD_OPTION_EXPANDED_ALL = 1;
@@ -167,7 +167,7 @@ public long[] getSavedStateArray() {
for (int i = 0; i < mGroupCount; i++) {
final long t = mCachedGroupPosInfo[i];
- expandedGroups[i] = ((long) mCachedGroupId[i] << 32l) | (t & FLAG_EXPANDED);
+ expandedGroups[i] = ((long) mCachedGroupId[i] << 32L) | (t & FLAG_EXPANDED);
}
Arrays.sort(expandedGroups);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableRecyclerViewWrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableRecyclerViewWrapperAdapter.java
index f9c27569..4611f3f0 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableRecyclerViewWrapperAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableRecyclerViewWrapperAdapter.java
@@ -16,7 +16,6 @@
package com.h6ah4i.android.widget.advrecyclerview.expandable;
-import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.h6ah4i.android.widget.advrecyclerview.adapter.ItemIdComposer;
@@ -33,6 +32,9 @@
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
class ExpandableRecyclerViewWrapperAdapter
extends SimpleWrapperAdapter
implements DraggableItemAdapter,
@@ -151,10 +153,11 @@ public int getItemViewType(int position) {
return (childPosition == RecyclerView.NO_POSITION) ? (type | VIEW_TYPE_FLAG_IS_GROUP) : (type);
}
+ @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (mExpandableItemAdapter == null) {
- return null;
+ throw new IllegalStateException();
}
final int maskedViewType = (viewType & (~VIEW_TYPE_FLAG_IS_GROUP));
@@ -177,7 +180,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
@SuppressWarnings("unchecked")
@Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
if (mExpandableItemAdapter == null) {
return;
}
@@ -225,7 +228,7 @@ private void rebuildPositionTranslator() {
}
@Override
- public void onViewRecycled(RecyclerView.ViewHolder holder, int viewType) {
+ public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder, int viewType) {
if (holder instanceof ExpandableItemViewHolder) {
((ExpandableItemViewHolder) holder).setExpandStateFlags(STATE_FLAG_INITIAL_VALUE);
}
@@ -277,7 +280,7 @@ protected void onHandleWrappedAdapterRangeMoved(int fromPosition, int toPosition
@SuppressWarnings("unchecked")
@Override
- public boolean onCheckCanStartDrag(RecyclerView.ViewHolder holder, int position, int x, int y) {
+ public boolean onCheckCanStartDrag(@NonNull RecyclerView.ViewHolder holder, int position, int x, int y) {
if (!(mExpandableItemAdapter instanceof ExpandableDraggableItemAdapter)) {
return false;
}
@@ -307,7 +310,7 @@ public boolean onCheckCanStartDrag(RecyclerView.ViewHolder holder, int position,
@SuppressWarnings("unchecked")
@Override
- public ItemDraggableRange onGetItemDraggableRange(RecyclerView.ViewHolder holder, int position) {
+ public ItemDraggableRange onGetItemDraggableRange(@NonNull RecyclerView.ViewHolder holder, int position) {
if (!(mExpandableItemAdapter instanceof ExpandableDraggableItemAdapter)) {
return null;
}
@@ -668,7 +671,7 @@ public void onMoveItem(int fromPosition, int toPosition) {
@SuppressWarnings("unchecked")
@Override
- public int onGetSwipeReactionType(RecyclerView.ViewHolder holder, int position, int x, int y) {
+ public int onGetSwipeReactionType(@NonNull RecyclerView.ViewHolder holder, int position, int x, int y) {
if (!(mExpandableItemAdapter instanceof BaseExpandableSwipeableItemAdapter)) {
return RecyclerViewSwipeManager.REACTION_CAN_NOT_SWIPE_ANY;
}
@@ -690,7 +693,7 @@ public int onGetSwipeReactionType(RecyclerView.ViewHolder holder, int position,
@SuppressWarnings("unchecked")
@Override
- public void onSwipeItemStarted(RecyclerView.ViewHolder holder, int position) {
+ public void onSwipeItemStarted(@NonNull RecyclerView.ViewHolder holder, int position) {
if (!(mExpandableItemAdapter instanceof BaseExpandableSwipeableItemAdapter)) {
return;
}
@@ -712,7 +715,7 @@ public void onSwipeItemStarted(RecyclerView.ViewHolder holder, int position) {
@SuppressWarnings("unchecked")
@Override
- public void onSetSwipeBackground(RecyclerView.ViewHolder holder, int position, int type) {
+ public void onSetSwipeBackground(@NonNull RecyclerView.ViewHolder holder, int position, int type) {
if (!(mExpandableItemAdapter instanceof BaseExpandableSwipeableItemAdapter)) {
return;
}
@@ -734,7 +737,7 @@ public void onSetSwipeBackground(RecyclerView.ViewHolder holder, int position, i
@SuppressWarnings("unchecked")
@Override
- public SwipeResultAction onSwipeItem(RecyclerView.ViewHolder holder, int position, int result) {
+ public SwipeResultAction onSwipeItem(@NonNull RecyclerView.ViewHolder holder, int position, int result) {
if (!(mExpandableItemAdapter instanceof BaseExpandableSwipeableItemAdapter)) {
return null;
}
@@ -757,7 +760,7 @@ public SwipeResultAction onSwipeItem(RecyclerView.ViewHolder holder, int positio
// NOTE: This method is called from RecyclerViewExpandableItemManager
/*package*/
@SuppressWarnings("unchecked")
- boolean onTapItem(RecyclerView.ViewHolder holder, int position, int x, int y) {
+ boolean onTapItem(@NonNull RecyclerView.ViewHolder holder, int position, int x, int y) {
if (mExpandableItemAdapter == null) {
return false;
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableSwipeableItemAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableSwipeableItemAdapter.java
index d7475d70..6f697a6d 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableSwipeableItemAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableSwipeableItemAdapter.java
@@ -16,10 +16,11 @@
package com.h6ah4i.android.widget.advrecyclerview.expandable;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public interface ExpandableSwipeableItemAdapter
extends BaseExpandableSwipeableItemAdapter {
@@ -39,7 +40,7 @@ public interface ExpandableSwipeableItemAdapter adapter, RecyclerView.ViewHolder holder,
+ @NonNull BaseExpandableSwipeableItemAdapter, ?> adapter,
+ @NonNull RecyclerView.ViewHolder holder,
int groupPosition, int childPosition, int result) {
if (childPosition == RecyclerView.NO_POSITION) {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/GroupPositionItemDraggableRange.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/GroupPositionItemDraggableRange.java
index 301b1561..3702b466 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/GroupPositionItemDraggableRange.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/GroupPositionItemDraggableRange.java
@@ -18,11 +18,14 @@
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
+import androidx.annotation.NonNull;
+
public class GroupPositionItemDraggableRange extends ItemDraggableRange {
public GroupPositionItemDraggableRange(int start, int end) {
super(start, end);
}
+ @NonNull
protected String getClassName() {
return "GroupPositionItemDraggableRange";
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/RecyclerViewExpandableItemManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/RecyclerViewExpandableItemManager.java
index 65499fb1..b41552ee 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/RecyclerViewExpandableItemManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/RecyclerViewExpandableItemManager.java
@@ -18,10 +18,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
@@ -34,14 +30,19 @@
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
- * Provides item expansion operation for {@link android.support.v7.widget.RecyclerView}
+ * Provides item expansion operation for {@link androidx.recyclerview.widget.RecyclerView}
*/
public class RecyclerViewExpandableItemManager implements ExpandableItemConstants {
private static final String TAG = "ARVExpandableItemMgr";
/**
- * Packed position version of {@link android.support.v7.widget.RecyclerView#NO_POSITION}
+ * Packed position version of {@link androidx.recyclerview.widget.RecyclerView#NO_POSITION}
*/
public static final long NO_EXPANDABLE_POSITION = ExpandableAdapterHelper.NO_EXPANDABLE_POSITION;
@@ -98,12 +99,12 @@ public interface OnGroupCollapseListener {
public RecyclerViewExpandableItemManager(@Nullable Parcelable savedState) {
mInternalUseOnItemTouchListener = new RecyclerView.OnItemTouchListener() {
@Override
- public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
+ public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
return RecyclerViewExpandableItemManager.this.onInterceptTouchEvent(rv, e);
}
@Override
- public void onTouchEvent(RecyclerView rv, MotionEvent e) {
+ public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
}
@Override
@@ -126,12 +127,12 @@ public boolean isReleased() {
}
/**
- * Attaches {@link android.support.v7.widget.RecyclerView} instance.
- * Before calling this method, the target {@link android.support.v7.widget.RecyclerView} must set
+ *
Attaches {@link androidx.recyclerview.widget.RecyclerView} instance.
+ * Before calling this method, the target {@link androidx.recyclerview.widget.RecyclerView} must set
* the wrapped adapter instance which is returned by the
- * {@link #createWrappedAdapter(android.support.v7.widget.RecyclerView.Adapter)} method.
+ * {@link #createWrappedAdapter(androidx.recyclerview.widget.RecyclerView.Adapter)} method.
*
- * @param rv The {@link android.support.v7.widget.RecyclerView} instance
+ * @param rv The {@link androidx.recyclerview.widget.RecyclerView} instance
*/
public void attachRecyclerView(@NonNull RecyclerView rv) {
if (isReleased()) {
@@ -148,7 +149,7 @@ public void attachRecyclerView(@NonNull RecyclerView rv) {
}
/**
- * Detach the {@link android.support.v7.widget.RecyclerView} instance and release internal field references.
+ * Detach the {@link androidx.recyclerview.widget.RecyclerView} instance and release internal field references.
* This method should be called in order to avoid memory leaks.
*/
public void release() {
@@ -169,6 +170,7 @@ public void release() {
* @return Wrapped adapter which is associated to this {@link RecyclerViewExpandableItemManager} instance.
*/
@SuppressWarnings("unchecked")
+ @NonNull
public RecyclerView.Adapter createWrappedAdapter(@NonNull RecyclerView.Adapter adapter) {
if (!adapter.hasStableIds()) {
throw new IllegalArgumentException("The passed adapter does not support stable IDs");
@@ -199,6 +201,7 @@ public RecyclerView.Adapter createWrappedAdapter(@NonNull RecyclerView.Adapter a
*
* @return The Parcelable object which stores information need to restore the internal states.
*/
+ @NonNull
public Parcelable getSavedState() {
long[] adapterSavedState = null;
@@ -209,7 +212,7 @@ public Parcelable getSavedState() {
return new SavedState(adapterSavedState);
}
- /*package*/ boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
+ /*package*/ boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
if (mWrapperAdapter == null) {
return false;
}
@@ -232,7 +235,7 @@ public Parcelable getSavedState() {
return false;
}
- private void handleActionDown(RecyclerView rv, MotionEvent e) {
+ private void handleActionDown(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
final RecyclerView.ViewHolder holder = CustomRecyclerViewUtils.findChildViewHolderUnderWithTranslation(rv, e.getX(), e.getY());
mInitialTouchX = (int) (e.getX() + 0.5f);
@@ -245,7 +248,7 @@ private void handleActionDown(RecyclerView rv, MotionEvent e) {
}
}
- private boolean handleActionUpOrCancel(RecyclerView rv, MotionEvent e) {
+ private boolean handleActionUpOrCancel(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
final long touchedItemId = mTouchedItemId;
final int initialTouchX = mInitialTouchX;
final int initialTouchY = mInitialTouchY;
@@ -391,7 +394,7 @@ public int getFlatPosition(long packedPosition) {
* See {@link #getPackedPositionForChild(int, int)}.
*
* @param packedPosition The packed position from which the child position will be returned.
- * @return The child position portion of the packed position. If this does not contain a child, returns {@link android.support.v7.widget.RecyclerView#NO_POSITION}.
+ * @return The child position portion of the packed position. If this does not contain a child, returns {@link androidx.recyclerview.widget.RecyclerView#NO_POSITION}.
*/
public static int getPackedPositionChild(long packedPosition) {
return ExpandableAdapterHelper.getPackedPositionChild(packedPosition);
@@ -426,7 +429,7 @@ public static long getPackedPositionForGroup(int groupPosition) {
* Gets the group position from a packed position. See {@link #getPackedPositionForChild(int, int)}.
*
* @param packedPosition The packed position from which the group position will be returned.
- * @return THe group position of the packed position. If this does not contain a group, returns {@link android.support.v7.widget.RecyclerView#NO_POSITION}.
+ * @return THe group position of the packed position. If this does not contain a group, returns {@link androidx.recyclerview.widget.RecyclerView#NO_POSITION}.
*/
public static int getPackedPositionGroup(long packedPosition) {
return ExpandableAdapterHelper.getPackedPositionGroup(packedPosition);
@@ -472,7 +475,7 @@ public static long getCombinedGroupId(long groupId) {
/**
* Checks whether the passed view type is a group's one.
*
- * @param rawViewType raw view type value (return value of {@link android.support.v7.widget.RecyclerView.ViewHolder#getItemViewType()})
+ * @param rawViewType raw view type value (return value of {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#getItemViewType()})
* @return True for the a group view type, otherwise false
*/
public static boolean isGroupViewType(int rawViewType) {
@@ -482,7 +485,7 @@ public static boolean isGroupViewType(int rawViewType) {
/**
* Gets group view type from a raw view type.
*
- * @param rawViewType raw view type value (return value of {@link android.support.v7.widget.RecyclerView.ViewHolder#getItemViewType()})
+ * @param rawViewType raw view type value (return value of {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#getItemViewType()})
* @return Group view type for the given raw view type.
*/
public static int getGroupViewType(int rawViewType) {
@@ -492,7 +495,7 @@ public static int getGroupViewType(int rawViewType) {
/**
* Gets child view type from a raw view type.
*
- * @param rawViewType raw view type value (return value of {@link android.support.v7.widget.RecyclerView.ViewHolder#getItemViewType()})
+ * @param rawViewType raw view type value (return value of {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#getItemViewType()})
* @return Child view type for the given raw view type.
*/
public static int getChildViewType(int rawViewType) {
@@ -502,7 +505,7 @@ public static int getChildViewType(int rawViewType) {
/**
* Checks whether the passed item ID is a group's one.
*
- * @param rawId raw item ID value (return value of {@link android.support.v7.widget.RecyclerView.ViewHolder#getItemId()})
+ * @param rawId raw item ID value (return value of {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#getItemId()})
* @return True for the a group view type, otherwise false
*/
public static boolean isGroupItemId(long rawId) {
@@ -512,7 +515,7 @@ public static boolean isGroupItemId(long rawId) {
/**
* Gets group item ID from a raw ID.
*
- * @param rawId raw item ID value (return value of {@link android.support.v7.widget.RecyclerView.ViewHolder#getItemId()})
+ * @param rawId raw item ID value (return value of {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#getItemId()})
* @return Group item ID for the given raw item ID.
*/
public static long getGroupItemId(long rawId) {
@@ -522,7 +525,7 @@ public static long getGroupItemId(long rawId) {
/**
* Gets child item ID from a raw ID.
*
- * @param rawId raw item ID value (return value of {@link android.support.v7.widget.RecyclerView.ViewHolder#getItemId()})
+ * @param rawId raw item ID value (return value of {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#getItemId()})
* @return Child item ID for the given raw item ID.
*/
public static long getChildItemId(long rawId) {
@@ -1052,7 +1055,7 @@ public void scrollToGroupWithTotalChildrenHeight(int groupPosition, int totalChi
* @param path Adapter path for the wrapped adapter returned by the {@link #createWrappedAdapter(RecyclerView.Adapter)}.
*/
@SuppressWarnings("StatementWithEmptyBody")
- public void scrollToGroupWithTotalChildrenHeight(int groupPosition, int totalChildrenHeight, int topMargin, int bottomMargin, AdapterPath path) {
+ public void scrollToGroupWithTotalChildrenHeight(int groupPosition, int totalChildrenHeight, int topMargin, int bottomMargin, @Nullable AdapterPath path) {
long packedPosition = RecyclerViewExpandableItemManager.getPackedPositionForGroup(groupPosition);
int flatPosition = getFlatPosition(packedPosition);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/annotation/ExpandableItemStateFlags.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/annotation/ExpandableItemStateFlags.java
index 8cab45fa..a56b289c 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/annotation/ExpandableItemStateFlags.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/annotation/ExpandableItemStateFlags.java
@@ -15,13 +15,13 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.expandable.annotation;
-import android.support.annotation.IntDef;
-
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
@IntDef(flag = true, value = {
ExpandableItemConstants.STATE_FLAG_IS_GROUP,
ExpandableItemConstants.STATE_FLAG_IS_CHILD,
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/headerfooter/AbstractHeaderFooterWrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/headerfooter/AbstractHeaderFooterWrapperAdapter.java
index 1beef34a..86317efc 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/headerfooter/AbstractHeaderFooterWrapperAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/headerfooter/AbstractHeaderFooterWrapperAdapter.java
@@ -15,9 +15,6 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.headerfooter;
-import android.support.annotation.IntRange;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPathSegment;
@@ -28,6 +25,11 @@
import java.util.List;
+import androidx.annotation.IntRange;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* A simplified version of ComposedAdapter for creating headers and footers.
*/
@@ -67,6 +69,7 @@ public AbstractHeaderFooterWrapperAdapter() {
* @param adapter Wrapped contents adapter.
*/
@SuppressWarnings("unchecked")
+ @NonNull
public AbstractHeaderFooterWrapperAdapter setAdapter(@NonNull RecyclerView.Adapter extends RecyclerView.ViewHolder> adapter) {
if (mWrappedAdapter != null) {
throw new IllegalStateException("setAdapter() can call only once");
@@ -125,6 +128,7 @@ protected RecyclerView.Adapter onCreateFooterAdapter() {
*
* @return Adapter for the header items
*/
+ @Nullable
public RecyclerView.Adapter getHeaderAdapter() {
return mHeaderAdapter;
}
@@ -134,6 +138,7 @@ public RecyclerView.Adapter getHeaderAdapter() {
*
* @return Adapter for the footer items
*/
+ @Nullable
public RecyclerView.Adapter getFooterAdapter() {
return mFooterAdapter;
}
@@ -142,6 +147,7 @@ public RecyclerView.Adapter getFooterAdapter() {
* Returns underlying adapter.
* @return The underlying adapter instance
*/
+ @Nullable
public RecyclerView.Adapter getWrappedAdapter() {
return mWrappedAdapter;
}
@@ -152,6 +158,7 @@ public RecyclerView.Adapter getWrappedAdapter() {
*
* @return AdapterPathSegment for the wrapped adapter
*/
+ @NonNull
public AdapterPathSegment getWrappedAdapterSegment() {
return new AdapterPathSegment(mWrappedAdapter, mWrappedAdapterTag);
}
@@ -161,6 +168,7 @@ public AdapterPathSegment getWrappedAdapterSegment() {
*
* @return AdapterPathSegment for the header adapter
*/
+ @NonNull
public AdapterPathSegment getHeaderSegment() {
return new AdapterPathSegment(mHeaderAdapter, mHeaderAdapterTag);
}
@@ -170,6 +178,7 @@ public AdapterPathSegment getHeaderSegment() {
*
* @return AdapterPathSegment for the footer adapter
*/
+ @NonNull
public AdapterPathSegment getFooterSegment() {
return new AdapterPathSegment(mFooterAdapter, mFooterAdapterTag);
}
@@ -182,11 +191,12 @@ public AdapterPathSegment getFooterSegment() {
* a header adapter position.
* @param viewType The view type of the new header View.
* @return A new ViewHolder for the header that holds a View of the given view type.
- * @see {@link RecyclerView.Adapter#onCreateViewHolder(ViewGroup, int)}
- * @see {@link #getHeaderItemViewType(int)}
- * @see {@link #onBindHeaderItemViewHolder(RecyclerView.ViewHolder, int)}
+ * @see RecyclerView.Adapter#onCreateViewHolder(ViewGroup, int)
+ * @see #getHeaderItemViewType(int)
+ * @see #onBindHeaderItemViewHolder(RecyclerView.ViewHolder, int)
*/
- public abstract HeaderVH onCreateHeaderItemViewHolder(ViewGroup parent, int viewType);
+ @NonNull
+ public abstract HeaderVH onCreateHeaderItemViewHolder(@NonNull ViewGroup parent, int viewType);
/**
* Called when RecyclerView needs a new {@link RecyclerView.ViewHolder} of the
@@ -196,11 +206,12 @@ public AdapterPathSegment getFooterSegment() {
* a footer adapter position.
* @param viewType The view type of the new footer View.
* @return A new ViewHolder for the footer that holds a View of the given view type.
- * @see {@link RecyclerView.Adapter#onCreateViewHolder(ViewGroup, int)}
- * @see {@link #getFooterItemViewType(int)}
- * @see {@link #onBindFooterItemViewHolder(RecyclerView.ViewHolder, int)}
+ * @see RecyclerView.Adapter#onCreateViewHolder(ViewGroup, int)
+ * @see #getFooterItemViewType(int)
+ * @see #onBindFooterItemViewHolder(RecyclerView.ViewHolder, int)
*/
- public abstract FooterVH onCreateFooterItemViewHolder(ViewGroup parent, int viewType);
+ @NonNull
+ public abstract FooterVH onCreateFooterItemViewHolder(@NonNull ViewGroup parent, int viewType);
/**
* Called by RecyclerView to display the data at the specified position. This method should
@@ -210,9 +221,9 @@ public AdapterPathSegment getFooterSegment() {
* @param holder The ViewHolder which should be updated to represent the contents of the
* item at the given position in the data set.
* @param localPosition The position of the item within the header adapter's data set.
- * @see {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}
+ * @see RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)
*/
- public abstract void onBindHeaderItemViewHolder(HeaderVH holder, int localPosition);
+ public abstract void onBindHeaderItemViewHolder(@NonNull HeaderVH holder, int localPosition);
/**
* Called by RecyclerView to display the data at the specified position. This method should
@@ -222,9 +233,9 @@ public AdapterPathSegment getFooterSegment() {
* @param holder The ViewHolder which should be updated to represent the contents of the
* item at the given position in the data set.
* @param localPosition The position of the item within the footer adapter's data set.
- * @see {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}
+ * @see RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)
*/
- public abstract void onBindFooterItemViewHolder(FooterVH holder, int localPosition);
+ public abstract void onBindFooterItemViewHolder(@NonNull FooterVH holder, int localPosition);
/**
* Called by RecyclerView to display the data at the specified position. This method should
@@ -236,9 +247,9 @@ public AdapterPathSegment getFooterSegment() {
* @param localPosition The position of the item within the header adapter's data set.
* @param payloads A non-null list of merged payloads. Can be empty list if requires full
* update.
- * @see {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List)}
+ * @see RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List)
*/
- public void onBindHeaderItemViewHolder(HeaderVH holder, int localPosition, List payloads) {
+ public void onBindHeaderItemViewHolder(@NonNull HeaderVH holder, int localPosition, List payloads) {
onBindHeaderItemViewHolder(holder, localPosition);
}
@@ -252,9 +263,9 @@ public void onBindHeaderItemViewHolder(HeaderVH holder, int localPosition, List<
* @param localPosition The position of the item within the footer adapter's data set.
* @param payloads A non-null list of merged payloads. Can be empty list if requires full
* update.
- * @see {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List)}
+ * @see RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List)
*/
- public void onBindFooterItemViewHolder(FooterVH holder, int localPosition, List payloads) {
+ public void onBindFooterItemViewHolder(@NonNull FooterVH holder, int localPosition, List payloads) {
onBindFooterItemViewHolder(holder, localPosition);
}
@@ -262,7 +273,7 @@ public void onBindFooterItemViewHolder(FooterVH holder, int localPosition, List<
* Returns the total number of items in the data set hold by the header adapter.
*
* @return The total number of items in the header adapter.
- * @see {@link RecyclerView.Adapter#getItemCount()}
+ * @see RecyclerView.Adapter#getItemCount()
*/
public abstract int getHeaderItemCount();
@@ -270,7 +281,7 @@ public void onBindFooterItemViewHolder(FooterVH holder, int localPosition, List<
* Returns the total number of items in the data set hold by the footer adapter.
*
* @return The total number of items in the footer adapter.
- * @see {@link RecyclerView.Adapter#getItemCount()}
+ * @see RecyclerView.Adapter#getItemCount()
*/
public abstract int getFooterItemCount();
@@ -280,7 +291,7 @@ public void onBindFooterItemViewHolder(FooterVH holder, int localPosition, List<
*
* @param localPosition Header adapter position to query
* @return the stable ID of the item at position
- * @see {@link RecyclerView.Adapter#getItemId(int)}
+ * @see RecyclerView.Adapter#getItemId(int)
*/
@IntRange(from = ItemIdComposer.MIN_WRAPPED_ID, to = ItemIdComposer.MAX_WRAPPED_ID)
public long getHeaderItemId(int localPosition) {
@@ -294,9 +305,9 @@ public long getHeaderItemId(int localPosition) {
* Return the stable ID for the item at localPosition
. If {@link #hasStableIds()}
* would return false this method should return {@link RecyclerView#NO_ID}.
*
- * @param localPosition Foote adapter position to query
+ * @param localPosition Footer adapter position to query
* @return the stable ID of the item at position
- * @see {@link RecyclerView.Adapter#getItemId(int)}
+ * @see RecyclerView.Adapter#getItemId(int)
*/
@IntRange(from = ItemIdComposer.MIN_WRAPPED_ID, to = ItemIdComposer.MAX_WRAPPED_ID)
public long getFooterItemId(int localPosition) {
@@ -362,19 +373,20 @@ public int getItemViewType(int position) {
return mHolder.getHeaderItemViewType(position);
}
+ @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return mHolder.onCreateHeaderItemViewHolder(parent, viewType);
}
@Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
throw new IllegalStateException();
}
@Override
@SuppressWarnings("unchecked")
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
mHolder.onBindHeaderItemViewHolder(holder, position, payloads);
}
}
@@ -401,19 +413,20 @@ public int getItemViewType(int position) {
return mHolder.getFooterItemViewType(position);
}
+ @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return mHolder.onCreateFooterItemViewHolder(parent, viewType);
}
@Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
throw new IllegalStateException();
}
@Override
@SuppressWarnings("unchecked")
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
mHolder.onBindFooterItemViewHolder(holder, position, payloads);
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/ItemSlidingAnimator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/ItemSlidingAnimator.java
index c2ae2b7f..dd46baa5 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/ItemSlidingAnimator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/ItemSlidingAnimator.java
@@ -18,11 +18,6 @@
import android.graphics.Rect;
import android.os.Build;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v4.view.ViewPropertyAnimatorListener;
-import android.support.v4.view.ViewPropertyAnimatorUpdateListener;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@@ -37,6 +32,12 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.ViewPropertyAnimatorCompat;
+import androidx.core.view.ViewPropertyAnimatorListener;
+import androidx.core.view.ViewPropertyAnimatorUpdateListener;
+import androidx.recyclerview.widget.RecyclerView;
+
public class ItemSlidingAnimator {
private static final String TAG = "ItemSlidingAnimator";
@@ -136,12 +137,12 @@ private boolean slideToSpecifiedPositionInternal(
final int translationX;
translationX = (int) ((proportional ? width * amount : amount) + 0.5f);
return animateSlideInternalCompat(
- holder, horizontal, translationX, 0, duration, interpolator, swipeFinish);
+ holder, true, translationX, 0, duration, interpolator, swipeFinish);
} else if (!horizontal && (!proportional || height != 0)) {
final int translationY;
translationY = (int) ((proportional ? height * amount : amount) + 0.5f);
return animateSlideInternalCompat(
- holder, horizontal, 0, translationY, duration, interpolator, swipeFinish);
+ holder, false, 0, translationY, duration, interpolator, swipeFinish);
} else {
if (swipeFinish != null) {
throw new IllegalStateException(
@@ -414,13 +415,13 @@ protected void onProcess(RecyclerView.ViewHolder holder) {
final int translationX;
translationX = (int) (width * mPosition + 0.5f);
- slideInternalCompat(holder, mHorizontal, translationX, 0);
+ slideInternalCompat(holder, true, translationX, 0);
} else {
final int height = containerView.getHeight();
final int translationY;
translationY = (int) (height * mPosition + 0.5f);
- slideInternalCompat(holder, mHorizontal, 0, translationY);
+ slideInternalCompat(holder, false, 0, translationY);
}
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RecyclerViewSwipeManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RecyclerViewSwipeManager.java
index 1a722e71..b7a70a8c 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RecyclerViewSwipeManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RecyclerViewSwipeManager.java
@@ -20,9 +20,6 @@
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -36,8 +33,12 @@
import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
- * Provides item swipe operation for {@link android.support.v7.widget.RecyclerView}
+ * Provides item swipe operation for {@link androidx.recyclerview.widget.RecyclerView}
*/
@SuppressWarnings("PointlessBitwiseExpression")
public class RecyclerViewSwipeManager implements SwipeableItemConstants {
@@ -111,12 +112,12 @@ public interface OnItemSwipeEventListener {
public RecyclerViewSwipeManager() {
mInternalUseOnItemTouchListener = new RecyclerView.OnItemTouchListener() {
@Override
- public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
+ public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
return RecyclerViewSwipeManager.this.onInterceptTouchEvent(rv, e);
}
@Override
- public void onTouchEvent(RecyclerView rv, MotionEvent e) {
+ public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
RecyclerViewSwipeManager.this.onTouchEvent(rv, e);
}
@@ -136,6 +137,7 @@ public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
* @return Wrapped adapter which is associated to this {@link RecyclerViewSwipeManager} instance.
*/
@SuppressWarnings("unchecked")
+ @NonNull
public RecyclerView.Adapter createWrappedAdapter(@NonNull RecyclerView.Adapter adapter) {
if (!adapter.hasStableIds()) {
throw new IllegalArgumentException("The passed adapter does not support stable IDs");
@@ -160,12 +162,12 @@ public boolean isReleased() {
}
/**
- * Attaches {@link android.support.v7.widget.RecyclerView} instance.
- * Before calling this method, the target {@link android.support.v7.widget.RecyclerView} must set
+ *
Attaches {@link androidx.recyclerview.widget.RecyclerView} instance.
+ * Before calling this method, the target {@link androidx.recyclerview.widget.RecyclerView} must set
* the wrapped adapter instance which is returned by the
- * {@link #createWrappedAdapter(android.support.v7.widget.RecyclerView.Adapter)} method.
+ * {@link #createWrappedAdapter(androidx.recyclerview.widget.RecyclerView.Adapter)} method.
*
- * @param rv The {@link android.support.v7.widget.RecyclerView} instance
+ * @param rv The {@link androidx.recyclerview.widget.RecyclerView} instance
*/
public void attachRecyclerView(@NonNull RecyclerView rv) {
if (isReleased()) {
@@ -200,7 +202,7 @@ public void attachRecyclerView(@NonNull RecyclerView rv) {
}
/**
- * Detach the {@link android.support.v7.widget.RecyclerView} instance and release internal field references.
+ * Detach the {@link androidx.recyclerview.widget.RecyclerView} instance and release internal field references.
* This method should be called in order to avoid memory leaks.
*/
public void release() {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RemovingItemDecorator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RemovingItemDecorator.java
index 0202dc1b..a1d955ae 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RemovingItemDecorator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RemovingItemDecorator.java
@@ -19,8 +19,6 @@
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.Interpolator;
@@ -28,6 +26,10 @@
import java.lang.ref.WeakReference;
+import androidx.annotation.NonNull;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
class RemovingItemDecorator extends RecyclerView.ItemDecoration {
@SuppressWarnings("unused")
private static final String TAG = "RemovingItemDecorator";
@@ -71,7 +73,7 @@ public void setMoveAnimationInterpolator(Interpolator interpolator) {
}
@Override
- public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
+ public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
final long elapsedTime = getElapsedTime(mStartTime);
final float scale = determineBackgroundScaleSwipeCompletedSuccessfully(elapsedTime);
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemAdapter.java
index 7202bda9..533721bb 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemAdapter.java
@@ -16,13 +16,15 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemDrawableTypes;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemReactions;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemResults;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public interface SwipeableItemAdapter {
/**
@@ -48,7 +50,7 @@ public interface SwipeableItemAdapter {
* - {@link SwipeableItemConstants#REACTION_CAN_SWIPE_DOWN}
*/
@SwipeableItemReactions
- int onGetSwipeReactionType(T holder, int position, int x, int y);
+ int onGetSwipeReactionType(@NonNull T holder, int position, int x, int y);
/**
* Called when started swiping an item.
@@ -58,7 +60,7 @@ public interface SwipeableItemAdapter {
* @param holder The ViewHolder that is associated the swiped item.
* @param position The position of the item within the adapter's data set.
*/
- void onSwipeItemStarted(T holder, int position);
+ void onSwipeItemStarted(@NonNull T holder, int position);
/**
* Called when sets background of the swiping item.
@@ -72,7 +74,7 @@ public interface SwipeableItemAdapter {
* {@link SwipeableItemConstants#DRAWABLE_SWIPE_RIGHT_BACKGROUND} or
* {@link SwipeableItemConstants#DRAWABLE_SWIPE_DOWN_BACKGROUND}.
*/
- void onSetSwipeBackground(T holder, int position, @SwipeableItemDrawableTypes int type);
+ void onSetSwipeBackground(@NonNull T holder, int position, @SwipeableItemDrawableTypes int type);
/**
* Called when an item is swiped.
@@ -90,5 +92,6 @@ public interface SwipeableItemAdapter {
*
* @return {@link SwipeResultAction} object.
*/
- SwipeResultAction onSwipeItem(T holder, int position, @SwipeableItemResults int result);
+ @Nullable
+ SwipeResultAction onSwipeItem(@NonNull T holder, int position, @SwipeableItemResults int result);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemConstants.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemConstants.java
index e26849ac..70fcec1a 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemConstants.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemConstants.java
@@ -16,13 +16,16 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable;
-import android.support.v7.widget.RecyclerView;
+import android.annotation.SuppressLint;
+
+import androidx.recyclerview.widget.RecyclerView;
public interface SwipeableItemConstants {
/**
* State flag for the {@link SwipeableItemViewHolder#setSwipeStateFlags(int)} and {@link SwipeableItemViewHolder#getSwipeStateFlags()} methods.
* Indicates that currently performing swiping.
*/
+ @SuppressWarnings("PointlessBitwiseExpression")
int STATE_FLAG_SWIPING = (1 << 0);
/**
@@ -35,6 +38,7 @@ public interface SwipeableItemConstants {
* State flag for the {@link SwipeableItemViewHolder#setSwipeStateFlags(int)} and {@link SwipeableItemViewHolder#getSwipeStateFlags()} methods.
* If this flag is set, some other flags are changed and require to apply.
*/
+ @SuppressWarnings("NumericOverflow")
int STATE_FLAG_IS_UPDATED = (1 << 31);
@@ -83,126 +87,126 @@ public interface SwipeableItemConstants {
// ---
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe any direction"
*/
int REACTION_CAN_NOT_SWIPE_ANY = 0;
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe left" (completely no reactions)
*/
int REACTION_CAN_NOT_SWIPE_LEFT = (InternalConstants.REACTION_CAN_NOT_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_LEFT);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe left" (not swipeable, but rubber-band effect applied)
*/
int REACTION_CAN_NOT_SWIPE_LEFT_WITH_RUBBER_BAND_EFFECT = (InternalConstants.REACTION_CAN_NOT_SWIPE_WITH_RUBBER_BAND_EFFECT << InternalConstants.BIT_SHIFT_AMOUNT_LEFT);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can swipe left"
*/
int REACTION_CAN_SWIPE_LEFT = (InternalConstants.REACTION_CAN_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_LEFT);
/**
* Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* If this flag is specified, swipe operation will not start even if user swipe an item to the LEFT direction.
*/
int REACTION_MASK_START_SWIPE_LEFT = (InternalConstants.REACTION_MASK_START_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_LEFT);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe up" (completely no reactions)
*/
int REACTION_CAN_NOT_SWIPE_UP = (InternalConstants.REACTION_CAN_NOT_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_UP);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe up" (not swipeable, but rubber-band effect applied)
*/
int REACTION_CAN_NOT_SWIPE_UP_WITH_RUBBER_BAND_EFFECT = (InternalConstants.REACTION_CAN_NOT_SWIPE_WITH_RUBBER_BAND_EFFECT << InternalConstants.BIT_SHIFT_AMOUNT_UP);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can swipe up"
*/
int REACTION_CAN_SWIPE_UP = (InternalConstants.REACTION_CAN_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_UP);
/**
* Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* If this flag is specified, swipe operation will not start even if user swipe an item to the UP direction.
*/
int REACTION_MASK_START_SWIPE_UP = (InternalConstants.REACTION_MASK_START_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_UP);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe right" (completely no reactions)
*/
int REACTION_CAN_NOT_SWIPE_RIGHT = (InternalConstants.REACTION_CAN_NOT_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_RIGHT);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe right" (not swipeable, but rubber-band effect applied)
*/
int REACTION_CAN_NOT_SWIPE_RIGHT_WITH_RUBBER_BAND_EFFECT = (InternalConstants.REACTION_CAN_NOT_SWIPE_WITH_RUBBER_BAND_EFFECT << InternalConstants.BIT_SHIFT_AMOUNT_RIGHT);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can swipe right"
*/
int REACTION_CAN_SWIPE_RIGHT = (InternalConstants.REACTION_CAN_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_RIGHT);
/**
* Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* If this flag is specified, swipe operation will not start even if user swipe an item to the RIGHT direction.
*/
int REACTION_MASK_START_SWIPE_RIGHT = (InternalConstants.REACTION_MASK_START_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_RIGHT);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe down" (completely no reactions)
*/
int REACTION_CAN_NOT_SWIPE_DOWN = (InternalConstants.REACTION_CAN_NOT_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_DOWN);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can not swipe down" (not swipeable, but rubber-band effect applied)
*/
int REACTION_CAN_NOT_SWIPE_DOWN_WITH_RUBBER_BAND_EFFECT = (InternalConstants.REACTION_CAN_NOT_SWIPE_WITH_RUBBER_BAND_EFFECT << InternalConstants.BIT_SHIFT_AMOUNT_DOWN);
/**
* Reaction type to swipe operation. Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* Indicates "can swipe down"
*/
int REACTION_CAN_SWIPE_DOWN = (InternalConstants.REACTION_CAN_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_DOWN);
/**
* Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* If this flag is specified, swipe operation will not start even if user swipe an item to the left direction.
*/
int REACTION_MASK_START_SWIPE_DOWN = (InternalConstants.REACTION_MASK_START_SWIPE << InternalConstants.BIT_SHIFT_AMOUNT_DOWN);
/**
* Used for the return value of the
- * {@link SwipeableItemAdapter#onGetSwipeReactionType(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method.
+ * {@link SwipeableItemAdapter#onGetSwipeReactionType(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int, int)} method.
* If this flag is specified, swiping starts on long press.
*/
int REACTION_START_SWIPE_ON_LONG_PRESS = InternalConstants.REACTION_START_SWIPE_ON_LONG_PRESS;
@@ -247,56 +251,37 @@ public interface SwipeableItemConstants {
int REACTION_CAN_SWIPE_BOTH_V =
REACTION_CAN_SWIPE_UP | REACTION_CAN_SWIPE_DOWN;
- // ---
-
- /**
- * @deprecated Use {@link #REACTION_CAN_NOT_SWIPE_ANY} directly.
- */
- int REACTION_CAN_NOT_SWIPE_BOTH = REACTION_CAN_NOT_SWIPE_ANY;
-
- /**
- * @deprecated Use {@link #REACTION_CAN_NOT_SWIPE_BOTH_H_WITH_RUBBER_BAND_EFFECT} directly.
- */
- int REACTION_CAN_NOT_SWIPE_BOTH_WITH_RUBBER_BAND_EFFECT = REACTION_CAN_NOT_SWIPE_BOTH_H_WITH_RUBBER_BAND_EFFECT;
-
- /**
- * @deprecated Use {@link #REACTION_CAN_SWIPE_BOTH_H} directly.
- */
- int REACTION_CAN_SWIPE_BOTH = REACTION_CAN_SWIPE_BOTH_H;
-
- // ---
-
/**
* Background drawable type used for the second argument of the
- * {@link SwipeableItemAdapter#onSetSwipeBackground(android.support.v7.widget.RecyclerView.ViewHolder, int, int)} method.
+ * {@link SwipeableItemAdapter#onSetSwipeBackground(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int)} method.
* Background image for the neutral (= not swiping) item.
*/
int DRAWABLE_SWIPE_NEUTRAL_BACKGROUND = 0;
/**
* Background drawable type used for the second argument of the
- * {@link SwipeableItemAdapter#onSetSwipeBackground(android.support.v7.widget.RecyclerView.ViewHolder, int, int)} method.
+ * {@link SwipeableItemAdapter#onSetSwipeBackground(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int)} method.
* Background image for the swiping-left item.
*/
int DRAWABLE_SWIPE_LEFT_BACKGROUND = 1;
/**
* Background drawable type used for the second argument of the
- * {@link SwipeableItemAdapter#onSetSwipeBackground(android.support.v7.widget.RecyclerView.ViewHolder, int, int)} method.
+ * {@link SwipeableItemAdapter#onSetSwipeBackground(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int)} method.
* Background image for the swiping-up item.
*/
int DRAWABLE_SWIPE_UP_BACKGROUND = 2;
/**
* Background drawable type used for the second argument of the
- * {@link SwipeableItemAdapter#onSetSwipeBackground(android.support.v7.widget.RecyclerView.ViewHolder, int, int)} method.
+ * {@link SwipeableItemAdapter#onSetSwipeBackground(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int)} method.
* Background image for the swiping-right item.
*/
int DRAWABLE_SWIPE_RIGHT_BACKGROUND = 3;
/**
* Background drawable type used for the second argument of the
- * {@link SwipeableItemAdapter#onSetSwipeBackground(android.support.v7.widget.RecyclerView.ViewHolder, int, int)} method.
+ * {@link SwipeableItemAdapter#onSetSwipeBackground(androidx.recyclerview.widget.RecyclerView.ViewHolder, int, int)} method.
* Background image for the swiping-down item.
*/
int DRAWABLE_SWIPE_DOWN_BACKGROUND = 4;
@@ -319,6 +304,7 @@ public interface SwipeableItemConstants {
* After-reaction type used for the {@link SwipeableItemViewHolder#setAfterSwipeReaction(int)} and {@link SwipeableItemViewHolder#getAfterSwipeReaction()} methods.
* Represents that the item moved to swiped direction.
*/
+ @SuppressLint("ShiftFlags")
int AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION = 2;
/**
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemState.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemState.java
new file mode 100644
index 00000000..a3da1d2e
--- /dev/null
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemState.java
@@ -0,0 +1,46 @@
+package com.h6ah4i.android.widget.advrecyclerview.swipeable;
+
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemStateFlags;
+
+/**
+ * Helper class for decoding {@link SwipeableItemViewHolder#getSwipeStateFlags()} flag values.
+ */
+public class SwipeableItemState {
+ private int mFlags;
+
+ @SwipeableItemStateFlags
+ public int getFlags() {
+ return mFlags;
+ }
+
+ public void setFlags(@SwipeableItemStateFlags int flags) {
+ mFlags = flags;
+ }
+
+ /**
+ * Checks whether the swiping is currently performed.
+ *
+ * @return True if the user is swiping an item, otherwise else.
+ */
+ public boolean isSwiping() {
+ return (mFlags & SwipeableItemConstants.STATE_FLAG_SWIPING) != 0;
+ }
+
+ /**
+ * Checks whether the item is being dragged.
+ *
+ * @return True if the associated item is being swiped, otherwise false.
+ */
+ public boolean isActive() {
+ return (mFlags & SwipeableItemConstants.STATE_FLAG_IS_ACTIVE) != 0;
+ }
+
+ /**
+ * Checks whether state flags are changed or not.
+ *
+ * @return True if flags are updated, otherwise false.
+ */
+ public boolean isUpdated() {
+ return (mFlags & SwipeableItemConstants.STATE_FLAG_IS_UPDATED) != 0;
+ }
+}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemViewHolder.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemViewHolder.java
index 9031b872..0d7ccb4d 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemViewHolder.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemViewHolder.java
@@ -16,15 +16,17 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable;
-import android.support.annotation.Nullable;
import android.view.View;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemAfterReactions;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Interface which provides required information for swiping item.
*
- * Implement this interface on your sub-class of the {@link android.support.v7.widget.RecyclerView.ViewHolder}.
+ * Implement this interface on your sub-class of the {@link androidx.recyclerview.widget.RecyclerView.ViewHolder}.
*/
public interface SwipeableItemViewHolder {
/**
@@ -34,19 +36,30 @@ public interface SwipeableItemViewHolder {
* - {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants#STATE_FLAG_SWIPING}
* - {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants#STATE_FLAG_IS_ACTIVE}
* - {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants#STATE_FLAG_IS_UPDATED}
+ * @see #getSwipeState()
*/
void setSwipeStateFlags(int flags);
/**
- * Gets the state flags value for swiping item
+ * Gets the state flags value for swiping item. You can access these flags more human friendly way through {@link #getSwipeState()}.
*
* @return Bitwise OR of these flags;
* - {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants#STATE_FLAG_SWIPING}
* - {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants#STATE_FLAG_IS_ACTIVE}
* - {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants#STATE_FLAG_IS_UPDATED}
+ * @see #getSwipeState()
*/
int getSwipeStateFlags();
+ /**
+ * Gets the state object for swipeable item.
+ * This method can be used inside of the {@link androidx.recyclerview.widget.RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}.
+ *
+ * @return {@link SwipeableItemState} object
+ */
+ @NonNull
+ SwipeableItemState getSwipeState();
+
/**
* Sets the result code of swiping item.
*
@@ -222,7 +235,7 @@ public interface SwipeableItemViewHolder {
*
* @return The container view instance.
*/
- @Nullable
+ @NonNull
View getSwipeableContainerView();
/**
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemWrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemWrapperAdapter.java
index ef8f0e3d..0c1e3388 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemWrapperAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemWrapperAdapter.java
@@ -16,19 +16,21 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
+import com.h6ah4i.android.widget.advrecyclerview.adapter.SimpleWrapperAdapter;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction;
-import com.h6ah4i.android.widget.advrecyclerview.utils.BaseWrapperAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
import java.util.List;
-class SwipeableItemWrapperAdapter extends BaseWrapperAdapter {
+import androidx.annotation.NonNull;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
+class SwipeableItemWrapperAdapter extends SimpleWrapperAdapter {
private static final String TAG = "ARVSwipeableWrapper";
private interface Constants extends SwipeableItemConstants {
@@ -69,7 +71,7 @@ protected void onRelease() {
}
@Override
- public void onViewRecycled(VH holder, int viewType) {
+ public void onViewRecycled(@NonNull VH holder, int viewType) {
super.onViewRecycled(holder, viewType);
if ((mSwipingItemId != RecyclerView.NO_ID) && (mSwipingItemId == holder.getItemId())) {
@@ -103,8 +105,9 @@ public void onViewRecycled(VH holder, int viewType) {
}
}
+ @NonNull
@Override
- public VH onCreateViewHolder(ViewGroup parent, int viewType) {
+ public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
final VH holder = super.onCreateViewHolder(parent, viewType);
if (holder instanceof SwipeableItemViewHolder) {
@@ -115,7 +118,7 @@ public VH onCreateViewHolder(ViewGroup parent, int viewType) {
}
@Override
- public void onBindViewHolder(VH holder, int position, List payloads) {
+ public void onBindViewHolder(@NonNull VH holder, int position, @NonNull List payloads) {
float prevSwipeItemSlideAmount = 0;
SwipeableItemViewHolder swipeableHolder = (holder instanceof SwipeableItemViewHolder) ? (((SwipeableItemViewHolder) holder)) : null;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableViewHolderUtils.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableViewHolderUtils.java
index ddc4521d..bb61dcd1 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableViewHolderUtils.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableViewHolderUtils.java
@@ -15,11 +15,13 @@
*/
package com.h6ah4i.android.widget.advrecyclerview.swipeable;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
class SwipeableViewHolderUtils {
- public static View getSwipeableContainerView(RecyclerView.ViewHolder vh) {
+ public static View getSwipeableContainerView(@Nullable RecyclerView.ViewHolder vh) {
if (vh instanceof SwipeableItemViewHolder) {
return getSwipeableContainerView((SwipeableItemViewHolder) vh);
} else {
@@ -27,7 +29,7 @@ public static View getSwipeableContainerView(RecyclerView.ViewHolder vh) {
}
}
- public static View getSwipeableContainerView(SwipeableItemViewHolder vh) {
+ public static View getSwipeableContainerView(@Nullable SwipeableItemViewHolder vh) {
if (vh instanceof RecyclerView.ViewHolder) {
View containerView = vh.getSwipeableContainerView();
View itemView = ((RecyclerView.ViewHolder) vh).itemView;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipingItemOperator.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipingItemOperator.java
index 119de77a..3eafbe6d 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipingItemOperator.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipingItemOperator.java
@@ -16,10 +16,11 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.animation.Interpolator;
+import androidx.recyclerview.widget.RecyclerView;
+
class SwipingItemOperator {
@SuppressWarnings("unused")
private static final String TAG = "SwipingItemOperator";
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/action/SwipeResultAction.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/action/SwipeResultAction.java
index d04bc47c..912db58f 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/action/SwipeResultAction.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/action/SwipeResultAction.java
@@ -16,7 +16,7 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable.action;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
public abstract class SwipeResultAction {
private final int mResultAction;
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemAfterReactions.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemAfterReactions.java
index 237d07b8..e100d2f2 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemAfterReactions.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemAfterReactions.java
@@ -16,13 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation;
-import android.support.annotation.IntDef;
-
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
@IntDef(flag = true, value = {
/*SwipeableItemConstants.AFTER_SWIPE_REACTION_DEFAULT,*/
SwipeableItemConstants.AFTER_SWIPE_REACTION_MOVE_TO_ORIGIN,
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemDrawableTypes.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemDrawableTypes.java
index 6a99a59b..96501ab1 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemDrawableTypes.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemDrawableTypes.java
@@ -16,13 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation;
-import android.support.annotation.IntDef;
-
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
@IntDef(flag = false, value = {
SwipeableItemConstants.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND,
SwipeableItemConstants.DRAWABLE_SWIPE_LEFT_BACKGROUND,
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemReactions.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemReactions.java
index 5c2e3b7c..1e5f1f75 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemReactions.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemReactions.java
@@ -17,14 +17,14 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation;
import android.annotation.SuppressLint;
-import android.support.annotation.IntDef;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-@SuppressWarnings("deprecation")
+import androidx.annotation.IntDef;
+
@SuppressLint("UniqueConstants")
@IntDef(flag = true, value = {
SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_ANY,
@@ -50,9 +50,6 @@
SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_V,
SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_V_WITH_RUBBER_BAND_EFFECT,
SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH_V,
- SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH,
- SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_WITH_RUBBER_BAND_EFFECT,
- SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH,
SwipeableItemConstants.REACTION_START_SWIPE_ON_LONG_PRESS,
})
@Retention(RetentionPolicy.SOURCE)
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemResults.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemResults.java
index a8e90f69..04612d22 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemResults.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemResults.java
@@ -16,13 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation;
-import android.support.annotation.IntDef;
-
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
@IntDef(flag = false, value = {
SwipeableItemConstants.RESULT_NONE,
SwipeableItemConstants.RESULT_CANCELED,
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemStateFlags.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemStateFlags.java
index 955bb6e8..eb9ef2a3 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemStateFlags.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemStateFlags.java
@@ -16,13 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation;
-import android.support.annotation.IntDef;
-
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
@IntDef(flag = true, value = {
SwipeableItemConstants.STATE_FLAG_SWIPING,
SwipeableItemConstants.STATE_FLAG_IS_ACTIVE,
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/touchguard/RecyclerViewTouchActionGuardManager.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/touchguard/RecyclerViewTouchActionGuardManager.java
index 2b7fdcd3..e02fba0d 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/touchguard/RecyclerViewTouchActionGuardManager.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/touchguard/RecyclerViewTouchActionGuardManager.java
@@ -16,12 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.touchguard;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* Hooks touch events to avoid unexpected scrolling.
*/
@@ -46,12 +47,12 @@ public class RecyclerViewTouchActionGuardManager {
public RecyclerViewTouchActionGuardManager() {
mInternalUseOnItemTouchListener = new RecyclerView.OnItemTouchListener() {
@Override
- public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
+ public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
return RecyclerViewTouchActionGuardManager.this.onInterceptTouchEvent(rv, e);
}
@Override
- public void onTouchEvent(RecyclerView rv, MotionEvent e) {
+ public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
RecyclerViewTouchActionGuardManager.this.onTouchEvent(rv, e);
}
@@ -71,9 +72,9 @@ public boolean isReleased() {
}
/**
- * Attaches {@link android.support.v7.widget.RecyclerView} instance.
+ * Attaches {@link androidx.recyclerview.widget.RecyclerView} instance.
*
- * @param rv The {@link android.support.v7.widget.RecyclerView} instance
+ * @param rv The {@link androidx.recyclerview.widget.RecyclerView} instance
*/
public void attachRecyclerView(@NonNull RecyclerView rv) {
if (isReleased()) {
@@ -91,7 +92,7 @@ public void attachRecyclerView(@NonNull RecyclerView rv) {
}
/**
- * Detach the {@link android.support.v7.widget.RecyclerView} instance and release internal field references.
+ * Detach the {@link androidx.recyclerview.widget.RecyclerView} instance and release internal field references.
*
* This method should be called in order to avoid memory leaks.
*/
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableItemViewHolder.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableItemViewHolder.java
index 9f588219..e8028d9d 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableItemViewHolder.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableItemViewHolder.java
@@ -16,28 +16,45 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class AbstractDraggableItemViewHolder extends RecyclerView.ViewHolder implements DraggableItemViewHolder {
- @DraggableItemStateFlags
- private int mDragStateFlags;
+ private final DraggableItemState mDragState = new DraggableItemState();
- public AbstractDraggableItemViewHolder(View itemView) {
+ public AbstractDraggableItemViewHolder(@NonNull View itemView) {
super(itemView);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setDragStateFlags(@DraggableItemStateFlags int flags) {
- mDragStateFlags = flags;
+ mDragState.setFlags(flags);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
@DraggableItemStateFlags
public int getDragStateFlags() {
- return mDragStateFlags;
+ return mDragState.getFlags();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @NonNull
+ public DraggableItemState getDragState() {
+ return mDragState;
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableSwipeableItemViewHolder.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableSwipeableItemViewHolder.java
index d84d183a..29fafb98 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableSwipeableItemViewHolder.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableSwipeableItemViewHolder.java
@@ -18,25 +18,42 @@
import android.view.View;
+import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemState;
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags;
+import androidx.annotation.NonNull;
+
public abstract class AbstractDraggableSwipeableItemViewHolder extends AbstractSwipeableItemViewHolder implements DraggableItemViewHolder {
- @DraggableItemStateFlags
- private int mDragStateFlags;
+ private final DraggableItemState mDragState = new DraggableItemState();
- public AbstractDraggableSwipeableItemViewHolder(View itemView) {
+ public AbstractDraggableSwipeableItemViewHolder(@NonNull View itemView) {
super(itemView);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setDragStateFlags(@DraggableItemStateFlags int flags) {
- mDragStateFlags = flags;
+ mDragState.setFlags(flags);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
@DraggableItemStateFlags
public int getDragStateFlags() {
- return mDragStateFlags;
+ return mDragState.getFlags();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @NonNull
+ public DraggableItemState getDragState() {
+ return mDragState;
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemAdapter.java
index 4e210368..bcf5ba08 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemAdapter.java
@@ -16,13 +16,16 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemAdapter;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class AbstractExpandableItemAdapter
extends RecyclerView.Adapter
implements ExpandableItemAdapter {
@@ -36,9 +39,10 @@ public abstract class AbstractExpandableItemAdapter payloads) {
+ public void onBindGroupViewHolder(@NonNull GVH holder, int groupPosition, int viewType, @NonNull List payloads) {
onBindGroupViewHolder(holder, groupPosition, viewType);
}
@@ -116,7 +120,7 @@ public void onBindGroupViewHolder(GVH holder, int groupPosition, int viewType, L
* {@inheritDoc}
*/
@Override
- public void onBindChildViewHolder(CVH holder, int groupPosition, int childPosition, int viewType, List payloads) {
+ public void onBindChildViewHolder(@NonNull CVH holder, int groupPosition, int childPosition, int viewType, @NonNull List payloads) {
onBindChildViewHolder(holder, groupPosition, childPosition, viewType);
}
@@ -134,7 +138,7 @@ public boolean onHookGroupExpand(int groupPosition, boolean fromUser) {
* {@inheritDoc}
*/
@Override
- public boolean onHookGroupExpand(int groupPosition, boolean fromUser, Object payload) {
+ public boolean onHookGroupExpand(int groupPosition, boolean fromUser, @Nullable Object payload) {
return onHookGroupExpand(groupPosition, fromUser);
}
@@ -152,7 +156,7 @@ public boolean onHookGroupCollapse(int groupPosition, boolean fromUser) {
* {@inheritDoc}
*/
@Override
- public boolean onHookGroupCollapse(int groupPosition, boolean fromUser, Object payload) {
+ public boolean onHookGroupCollapse(int groupPosition, boolean fromUser, @Nullable Object payload) {
return onHookGroupCollapse(groupPosition, fromUser);
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemViewHolder.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemViewHolder.java
index 9ee86662..278c37ae 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemViewHolder.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemViewHolder.java
@@ -16,28 +16,45 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
+import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemState;
import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.expandable.annotation.ExpandableItemStateFlags;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class AbstractExpandableItemViewHolder extends RecyclerView.ViewHolder implements ExpandableItemViewHolder {
- @ExpandableItemStateFlags
- private int mExpandStateFlags;
+ private final ExpandableItemState mExpandState = new ExpandableItemState();
- public AbstractExpandableItemViewHolder(View itemView) {
+ public AbstractExpandableItemViewHolder(@NonNull View itemView) {
super(itemView);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setExpandStateFlags(@ExpandableItemStateFlags int flags) {
- mExpandStateFlags = flags;
+ mExpandState.setFlags(flags);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
@ExpandableItemStateFlags
public int getExpandStateFlags() {
- return mExpandStateFlags;
+ return mExpandState.getFlags();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @NonNull
+ public ExpandableItemState getExpandState() {
+ return mExpandState;
}
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractSwipeableItemViewHolder.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractSwipeableItemViewHolder.java
index 803112b6..1616c445 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractSwipeableItemViewHolder.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractSwipeableItemViewHolder.java
@@ -16,18 +16,20 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager;
+import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemState;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemViewHolder;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemAfterReactions;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemResults;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemStateFlags;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public abstract class AbstractSwipeableItemViewHolder extends RecyclerView.ViewHolder implements SwipeableItemViewHolder {
- @SwipeableItemStateFlags
- private int mSwipeStateFlags;
+ private SwipeableItemState mSwipeState = new SwipeableItemState();
@SwipeableItemResults
private int mSwipeResult = RecyclerViewSwipeManager.RESULT_NONE;
@SwipeableItemAfterReactions
@@ -40,19 +42,25 @@ public abstract class AbstractSwipeableItemViewHolder extends RecyclerView.ViewH
private float mMaxRightSwipeAmount = RecyclerViewSwipeManager.OUTSIDE_OF_THE_WINDOW_RIGHT;
private float mMaxDownSwipeAmount = RecyclerViewSwipeManager.OUTSIDE_OF_THE_WINDOW_BOTTOM;
- public AbstractSwipeableItemViewHolder(View itemView) {
+ public AbstractSwipeableItemViewHolder(@NonNull View itemView) {
super(itemView);
}
@Override
public void setSwipeStateFlags(@SwipeableItemStateFlags int flags) {
- mSwipeStateFlags = flags;
+ mSwipeState.setFlags(flags);
}
@Override
@SwipeableItemStateFlags
public int getSwipeStateFlags() {
- return mSwipeStateFlags;
+ return mSwipeState.getFlags();
+ }
+
+ @Override
+ @NonNull
+ public SwipeableItemState getSwipeState() {
+ return mSwipeState;
}
@Override
@@ -108,6 +116,7 @@ public float getSwipeItemHorizontalSlideAmount() {
}
@Override
+ @NonNull
public abstract View getSwipeableContainerView();
@Override
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/BaseWrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/BaseWrapperAdapter.java
deleted file mode 100644
index 1dbcf9b4..00000000
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/BaseWrapperAdapter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2015 Haruki Hasegawa
- *
- * 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.
- */
-
-package com.h6ah4i.android.widget.advrecyclerview.utils;
-
-import android.support.v7.widget.RecyclerView;
-
-import com.h6ah4i.android.widget.advrecyclerview.adapter.SimpleWrapperAdapter;
-
-/**
- * This class exists just for compatibility purpose and it will be deprecated soon. Use {@link SimpleWrapperAdapter} directly.
- * @param ViewHolder type
- */
-// @Deprecated
-public class BaseWrapperAdapter extends SimpleWrapperAdapter {
- public BaseWrapperAdapter(RecyclerView.Adapter adapter) {
- super(adapter);
- }
-}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/CustomRecyclerViewUtils.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/CustomRecyclerViewUtils.java
index 92c256b6..4000e429 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/CustomRecyclerViewUtils.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/CustomRecyclerViewUtils.java
@@ -17,17 +17,18 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
import android.graphics.Rect;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.view.ViewCompat;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.OrientationHelper;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.view.ViewGroup;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.OrientationHelper;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.recyclerview.widget.StaggeredGridLayoutManager;
+
public class CustomRecyclerViewUtils {
public static final int ORIENTATION_UNKNOWN = -1;
public static final int ORIENTATION_HORIZONTAL = OrientationHelper.HORIZONTAL; // = 0
@@ -72,13 +73,13 @@ public static int extractOrientation(int layoutType) {
public static int getLayoutType(@Nullable RecyclerView.LayoutManager layoutManager) {
if (layoutManager instanceof GridLayoutManager) {
- if (((GridLayoutManager) layoutManager).getOrientation() == GridLayoutManager.HORIZONTAL) {
+ if (((GridLayoutManager) layoutManager).getOrientation() == RecyclerView.HORIZONTAL) {
return LAYOUT_TYPE_GRID_HORIZONTAL;
} else {
return LAYOUT_TYPE_GRID_VERTICAL;
}
} else if (layoutManager instanceof LinearLayoutManager) {
- if (((LinearLayoutManager) layoutManager).getOrientation() == LinearLayoutManager.HORIZONTAL) {
+ if (((LinearLayoutManager) layoutManager).getOrientation() == RecyclerView.HORIZONTAL) {
return LAYOUT_TYPE_LINEAR_HORIZONTAL;
} else {
return LAYOUT_TYPE_LINEAR_VERTICAL;
@@ -113,7 +114,7 @@ public static RecyclerView.ViewHolder findChildViewHolderUnderWithTranslation(@N
return (child != null) ? rv.getChildViewHolder(child) : null;
}
- public static Rect getLayoutMargins(View v, Rect outMargins) {
+ public static Rect getLayoutMargins(@NonNull View v, @NonNull Rect outMargins) {
final ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
final ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
@@ -127,7 +128,7 @@ public static Rect getLayoutMargins(View v, Rect outMargins) {
return outMargins;
}
- public static Rect getDecorationOffsets(@NonNull RecyclerView.LayoutManager layoutManager, View view, Rect outDecorations) {
+ public static Rect getDecorationOffsets(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View view, @NonNull Rect outDecorations) {
outDecorations.left = layoutManager.getLeftDecorationWidth(view);
outDecorations.right = layoutManager.getRightDecorationWidth(view);
outDecorations.top = layoutManager.getTopDecorationHeight(view);
@@ -245,7 +246,7 @@ private static int findLastVisibleItemPositionIncludesPadding(LinearLayoutManage
private static View findOneVisibleChildIncludesPadding(
LinearLayoutManager lm, int fromIndex, int toIndex,
boolean completelyVisible, boolean acceptPartiallyVisible) {
- boolean isVertical = (lm.getOrientation() == LinearLayoutManager.VERTICAL);
+ boolean isVertical = (lm.getOrientation() == RecyclerView.VERTICAL);
final int start = 0;
final int end = (isVertical) ? lm.getHeight() : lm.getWidth();
final int next = toIndex > fromIndex ? 1 : -1;
@@ -277,7 +278,7 @@ public static int safeGetLayoutPosition(@Nullable RecyclerView.ViewHolder holder
return (holder != null) ? holder.getLayoutPosition() : RecyclerView.NO_POSITION;
}
- public static View findViewByPosition(RecyclerView.LayoutManager layoutManager, int position) {
+ public static View findViewByPosition(@NonNull RecyclerView.LayoutManager layoutManager, int position) {
return (position != RecyclerView.NO_POSITION) ? layoutManager.findViewByPosition(position) : null;
}
@@ -315,8 +316,7 @@ public static int getSpanSize(@Nullable RecyclerView.ViewHolder holder) {
final boolean isFullSpan = ((StaggeredGridLayoutManager.LayoutParams) lp).isFullSpan();
if (isFullSpan) {
final RecyclerView rv = (RecyclerView) itemView.getParent();
- final int spanCount = getSpanCount(rv);
- return spanCount;
+ return getSpanCount(rv);
} else {
return 1;
}
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapter.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapter.java
index 09a8820d..af8d8b31 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapter.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapter.java
@@ -16,15 +16,15 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPathSegment;
import com.h6ah4i.android.widget.advrecyclerview.adapter.SimpleWrapperAdapter;
import com.h6ah4i.android.widget.advrecyclerview.adapter.UnwrapPositionResult;
import com.h6ah4i.android.widget.advrecyclerview.adapter.WrapperAdapter;
import com.h6ah4i.android.widget.advrecyclerview.utils.annotation.DebugWrapperAdapterSettingFlags;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* A wrapper adapter for debugging purpose.
*/
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/RecyclerViewAdapterUtils.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/RecyclerViewAdapterUtils.java
index cccd8a06..0ab47a93 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/RecyclerViewAdapterUtils.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/RecyclerViewAdapterUtils.java
@@ -16,11 +16,12 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewParent;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public class RecyclerViewAdapterUtils {
private RecyclerViewAdapterUtils() {
}
@@ -46,7 +47,7 @@ public static RecyclerView getParentRecyclerView(@Nullable View view) {
}
/**
- * Gets directly child of RecyclerView (== {@link android.support.v7.widget.RecyclerView.ViewHolder#itemView}})
+ * Gets directly child of RecyclerView (== {@link androidx.recyclerview.widget.RecyclerView.ViewHolder#itemView}})
* @param view Child view of the RecyclerView's item
* @return Item view
*/
@@ -60,7 +61,7 @@ public static View getParentViewHolderItemView(@Nullable View view) {
}
/**
- * Gets {@link android.support.v7.widget.RecyclerView.ViewHolder}.
+ * Gets {@link androidx.recyclerview.widget.RecyclerView.ViewHolder}.
* @param view Child view of the RecyclerView's item
* @return ViewHolder
*/
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrappedAdapterUtils.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrappedAdapterUtils.java
index cf75747c..5d368a97 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrappedAdapterUtils.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrappedAdapterUtils.java
@@ -16,12 +16,12 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.adapter.WrappedAdapter;
import com.h6ah4i.android.widget.advrecyclerview.adapter.WrapperAdapter;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
public class WrappedAdapterUtils {
private WrappedAdapterUtils() {
}
@@ -54,7 +54,7 @@ public static void invokeOnViewAttachedToWindow(@NonNull RecyclerView.Adapter ad
}
@SuppressWarnings("unchecked")
- public static void invokeOnViewDetachedFromWindow(RecyclerView.Adapter adapter, RecyclerView.ViewHolder holder, int viewType) {
+ public static void invokeOnViewDetachedFromWindow(@NonNull RecyclerView.Adapter adapter, @NonNull RecyclerView.ViewHolder holder, int viewType) {
if (adapter instanceof WrappedAdapter) {
((WrappedAdapter) adapter).onViewDetachedFromWindow(holder, viewType);
} else {
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrapperAdapterUtils.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrapperAdapterUtils.java
index 3586889f..70032010 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrapperAdapterUtils.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrapperAdapterUtils.java
@@ -16,10 +16,6 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.RecyclerView;
-
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPath;
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPathSegment;
import com.h6ah4i.android.widget.advrecyclerview.adapter.SimpleWrapperAdapter;
@@ -29,12 +25,16 @@
import java.util.ArrayList;
import java.util.List;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
public class WrapperAdapterUtils {
private WrapperAdapterUtils() {
}
- public static T findWrappedAdapter(RecyclerView.Adapter adapter, Class clazz) {
+ public static T findWrappedAdapter(@Nullable RecyclerView.Adapter adapter, @NonNull Class clazz) {
if (clazz.isInstance(adapter)) {
return clazz.cast(adapter);
} else if (adapter instanceof SimpleWrapperAdapter) {
@@ -45,7 +45,7 @@ public static T findWrappedAdapter(RecyclerView.Adapter adapter, Class cl
}
}
- public static T findWrappedAdapter(RecyclerView.Adapter originAdapter, Class clazz, int position) {
+ public static T findWrappedAdapter(@Nullable RecyclerView.Adapter originAdapter, @NonNull Class clazz, int position) {
final AdapterPath path = new AdapterPath();
final int wrappedPosition = unwrapPosition(originAdapter, null, null, position, path);
@@ -62,12 +62,12 @@ public static T findWrappedAdapter(RecyclerView.Adapter originAdapter, Class
return null;
}
- public static RecyclerView.Adapter releaseAll(RecyclerView.Adapter adapter) {
+ public static RecyclerView.Adapter releaseAll(@Nullable RecyclerView.Adapter adapter) {
return releaseCyclically(adapter);
}
@SuppressWarnings("unchecked")
- private static RecyclerView.Adapter releaseCyclically(RecyclerView.Adapter adapter) {
+ private static RecyclerView.Adapter releaseCyclically(@Nullable RecyclerView.Adapter adapter) {
if (!(adapter instanceof WrapperAdapter)) {
return adapter;
}
@@ -102,11 +102,11 @@ public static int unwrapPosition(@NonNull RecyclerView.Adapter originAdapter, @N
return unwrapPosition(originAdapter, targetAdapter, targetAdapterTag, position, null);
}
- public static int unwrapPosition(RecyclerView.Adapter originAdapter, AdapterPathSegment targetAdapterPathSegment, int originPosition, @Nullable AdapterPath destPath) {
+ public static int unwrapPosition(@Nullable RecyclerView.Adapter originAdapter, @Nullable AdapterPathSegment targetAdapterPathSegment, int originPosition, @Nullable AdapterPath destPath) {
return unwrapPosition(originAdapter, targetAdapterPathSegment.adapter, targetAdapterPathSegment.tag, originPosition, destPath);
}
- public static int unwrapPosition(RecyclerView.Adapter originAdapter, RecyclerView.Adapter targetAdapter, Object targetAdapterTag, int originPosition, @Nullable AdapterPath destPath) {
+ public static int unwrapPosition(@Nullable RecyclerView.Adapter originAdapter, @Nullable RecyclerView.Adapter targetAdapter, @Nullable Object targetAdapterTag, int originPosition, @Nullable AdapterPath destPath) {
RecyclerView.Adapter wrapper = originAdapter;
int wrappedPosition = originPosition;
final UnwrapPositionResult tmpResult = new UnwrapPositionResult();
diff --git a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/annotation/DebugWrapperAdapterSettingFlags.java b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/annotation/DebugWrapperAdapterSettingFlags.java
index 0f246c38..7825e446 100644
--- a/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/annotation/DebugWrapperAdapterSettingFlags.java
+++ b/library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/annotation/DebugWrapperAdapterSettingFlags.java
@@ -16,13 +16,13 @@
package com.h6ah4i.android.widget.advrecyclerview.utils.annotation;
-import android.support.annotation.IntDef;
-
import com.h6ah4i.android.widget.advrecyclerview.utils.DebugWrapperAdapter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef;
+
@IntDef(flag = true, value = {
DebugWrapperAdapter.FLAG_VERIFY_WRAP_POSITION,
DebugWrapperAdapter.FLAG_VERIFY_UNWRAP_POSITION,
diff --git a/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposerTest.java b/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposerTest.java
index a09bc775..551a9bd7 100644
--- a/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposerTest.java
+++ b/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemIdComposerTest.java
@@ -16,12 +16,12 @@
package com.h6ah4i.android.widget.advrecyclerview.adapter;
-import android.support.v7.widget.RecyclerView;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import androidx.recyclerview.widget.RecyclerView;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -145,6 +145,7 @@ public void composeExpandableChildId_ChildIdMinOutOfRange() throws Exception {
@Test
public void composeExpandableGroupId() throws Exception {
// zero
+ //noinspection PointlessBitwiseExpression
assertThat(ItemIdComposer.composeExpandableGroupId(0L), is((0L << ItemIdComposer.BIT_OFFSET_GROUP_ID) | ItemIdComposer.BIT_MASK_CHILD_ID));
// one
diff --git a/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposerTest.java b/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposerTest.java
index 5477529a..816d8914 100644
--- a/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposerTest.java
+++ b/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/adapter/ItemViewTypeComposerTest.java
@@ -103,7 +103,7 @@ public void extractWrappedViewTypePart() throws Exception {
assertThat(ItemViewTypeComposer.extractWrappedViewTypePart(0), is(0));
// one
- assertThat(ItemViewTypeComposer.extractWrappedViewTypePart(1 << ItemViewTypeComposer.MIN_WRAPPED_VIEW_TYPE), is(1));
+ assertThat(ItemViewTypeComposer.extractWrappedViewTypePart(1 << ItemViewTypeComposer.BIT_OFFSET_WRAPPED_VIEW_TYPE), is(1));
// full bits
assertThat(ItemViewTypeComposer.extractWrappedViewTypePart(ItemViewTypeComposer.BIT_MASK_WRAPPED_VIEW_TYPE), is(-1));
diff --git a/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapterTest.java b/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapterTest.java
index 6ebb8f3d..a73335fb 100644
--- a/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapterTest.java
+++ b/library/src/test/java/com/h6ah4i/android/widget/advrecyclerview/utils/DebugWrapperAdapterTest.java
@@ -17,12 +17,9 @@
package com.h6ah4i.android.widget.advrecyclerview.utils;
import android.os.Build;
-import android.support.annotation.NonNull;
-import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
-import com.h6ah4i.android.widget.advrecyclerview.BuildConfig;
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPath;
import com.h6ah4i.android.widget.advrecyclerview.adapter.AdapterPathSegment;
import com.h6ah4i.android.widget.advrecyclerview.adapter.SimpleWrapperAdapter;
@@ -32,14 +29,17 @@
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-@RunWith(RobolectricTestRunner.class)
-@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
+@Config(manifest=Config.NONE, sdk = Build.VERSION_CODES.P)
+@RunWith(AndroidJUnit4.class)
public class DebugWrapperAdapterTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -147,13 +147,14 @@ public int getItemCount() {
return 0;
}
+ @NonNull
@Override
- public TestViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ public TestViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
throw new IllegalStateException("not implemented");
}
@Override
- public void onBindViewHolder(TestViewHolder holder, int position) {
+ public void onBindViewHolder(@NonNull TestViewHolder holder, int position) {
throw new IllegalStateException("not implemented");
}
}
diff --git a/methodscount/.gitignore b/methodscount/.gitignore
deleted file mode 100644
index a7747886..00000000
--- a/methodscount/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/build
-
diff --git a/methodscount/build.gradle b/methodscount/build.gradle
deleted file mode 100644
index 5fab2b92..00000000
--- a/methodscount/build.gradle
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-* Copyright (C) 2016 Haruki Hasegawa
-*
-* 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.
-*/
-
-apply plugin: 'com.android.library'
-
-apply plugin: 'me.vigi.fat-aar'
-
-// Common configurations
-apply from: '../common/android-set-common-properties.gradle'
-
-android {
- defaultConfig {
- minSdkVersion 9
- targetSdkVersion 25
-
- versionCode 1
- versionName "1"
- }
-
- buildTypes {
- release {
- }
- debug {
- }
- }
-
- lintOptions {
- abortOnError false
- }
-}
-
-dependencies {
- embed project(':library')
-}
diff --git a/methodscount/src/main/AndroidManifest.xml b/methodscount/src/main/AndroidManifest.xml
deleted file mode 100644
index d8f15856..00000000
--- a/methodscount/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
diff --git a/methodscount/src/main/java/methodscount/.gitkeep b/methodscount/src/main/java/methodscount/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/settings.gradle b/settings.gradle
index 3198622e..7294b583 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1 @@
include ':library', ':example'
-
-if (System.env.USE_METHOD_COUNT == "1") {
- include ':methodscount'
-}