├── app ├── .gitignore ├── app-release.apk ├── src │ └── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── integers.xml │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ ├── attrs.xml │ │ │ └── colors.xml │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-hdpi │ │ │ ├── ic_expand_less.png │ │ │ ├── ic_expand_more.png │ │ │ ├── material_shadow_z1.xml │ │ │ └── material_shadow_z3.xml │ │ ├── drawable-mdpi │ │ │ ├── ic_expand_less.png │ │ │ ├── ic_expand_more.png │ │ │ ├── material_shadow_z1.xml │ │ │ └── material_shadow_z3.xml │ │ ├── drawable-xhdpi │ │ │ ├── ic_expand_less.png │ │ │ ├── ic_expand_more.png │ │ │ └── material_shadow_z1.xml │ │ ├── drawable-xxhdpi │ │ │ ├── ic_expand_less.png │ │ │ ├── ic_expand_more.png │ │ │ ├── material_shadow_z1.xml │ │ │ └── material_shadow_z3.xml │ │ ├── drawable-nodpi │ │ │ ├── material_shadow_z1_mdpi.9.png │ │ │ ├── material_shadow_z1_xhdpi.9.png │ │ │ ├── material_shadow_z3_mdpi.9.png │ │ │ ├── material_shadow_z3_xhdpi.9.png │ │ │ ├── material_shadow_z1_xxhdpi.9.png │ │ │ ├── material_shadow_z1_xxxhdpi.9.png │ │ │ ├── material_shadow_z3_xxhdpi.9.png │ │ │ └── material_shadow_z3_xxxhdpi.9.png │ │ ├── drawable │ │ │ ├── toolbar_drop_shadow.xml │ │ │ ├── cell_bg_normal.xml │ │ │ ├── cell_bg_pressed.xml │ │ │ ├── bg_swipe_item_neutral.xml │ │ │ ├── bg_item_normal_state.xml │ │ │ ├── list_divider_h.xml │ │ │ ├── list_divider_v.xml │ │ │ ├── bg_group_item_normal_state.xml │ │ │ └── bg_group_item_expanded_state.xml │ │ ├── values-v21 │ │ │ └── styles.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ ├── layout │ │ │ ├── content_main.xml │ │ │ ├── activity_main.xml │ │ │ ├── widget_expandable_item_indicator.xml │ │ │ └── list_group_item.xml │ │ ├── drawable-ldpi │ │ │ ├── material_shadow_z1.xml │ │ │ └── material_shadow_z3.xml │ │ ├── drawable-tvdpi │ │ │ ├── material_shadow_z1.xml │ │ │ └── material_shadow_z3.xml │ │ ├── animator │ │ │ ├── expand_less_to_expand_more_rotation.xml │ │ │ └── expand_more_to_expand_less_rotation.xml │ │ ├── drawable-v21 │ │ │ ├── ic_expand_less_to_expand_more.xml │ │ │ ├── ic_expand_more_to_expand_less.xml │ │ │ ├── ic_expand_less_vector.xml │ │ │ └── ic_expand_more_vector.xml │ │ └── values-v11 │ │ │ └── styles.xml │ │ ├── java │ │ └── com │ │ │ └── armani2015 │ │ │ └── android │ │ │ ├── utils │ │ │ ├── CONSTANTS.java │ │ │ └── ListChopper.java │ │ │ ├── MyApplication.java │ │ │ └── common │ │ │ ├── utils │ │ │ ├── DrawableUtils.java │ │ │ └── ViewUtils.java │ │ │ ├── data │ │ │ └── AbstractExpandableDataProvider.java │ │ │ └── widget │ │ │ ├── ExpandableItemIndicatorImplNoAnim.java │ │ │ ├── ExpandableItemIndicatorImplAnim.java │ │ │ └── ExpandableItemIndicator.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── expandableListview ├── .gitignore ├── .idea │ ├── .name │ ├── copyright │ │ └── profiles_settings.xml │ ├── encodings.xml │ ├── gradle.xml │ ├── compiler.xml │ └── misc.xml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── local.properties ├── proguard-rules.pro ├── library-data.properties ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── h6ah4i │ │ │ └── android │ │ │ └── widget │ │ │ └── advrecyclerview │ │ │ ├── event │ │ │ ├── RecyclerViewEventDistributorListener.java │ │ │ ├── RecyclerViewRecyclerEventDistributor.java │ │ │ └── RecyclerViewOnScrollEventDistributor.java │ │ │ ├── animator │ │ │ └── impl │ │ │ │ ├── ItemAnimationInfo.java │ │ │ │ ├── AddAnimationInfo.java │ │ │ │ ├── RemoveAnimationInfo.java │ │ │ │ ├── MoveAnimationInfo.java │ │ │ │ ├── ChangeAnimationInfo.java │ │ │ │ ├── ItemAddAnimationManager.java │ │ │ │ ├── ItemRemoveAnimationManager.java │ │ │ │ ├── ItemMoveAnimationManager.java │ │ │ │ └── ItemChangeAnimationManager.java │ │ │ ├── swipeable │ │ │ ├── action │ │ │ │ ├── SwipeResultActionDefault.java │ │ │ │ ├── SwipeResultActionRemoveItem.java │ │ │ │ ├── SwipeResultActionMoveToSwipedDirection.java │ │ │ │ ├── LegacySwipeResultAction.java │ │ │ │ └── SwipeResultAction.java │ │ │ ├── InternalHelperKK.java │ │ │ ├── RubberBandInterpolator.java │ │ │ ├── annotation │ │ │ │ ├── SwipeableItemStateFlags.java │ │ │ │ ├── SwipeableItemAfterReactions.java │ │ │ │ ├── SwipeableItemResults.java │ │ │ │ ├── SwipeableItemDrawableTypes.java │ │ │ │ └── SwipeableItemReactions.java │ │ │ ├── InternalConstants.java │ │ │ ├── SwipeableItemAdapter.java │ │ │ ├── SwipeReactionUtils.java │ │ │ ├── SwipeableItemInternalUtils.java │ │ │ ├── BaseSwipeableItemAdapter.java │ │ │ └── LegacySwipeableItemAdapter.java │ │ │ ├── expandable │ │ │ ├── ChildPositionItemDraggableRange.java │ │ │ ├── GroupPositionItemDraggableRange.java │ │ │ ├── annotation │ │ │ │ └── ExpandableItemStateFlags.java │ │ │ ├── ExpandableItemViewHolder.java │ │ │ ├── ExpandableItemConstants.java │ │ │ ├── LegacyExpandableSwipeResultAction.java │ │ │ ├── ExpandableAdapterHelper.java │ │ │ ├── ExpandableSwipeableItemInternalUtils.java │ │ │ ├── ExpandableDraggableItemAdapter.java │ │ │ └── ExpandableSwipeableItemAdapter.java │ │ │ ├── draggable │ │ │ ├── LeftRightEdgeEffectDecorator.java │ │ │ ├── TopBottomEdgeEffectDecorator.java │ │ │ ├── annotation │ │ │ │ └── DraggableItemStateFlags.java │ │ │ ├── DraggingItemInfo.java │ │ │ ├── ItemDraggableRange.java │ │ │ ├── BasicSwapTargetTranslationInterpolator.java │ │ │ ├── DraggableItemConstants.java │ │ │ ├── DraggableItemAdapter.java │ │ │ └── DraggableItemViewHolder.java │ │ │ └── utils │ │ │ ├── AbstractDraggableSwipeableItemViewHolder.java │ │ │ ├── AbstractDraggableItemViewHolder.java │ │ │ ├── AbstractExpandableItemViewHolder.java │ │ │ ├── WrapperAdapterUtils.java │ │ │ └── RecyclerViewAdapterUtils.java │ └── androidTest │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── h6ah4i │ │ └── android │ │ └── widget │ │ └── advrecyclerview │ │ ├── ApplicationTest.java │ │ ├── SwipeDismissItemAnimatorTest.java │ │ ├── RefactoredDefaultItemAnimatorTest.java │ │ └── TestActivity.java ├── build.gradle └── gradlew.bat ├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── settings.gradle ├── RELEASE-NOTES.md ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── NOTICE ├── artifacts.gradle ├── gradle.properties ├── versioning.gradle ├── gradlew.bat └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /expandableListview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /expandableListview/.idea/.name: -------------------------------------------------------------------------------- 1 | expandableListview -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | expandable-recyclerview-with-gridlayout -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':expandableListview' -------------------------------------------------------------------------------- /RELEASE-NOTES.md: -------------------------------------------------------------------------------- 1 | 2 | ## 0.5.0 3 | 4 | - Initial release 5 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/app-release.apk -------------------------------------------------------------------------------- /expandableListview/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Expandable RecyclerView with grid layout 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_expand_less.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-hdpi/ic_expand_less.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_expand_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-hdpi/ic_expand_more.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_expand_less.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-mdpi/ic_expand_less.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_expand_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-mdpi/ic_expand_more.png -------------------------------------------------------------------------------- /app/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 200 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_expand_less.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-xhdpi/ic_expand_less.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_expand_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-xhdpi/ic_expand_more.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_expand_less.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-xxhdpi/ic_expand_less.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_expand_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-xxhdpi/ic_expand_more.png -------------------------------------------------------------------------------- /expandableListview/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/expandableListview/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z1_mdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z1_mdpi.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z1_xhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z1_xhdpi.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z3_mdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z3_mdpi.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z3_xhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z3_xhdpi.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z1_xxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z1_xxhdpi.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z1_xxxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z1_xxxhdpi.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z3_xxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z3_xxhdpi.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/material_shadow_z3_xxxhdpi.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabricethilaw/expandable-recyclerview-with-gridlayout/HEAD/app/src/main/res/drawable-nodpi/material_shadow_z3_xxxhdpi.9.png -------------------------------------------------------------------------------- /expandableListview/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /expandableListview/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/toolbar_drop_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /expandableListview/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/cell_bg_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/cell_bg_pressed.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/armani2015/android/utils/CONSTANTS.java: -------------------------------------------------------------------------------- 1 | package com.armani2015.android.utils; 2 | 3 | 4 | import com.armani2015.android.R; 5 | 6 | /** 7 | * Created by Thilaw Fabrice on 2016-04-26. 8 | */ 9 | public class CONSTANTS { 10 | 11 | public static final int MAX_CELLS_PER_GRID_ROW = 4; 12 | public static final int[] CELLS_IDS = { 13 | R.id.cell_1, 14 | R.id.cell_2, 15 | R.id.cell_3, 16 | R.id.cell_4 17 | }; 18 | 19 | } -------------------------------------------------------------------------------- /expandableListview/local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | #Fri May 27 21:09:31 WAT 2016 11 | sdk.dir=D\:\\Programmes\\ANDROID\\Marshalow\\sdk26_01_2016 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 7 | 2dp 8 | 9 | 96dp 10 | 96dp 11 | 128dp 12 | ?android:attr/actionBarSize 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 16dp 6 | 96dp 7 | 16dp 8 | 48dp 9 | 10 | 128dp 11 | ?android:actionBarSize 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 29 | 30 | -------------------------------------------------------------------------------- /expandableListview/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.android.library' 18 | 19 | // Common configurations 20 | 21 | android { 22 | compileSdkVersion 23 23 | buildToolsVersion "23.0.2" 24 | defaultConfig { 25 | minSdkVersion 15 26 | targetSdkVersion 23 27 | } 28 | buildTypes { 29 | release { 30 | minifyEnabled false 31 | shrinkResources false 32 | consumerProguardFiles 'proguard-rules.pro' 33 | } 34 | debug { 35 | minifyEnabled false 36 | shrinkResources false 37 | consumerProguardFiles 'proguard-rules.pro' 38 | } 39 | } 40 | } 41 | 42 | dependencies { 43 | compile 'com.android.support:appcompat-v7:23.1.1' 44 | compile 'com.android.support:recyclerview-v7:23.1.1' 45 | } 46 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemAfterReactions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation; 18 | 19 | import android.support.annotation.IntDef; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | 26 | @IntDef(flag = true, value = { 27 | SwipeableItemConstants.AFTER_SWIPE_REACTION_DEFAULT, 28 | SwipeableItemConstants.AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION, 29 | SwipeableItemConstants.AFTER_SWIPE_REACTION_REMOVE_ITEM, 30 | }) 31 | @Retention(RetentionPolicy.SOURCE) 32 | public @interface SwipeableItemAfterReactions { 33 | } 34 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/annotation/DraggableItemStateFlags.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.draggable.annotation; 18 | 19 | import android.support.annotation.IntDef; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | 26 | @IntDef(flag = true, value = { 27 | DraggableItemConstants.STATE_FLAG_DRAGGING, 28 | DraggableItemConstants.STATE_FLAG_IS_ACTIVE, 29 | DraggableItemConstants.STATE_FLAG_IS_IN_RANGE, 30 | DraggableItemConstants.STATE_FLAG_IS_UPDATED, 31 | }) 32 | @Retention(RetentionPolicy.SOURCE) 33 | public @interface DraggableItemStateFlags { 34 | } 35 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/annotation/ExpandableItemStateFlags.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.h6ah4i.android.widget.advrecyclerview.expandable.annotation; 17 | 18 | import android.support.annotation.IntDef; 19 | 20 | import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | 25 | @IntDef(flag = true, value = { 26 | ExpandableItemConstants.STATE_FLAG_IS_GROUP, 27 | ExpandableItemConstants.STATE_FLAG_IS_CHILD, 28 | ExpandableItemConstants.STATE_FLAG_IS_EXPANDED, 29 | ExpandableItemConstants.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED, 30 | ExpandableItemConstants.STATE_FLAG_IS_UPDATED, 31 | }) 32 | @Retention(RetentionPolicy.SOURCE) 33 | public @interface ExpandableItemStateFlags { 34 | } 35 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemResults.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation; 18 | 19 | import android.support.annotation.IntDef; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | 26 | @IntDef(flag = false, value = { 27 | SwipeableItemConstants.RESULT_NONE, 28 | SwipeableItemConstants.RESULT_CANCELED, 29 | SwipeableItemConstants.RESULT_SWIPED_LEFT, 30 | SwipeableItemConstants.RESULT_SWIPED_UP, 31 | SwipeableItemConstants.RESULT_SWIPED_RIGHT, 32 | SwipeableItemConstants.RESULT_SWIPED_DOWN, 33 | }) 34 | @Retention(RetentionPolicy.SOURCE) 35 | public @interface SwipeableItemResults { 36 | } 37 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemDrawableTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation; 18 | 19 | import android.support.annotation.IntDef; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | 26 | @IntDef(flag = false, value = { 27 | SwipeableItemConstants.DRAWABLE_SWIPE_NEUTRAL_BACKGROUND, 28 | SwipeableItemConstants.DRAWABLE_SWIPE_LEFT_BACKGROUND, 29 | SwipeableItemConstants.DRAWABLE_SWIPE_UP_BACKGROUND, 30 | SwipeableItemConstants.DRAWABLE_SWIPE_RIGHT_BACKGROUND, 31 | SwipeableItemConstants.DRAWABLE_SWIPE_DOWN_BACKGROUND, 32 | }) 33 | @Retention(RetentionPolicy.SOURCE) 34 | public @interface SwipeableItemDrawableTypes { 35 | } 36 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/AddAnimationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | public class AddAnimationInfo extends ItemAnimationInfo { 22 | public RecyclerView.ViewHolder holder; 23 | 24 | public AddAnimationInfo(RecyclerView.ViewHolder holder) { 25 | this.holder = holder; 26 | } 27 | 28 | @Override 29 | public RecyclerView.ViewHolder getAvailableViewHolder() { 30 | return holder; 31 | } 32 | 33 | @Override 34 | public void clear(RecyclerView.ViewHolder item) { 35 | if (holder == null) { 36 | holder = null; 37 | } 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "AddAnimationInfo{" + 43 | "holder=" + holder + 44 | '}'; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/RemoveAnimationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | public class RemoveAnimationInfo extends ItemAnimationInfo { 22 | public RecyclerView.ViewHolder holder; 23 | 24 | public RemoveAnimationInfo(RecyclerView.ViewHolder holder) { 25 | this.holder = holder; 26 | } 27 | 28 | @Override 29 | public RecyclerView.ViewHolder getAvailableViewHolder() { 30 | return holder; 31 | } 32 | 33 | @Override 34 | public void clear(RecyclerView.ViewHolder item) { 35 | if (holder == item) { 36 | holder = null; 37 | } 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "RemoveAnimationInfo{" + 43 | "holder=" + holder + 44 | '}'; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/InternalConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable; 18 | 19 | class InternalConstants { 20 | // bit: 0-5 : LEFT 21 | // bit: 6-11 : UP 22 | // bit: 12-17 : RIGHT 23 | // bit: 18-23 : DOWN 24 | // bit: 24 : REACTION_START_SWIPE_ON_LONG_PRESS 25 | static final int BIT_SHIFT_AMOUNT_LEFT = 0; 26 | static final int BIT_SHIFT_AMOUNT_UP = 6; 27 | static final int BIT_SHIFT_AMOUNT_RIGHT = 12; 28 | static final int BIT_SHIFT_AMOUNT_DOWN = 18; 29 | 30 | static final int REACTION_CAN_NOT_SWIPE = 0; 31 | static final int REACTION_CAN_NOT_SWIPE_WITH_RUBBER_BAND_EFFECT = 1; 32 | static final int REACTION_CAN_SWIPE = 2; 33 | static final int REACTION_MASK_START_SWIPE = 8; 34 | 35 | static final int REACTION_START_SWIPE_ON_LONG_PRESS = (1 << 24); 36 | 37 | static final int REACTION_CAPABILITY_MASK = 0x3; 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/armani2015/android/common/data/AbstractExpandableDataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.armani2015.android.common.data; 18 | 19 | public abstract class AbstractExpandableDataProvider { 20 | public static abstract class BaseData { 21 | 22 | public abstract String getText(); 23 | 24 | public abstract void setPinned(boolean pinned); 25 | 26 | public abstract boolean isPinned(); 27 | } 28 | 29 | public static abstract class GroupData extends BaseData { 30 | public abstract boolean isSectionHeader(); 31 | 32 | public abstract long getGroupId(); 33 | } 34 | 35 | public static abstract class GridData extends BaseData { 36 | public abstract long getGridId(); 37 | } 38 | 39 | public abstract int getGroupCount(); 40 | 41 | public abstract int getGridCount(int groupPosition); 42 | 43 | public abstract GroupData getGroupItem(int groupPosition); 44 | 45 | public abstract GridData getGridItem(int groupPosition, int gridPosition); 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableSwipeableItemViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.utils; 18 | 19 | import android.view.View; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemViewHolder; 22 | import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags; 23 | 24 | public abstract class AbstractDraggableSwipeableItemViewHolder extends AbstractSwipeableItemViewHolder implements DraggableItemViewHolder { 25 | @DraggableItemStateFlags 26 | private int mDragStateFlags; 27 | 28 | public AbstractDraggableSwipeableItemViewHolder(View itemView) { 29 | super(itemView); 30 | } 31 | 32 | @Override 33 | public void setDragStateFlags(@DraggableItemStateFlags int flags) { 34 | mDragStateFlags = flags; 35 | } 36 | 37 | @Override 38 | @DraggableItemStateFlags 39 | public int getDragStateFlags() { 40 | return mDragStateFlags; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableItemViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.utils; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | import android.view.View; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemViewHolder; 23 | import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags; 24 | 25 | public abstract class AbstractDraggableItemViewHolder extends RecyclerView.ViewHolder implements DraggableItemViewHolder { 26 | @DraggableItemStateFlags 27 | private int mDragStateFlags; 28 | 29 | public AbstractDraggableItemViewHolder(View itemView) { 30 | super(itemView); 31 | } 32 | 33 | @Override 34 | public void setDragStateFlags(@DraggableItemStateFlags int flags) { 35 | mDragStateFlags = flags; 36 | } 37 | 38 | @Override 39 | @DraggableItemStateFlags 40 | public int getDragStateFlags() { 41 | return mDragStateFlags; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggingItemInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.draggable; 18 | 19 | import android.graphics.Rect; 20 | import android.support.v7.widget.RecyclerView; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; 23 | 24 | public class DraggingItemInfo { 25 | public final int width; 26 | public final int height; 27 | public final long id; 28 | public final int grabbedPositionX; 29 | public final int grabbedPositionY; 30 | public final Rect margins; 31 | 32 | public DraggingItemInfo(RecyclerView.ViewHolder vh, int touchX, int touchY) { 33 | width = vh.itemView.getWidth(); 34 | height = vh.itemView.getHeight(); 35 | id = vh.getItemId(); 36 | grabbedPositionX = touchX - vh.itemView.getLeft(); 37 | grabbedPositionY = touchY - vh.itemView.getTop(); 38 | margins = new Rect(); 39 | CustomRecyclerViewUtils.getLayoutMargins(vh.itemView, margins); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.utils; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | import android.view.View; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemViewHolder; 23 | import com.h6ah4i.android.widget.advrecyclerview.expandable.annotation.ExpandableItemStateFlags; 24 | 25 | public abstract class AbstractExpandableItemViewHolder extends RecyclerView.ViewHolder implements ExpandableItemViewHolder { 26 | @ExpandableItemStateFlags 27 | private int mExpandStateFlags; 28 | 29 | public AbstractExpandableItemViewHolder(View itemView) { 30 | super(itemView); 31 | } 32 | 33 | @Override 34 | public void setExpandStateFlags(@ExpandableItemStateFlags int flags) { 35 | mExpandStateFlags = flags; 36 | } 37 | 38 | @Override 39 | @ExpandableItemStateFlags 40 | public int getExpandStateFlags() { 41 | return mExpandStateFlags; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/armani2015/android/common/widget/ExpandableItemIndicatorImplNoAnim.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.armani2015.android.common.widget; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | import android.view.LayoutInflater; 22 | import android.view.View; 23 | import android.widget.ImageView; 24 | 25 | import com.armani2015.android.R; 26 | 27 | 28 | class ExpandableItemIndicatorImplNoAnim extends ExpandableItemIndicator.Impl { 29 | private ImageView mImageView; 30 | 31 | @Override 32 | public void onInit(Context context, AttributeSet attrs, int defStyleAttr, ExpandableItemIndicator thiz) { 33 | View v = LayoutInflater.from(context).inflate( 34 | R.layout.widget_expandable_item_indicator, thiz, true); 35 | mImageView = (ImageView) v.findViewById(R.id.image_view); 36 | } 37 | 38 | @Override 39 | public void setExpandedState(boolean isExpanded, boolean animate) { 40 | int resId = (isExpanded) ? R.drawable.ic_expand_less : R.drawable.ic_expand_more; 41 | mImageView.setImageResource(resId); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/ItemDraggableRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.draggable; 18 | 19 | public class ItemDraggableRange { 20 | private final int mStart; 21 | private final int mEnd; 22 | 23 | public ItemDraggableRange(int start, int end) { 24 | if (!(start <= end)) { 25 | throw new IllegalArgumentException("end position (= " + end + ") is smaller than start position (=" + start + ")"); 26 | } 27 | 28 | mStart = start; 29 | mEnd = end; 30 | } 31 | 32 | public int getStart() { 33 | return mStart; 34 | } 35 | 36 | public int getEnd() { 37 | return mEnd; 38 | } 39 | 40 | public boolean checkInRange(int position) { 41 | return ((position >= mStart) && (position <= mEnd)); 42 | } 43 | 44 | protected String getClassName() { 45 | return "ItemDraggableRange"; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return getClassName() + "{" + 51 | "mStart=" + mStart + 52 | ", mEnd=" + mEnd + 53 | '}'; 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/MoveAnimationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | public class MoveAnimationInfo extends ItemAnimationInfo { 22 | public RecyclerView.ViewHolder holder; 23 | public int fromX, fromY, toX, toY; 24 | 25 | public MoveAnimationInfo(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) { 26 | this.holder = holder; 27 | this.fromX = fromX; 28 | this.fromY = fromY; 29 | this.toX = toX; 30 | this.toY = toY; 31 | } 32 | 33 | @Override 34 | public RecyclerView.ViewHolder getAvailableViewHolder() { 35 | return holder; 36 | } 37 | 38 | @Override 39 | public void clear(RecyclerView.ViewHolder item) { 40 | if (holder == item) { 41 | holder = null; 42 | } 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "MoveAnimationInfo{" + 48 | "holder=" + holder + 49 | ", fromX=" + fromX + 50 | ", fromY=" + fromY + 51 | ", toX=" + toX + 52 | ", toY=" + toY + 53 | '}'; 54 | } 55 | } -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/BasicSwapTargetTranslationInterpolator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.draggable; 18 | 19 | 20 | import android.view.animation.Interpolator; 21 | 22 | public class BasicSwapTargetTranslationInterpolator implements Interpolator { 23 | private final float mThreshold; 24 | private final float mHalfValidRange; 25 | private final float mInvValidRange; 26 | 27 | public BasicSwapTargetTranslationInterpolator() { 28 | this(0.3f); 29 | } 30 | 31 | public BasicSwapTargetTranslationInterpolator(float threshold) { 32 | if (!(threshold >= 0 && threshold < 0.5f)) { 33 | throw new IllegalArgumentException("Invalid threshold range: " + threshold); 34 | } 35 | final float validRange = 1.0f - 2 * threshold; 36 | 37 | mThreshold = threshold; 38 | mHalfValidRange = validRange * 0.5f; 39 | mInvValidRange = 1.0f / validRange; 40 | } 41 | 42 | @Override 43 | public float getInterpolation(float input) { 44 | if (Math.abs(input - 0.5f) < mHalfValidRange) { 45 | return (input - mThreshold) * mInvValidRange; 46 | } else { 47 | return (input < 0.5f) ? 0.0f : 1.0f; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/action/LegacySwipeResultAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable.action; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.LegacySwipeableItemAdapter; 22 | 23 | public class LegacySwipeResultAction 24 | extends SwipeResultAction { 25 | 26 | LegacySwipeableItemAdapter mAdapter; 27 | VH mHolder; 28 | int mPosition; 29 | int mResult; 30 | int mReaction; 31 | 32 | public LegacySwipeResultAction( 33 | LegacySwipeableItemAdapter adapter, 34 | VH holder, int position, int result, int reaction) { 35 | super(reaction); 36 | mAdapter = adapter; 37 | mHolder = holder; 38 | mPosition = position; 39 | mResult = result; 40 | mReaction = reaction; 41 | } 42 | 43 | @Override 44 | protected void onPerformAction() { 45 | mAdapter.onPerformAfterSwipeReaction( 46 | mHolder, mPosition, mResult, mReaction); 47 | } 48 | 49 | @Override 50 | protected void onCleanUp() { 51 | super.onCleanUp(); 52 | 53 | mAdapter = null; 54 | mHolder = null; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.draggable; 18 | 19 | public interface DraggableItemConstants { 20 | /** 21 | * State flag for the {@link DraggableItemViewHolder#setDragStateFlags(int)} and {@link DraggableItemViewHolder#getDragStateFlags()} methods. 22 | * Indicates that currently performing dragging. 23 | */ 24 | int STATE_FLAG_DRAGGING = (1 << 0); 25 | 26 | /** 27 | * State flag for the {@link DraggableItemViewHolder#setDragStateFlags(int)} and {@link DraggableItemViewHolder#getDragStateFlags()} methods. 28 | * Indicates that this item is being dragged. 29 | */ 30 | int STATE_FLAG_IS_ACTIVE = (1 << 1); 31 | 32 | /** 33 | * State flag for the {@link DraggableItemViewHolder#setDragStateFlags(int)} and {@link DraggableItemViewHolder#getDragStateFlags()} methods. 34 | * Indicates that this item is in the range of drag-sortable items 35 | */ 36 | int STATE_FLAG_IS_IN_RANGE = (1 << 2); 37 | 38 | /** 39 | * State flag for the {@link DraggableItemViewHolder#setDragStateFlags(int)} and {@link DraggableItemViewHolder#getDragStateFlags()} methods. 40 | * If this flag is set, some other flags are changed and require to apply. 41 | */ 42 | int STATE_FLAG_IS_UPDATED = (1 << 31); 43 | 44 | // --- 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/armani2015/android/utils/ListChopper.java: -------------------------------------------------------------------------------- 1 | package com.armani2015.android.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by Thilaw Fabrice on 2016-05-23. 8 | */ 9 | public class ListChopper { 10 | 11 | 12 | /** 13 | * Splits a list into non-view sublists of length L 14 | * 15 | * @param list - the main list to be split 16 | * @param L - the maximum size of each sublist. Last sublist may a lesser size 17 | * @param the type of the items in the main list and sublists 18 | * @return A list of sublists 19 | */ 20 | public static List> splitListBySize(List list, final int L) { 21 | List> parts = new ArrayList>(); 22 | final int N = list.size(); 23 | for (int i = 0; i < N; i += L) { 24 | parts.add(new ArrayList( 25 | list.subList(i, Math.min(N, i + L))) 26 | ); 27 | } 28 | return parts; 29 | } 30 | 31 | /** 32 | * /** Splits a list into non-view iParts of sublists 33 | * 34 | * @param list - the main list to be split 35 | * @param the type of the items in the main list and sublists 36 | * @param iParts - the expected numbers of sublists we may get after split 37 | * @return A list of sublists 38 | */ 39 | public static List> splitListByParts(final List list, final int iParts) { 40 | final List> lsParts = new ArrayList>(); 41 | final int iChunkSize = list.size() / iParts; 42 | int iLeftOver = list.size() % iParts; 43 | int iTake = iChunkSize; 44 | 45 | for (int i = 0, iT = list.size(); i < iT; i += iTake) { 46 | if (iLeftOver > 0) { 47 | iLeftOver--; 48 | 49 | iTake = iChunkSize + 1; 50 | } else { 51 | iTake = iChunkSize; 52 | } 53 | 54 | lsParts.add(new ArrayList(list.subList(i, Math.min(iT, i + iTake)))); 55 | } 56 | 57 | return lsParts; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/WrapperAdapterUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.utils; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | public class WrapperAdapterUtils { 22 | 23 | private WrapperAdapterUtils() { 24 | } 25 | 26 | public static T findWrappedAdapter(RecyclerView.Adapter adapter, Class clazz) { 27 | if (clazz.isInstance(adapter)) { 28 | return clazz.cast(adapter); 29 | } else if (adapter instanceof BaseWrapperAdapter) { 30 | final RecyclerView.Adapter wrappedAdapter = ((BaseWrapperAdapter) adapter).getWrappedAdapter(); 31 | return findWrappedAdapter(wrappedAdapter, clazz); 32 | } else { 33 | return null; 34 | } 35 | } 36 | 37 | public static RecyclerView.Adapter releaseAll(RecyclerView.Adapter adapter) { 38 | return releaseCyclically(adapter); 39 | } 40 | 41 | private static RecyclerView.Adapter releaseCyclically(RecyclerView.Adapter adapter) { 42 | if (!(adapter instanceof BaseWrapperAdapter)) { 43 | return adapter; 44 | } 45 | 46 | final BaseWrapperAdapter wrapperAdapter = (BaseWrapperAdapter) adapter; 47 | final RecyclerView.Adapter wrappedAdapter = wrapperAdapter.getWrappedAdapter(); 48 | 49 | wrapperAdapter.release(); 50 | 51 | return releaseCyclically(wrappedAdapter); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction; 22 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemResults; 23 | 24 | public interface SwipeableItemAdapter extends BaseSwipeableItemAdapter { 25 | /** 26 | * Called when item is swiped. 27 | *

28 | * *Note that do not change the data set and do not call notifyDataXXX() methods inside of this method.* 29 | * 30 | * @param holder The ViewHolder which is associated to the swiped item. 31 | * @param position The position of the item within the adapter's data set. 32 | * @param result The result code of user's swipe operation. 33 | * {@link SwipeableItemConstants#RESULT_CANCELED}, 34 | * {@link SwipeableItemConstants#RESULT_SWIPED_LEFT}, 35 | * {@link SwipeableItemConstants#RESULT_SWIPED_UP}, 36 | * {@link SwipeableItemConstants#RESULT_SWIPED_RIGHT} or 37 | * {@link SwipeableItemConstants#RESULT_SWIPED_DOWN} 38 | * @return Result action. 39 | */ 40 | SwipeResultAction onSwipeItem(T holder, int position, @SwipeableItemResults int result); 41 | } 42 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/action/SwipeResultAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable.action; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | public abstract class SwipeResultAction { 22 | private final int mResultAction; 23 | 24 | protected SwipeResultAction(int resultAction) { 25 | mResultAction = resultAction; 26 | } 27 | 28 | public int getResultActionType() { 29 | return mResultAction; 30 | } 31 | 32 | public final void performAction() { 33 | onPerformAction(); 34 | } 35 | 36 | public final void slideAnimationEnd() { 37 | onSlideAnimationEnd(); 38 | onCleanUp(); 39 | } 40 | 41 | /** 42 | * This method is called immediately after returning from the {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemAdapter#onSwipeItem(RecyclerView.ViewHolder, int, int)} method. 43 | * You can modify data set and call notifyXXX() methods of adapter in this method. 44 | */ 45 | protected void onPerformAction() { 46 | } 47 | 48 | /** 49 | * This method is called when item slide animation has completed. 50 | */ 51 | protected void onSlideAnimationEnd() { 52 | } 53 | 54 | /** 55 | * This method is called after the {@link #onSlideAnimationEnd()} method. Clear fields to avoid memory leaks. 56 | */ 57 | protected void onCleanUp() { 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableItemViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.expandable; 18 | 19 | import com.h6ah4i.android.widget.advrecyclerview.expandable.annotation.ExpandableItemStateFlags; 20 | 21 | /** 22 | *

Interface which provides required information for expanding item.

23 | *

Implement this interface on your sub-class of the {@link android.support.v7.widget.RecyclerView.ViewHolder}.

24 | */ 25 | public interface ExpandableItemViewHolder { 26 | /** 27 | * Sets the state flags value for expanding item 28 | * 29 | * @param flags Bitwise OR of these flags; 30 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_GROUP} 31 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_CHILD} 32 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_EXPANDED} 33 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_UPDATED} 34 | */ 35 | void setExpandStateFlags(@ExpandableItemStateFlags int flags); 36 | 37 | /** 38 | * Gets the state flags value for expanding item 39 | * 40 | * @return Bitwise OR of these flags; 41 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_GROUP} 42 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_CHILD} 43 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_EXPANDED} 44 | * - {@link ExpandableItemConstants#STATE_FLAG_IS_UPDATED} 45 | */ 46 | @ExpandableItemStateFlags 47 | int getExpandStateFlags(); 48 | } 49 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeReactionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable; 18 | 19 | class SwipeReactionUtils { 20 | public static int extractLeftReaction(int type) { 21 | return ((type >>> InternalConstants.BIT_SHIFT_AMOUNT_LEFT) & InternalConstants.REACTION_CAPABILITY_MASK); 22 | } 23 | 24 | public static int extractUpReaction(int type) { 25 | return ((type >>> InternalConstants.BIT_SHIFT_AMOUNT_UP) & InternalConstants.REACTION_CAPABILITY_MASK); 26 | } 27 | 28 | public static int extractRightReaction(int type) { 29 | return ((type >>> InternalConstants.BIT_SHIFT_AMOUNT_RIGHT) & InternalConstants.REACTION_CAPABILITY_MASK); 30 | } 31 | 32 | public static int extractDownReaction(int type) { 33 | return ((type >>> InternalConstants.BIT_SHIFT_AMOUNT_DOWN) & InternalConstants.REACTION_CAPABILITY_MASK); 34 | } 35 | 36 | public static boolean canSwipeLeft(int reactionType) { 37 | return (extractLeftReaction(reactionType) == InternalConstants.REACTION_CAN_SWIPE); 38 | } 39 | 40 | public static boolean canSwipeUp(int reactionType) { 41 | return (extractUpReaction(reactionType) == InternalConstants.REACTION_CAN_SWIPE); 42 | } 43 | 44 | public static boolean canSwipeRight(int reactionType) { 45 | return (extractRightReaction(reactionType) == InternalConstants.REACTION_CAN_SWIPE); 46 | } 47 | 48 | public static boolean canSwipeDown(int reactionType) { 49 | return (extractDownReaction(reactionType) == InternalConstants.REACTION_CAN_SWIPE); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_group_item.xml: -------------------------------------------------------------------------------- 1 | 16 | 22 | 23 | 31 | 32 | 42 | 43 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemInternalUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.LegacySwipeResultAction; 22 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction; 23 | 24 | public class SwipeableItemInternalUtils { 25 | private SwipeableItemInternalUtils() { 26 | } 27 | 28 | @SuppressWarnings("unchecked") 29 | public static SwipeResultAction invokeOnSwipeItem( 30 | BaseSwipeableItemAdapter adapter, RecyclerView.ViewHolder holder, int position, int result) { 31 | 32 | if (adapter instanceof LegacySwipeableItemAdapter) { 33 | 34 | int reaction = ((LegacySwipeableItemAdapter) adapter).onSwipeItem( 35 | holder, position, result); 36 | 37 | switch (reaction) { 38 | case RecyclerViewSwipeManager.AFTER_SWIPE_REACTION_DEFAULT: 39 | case RecyclerViewSwipeManager.AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION: 40 | case RecyclerViewSwipeManager.AFTER_SWIPE_REACTION_REMOVE_ITEM: 41 | //noinspection deprecation 42 | return new LegacySwipeResultAction<>( 43 | (LegacySwipeableItemAdapter) adapter, 44 | holder, position, result, reaction); 45 | default: 46 | throw new IllegalStateException("Unexpected reaction type: " + reaction); 47 | } 48 | } else { 49 | return ((SwipeableItemAdapter) adapter).onSwipeItem(holder, position, result); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ChangeAnimationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | public class ChangeAnimationInfo extends ItemAnimationInfo { 22 | public RecyclerView.ViewHolder newHolder, oldHolder; 23 | public int fromX, fromY, toX, toY; 24 | 25 | public ChangeAnimationInfo(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, 26 | int fromX, int fromY, int toX, int toY) { 27 | this.oldHolder = oldHolder; 28 | this.newHolder = newHolder; 29 | this.fromX = fromX; 30 | this.fromY = fromY; 31 | this.toX = toX; 32 | this.toY = toY; 33 | } 34 | 35 | @Override 36 | public RecyclerView.ViewHolder getAvailableViewHolder() { 37 | return (oldHolder != null) ? oldHolder : newHolder; 38 | } 39 | 40 | @Override 41 | public void clear(RecyclerView.ViewHolder item) { 42 | if (oldHolder == item) { 43 | oldHolder = null; 44 | } 45 | if (newHolder == item) { 46 | newHolder = null; 47 | } 48 | if (oldHolder == null && newHolder == null) { 49 | fromX = 0; 50 | fromY = 0; 51 | toX = 0; 52 | toY = 0; 53 | } 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "ChangeInfo{" + 59 | ", oldHolder=" + oldHolder + 60 | ", newHolder=" + newHolder + 61 | ", fromX=" + fromX + 62 | ", fromY=" + fromY + 63 | ", toX=" + toX + 64 | ", toY=" + toY + 65 | '}'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.draggable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | public interface DraggableItemAdapter { 22 | 23 | /** 24 | * Called when user is attempt to drag the item. 25 | * 26 | * @param holder The ViewHolder which is associated to item user is attempt to start dragging. 27 | * @param position The position of the item within the adapter's data set. 28 | * @param x Touched X position. Relative from the itemView's top-left. 29 | * @param y Touched Y position. Relative from the itemView's top-left. 30 | * @return Whether can start dragging. 31 | */ 32 | boolean onCheckCanStartDrag(T holder, int position, int x, int y); 33 | 34 | /** 35 | * Called after the {@link #onCheckCanStartDrag(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method returned true. 36 | * 37 | * @param holder The ViewHolder which is associated to item user is attempt to start dragging. 38 | * @param position The position of the item within the adapter's data set. 39 | * @return null: no constraints (= new ItemDraggableRange(0, getItemCount() - 1)), 40 | * otherwise: the range specified item can be drag-sortable. 41 | */ 42 | ItemDraggableRange onGetItemDraggableRange(T holder, int position); 43 | 44 | /** 45 | * Called when item is moved. Should apply the move operation result to data set. 46 | * 47 | * @param fromPosition Previous position of the item. 48 | * @param toPosition New position of the item. 49 | */ 50 | void onMoveItem(int fromPosition, int toPosition); 51 | } 52 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableItemConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.expandable; 18 | 19 | public interface ExpandableItemConstants { 20 | /** 21 | * State flag for the {@link ExpandableItemViewHolder#setExpandStateFlags(int)} and {@link ExpandableItemViewHolder#getExpandStateFlags()} methods. 22 | * Indicates that this ViewHolder is associated to group item. 23 | */ 24 | @SuppressWarnings("PointlessBitwiseExpression") 25 | int STATE_FLAG_IS_GROUP = (1 << 0); 26 | 27 | /** 28 | * State flag for the {@link ExpandableItemViewHolder#setExpandStateFlags(int)} and {@link ExpandableItemViewHolder#getExpandStateFlags()} methods. 29 | * Indicates that this ViewHolder is associated to child item. 30 | */ 31 | int STATE_FLAG_IS_CHILD = (1 << 1); 32 | 33 | /** 34 | * State flag for the {@link ExpandableItemViewHolder#setExpandStateFlags(int)} and {@link ExpandableItemViewHolder#getExpandStateFlags()} methods. 35 | * Indicates that this is an expanded group item. 36 | */ 37 | int STATE_FLAG_IS_EXPANDED = (1 << 2); 38 | 39 | /** 40 | * State flag for the {@link ExpandableItemViewHolder#setExpandStateFlags(int)} and {@link ExpandableItemViewHolder#getExpandStateFlags()} methods. 41 | * If this flag is set, the {@link #STATE_FLAG_IS_EXPANDED} flag has changed. 42 | */ 43 | int STATE_FLAG_HAS_EXPANDED_STATE_CHANGED = (1 << 3); 44 | 45 | /** 46 | * State flag for the {@link ExpandableItemViewHolder#setExpandStateFlags(int)} and {@link ExpandableItemViewHolder#getExpandStateFlags()} methods. 47 | * If this flag is set, some other flags are changed and require to apply. 48 | */ 49 | int STATE_FLAG_IS_UPDATED = (1 << 31); 50 | // --- 51 | } 52 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/LegacyExpandableSwipeResultAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.expandable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction; 22 | 23 | public class LegacyExpandableSwipeResultAction 24 | extends SwipeResultAction { 25 | 26 | LegacyExpandableSwipeableItemAdapter mAdapter; 27 | RecyclerView.ViewHolder mHolder; 28 | int mGroupPosition; 29 | int mChildPosition; 30 | int mResult; 31 | int mReaction; 32 | 33 | public LegacyExpandableSwipeResultAction( 34 | LegacyExpandableSwipeableItemAdapter adapter, 35 | RecyclerView.ViewHolder holder, int groupPosition, int childPosition, int result, int reaction) { 36 | super(reaction); 37 | mAdapter = adapter; 38 | mHolder = holder; 39 | mGroupPosition = groupPosition; 40 | mChildPosition = childPosition; 41 | mResult = result; 42 | mReaction = reaction; 43 | } 44 | 45 | @SuppressWarnings("unchecked") 46 | @Override 47 | protected void onPerformAction() { 48 | if (mChildPosition == RecyclerView.NO_POSITION) { 49 | mAdapter.onPerformAfterSwipeGroupReaction( 50 | (GVH) mHolder, mGroupPosition, mResult, mReaction); 51 | } else { 52 | mAdapter.onPerformAfterSwipeChildReaction( 53 | (CVH) mHolder, mGroupPosition, mChildPosition, mResult, mReaction); 54 | } 55 | } 56 | 57 | @Override 58 | protected void onCleanUp() { 59 | super.onCleanUp(); 60 | 61 | mAdapter = null; 62 | mHolder = null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemViewHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.draggable; 18 | 19 | import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags; 20 | 21 | /** 22 | * Interface which provides required information for dragging item. 23 | *

24 | * Implement this interface on your sub-class of the {@link android.support.v7.widget.RecyclerView.ViewHolder}. 25 | */ 26 | public interface DraggableItemViewHolder { 27 | /** 28 | * Sets the state flags value for dragging item 29 | * 30 | * @param flags Bitwise OR of these flags; 31 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_DRAGGING} 32 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_ACTIVE} 33 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_IN_RANGE} 34 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_UPDATED} 35 | */ 36 | void setDragStateFlags(@DraggableItemStateFlags int flags); 37 | 38 | /** 39 | * Gets the state flags value for dragging item 40 | * 41 | * @return Bitwise OR of these flags; 42 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_DRAGGING} 43 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_ACTIVE} 44 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_IN_RANGE} 45 | * - {@link com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemConstants#STATE_FLAG_IS_UPDATED} 46 | */ 47 | @DraggableItemStateFlags 48 | int getDragStateFlags(); 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/armani2015/android/common/widget/ExpandableItemIndicatorImplAnim.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.armani2015.android.common.widget; 18 | 19 | import android.annotation.TargetApi; 20 | import android.content.Context; 21 | import android.graphics.drawable.Animatable; 22 | import android.os.Build; 23 | import android.support.v4.content.ContextCompat; 24 | import android.support.v4.graphics.drawable.DrawableCompat; 25 | import android.util.AttributeSet; 26 | import android.view.LayoutInflater; 27 | import android.view.View; 28 | import android.widget.ImageView; 29 | 30 | import com.armani2015.android.R; 31 | 32 | 33 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 34 | class ExpandableItemIndicatorImplAnim extends ExpandableItemIndicator.Impl { 35 | private ImageView mImageView; 36 | private int mColor; 37 | 38 | @Override 39 | public void onInit(Context context, AttributeSet attrs, int defStyleAttr, ExpandableItemIndicator thiz) { 40 | View v = LayoutInflater.from(context).inflate(R.layout.widget_expandable_item_indicator, thiz, true); 41 | mImageView = (ImageView) v.findViewById(R.id.image_view); 42 | mColor = ContextCompat.getColor(context, R.color.expandable_item_indicator_color); 43 | } 44 | 45 | @Override 46 | public void setExpandedState(boolean isExpanded, boolean animate) { 47 | if (animate) { 48 | int resId = isExpanded ? R.drawable.ic_expand_more_to_expand_less : R.drawable.ic_expand_less_to_expand_more; 49 | mImageView.setImageResource(resId); 50 | DrawableCompat.setTint(mImageView.getDrawable(), mColor); 51 | ((Animatable) mImageView.getDrawable()).start(); 52 | } else { 53 | int resId = isExpanded ? R.drawable.ic_expand_less_vector : R.drawable.ic_expand_more_vector; 54 | mImageView.setImageResource(resId); 55 | DrawableCompat.setTint(mImageView.getDrawable(), mColor); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /expandableListview/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemAddAnimationManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | import android.util.Log; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator; 23 | 24 | public abstract class ItemAddAnimationManager extends BaseItemAnimationManager { 25 | private static final String TAG = "ARVItemAddAnimMgr"; 26 | 27 | public ItemAddAnimationManager(BaseItemAnimator itemAnimator) { 28 | super(itemAnimator); 29 | } 30 | 31 | @Override 32 | public long getDuration() { 33 | return mItemAnimator.getAddDuration(); 34 | } 35 | 36 | @Override 37 | public void setDuration(long duration) { 38 | mItemAnimator.setAddDuration(duration); 39 | } 40 | 41 | @Override 42 | public void dispatchStarting(AddAnimationInfo info, RecyclerView.ViewHolder item) { 43 | if (debugLogEnabled()) { 44 | Log.d(TAG, "dispatchAddStarting(" + item + ")"); 45 | } 46 | mItemAnimator.dispatchAddStarting(item); 47 | } 48 | 49 | @Override 50 | public void dispatchFinished(AddAnimationInfo info, RecyclerView.ViewHolder item) { 51 | if (debugLogEnabled()) { 52 | Log.d(TAG, "dispatchAddFinished(" + item + ")"); 53 | } 54 | mItemAnimator.dispatchAddFinished(item); 55 | } 56 | 57 | @Override 58 | protected boolean endNotStartedAnimation(AddAnimationInfo info, RecyclerView.ViewHolder item) { 59 | if ((info.holder != null) && ((item == null) || (info.holder == item))) { 60 | onAnimationEndedBeforeStarted(info, info.holder); 61 | dispatchFinished(info, info.holder); 62 | info.clear(info.holder); 63 | return true; 64 | } else { 65 | return false; 66 | } 67 | } 68 | 69 | public abstract boolean addPendingAnimation(RecyclerView.ViewHolder item); 70 | } 71 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemRemoveAnimationManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | import android.util.Log; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator; 23 | 24 | public abstract class ItemRemoveAnimationManager extends BaseItemAnimationManager { 25 | private static final String TAG = "ARVItemRemoveAnimMgr"; 26 | 27 | public ItemRemoveAnimationManager(BaseItemAnimator itemAnimator) { 28 | super(itemAnimator); 29 | } 30 | 31 | @Override 32 | public long getDuration() { 33 | return mItemAnimator.getRemoveDuration(); 34 | } 35 | 36 | @Override 37 | public void setDuration(long duration) { 38 | mItemAnimator.setRemoveDuration(duration); 39 | } 40 | 41 | @Override 42 | public void dispatchStarting(RemoveAnimationInfo info, RecyclerView.ViewHolder item) { 43 | if (debugLogEnabled()) { 44 | Log.d(TAG, "dispatchRemoveStarting(" + item + ")"); 45 | } 46 | mItemAnimator.dispatchRemoveStarting(item); 47 | } 48 | 49 | @Override 50 | public void dispatchFinished(RemoveAnimationInfo info, RecyclerView.ViewHolder item) { 51 | if (debugLogEnabled()) { 52 | Log.d(TAG, "dispatchRemoveFinished(" + item + ")"); 53 | } 54 | mItemAnimator.dispatchRemoveFinished(item); 55 | } 56 | 57 | @Override 58 | protected boolean endNotStartedAnimation(RemoveAnimationInfo info, RecyclerView.ViewHolder item) { 59 | if ((info.holder != null) && ((item == null) || (info.holder == item))) { 60 | onAnimationEndedBeforeStarted(info, info.holder); 61 | dispatchFinished(info, info.holder); 62 | info.clear(info.holder); 63 | return true; 64 | } else { 65 | return false; 66 | } 67 | } 68 | 69 | public abstract boolean addPendingAnimation(RecyclerView.ViewHolder holder); 70 | } 71 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemMoveAnimationManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | import android.util.Log; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator; 23 | 24 | public abstract class ItemMoveAnimationManager extends BaseItemAnimationManager { 25 | public static final String TAG = "ARVItemMoveAnimMgr"; 26 | 27 | public ItemMoveAnimationManager(BaseItemAnimator itemAnimator) { 28 | super(itemAnimator); 29 | } 30 | 31 | @Override 32 | public long getDuration() { 33 | return mItemAnimator.getMoveDuration(); 34 | } 35 | 36 | @Override 37 | public void setDuration(long duration) { 38 | mItemAnimator.setMoveDuration(duration); 39 | } 40 | 41 | @Override 42 | public void dispatchStarting(MoveAnimationInfo info, RecyclerView.ViewHolder item) { 43 | if (debugLogEnabled()) { 44 | Log.d(TAG, "dispatchMoveStarting(" + item + ")"); 45 | } 46 | mItemAnimator.dispatchMoveStarting(item); 47 | } 48 | 49 | @Override 50 | public void dispatchFinished(MoveAnimationInfo info, RecyclerView.ViewHolder item) { 51 | if (debugLogEnabled()) { 52 | Log.d(TAG, "dispatchMoveFinished(" + item + ")"); 53 | } 54 | mItemAnimator.dispatchMoveFinished(item); 55 | } 56 | 57 | @Override 58 | protected boolean endNotStartedAnimation(MoveAnimationInfo info, RecyclerView.ViewHolder item) { 59 | if ((info.holder != null) && ((item == null) || (info.holder == item))) { 60 | onAnimationEndedBeforeStarted(info, info.holder); 61 | dispatchFinished(info, info.holder); 62 | info.clear(info.holder); 63 | return true; 64 | } else { 65 | return false; 66 | } 67 | } 68 | 69 | public abstract boolean addPendingAnimation(RecyclerView.ViewHolder item, int fromX, int fromY, int toX, int toY); 70 | } 71 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableAdapterHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.expandable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | class ExpandableAdapterHelper { 22 | public static final long NO_EXPANDABLE_POSITION = 0xffffffffffffffffl; 23 | 24 | private static final long LOWER_32BIT_MASK = 0x00000000ffffffffl; 25 | private static final long LOWER_31BIT_MASK = 0x000000007fffffffl; 26 | 27 | /*package*/ static final int VIEW_TYPE_FLAG_IS_GROUP = 0x80000000; 28 | 29 | public static long getPackedPositionForChild(int groupPosition, int childPosition) { 30 | return ((long) childPosition << 32) | (groupPosition & LOWER_32BIT_MASK); 31 | } 32 | 33 | public static long getPackedPositionForGroup(int groupPosition) { 34 | return ((long) RecyclerView.NO_POSITION << 32) | (groupPosition & LOWER_32BIT_MASK); 35 | } 36 | 37 | public static int getPackedPositionChild(long packedPosition) { 38 | return (int) (packedPosition >>> 32); 39 | } 40 | 41 | public static int getPackedPositionGroup(long packedPosition) { 42 | return (int) (packedPosition & LOWER_32BIT_MASK); 43 | } 44 | 45 | public static long getCombinedChildId(long groupId, long childId) { 46 | return ((groupId & LOWER_31BIT_MASK) << 32) | (childId & LOWER_32BIT_MASK); 47 | } 48 | 49 | public static long getCombinedGroupId(long groupId) { 50 | //noinspection PointlessBitwiseExpression 51 | return ((groupId & LOWER_31BIT_MASK) << 32) | (RecyclerView.NO_ID & LOWER_32BIT_MASK); 52 | } 53 | 54 | public static boolean isGroupViewType(int rawViewType) { 55 | return ((rawViewType & VIEW_TYPE_FLAG_IS_GROUP) != 0); 56 | } 57 | 58 | public static int getGroupViewType(int rawViewType) { 59 | return (rawViewType & (~VIEW_TYPE_FLAG_IS_GROUP)); 60 | } 61 | 62 | public static int getChildViewType(int rawViewType) { 63 | return (rawViewType & (~VIEW_TYPE_FLAG_IS_GROUP)); 64 | } 65 | 66 | private ExpandableAdapterHelper() { 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Expandable RecyclerView With Grid Layout 2 | =============== 3 | 4 | This is demo project for implementing an Expandable RecyclerView with grid items 5 | 6 | --- 7 | 8 | ### Download the example app 9 | 10 | 11 | Get it on Google Play 13 | 14 | 15 | 16 | ### Demonstration video on YouTube 17 | 18 | 19 | Expandable 20 | 21 | 22 | --- 23 | 24 | Target platforms 25 | --- 26 | 27 | - API level 15 or later 28 | 29 | 30 | Latest version 31 | --- 32 | 33 | - Version 0.5.0 (May. 30, 2016) ([RELEASE NOTES](./RELEASE-NOTES.md)) 34 | 35 | * Support library v23.0.2 was used 36 | * Android Advanced RecyclerView library was used 37 | 38 | 39 | Getting started 40 | --- 41 | 42 | This project provides an Expandable RecyclerView with group items that can be individually expanded to show its children in a two-dimensional scrolling grid. 43 | 44 | 45 | Usage 46 | --- 47 | [Expandable Grid Item] 48 | Each GridRowHolder object receives a data array from RecyclerView adapter to display in a grid row. Then it breaks up the layout of its row in rectangular cells of equal size. Each cell displays a piece of data and can be selected by user. 49 | 50 | Please check the implementation of simple example. 51 | 52 | - [Expandable Grid Item] (https://github.com/Armani2015/expandable-recyclerview-with-gridlayout/blob/master/app/src/main/java/com/armani2015/android/adapters/ExpandableGridItemAdapter.java) 53 | 54 | 55 | License ("Expandable RecyclerView With Grid Layout") 56 | --- 57 | 58 | This project is licensed under the [Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). 59 | 60 | See [`LICENSE`](LICENSE) for full of the license text. 61 | 62 | Copyright (C) 2016 Fabrice Thilaw 63 | 64 | Licensed under the Apache License, Version 2.0 (the "License"); 65 | you may not use this file except in compliance with the License. 66 | You may obtain a copy of the License at 67 | 68 | http://www.apache.org/licenses/LICENSE-2.0 69 | 70 | Unless required by applicable law or agreed to in writing, software 71 | distributed under the License is distributed on an "AS IS" BASIS, 72 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 73 | See the License for the specific language governing permissions and 74 | limitations under the License. 75 | 76 | # expandable-recyclerview-with-gridlayout 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/armani2015/android/common/widget/ExpandableItemIndicator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.armani2015.android.common.widget; 18 | 19 | import android.content.Context; 20 | import android.os.Build; 21 | import android.os.Parcelable; 22 | import android.util.AttributeSet; 23 | import android.util.SparseArray; 24 | import android.widget.FrameLayout; 25 | 26 | public class ExpandableItemIndicator extends FrameLayout { 27 | static abstract class Impl { 28 | public abstract void onInit(Context context, AttributeSet attrs, int defStyleAttr, ExpandableItemIndicator thiz); 29 | 30 | public abstract void setExpandedState(boolean isExpanded, boolean animate); 31 | } 32 | 33 | private Impl mImpl; 34 | 35 | public ExpandableItemIndicator(Context context) { 36 | super(context); 37 | onInit(context, null, 0); 38 | } 39 | 40 | public ExpandableItemIndicator(Context context, AttributeSet attrs) { 41 | super(context, attrs); 42 | onInit(context, attrs, 0); 43 | } 44 | 45 | public ExpandableItemIndicator(Context context, AttributeSet attrs, int defStyleAttr) { 46 | super(context, attrs, defStyleAttr); 47 | onInit(context, attrs, defStyleAttr); 48 | } 49 | 50 | protected void onInit(Context context, AttributeSet attrs, int defStyleAttr) { 51 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 52 | // NOTE: VectorDrawable only supports API level 21 or later 53 | mImpl = new ExpandableItemIndicatorImplAnim(); 54 | } else { 55 | mImpl = new ExpandableItemIndicatorImplNoAnim(); 56 | } 57 | mImpl.onInit(context, attrs, defStyleAttr, this); 58 | } 59 | 60 | @Override 61 | protected void dispatchSaveInstanceState(SparseArray container) { 62 | super.dispatchFreezeSelfOnly(container); 63 | } 64 | 65 | @Override 66 | protected void dispatchRestoreInstanceState(SparseArray container) { 67 | super.dispatchThawSelfOnly(container); 68 | } 69 | 70 | public void setExpandedState(boolean isExpanded, boolean animate) { 71 | mImpl.setExpandedState(isExpanded, animate); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewRecyclerEventDistributor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.event; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import java.lang.ref.WeakReference; 22 | 23 | public class RecyclerViewRecyclerEventDistributor extends BaseRecyclerViewEventDistributor { 24 | 25 | private InternalRecyclerListener mInternalRecyclerListener; 26 | 27 | public RecyclerViewRecyclerEventDistributor() { 28 | super(); 29 | 30 | mInternalRecyclerListener = new InternalRecyclerListener(this); 31 | } 32 | 33 | @Override 34 | protected void onRecyclerViewAttached(RecyclerView rv) { 35 | super.onRecyclerViewAttached(rv); 36 | 37 | rv.setRecyclerListener(mInternalRecyclerListener); 38 | } 39 | 40 | @Override 41 | protected void onRelease() { 42 | super.onRelease(); 43 | 44 | if (mInternalRecyclerListener != null) { 45 | mInternalRecyclerListener.release(); 46 | mInternalRecyclerListener = null; 47 | } 48 | } 49 | 50 | /*package*/ void handleOnViewRecycled(RecyclerView.ViewHolder holder) { 51 | if (mListeners == null) { 52 | return; 53 | } 54 | 55 | for (RecyclerView.RecyclerListener listener : mListeners) { 56 | listener.onViewRecycled(holder); 57 | } 58 | } 59 | 60 | private static class InternalRecyclerListener implements RecyclerView.RecyclerListener { 61 | private WeakReference mRefDistributor; 62 | 63 | public InternalRecyclerListener(RecyclerViewRecyclerEventDistributor distributor) { 64 | super(); 65 | mRefDistributor = new WeakReference<>(distributor); 66 | } 67 | 68 | @Override 69 | public void onViewRecycled(RecyclerView.ViewHolder holder) { 70 | final RecyclerViewRecyclerEventDistributor distributor = mRefDistributor.get(); 71 | 72 | if (distributor != null) { 73 | distributor.handleOnViewRecycled(holder); 74 | } 75 | } 76 | 77 | public void release() { 78 | mRefDistributor.clear(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/RecyclerViewAdapterUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.utils; 18 | 19 | import android.support.annotation.Nullable; 20 | import android.support.v7.widget.RecyclerView; 21 | import android.view.View; 22 | import android.view.ViewParent; 23 | 24 | public class RecyclerViewAdapterUtils { 25 | private RecyclerViewAdapterUtils() { 26 | } 27 | 28 | /** 29 | * Gets parent RecyclerView instance. 30 | * 31 | * @param view Child view of the RecyclerView's item 32 | * @return Parent RecyclerView instance 33 | */ 34 | public static RecyclerView getParentRecyclerView(@Nullable View view) { 35 | if (view == null) { 36 | return null; 37 | } 38 | ViewParent parent = view.getParent(); 39 | if (parent instanceof RecyclerView) { 40 | return (RecyclerView) parent; 41 | } else if (parent instanceof View) { 42 | return getParentRecyclerView((View) parent); 43 | } else { 44 | return null; 45 | } 46 | } 47 | 48 | /** 49 | * Gets directly child of RecyclerView (== {@link android.support.v7.widget.RecyclerView.ViewHolder#itemView}}) 50 | * 51 | * @param view Child view of the RecyclerView's item 52 | * @return Item view 53 | */ 54 | public static View getParentViewHolderItemView(@Nullable View view) { 55 | if (view == null) { 56 | return null; 57 | } 58 | ViewParent parent = view.getParent(); 59 | if (parent instanceof RecyclerView) { 60 | return view; 61 | } else if (parent instanceof View) { 62 | return getParentViewHolderItemView((View) parent); 63 | } else { 64 | return null; 65 | } 66 | } 67 | 68 | /** 69 | * Gets {@link android.support.v7.widget.RecyclerView.ViewHolder}. 70 | * 71 | * @param view Child view of the RecyclerView's item 72 | * @return ViewHolder 73 | */ 74 | public static RecyclerView.ViewHolder getViewHolder(@Nullable View view) { 75 | RecyclerView rv = getParentRecyclerView(view); 76 | View rvChild = getParentViewHolderItemView(view); 77 | 78 | if (rv != null && rvChild != null) { 79 | return rv.getChildViewHolder(rvChild); 80 | } else { 81 | return null; 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableSwipeableItemInternalUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.expandable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager; 22 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction; 23 | 24 | class ExpandableSwipeableItemInternalUtils { 25 | private ExpandableSwipeableItemInternalUtils() { 26 | } 27 | 28 | @SuppressWarnings("unchecked") 29 | public static SwipeResultAction invokeOnSwipeItem( 30 | BaseExpandableSwipeableItemAdapter adapter, RecyclerView.ViewHolder holder, 31 | int groupPosition, int childPosition, int result) { 32 | 33 | if (adapter instanceof LegacyExpandableSwipeableItemAdapter) { 34 | int reaction; 35 | 36 | if (childPosition == RecyclerView.NO_POSITION) { 37 | reaction = ((LegacyExpandableSwipeableItemAdapter) adapter).onSwipeGroupItem( 38 | holder, groupPosition, result); 39 | } else { 40 | reaction = ((LegacyExpandableSwipeableItemAdapter) adapter).onSwipeChildItem( 41 | holder, groupPosition, childPosition, result); 42 | } 43 | 44 | switch (reaction) { 45 | case RecyclerViewSwipeManager.AFTER_SWIPE_REACTION_DEFAULT: 46 | case RecyclerViewSwipeManager.AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION: 47 | case RecyclerViewSwipeManager.AFTER_SWIPE_REACTION_REMOVE_ITEM: 48 | //noinspection deprecation 49 | return new LegacyExpandableSwipeResultAction<>( 50 | (LegacyExpandableSwipeableItemAdapter) adapter, 51 | holder, groupPosition, childPosition, result, reaction); 52 | default: 53 | throw new IllegalStateException("Unexpected reaction type: " + reaction); 54 | } 55 | } else { 56 | if (childPosition == RecyclerView.NO_POSITION) { 57 | return ((ExpandableSwipeableItemAdapter) adapter).onSwipeGroupItem(holder, groupPosition, result); 58 | } else { 59 | return ((ExpandableSwipeableItemAdapter) adapter).onSwipeChildItem(holder, groupPosition, childPosition, result); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/annotation/SwipeableItemReactions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation; 18 | 19 | import android.annotation.SuppressLint; 20 | import android.support.annotation.IntDef; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemConstants; 23 | 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | 27 | @SuppressWarnings("deprecation") 28 | @SuppressLint("UniqueConstants") 29 | @IntDef(flag = true, value = { 30 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_ANY, 31 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_LEFT, 32 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_LEFT_WITH_RUBBER_BAND_EFFECT, 33 | SwipeableItemConstants.REACTION_CAN_SWIPE_LEFT, 34 | SwipeableItemConstants.REACTION_MASK_START_SWIPE_LEFT, 35 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_UP, 36 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_UP_WITH_RUBBER_BAND_EFFECT, 37 | SwipeableItemConstants.REACTION_CAN_SWIPE_UP, 38 | SwipeableItemConstants.REACTION_MASK_START_SWIPE_UP, 39 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_RIGHT, 40 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_RIGHT_WITH_RUBBER_BAND_EFFECT, 41 | SwipeableItemConstants.REACTION_CAN_SWIPE_RIGHT, 42 | SwipeableItemConstants.REACTION_MASK_START_SWIPE_RIGHT, 43 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_DOWN, 44 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_DOWN_WITH_RUBBER_BAND_EFFECT, 45 | SwipeableItemConstants.REACTION_CAN_SWIPE_DOWN, 46 | SwipeableItemConstants.REACTION_MASK_START_SWIPE_DOWN, 47 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_H, 48 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_H_WITH_RUBBER_BAND_EFFECT, 49 | SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH_H, 50 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_V, 51 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_V_WITH_RUBBER_BAND_EFFECT, 52 | SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH_V, 53 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH, 54 | SwipeableItemConstants.REACTION_CAN_NOT_SWIPE_BOTH_WITH_RUBBER_BAND_EFFECT, 55 | SwipeableItemConstants.REACTION_CAN_SWIPE_BOTH, 56 | SwipeableItemConstants.REACTION_START_SWIPE_ON_LONG_PRESS, 57 | }) 58 | @Retention(RetentionPolicy.SOURCE) 59 | public @interface SwipeableItemReactions { 60 | } 61 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/BaseSwipeableItemAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemDrawableTypes; 22 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemReactions; 23 | 24 | public interface BaseSwipeableItemAdapter { 25 | 26 | /** 27 | * Called when user is attempt to swipe the item. 28 | * 29 | * @param holder The ViewHolder which is associated to item user is attempt to start swiping. 30 | * @param position The position of the item within the adapter's data set. 31 | * @param x Touched X position. Relative from the itemView's top-left. 32 | * @param y Touched Y position. Relative from the itemView's top-left. 33 | * @return Reaction type. Bitwise OR of these flags; 34 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_LEFT} 35 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_LEFT_WITH_RUBBER_BAND_EFFECT} 36 | * - {@link SwipeableItemConstants#REACTION_CAN_SWIPE_LEFT} 37 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_UP} 38 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_UP_WITH_RUBBER_BAND_EFFECT} 39 | * - {@link SwipeableItemConstants#REACTION_CAN_SWIPE_UP} 40 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_RIGHT} 41 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_RIGHT_WITH_RUBBER_BAND_EFFECT} 42 | * - {@link SwipeableItemConstants#REACTION_CAN_SWIPE_RIGHT} 43 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_DOWN} 44 | * - {@link SwipeableItemConstants#REACTION_CAN_NOT_SWIPE_DOWN_WITH_RUBBER_BAND_EFFECT} 45 | * - {@link SwipeableItemConstants#REACTION_CAN_SWIPE_DOWN} 46 | */ 47 | @SwipeableItemReactions 48 | int onGetSwipeReactionType(T holder, int position, int x, int y); 49 | 50 | /** 51 | * Called when sets background of the swiping item. 52 | * 53 | * @param holder The ViewHolder which is associated to the swiping item. 54 | * @param position The position of the item within the adapter's data set. 55 | * @param type Background type. One of the 56 | * {@link SwipeableItemConstants#DRAWABLE_SWIPE_NEUTRAL_BACKGROUND}, 57 | * {@link SwipeableItemConstants#DRAWABLE_SWIPE_LEFT_BACKGROUND}, 58 | * {@link SwipeableItemConstants#DRAWABLE_SWIPE_UP_BACKGROUND}, 59 | * {@link SwipeableItemConstants#DRAWABLE_SWIPE_RIGHT_BACKGROUND} or 60 | * {@link SwipeableItemConstants#DRAWABLE_SWIPE_DOWN_BACKGROUND}. 61 | */ 62 | void onSetSwipeBackground(T holder, int position, @SwipeableItemDrawableTypes int type); 63 | } 64 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/animator/impl/ItemChangeAnimationManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.animator.impl; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | import android.util.Log; 21 | 22 | import com.h6ah4i.android.widget.advrecyclerview.animator.BaseItemAnimator; 23 | 24 | public abstract class ItemChangeAnimationManager extends BaseItemAnimationManager { 25 | private static final String TAG = "ARVItemChangeAnimMgr"; 26 | 27 | public ItemChangeAnimationManager(BaseItemAnimator itemAnimator) { 28 | super(itemAnimator); 29 | } 30 | 31 | @Override 32 | public void dispatchStarting(ChangeAnimationInfo info, RecyclerView.ViewHolder item) { 33 | if (debugLogEnabled()) { 34 | Log.d(TAG, "dispatchChangeStarting(" + item + ")"); 35 | } 36 | mItemAnimator.dispatchChangeStarting(item, (item == info.oldHolder)); 37 | } 38 | 39 | @Override 40 | public void dispatchFinished(ChangeAnimationInfo info, RecyclerView.ViewHolder item) { 41 | if (debugLogEnabled()) { 42 | Log.d(TAG, "dispatchChangeFinished(" + item + ")"); 43 | } 44 | mItemAnimator.dispatchChangeFinished(item, (item == info.oldHolder)); 45 | } 46 | 47 | @Override 48 | public long getDuration() { 49 | return mItemAnimator.getChangeDuration(); 50 | } 51 | 52 | @Override 53 | public void setDuration(long duration) { 54 | mItemAnimator.setChangeDuration(duration); 55 | } 56 | 57 | @Override 58 | protected void onCreateAnimation(ChangeAnimationInfo info) { 59 | if (info.oldHolder != null && info.oldHolder.itemView != null) { 60 | onCreateChangeAnimationForOldItem(info); 61 | } 62 | 63 | if (info.newHolder != null && info.newHolder.itemView != null) { 64 | onCreateChangeAnimationForNewItem(info); 65 | } 66 | } 67 | 68 | @Override 69 | protected boolean endNotStartedAnimation(ChangeAnimationInfo info, RecyclerView.ViewHolder item) { 70 | if ((info.oldHolder != null) && ((item == null) || (info.oldHolder == item))) { 71 | onAnimationEndedBeforeStarted(info, info.oldHolder); 72 | dispatchFinished(info, info.oldHolder); 73 | info.clear(info.oldHolder); 74 | } 75 | 76 | if ((info.newHolder != null) && ((item == null) || (info.newHolder == item))) { 77 | onAnimationEndedBeforeStarted(info, info.newHolder); 78 | dispatchFinished(info, info.newHolder); 79 | info.clear(info.newHolder); 80 | } 81 | 82 | return (info.oldHolder == null && info.newHolder == null); 83 | } 84 | 85 | protected abstract void onCreateChangeAnimationForNewItem(ChangeAnimationInfo info); 86 | 87 | protected abstract void onCreateChangeAnimationForOldItem(ChangeAnimationInfo info); 88 | 89 | public abstract boolean addPendingAnimation(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY); 90 | } 91 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/LegacySwipeableItemAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.swipeable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemAfterReactions; 22 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemResults; 23 | 24 | /** 25 | * This class is for easy migration from Advanced RecyclerView v0.7.x. 26 | * Just change {@link SwipeableItemAdapter} to {@link LegacySwipeableItemAdapter}. 27 | * However this class will be removed in future, so it's recommended to migrate to 28 | * the new {@link SwipeableItemAdapter} interface. 29 | * 30 | * @param Type of the view holder class 31 | */ 32 | public interface LegacySwipeableItemAdapter extends BaseSwipeableItemAdapter { 33 | 34 | /** 35 | *

Called when item is swiped.

36 | *

*Note that do not change the data set and do not call notifyDataXXX() methods inside of this method.*

37 | * 38 | * @param holder The ViewHolder which is associated to the swiped item. 39 | * @param position The position of the item within the adapter's data set. 40 | * @param result The result code of user's swipe operation. 41 | * {@link SwipeableItemConstants#RESULT_CANCELED}, 42 | * {@link SwipeableItemConstants#RESULT_SWIPED_LEFT}, 43 | * {@link SwipeableItemConstants#RESULT_SWIPED_UP}, 44 | * {@link SwipeableItemConstants#RESULT_SWIPED_RIGHT} or 45 | * {@link SwipeableItemConstants#RESULT_SWIPED_DOWN} 46 | * @return Reaction type of after swiping. 47 | * One of the {@link SwipeableItemConstants#AFTER_SWIPE_REACTION_DEFAULT}, 48 | * {@link SwipeableItemConstants#AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION} or 49 | * {@link SwipeableItemConstants#AFTER_SWIPE_REACTION_REMOVE_ITEM}. 50 | */ 51 | @SwipeableItemAfterReactions 52 | int onSwipeItem(T holder, int position, int result); 53 | 54 | /** 55 | *

Called after {@link #onSwipeItem(android.support.v7.widget.RecyclerView.ViewHolder, int, int)} method.

56 | *

You can update the data set and call notifyDataXXX() methods inside of this method.

57 | * 58 | * @param holder The ViewHolder which is associated to the swiped item. 59 | * @param position The position of the item within the adapter's data set. 60 | * @param result The result code of user's swipe operation. 61 | * {@link SwipeableItemConstants#RESULT_CANCELED}, 62 | * {@link SwipeableItemConstants#RESULT_SWIPED_LEFT}, 63 | * {@link SwipeableItemConstants#RESULT_SWIPED_UP}, 64 | * {@link SwipeableItemConstants#RESULT_SWIPED_RIGHT} or 65 | * {@link SwipeableItemConstants#RESULT_SWIPED_DOWN} 66 | * @param reaction Reaction type. One of the {@link SwipeableItemConstants#AFTER_SWIPE_REACTION_DEFAULT}, 67 | * {@link SwipeableItemConstants#AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION} or 68 | * {@link SwipeableItemConstants#AFTER_SWIPE_REACTION_REMOVE_ITEM}. 69 | */ 70 | void onPerformAfterSwipeReaction(T holder, int position, @SwipeableItemResults int result, @SwipeableItemAfterReactions int reaction); 71 | } 72 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/event/RecyclerViewOnScrollEventDistributor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.event; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import java.lang.ref.WeakReference; 22 | 23 | /** 24 | * Deprecated. 25 | *

26 | * Please use {@link RecyclerView#addOnScrollListener(RecyclerView.OnScrollListener)} and {@link RecyclerView#removeOnScrollListener(RecyclerView.OnScrollListener)} instead. 27 | */ 28 | @Deprecated 29 | public class RecyclerViewOnScrollEventDistributor extends BaseRecyclerViewEventDistributor { 30 | 31 | private InternalOnScrollListener mInternalOnScrollListener; 32 | 33 | public RecyclerViewOnScrollEventDistributor() { 34 | super(); 35 | 36 | mInternalOnScrollListener = new InternalOnScrollListener(this); 37 | } 38 | 39 | @Override 40 | protected void onRecyclerViewAttached(RecyclerView rv) { 41 | super.onRecyclerViewAttached(rv); 42 | 43 | rv.addOnScrollListener(mInternalOnScrollListener); 44 | } 45 | 46 | @Override 47 | protected void onRelease() { 48 | if (mInternalOnScrollListener != null) { 49 | if (mRecyclerView != null) { 50 | mRecyclerView.removeOnScrollListener(mInternalOnScrollListener); 51 | } 52 | mInternalOnScrollListener.release(); 53 | mInternalOnScrollListener = null; 54 | } 55 | 56 | super.onRelease(); 57 | } 58 | 59 | /*package*/ void handleOnScrollStateChanged(RecyclerView recyclerView, int newState) { 60 | if (mListeners == null) { 61 | return; 62 | } 63 | 64 | for (RecyclerView.OnScrollListener listener : mListeners) { 65 | listener.onScrollStateChanged(recyclerView, newState); 66 | } 67 | } 68 | 69 | /*package*/ void handleOnScrolled(RecyclerView recyclerView, int dx, int dy) { 70 | if (mListeners == null) { 71 | return; 72 | } 73 | 74 | for (RecyclerView.OnScrollListener listener : mListeners) { 75 | listener.onScrolled(recyclerView, dx, dy); 76 | } 77 | } 78 | 79 | @SuppressWarnings("deprecation") 80 | private static class InternalOnScrollListener extends RecyclerView.OnScrollListener { 81 | private WeakReference mRefDistributor; 82 | 83 | public InternalOnScrollListener(RecyclerViewOnScrollEventDistributor distributor) { 84 | super(); 85 | mRefDistributor = new WeakReference<>(distributor); 86 | } 87 | 88 | @Override 89 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { 90 | final RecyclerViewOnScrollEventDistributor distributor = mRefDistributor.get(); 91 | if (distributor != null) { 92 | distributor.handleOnScrollStateChanged(recyclerView, newState); 93 | } 94 | } 95 | 96 | @Override 97 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 98 | final RecyclerViewOnScrollEventDistributor holder = mRefDistributor.get(); 99 | if (holder != null) { 100 | holder.handleOnScrolled(recyclerView, dx, dy); 101 | } 102 | } 103 | 104 | public void release() { 105 | mRefDistributor.clear(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableDraggableItemAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.expandable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange; 22 | 23 | public interface ExpandableDraggableItemAdapter { 24 | /** 25 | * Called when user is attempt to drag the group item. 26 | * 27 | * @param holder The group ViewHolder which is associated to item user is attempt to start dragging. 28 | * @param groupPosition Group position. 29 | * @param x Touched X position. Relative from the itemView's top-left. 30 | * @param y Touched Y position. Relative from the itemView's top-left. 31 | * @return Whether can start dragging. 32 | */ 33 | boolean onCheckGroupCanStartDrag(GVH holder, int groupPosition, int x, int y); 34 | 35 | /** 36 | * Called when user is attempt to drag the child item. 37 | * 38 | * @param holder The child ViewHolder which is associated to item user is attempt to start dragging. 39 | * @param groupPosition Group position. 40 | * @param childPosition Child position. 41 | * @param x Touched X position. Relative from the itemView's top-left. 42 | * @param y Touched Y position. Relative from the itemView's top-left. 43 | * @return Whether can start dragging. 44 | */ 45 | boolean onCheckChildCanStartDrag(CVH holder, int groupPosition, int childPosition, int x, int y); 46 | 47 | /** 48 | * Called after the {@link #onCheckGroupCanStartDrag(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method returned true. 49 | * 50 | * @param holder The ViewHolder which is associated to item user is attempt to start dragging. 51 | * @param groupPosition Group position. 52 | * @return null: no constraints (= new ItemDraggableRange(0, getGroupCount() - 1)), 53 | * otherwise: the range specified item can be drag-sortable. 54 | */ 55 | ItemDraggableRange onGetGroupItemDraggableRange(GVH holder, int groupPosition); 56 | 57 | /** 58 | * Called after the {@link #onCheckChildCanStartDrag(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int, int)} method returned true. 59 | * 60 | * @param holder The ViewHolder which is associated to item user is attempt to start dragging. 61 | * @param groupPosition Group position. 62 | * @param childPosition Child position. 63 | * @return null: no constraints (= new ItemDraggableRange(0, getGroupCount() - 1)), 64 | * otherwise: the range specified item can be drag-sortable. 65 | */ 66 | ItemDraggableRange onGetChildItemDraggableRange(CVH holder, int groupPosition, int childPosition); 67 | 68 | /** 69 | * Called when group item is moved. Should apply the move operation result to data set. 70 | * 71 | * @param fromGroupPosition Previous group position of the item. 72 | * @param toGroupPosition New group position of the item. 73 | */ 74 | void onMoveGroupItem(int fromGroupPosition, int toGroupPosition); 75 | 76 | /** 77 | * Called when child item is moved. Should apply the move operation result to data set. 78 | * 79 | * @param fromGroupPosition Previous group position of the item. 80 | * @param fromChildPosition Previous child position of the item. 81 | * @param toGroupPosition New group position of the item. 82 | * @param toChildPosition New child position of the item. 83 | */ 84 | void onMoveChildItem(int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition); 85 | } 86 | -------------------------------------------------------------------------------- /expandableListview/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableSwipeableItemAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Haruki Hasegawa 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.h6ah4i.android.widget.advrecyclerview.expandable; 18 | 19 | import android.support.v7.widget.RecyclerView; 20 | 21 | import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAction; 22 | 23 | public interface ExpandableSwipeableItemAdapter 24 | extends BaseExpandableSwipeableItemAdapter { 25 | 26 | /** 27 | * Called when group item is swiped. 28 | *

29 | * *Note that do not change data set and do not call notifyDataXXX() methods inside of this method.* 30 | * 31 | * @param holder The ViewHolder which is associated to the swiped item. 32 | * @param groupPosition Group position. 33 | * @param result The result code of user's swipe operation. 34 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_CANCELED}, 35 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_LEFT}, 36 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_UP}, 37 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_RIGHT} or 38 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_DOWN} 39 | * @return Reaction type of after swiping. 40 | * One of the {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#AFTER_SWIPE_REACTION_DEFAULT}, 41 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION} or 42 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#AFTER_SWIPE_REACTION_REMOVE_ITEM}. 43 | */ 44 | SwipeResultAction onSwipeGroupItem(GVH holder, int groupPosition, int result); 45 | 46 | /** 47 | * Called when child item is swiped. 48 | *

49 | * *Note that do not change data set and do not call notifyDataXXX() methods inside of this method.* 50 | * 51 | * @param holder The ViewHolder which is associated to the swiped item. 52 | * @param groupPosition Group position. 53 | * @param childPosition Child position. 54 | * @param result The result code of user's swipe operation. 55 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_CANCELED}, 56 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_LEFT}, 57 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_UP}, 58 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_RIGHT} or 59 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#RESULT_SWIPED_DOWN} 60 | * @return Reaction type of after swiping. 61 | * One of the {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#AFTER_SWIPE_REACTION_DEFAULT}, 62 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#AFTER_SWIPE_REACTION_MOVE_TO_SWIPED_DIRECTION} or 63 | * {@link com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager#AFTER_SWIPE_REACTION_REMOVE_ITEM}. 64 | */ 65 | SwipeResultAction onSwipeChildItem(CVH holder, int groupPosition, int childPosition, int result); 66 | } 67 | --------------------------------------------------------------------------------