├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_channel_edit.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── drawable │ │ │ ├── bg_channel_n.xml │ │ │ ├── bg_channel_p.xml │ │ │ ├── bg_channel.xml │ │ │ └── bg_btn.xml │ │ ├── layout │ │ │ ├── item_drag.xml │ │ │ ├── activity_demo.xml │ │ │ ├── activity_main.xml │ │ │ ├── item_other_channel_header.xml │ │ │ ├── item_other.xml │ │ │ ├── item_my.xml │ │ │ └── item_my_channel_header.xml │ │ └── values-w820dp │ │ │ └── dimens.xml │ │ ├── java │ │ └── me │ │ │ └── yokeyword │ │ │ └── itemtouchhelperdemo │ │ │ ├── helper │ │ │ ├── OnItemMoveListener.java │ │ │ ├── OnDragVHListener.java │ │ │ └── ItemDragHelperCallback.java │ │ │ ├── demochannel │ │ │ ├── ChannelEntity.java │ │ │ ├── ChannelActivity.java │ │ │ └── ChannelAdapter.java │ │ │ ├── MainActivity.java │ │ │ └── demodrag │ │ │ ├── DragActivity.java │ │ │ └── DragAdapter.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | ItemTouchHelperDemo -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoKeyword/ItemTouchHelperDemo/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.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/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoKeyword/ItemTouchHelperDemo/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoKeyword/ItemTouchHelperDemo/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoKeyword/ItemTouchHelperDemo/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoKeyword/ItemTouchHelperDemo/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_channel_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoKeyword/ItemTouchHelperDemo/HEAD/app/src/main/res/mipmap-xhdpi/ic_channel_edit.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YoKeyword/ItemTouchHelperDemo/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_channel_n.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_channel_p.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ItemTouchHelperDemo 2 | 使用ItemTouchHelper实现今日头条 网易新闻 的频道排序、频道移动 3 | 4 | # 效果演示 5 | ![部分效果演示.gif](http://upload-images.jianshu.io/upload_images/937851-2df50ff9833dd386.gif?imageMogr2/auto-orient/strip) 6 | 7 | # 源码分析 8 | 查看[我的这篇简书](http://www.jianshu.com/p/d30fd8da4eac) 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 21 11:34:03 PDT 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.8-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/me/yokeyword/itemtouchhelperdemo/helper/OnItemMoveListener.java: -------------------------------------------------------------------------------- 1 | package me.yokeyword.itemtouchhelperdemo.helper; 2 | 3 | /** 4 | * Item移动后 触发 5 | * Created by YoKeyword on 15/12/28. 6 | */ 7 | public interface OnItemMoveListener { 8 | void onItemMove(int fromPosition, int toPosition); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ItemTouchHelperDemo 3 | 长按编辑,拖拽排序 4 | 我的频道 5 | 其他频道 6 | 编辑 7 | 完成 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_drag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_channel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #9c9c9c 7 | #DDDDDD 8 | #ef4836 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/me/yokeyword/itemtouchhelperdemo/helper/OnDragVHListener.java: -------------------------------------------------------------------------------- 1 | package me.yokeyword.itemtouchhelperdemo.helper; 2 | 3 | /** 4 | * ViewHolder 被选中 以及 拖拽释放 触发监听器 5 | * Created by YoKeyword on 15/12/29. 6 | */ 7 | public interface OnDragVHListener { 8 | /** 9 | * Item被选中时触发 10 | */ 11 | void onItemSelected(); 12 | 13 | 14 | /** 15 | * Item在拖拽结束/滑动结束后触发 16 | */ 17 | void onItemFinish(); 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | e 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/me/yokeyword/itemtouchhelperdemo/demochannel/ChannelEntity.java: -------------------------------------------------------------------------------- 1 | package me.yokeyword.itemtouchhelperdemo.demochannel; 2 | 3 | /** 4 | * 频道实体类 5 | * Created by YoKeyword on 15/12/29. 6 | */ 7 | public class ChannelEntity { 8 | 9 | private long id; 10 | private String name; 11 | 12 | public long getId() { 13 | return id; 14 | } 15 | 16 | public void setId(long id) { 17 | this.id = id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/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 /Users/YoKeyword/Documents/android-sdk-macosx/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 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 |