├── example ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable-nodpi │ │ │ ├── may.jpg │ │ │ ├── april.jpg │ │ │ ├── august.jpg │ │ │ ├── husky.jpg │ │ │ ├── july.jpg │ │ │ ├── june.jpg │ │ │ ├── march.jpg │ │ │ ├── december.jpg │ │ │ ├── february.jpg │ │ │ ├── january.jpg │ │ │ ├── november.jpg │ │ │ ├── october.jpg │ │ │ ├── september.jpg │ │ │ ├── ic_empty_list.png │ │ │ └── gesture_recycler_big.png │ │ ├── drawable-hdpi │ │ │ ├── ic_ok.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_fingerprint.png │ │ ├── drawable-mdpi │ │ │ ├── ic_ok.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_fingerprint.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_ok.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_fingerprint.png │ │ ├── drawable-xxhdpi │ │ │ ├── ic_ok.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_fingerprint.png │ │ ├── values │ │ │ ├── integers.xml │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ ├── strings.xml │ │ │ └── dimens.xml │ │ ├── drawable │ │ │ └── rectangle_background.xml │ │ ├── menu │ │ │ ├── recycler_menu.xml │ │ │ └── recycler_empty_menu.xml │ │ └── layout │ │ │ ├── activity_recycler.xml │ │ │ ├── footer_item.xml │ │ │ ├── header_item.xml │ │ │ ├── first_background_item.xml │ │ │ ├── second_background_item.xml │ │ │ ├── month_header_item.xml │ │ │ ├── fragment_recycler.xml │ │ │ ├── grid_item.xml │ │ │ ├── activity_start.xml │ │ │ ├── linear_item.xml │ │ │ └── linear_item_with_background.xml │ │ ├── java │ │ └── com │ │ │ └── thesurix │ │ │ └── example │ │ │ └── gesturerecycler │ │ │ ├── model │ │ │ ├── MonthHeader.kt │ │ │ ├── MonthItem.kt │ │ │ └── Month.kt │ │ │ ├── adapter │ │ │ ├── GridItemViewHolder.kt │ │ │ ├── MonthHeaderViewHolder.kt │ │ │ ├── LinearItemViewHolder.kt │ │ │ ├── LinearItemWithBackgroundViewHolder.kt │ │ │ ├── MonthsAdapter.kt │ │ │ └── BaseMonthViewHolder.kt │ │ │ ├── callback │ │ │ └── MonthDiffCallback.kt │ │ │ ├── StartActivity.kt │ │ │ ├── RecyclerActivity.kt │ │ │ └── fragment │ │ │ ├── BaseFragment.kt │ │ │ ├── LinearRecyclerFragment.kt │ │ │ ├── GridRecyclerFragment.kt │ │ │ └── EmptyViewFragment.kt │ │ └── AndroidManifest.xml └── build.gradle ├── library ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ └── java │ │ │ └── com │ │ │ └── thesurix │ │ │ └── gesturerecycler │ │ │ ├── transactions │ │ │ ├── Transaction.kt │ │ │ ├── Transactional.kt │ │ │ ├── RevertReorderTransaction.kt │ │ │ ├── AddTransaction.kt │ │ │ ├── RemoveTransaction.kt │ │ │ ├── SwapTransaction.kt │ │ │ ├── InsertTransaction.kt │ │ │ └── MoveTransaction.kt │ │ │ ├── util │ │ │ ├── FixedSizeArrayDequeue.kt │ │ │ └── extensions.kt │ │ │ ├── GestureListener.kt │ │ │ ├── DefaultItemClickListener.kt │ │ │ ├── EmptyViewDataObserver.kt │ │ │ ├── GestureViewHolder.kt │ │ │ ├── LayoutFlags.kt │ │ │ ├── RecyclerItemTouchListener.kt │ │ │ ├── GestureTouchHelperCallback.kt │ │ │ ├── GestureManager.kt │ │ │ └── GestureAdapter.kt │ └── test │ │ └── java │ │ └── com │ │ └── thesurix │ │ └── gesturerecycler │ │ ├── BaseTransactionTest.kt │ │ ├── MoveTransactionTest.kt │ │ ├── RevertReorderTransactionTest.kt │ │ ├── AddTransactionTest.kt │ │ ├── RemoveTransactionTest.kt │ │ ├── InsertTransactionTest.kt │ │ └── SwapTransactionTest.kt ├── lib-proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── LICENSE.txt ├── dependencies.gradle ├── gradle.properties ├── gradlew.bat ├── publish-mavencentral.gradle ├── gradlew └── README.md /example/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':example', ':library' 2 | 3 | project(':library').name = 'gesture-recycler' 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Gesture Recycler Library 3 | 4 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/may.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/may.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-hdpi/ic_ok.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-mdpi/ic_ok.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/april.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/april.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/august.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/august.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/husky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/husky.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/july.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/july.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/june.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/june.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/march.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/march.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-xhdpi/ic_ok.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-xxhdpi/ic_ok.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/december.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/december.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/february.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/february.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/january.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/january.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/november.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/november.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/october.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/october.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/september.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/september.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_fingerprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-hdpi/ic_fingerprint.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_fingerprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-mdpi/ic_fingerprint.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/ic_empty_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/ic_empty_list.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 250 4 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_fingerprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-xhdpi/ic_fingerprint.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_fingerprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-xxhdpi/ic_fingerprint.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-nodpi/gesture_recycler_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thesurix/gesture-recycler/HEAD/example/src/main/res/drawable-nodpi/gesture_recycler_big.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Feb 17 23:18:17 CET 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /example/src/main/java/com/thesurix/example/gesturerecycler/model/MonthHeader.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.example.gesturerecycler.model 2 | 3 | class MonthHeader(override val name: String) : MonthItem { 4 | 5 | override val type: MonthItem.MonthItemType 6 | get() = MonthItem.MonthItemType.HEADER 7 | } 8 | -------------------------------------------------------------------------------- /example/src/main/java/com/thesurix/example/gesturerecycler/model/MonthItem.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.example.gesturerecycler.model 2 | 3 | interface MonthItem { 4 | 5 | val type: MonthItemType 6 | 7 | val name: String 8 | 9 | enum class MonthItemType { 10 | HEADER, MONTH 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/src/main/res/drawable/rectangle_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/java/com/thesurix/gesturerecycler/transactions/Transaction.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.gesturerecycler.transactions 2 | 3 | /** 4 | * @author thesurix 5 | */ 6 | interface Transaction { 7 | fun perform(transactional: Transactional): Boolean 8 | fun revert(transactional: Transactional): Boolean 9 | } -------------------------------------------------------------------------------- /example/src/main/res/menu/recycler_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /example/src/main/java/com/thesurix/example/gesturerecycler/model/Month.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.example.gesturerecycler.model 2 | 3 | 4 | import androidx.annotation.DrawableRes 5 | 6 | class Month(override val name: String, @param:DrawableRes val drawableId: Int) : MonthItem { 7 | 8 | override val type: MonthItem.MonthItemType 9 | get() = MonthItem.MonthItemType.MONTH 10 | } 11 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_recycler.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /library/src/main/java/com/thesurix/gesturerecycler/transactions/Transactional.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.gesturerecycler.transactions 2 | 3 | /** 4 | * @author thesurix 5 | */ 6 | interface Transactional { 7 | val data: MutableList 8 | fun notifyChanged(position: Int) 9 | fun notifyInserted(position: Int) 10 | fun notifyRemoved(position: Int) 11 | fun notifyMoved(fromPosition: Int, toPosition: Int) 12 | } -------------------------------------------------------------------------------- /example/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #3f51b5 8 | #e91e63 9 | #f44336 10 | #4caf50 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/java/com/thesurix/gesturerecycler/util/FixedSizeArrayDequeue.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.gesturerecycler.util 2 | 3 | import java.util.* 4 | 5 | /** 6 | * @author thesurix 7 | */ 8 | class FixedSizeArrayDequeue(private val maxSize: Int) : ArrayDeque(maxSize) { 9 | 10 | override fun offer(e: E): Boolean { 11 | if (size == maxSize) { 12 | removeFirst() 13 | } 14 | 15 | return super.offer(e) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/thesurix/gesturerecycler/GestureListener.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.gesturerecycler 2 | 3 | 4 | import androidx.recyclerview.widget.ItemTouchHelper 5 | 6 | /** 7 | * Default gesture listener that handles manual spawned drag gestures. 8 | * @author thesurix 9 | */ 10 | class GestureListener(private val touchHelper: ItemTouchHelper) : GestureAdapter.OnGestureListener { 11 | 12 | override fun onStartDrag(viewHolder: GestureViewHolder) { 13 | touchHelper.startDrag(viewHolder) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/src/main/res/layout/footer_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /example/src/main/res/layout/header_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # Android Studio Navigation editor temp files 29 | .navigation/ 30 | 31 | # Android Studio captures folder 32 | captures/ 33 | 34 | 35 | *.iml 36 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2020 thesurix 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/thesurix/gesturerecycler/DefaultItemClickListener.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.gesturerecycler 2 | 3 | /** 4 | * Default implementation of the [RecyclerItemTouchListener.ItemClickListener]. 5 | * @author thesurix 6 | */ 7 | open class DefaultItemClickListener : RecyclerItemTouchListener.ItemClickListener { 8 | 9 | override fun onItemClick(item: T, position: Int): Boolean { 10 | return false 11 | } 12 | 13 | override fun onItemLongPress(item: T, position: Int) { 14 | } 15 | 16 | override fun onDoubleTap(item: T, position: Int): Boolean { 17 | return false 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/src/main/java/com/thesurix/gesturerecycler/util/extensions.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.gesturerecycler.util 2 | 3 | /** 4 | * Swaps two items inside [MutableList] 5 | * @param firstIndex first index to swap 6 | * @param secondIndex second index to swap 7 | */ 8 | fun MutableList.swap(firstIndex: Int, secondIndex: Int) { 9 | val tmp = this[firstIndex] 10 | this[firstIndex] = this[secondIndex] 11 | this[secondIndex] = tmp 12 | } 13 | 14 | /** 15 | * Returns data offset based on header state. 16 | * @param headerEnabled header flag 17 | * @return data offset 18 | */ 19 | fun getDataOffset(headerEnabled: Boolean) = if (headerEnabled) -1 else 0 -------------------------------------------------------------------------------- /library/src/test/java/com/thesurix/gesturerecycler/BaseTransactionTest.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.gesturerecycler 2 | 3 | import com.thesurix.gesturerecycler.transactions.Transactional 4 | import org.junit.Before 5 | import org.junit.runner.RunWith 6 | import org.mockito.Mock 7 | import org.mockito.Mockito 8 | import org.mockito.junit.MockitoJUnitRunner 9 | 10 | @RunWith(MockitoJUnitRunner::class) 11 | abstract class BaseTransactionTest { 12 | 13 | @Mock 14 | lateinit var transactional: Transactional 15 | 16 | val data = mutableListOf("A", "B", "C", "D", "E") 17 | 18 | @Before 19 | fun setUp() { 20 | Mockito.`when`(transactional.data).thenReturn(data) 21 | } 22 | } -------------------------------------------------------------------------------- /library/lib-proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/thesurix/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /example/src/main/java/com/thesurix/example/gesturerecycler/adapter/GridItemViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.example.gesturerecycler.adapter 2 | 3 | import android.view.View 4 | import android.view.ViewStub 5 | import android.widget.ImageView 6 | import android.widget.TextView 7 | import com.thesurix.example.gesturerecycler.databinding.GridItemBinding 8 | 9 | class GridItemViewHolder (private val binding: GridItemBinding) : BaseMonthViewHolder(binding.root) { 10 | override val monthText: TextView 11 | get() = binding.monthText 12 | override val monthPicture: ImageView 13 | get() = binding.monthImage 14 | override val itemDrag: ImageView 15 | get() = binding.monthDrag 16 | override val foreground: View? 17 | get() = null 18 | } -------------------------------------------------------------------------------- /example/src/main/java/com/thesurix/example/gesturerecycler/adapter/MonthHeaderViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.example.gesturerecycler.adapter 2 | 3 | import android.widget.TextView 4 | import com.thesurix.example.gesturerecycler.databinding.MonthHeaderItemBinding 5 | import com.thesurix.example.gesturerecycler.model.MonthItem 6 | import com.thesurix.gesturerecycler.GestureViewHolder 7 | 8 | 9 | class MonthHeaderViewHolder(binding: MonthHeaderItemBinding) : GestureViewHolder(binding.root) { 10 | 11 | private val headerText: TextView = binding.headerText 12 | 13 | override fun canDrag() = false 14 | 15 | override fun canSwipe() = false 16 | 17 | override fun bind(item: MonthItem) { 18 | headerText.text = item.name 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/src/main/java/com/thesurix/example/gesturerecycler/adapter/LinearItemViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.thesurix.example.gesturerecycler.adapter 2 | 3 | import android.view.View 4 | import android.view.ViewStub 5 | import android.widget.ImageView 6 | import android.widget.TextView 7 | import com.thesurix.example.gesturerecycler.databinding.LinearItemBinding 8 | 9 | class LinearItemViewHolder (private val binding: LinearItemBinding) : BaseMonthViewHolder(binding.root) { 10 | override val monthText: TextView 11 | get() = binding.monthText 12 | override val monthPicture: ImageView 13 | get() = binding.monthImage 14 | override val itemDrag: ImageView 15 | get() = binding.monthDrag 16 | override val foreground: View? 17 | get() = null 18 | } -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |