├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── dyhdyh │ │ └── helper │ │ └── itemtouch │ │ └── example │ │ ├── MainActivity.java │ │ ├── PreviewPopupWindow.java │ │ ├── SlideViewPager.java │ │ ├── ViewPagerActivity.java │ │ ├── adapter │ │ └── ExampleAdapter.java │ │ └── exampledata │ │ └── ExampleData.java │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── bg_preview.xml │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_main.xml │ ├── activity_viewpager.xml │ ├── item_example.xml │ └── popup_preview.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── config.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── item-touch-move-helper ├── .gitignore ├── bintray.gradle ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── dyhdyh │ └── helper │ └── itemtouch │ ├── ItemTouchMoveHelper.java │ ├── OnItemTouchMoveListener.java │ ├── SimpleItemTouchMoveListener.java │ └── simple │ ├── OnMovePreviewListener.java │ └── SimpleMovePreviewListener.java ├── screenshot.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | 43 | # Keystore files 44 | *.jks 45 | 46 | # External native build folder generated in Android Studio 2.2 and later 47 | .externalNativeBuild 48 | 49 | # Google Services (e.g. APIs or Firebase) 50 | google-services.json 51 | 52 | # Freeline 53 | freeline.py 54 | freeline/ 55 | freeline_project_description.json 56 | .idea 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 dengyuhan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ItemTouchMoveHelper 2 | RecyclerView的Item滑动触摸辅助类 3 | 4 | ![](screenshot.gif) 5 | 6 | 7 | ### Gradle引入 8 | ``` 9 | implementation 'com.dyhdyh:item-touch-move-helper:1.0.4' 10 | ``` 11 | 12 | ### 普通的滑动触摸监听 13 | ``` 14 | recyclerView.addOnItemTouchListener(new SimpleItemTouchMoveListener() { 15 | @Override 16 | public void onItemTouchMove(boolean isTouchChild, View childView, int childPosition, MotionEvent event) { 17 | //isTouchChild = 是否触摸在itemView上 18 | //childView = 当isTouchChild为true时指触摸的itemView,false时为null 19 | //childPosition = 当isTouchChild为true时指触摸的item位置,false时为-1 20 | Log.d("onItemTouchMove----->", isTouchChild + "," + childPosition + "," + event.getX() + "," + event.getY() + "," + event.getAction()); 21 | } 22 | 23 | @Override 24 | public boolean onInterceptEnable() { 25 | //当需要拦截事件回调onItemTouchMove的时候返回true,否则false,一般需要动态控制 26 | return true; 27 | } 28 | }); 29 | ``` 30 | 31 | ### *微信表情预览 32 | 内置了预览效果的监听,在对应的回调控制预览框即可 33 | 34 | ``` 35 | recyclerView.addOnItemTouchListener(new SimpleMovePreviewListener(recyclerView, new OnMovePreviewListener() { 36 | @Override 37 | public void onPreview(View childView, int childPosition) { 38 | //弹出预览框 39 | //popupWindow.showAsDropDown(childView,offsetX,offsetY); 40 | } 41 | 42 | @Override 43 | public void onCancelPreview() { 44 | //取消预览框 45 | //popupWindow.dismiss(); 46 | } 47 | })); 48 | ``` 49 | 50 | ##### 具体使用可以参考[MainActivity](https://github.com/dengyuhan/ItemTouchMoveHelper/blob/master/app/src/main/java/com/dyhdyh/helper/itemtouch/example/MainActivity.java) 51 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.android.compileSdkVersion 5 | buildToolsVersion rootProject.ext.android.buildToolsVersion 6 | defaultConfig { 7 | applicationId "com.dyhdyh.helper.itemtouch.example" 8 | minSdkVersion rootProject.ext.android.minSdkVersion 9 | targetSdkVersion rootProject.ext.android.targetSdkVersion 10 | versionCode rootProject.ext.android.versionCode 11 | versionName rootProject.ext.android.versionName 12 | } 13 | 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(include: ['*.jar'], dir: 'libs') 24 | implementation 'com.github.bumptech.glide:glide:3.7.0' 25 | implementation 'com.android.support:recyclerview-v7:26.1.0' 26 | implementation 'com.android.support:appcompat-v7:26.1.0' 27 | implementation project(':item-touch-move-helper') 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/dyhdyh/helper/itemtouch/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.example; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.GridLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.util.Log; 8 | import android.view.View; 9 | 10 | import com.dyhdyh.helper.itemtouch.example.adapter.ExampleAdapter; 11 | import com.dyhdyh.helper.itemtouch.example.exampledata.ExampleData; 12 | import com.dyhdyh.helper.itemtouch.simple.OnMovePreviewListener; 13 | import com.dyhdyh.helper.itemtouch.simple.SimpleMovePreviewListener; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | RecyclerView rv; 17 | private PreviewPopupWindow mPreviewWindow; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | 24 | mPreviewWindow = new PreviewPopupWindow(this); 25 | 26 | rv = findViewById(R.id.rv); 27 | final ExampleAdapter adapter = new ExampleAdapter(ExampleData.create()); 28 | rv.setLayoutManager(new GridLayoutManager(this, 4)); 29 | rv.setAdapter(adapter); 30 | 31 | /* 32 | //普通的Item滑动触摸监听 33 | rv.addOnItemTouchListener(new SimpleItemTouchMoveListener() { 34 | @Override 35 | public void onItemTouchMove(boolean isTouchChild, View childView, int childPosition, MotionEvent event) { 36 | //isTouchChild = 是否触摸在itemView上 37 | //childView = 当isTouchChild为true时指触摸的itemView,false时为null 38 | //childPosition = 当isTouchChild为true时指触摸的item位置,false时为-1 39 | Log.d("onItemTouchMove----->", isTouchChild + "," + childPosition + "," + event.getX() + "," + event.getY() + "," + event.getAction()); 40 | } 41 | 42 | @Override 43 | public boolean onInterceptEnable() { 44 | //当需要拦截事件回调onItemTouchMove的时候返回true,否则false,一般需要动态控制 45 | return true; 46 | } 47 | }); 48 | */ 49 | 50 | //微信表情商店预览效果 51 | rv.addOnItemTouchListener(new SimpleMovePreviewListener(rv, new OnMovePreviewListener() { 52 | @Override 53 | public void onPreview(View childView, int childPosition) { 54 | Log.d("SimpleMovePreview----->", "onPreview---->" + childPosition + "," + childView); 55 | 56 | final ExampleData item = adapter.getItem(childPosition); 57 | mPreviewWindow.setFileUrl(item.getFile()); 58 | 59 | if (mPreviewWindow.isShowing()) { 60 | mPreviewWindow.dismiss(); 61 | } 62 | //居中 63 | int offsetX = (mPreviewWindow.getWidth() - childView.getWidth()) / 2; 64 | int height = childView.getHeight() + mPreviewWindow.getHeight(); 65 | mPreviewWindow.showAsDropDown(childView, -offsetX, -height); 66 | } 67 | 68 | @Override 69 | public void onCancelPreview() { 70 | Log.d("SimpleMovePreview----->", "onCancelPreview---->"); 71 | mPreviewWindow.dismiss(); 72 | } 73 | })); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/dyhdyh/helper/itemtouch/example/PreviewPopupWindow.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.example; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.widget.ImageView; 7 | import android.widget.PopupWindow; 8 | 9 | import com.bumptech.glide.Glide; 10 | 11 | /** 12 | * @author dengyuhan 13 | * created 2018/4/8 15:33 14 | */ 15 | public class PreviewPopupWindow extends PopupWindow { 16 | private String mFileUrl; 17 | private int mItemPosition; 18 | 19 | private ImageView iv; 20 | 21 | public PreviewPopupWindow(Context context) { 22 | super(LayoutInflater.from(context).inflate(R.layout.popup_preview, null), context.getResources().getDimensionPixelSize(R.dimen.size_preview), context.getResources().getDimensionPixelSize(R.dimen.size_preview)); 23 | iv = getContentView().findViewById(R.id.iv_preview); 24 | } 25 | 26 | public void setFileUrl(String fileUrl) { 27 | this.mFileUrl = fileUrl; 28 | } 29 | 30 | public void setItemPosition(int itemPosition) { 31 | this.mItemPosition = itemPosition; 32 | } 33 | 34 | @Override 35 | public void showAsDropDown(View anchor, int xoff, int yoff) { 36 | super.showAsDropDown(anchor, xoff, yoff); 37 | Glide.with(anchor.getContext()) 38 | .load(mFileUrl) 39 | .into(iv); 40 | } 41 | 42 | 43 | public String getFileUrl() { 44 | return mFileUrl; 45 | } 46 | 47 | public int getItemPosition() { 48 | return mItemPosition; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/dyhdyh/helper/itemtouch/example/SlideViewPager.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.example; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | /** 9 | * @author dengyuhan 10 | * created 2018/11/26 17:27 11 | */ 12 | public class SlideViewPager extends ViewPager { 13 | private boolean isSlideEnabled; 14 | 15 | public SlideViewPager(Context context) { 16 | super(context); 17 | } 18 | 19 | public SlideViewPager(Context context, AttributeSet attrs) { 20 | super(context, attrs); 21 | } 22 | 23 | public void setSlideEnabled(boolean slideEnabled) { 24 | isSlideEnabled = slideEnabled; 25 | } 26 | 27 | @Override 28 | public boolean onInterceptTouchEvent(MotionEvent ev) { 29 | return isSlideEnabled; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/dyhdyh/helper/itemtouch/example/ViewPagerActivity.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.example; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.view.PagerAdapter; 6 | import android.support.v4.view.ViewPager; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.GridLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.util.Log; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | 14 | import com.dyhdyh.helper.itemtouch.example.adapter.ExampleAdapter; 15 | import com.dyhdyh.helper.itemtouch.example.exampledata.ExampleData; 16 | import com.dyhdyh.helper.itemtouch.simple.OnMovePreviewListener; 17 | import com.dyhdyh.helper.itemtouch.simple.SimpleMovePreviewListener; 18 | 19 | /** 20 | * @author dengyuhan 21 | * created 2018/11/26 15:11 22 | */ 23 | public class ViewPagerActivity extends AppCompatActivity { 24 | private PreviewPopupWindow mPreviewWindow; 25 | 26 | @Override 27 | protected void onCreate(@Nullable Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_viewpager); 30 | 31 | mPreviewWindow = new PreviewPopupWindow(this); 32 | 33 | final ViewPager viewpager = findViewById(R.id.viewpager); 34 | viewpager.setAdapter(new PagerAdapter() { 35 | 36 | @Override 37 | public int getCount() { 38 | return 3; 39 | } 40 | 41 | @Override 42 | public boolean isViewFromObject(View view, Object object) { 43 | return view == object; 44 | } 45 | 46 | @Override 47 | public Object instantiateItem(ViewGroup container, int position) { 48 | RecyclerView rv = new RecyclerView(container.getContext()); 49 | final ExampleAdapter adapter = new ExampleAdapter(ExampleData.create()); 50 | rv.setLayoutManager(new GridLayoutManager(container.getContext(), 4)); 51 | rv.setAdapter(adapter); 52 | //微信表情商店预览效果 53 | rv.addOnItemTouchListener(new SimpleMovePreviewListener(rv, new OnMovePreviewListener() { 54 | 55 | @Override 56 | public void onPreview(View childView, int childPosition) { 57 | Log.d("SimpleMovePreview----->", "onPreview---->" + childPosition + "," + childView); 58 | 59 | final ExampleData item = adapter.getItem(childPosition); 60 | mPreviewWindow.setFileUrl(item.getFile()); 61 | 62 | if (mPreviewWindow.isShowing()) { 63 | mPreviewWindow.dismiss(); 64 | } 65 | //居中 66 | int offsetX = (mPreviewWindow.getWidth() - childView.getWidth()) / 2; 67 | int height = childView.getHeight() + mPreviewWindow.getHeight(); 68 | mPreviewWindow.showAsDropDown(childView, -offsetX, -height); 69 | 70 | viewpager.requestDisallowInterceptTouchEvent(true); 71 | } 72 | 73 | @Override 74 | public void onCancelPreview() { 75 | Log.d("SimpleMovePreview----->", "onCancelPreview---->"); 76 | mPreviewWindow.dismiss(); 77 | } 78 | })); 79 | container.addView(rv); 80 | return rv; 81 | } 82 | 83 | @Override 84 | public void destroyItem(ViewGroup container, int position, Object object) { 85 | container.removeView((View) object); 86 | } 87 | 88 | 89 | }); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/dyhdyh/helper/itemtouch/example/adapter/ExampleAdapter.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.example.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.Toast; 9 | 10 | import com.bumptech.glide.Glide; 11 | import com.dyhdyh.helper.itemtouch.example.R; 12 | import com.dyhdyh.helper.itemtouch.example.exampledata.ExampleData; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @author dengyuhan 18 | * created 2018/3/21 19:16 19 | */ 20 | public class ExampleAdapter extends RecyclerView.Adapter { 21 | private List mData; 22 | 23 | public ExampleAdapter(List data) { 24 | this.mData = data; 25 | } 26 | 27 | 28 | @Override 29 | public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) { 30 | return new ItemHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_example, parent, false)); 31 | } 32 | 33 | @Override 34 | public void onBindViewHolder(ItemHolder holder, int position) { 35 | final ExampleData item = mData.get(position); 36 | Glide.with(holder.itemView.getContext()) 37 | .load(item.getCover()) 38 | .into(holder.iv); 39 | 40 | holder.itemView.setOnClickListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View v) { 43 | Toast.makeText(v.getContext(), "click", Toast.LENGTH_SHORT).show(); 44 | } 45 | }); 46 | 47 | } 48 | 49 | public ExampleData getItem(int position) { 50 | return mData.get(position); 51 | } 52 | 53 | @Override 54 | public int getItemCount() { 55 | return mData.size(); 56 | } 57 | 58 | static class ItemHolder extends RecyclerView.ViewHolder { 59 | ImageView iv; 60 | 61 | public ItemHolder(View itemView) { 62 | super(itemView); 63 | iv = itemView.findViewById(R.id.iv_example); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/dyhdyh/helper/itemtouch/example/exampledata/ExampleData.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.example.exampledata; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | /** 7 | * @author dengyuhan 8 | * created 2018/4/8 14:47 9 | */ 10 | public class ExampleData { 11 | private String cover; 12 | private String file; 13 | 14 | public static List create() { 15 | ExampleData[] array = new ExampleData[]{new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM7a38SyvibMdKmy3iaCuYN2D5KcibAg4vd2yjsM4YNc9PXj2mmBql4PKZo/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLDPE4aaDRRPQFNXh4QeP98sYnD94JgsbSYNY8WWGuEwspjbVOkumoVE/0"), 16 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCmxPqI7fND1u66qqFpsoh1ZKWhuKStgBh0vtGKWoOATns1jtzaWicxD/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCmxPqI7fND1vb0lUe4N1jWRSoblQuibVCrIFMQPzQozR0ZzMYgS43Wp/0"), 17 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM77fkVv3h31dbpFd4awutSbf8886qcUrvSms6qnoEPUskDWHcDvXAqE/0", "http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM77fkVv3h31daKuEVVibtHzLyAHia41dmLTtmQUG3sUEP9L04ia7nbkFP0/0"), 18 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM4CztgJabQibWic3wh7OwnTGtLZxLVoWGibb3beBQYnnIv6COIK3o2zRrp/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLDOlsGtttOfyC252oezpmGRbsccdXpSy5s72pA6ZjcOb2MlTXAJAkV7/0"), 19 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAszSAQ4gJlhxTEIEvozy84ichaVSEUsdvNEqplvrpMSuIujXjd4ITUK/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAszSAQ4gJlh31MpvkJsSTibSacK9TuvcibcjBPab31zCpuhuicLgicE37q/0"), 20 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM7dFHfr7icWeptaGibf8YYYtZlRNJ552xCFO8SOD3daG2IcxCauH4OBoh/0", "http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM7dFHfr7icWepvyr4z9y4VKwVa8zRib46uuuHQly8lZb3Y5VtT6UQBkn8/0"), 21 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLBVWrxFJdiaibziamAcz90FXMEJaZDJqKoTsA9tqhxod9Y2Miciby756CepU/0", "http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM7B8OOkp5LFWTToz5k7Ka1OksXNfbHAwV9iblegzxh5LJFp7Xhhy4eu5/0"), 22 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM59iamsj3Ciaial8C23icFex1nCKiaqLrT0BW7fHQANvpJV8ceyge18yRJQg/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLA8JYkwicuPa1NNrLkVOPPK43aRib4K5rb4PHEr9ALuiaOjyjMwPsupUJk/0"), 23 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLA5Maia2pqHavQuI0tnrA2lsZ947BAhOK0E3zeQ2yq85vPD2oQIpGWdW/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLA5Maia2pqHavVp139hiaiaCLia3pNHg5y9qENcqluoYgQiaIEP1IpDLic408/0"), 24 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLDmvO21MHeS1RxFMZuNAYxlwVnEVHgNJGHWPV6PDCNm8iczGpzEr7XJR/0", "http://mmbiz.qpic.cn/mmemoticon/DhduwiaBa7le1zztatj9ice6RUKa9C7icHl1ZLqHJTwBI4sZI5k6ydAlw/0"), 25 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCSGzU8cqeRmKCmRd2YdQibTmoLB0wu4PDibYBqCTwnk1jyusn5wfacGh/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCSGzU8cqeRmIJqbnkiaf6WKcSiadic4PMW1nEiaHlUp0Fden26D8F0SLjL/0"), 26 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAhXBBjIqSl2S8ia0ajm0zl2gcf95fU8adPtSckibPJmN5Sh6knz5EZaS/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAhXBBjIqSl2QmU3ennibvqPyYeU6XH1xSuZiandr6maC92csllQg1BZc/0"), 27 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLA0S5KxD3YJjY6JFleEicgC3t3odB1RbrpFiaWcxHRiahCe4UlMWOrgkc9/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLA0S5KxD3YJjR8LTwEeHF26ZopvoJyHL6uMuarYMPmyA10qvoO2VKaz/0"), 28 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCdwOLyl7c6JMPmicicf2xGIsF3PKWpM3wvebwFvoUj7NagKiaOTHHsibpG/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCdwOLyl7c6JEDC08hap3R3ZHZQicDpe1ibfncL9k9zNZ0d3XLciaBOno5/0"), 29 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCekdibhG6xrkeytaXZibTrmMx5ibZAv50npjH1RXUpZqWGU1URVF398q8/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCekdibhG6xrkYic3tw7SXOd3GuuIuKgicvKZZIPWZWcH7jzQCNbuPSic8O/0"), 30 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLDNuP3ULtMbekIPR3riacP9JIPSRha22meDcuwpnfIY77O9yvhNqHjx0/0", "http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM7lf1vRwFDtwPpbaCqXpgJiaD8dnxzia4B6z4dpQY2rrYwNEmfVBVfPE6/0"), 31 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM7ODaqSxITnwia8o7lP5r42x9gPtA7FQe7fzWTl70zf0wzknic5p7JEZ4/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLA4XqclcticIpLD7Iic8esgaJVBmKfBfLAaib51Tqq63cnt5t1nu6JvE2b/0"), 32 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLBpI7y0C4mp9oG8CrgeZ4gXDrKwfouOCCbHcSUOw2B11fPFRLiaFzE9A/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLBpI7y0C4mp9vQ5bZB9xzHIMUbshfBKvbe5TPjbxL5ueHYqOhUOp7MW/0"), 33 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM5guAKrqOtGXibPiaibZ5tic9LFI01oLtScWibAKTDPGPibBbaszVZGgT0vwI/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLCDicxCiafP2KptliaPyj5miacUxF5iaJWNmjsPSeNFmjXxxmaApAhrYQg5P/0"), 34 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLC3ib2qk5SSCGHvLGNMXKmE7QOiaYEt83ibH8JF7Y3p6eCERFqVA34YyWB/0", "http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM6n8rbxOAOExDkibpHhntlIicnBjDyA6A0eggwpqCphHk65IibJcDI9M5N/0"), 35 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAWgbExnXhiceI6IZQRv6icdh7jqOT824wB5cvNoRs0Tb7qiaBkUyTbia6X/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAWgbExnXhiceNIXyLAtULyqaQJOhNk0WXuKo1xD8b6Zuic3gkhicDTiaiah/0"), 36 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAqn9uGg0riawbM4q7XPyS9gkuibARj6qT8yDzEddiaBRkgBXbjM7hhwjX/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLAqn9uGg0riawZvib9LvhFrzPl2H2eTPGOJendc2DW8wu2sgBeJJQv6icv/0"), 37 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM5GInBY3yWKjyqYzj1fkiaO5GNPmDIFfwKo3HLpITtYB8UIwX5o3J4dL/0", "http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLDSKTMRgM8agtDAiaIbp4jKJGibn4VGxrPgzxsDqa2cyBPXflP6uh5chd/0"), 38 | new ExampleData("http://mmbiz.qpic.cn/mmemoticon/ajNVdqHZLLACNZkcWvHBNdBXecXVOmiaePnW8gycRicUbsDlVoKTKInXfShoQA2sTJ/0", "http://mmbiz.qpic.cn/mmemoticon/Q3auHgzwzM6xv5afsBmPyGohttEeNHDQIH3j5RQkz0wbUtpdwYVfwJyuoPEdzkAg/0"), 39 | }; 40 | 41 | return Arrays.asList(array); 42 | } 43 | 44 | public ExampleData(String cover, String file) { 45 | this.cover = cover; 46 | this.file = file; 47 | } 48 | 49 | public String getCover() { 50 | return cover; 51 | } 52 | 53 | public void setCover(String cover) { 54 | this.cover = cover; 55 | } 56 | 57 | public String getFile() { 58 | return file; 59 | } 60 | 61 | public void setFile(String file) { 62 | this.file = file; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_preview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_viewpager.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/popup_preview.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #E0E0E0 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 100dp 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ItemTouchMoveHelper 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | apply from: "config.gradle" 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.0' 11 | 12 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' 13 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 14 | 15 | // NOTE: Do not place your application dependencies here; they belong 16 | // in the individual module build.gradle files 17 | } 18 | } 19 | 20 | allprojects { 21 | repositories { 22 | google() 23 | jcenter() 24 | } 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /config.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | android = 3 | [ 4 | //版本号 5 | versionCode : 5, 6 | versionName : "1.0.4", 7 | 8 | //sdk版本 9 | compileSdkVersion: 26, 10 | buildToolsVersion: "26.0.2", 11 | minSdkVersion : 14, 12 | targetSdkVersion : 26, 13 | supportVersion : "26.1.0", 14 | ] 15 | 16 | jcenter = 17 | [ 18 | //项目名称 19 | name : "ItemTouchMoveHelper", 20 | groupId : "com.dyhdyh", 21 | //项目地址 22 | siteUrl : "https://github.com/dengyuhan/ItemTouchMoveHelper", 23 | //项目git地址 24 | gitUrl : "https://github.com/dengyuhan/ItemTouchMoveHelper.git", 25 | //项目描述 26 | description: "RecyclerView的Item滑动触摸辅助类,可以用来实现微信里的表情商店预览功能", 27 | //开发者的一些基本信息 28 | authorId : "dengyuhan", 29 | authorName : "dengyuhan", 30 | authorEmail: "22309946@qq.com", 31 | 32 | //开源协议 33 | licenses : { 34 | license { 35 | name 'MIT' 36 | url 'https://opensource.org/licenses/MIT' 37 | } 38 | }, 39 | licenseName: 'MIT' 40 | ] 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Apr 08 14:20:05 CST 2018 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-4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /item-touch-move-helper/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /item-touch-move-helper/bintray.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.github.dcendents.android-maven' 2 | apply plugin: 'com.jfrog.bintray' 3 | 4 | version = rootProject.ext.android.versionName 5 | group = rootProject.ext.jcenter.groupId 6 | 7 | android { 8 | compileSdkVersion rootProject.ext.android.compileSdkVersion 9 | buildToolsVersion rootProject.ext.android.buildToolsVersion 10 | 11 | defaultConfig { 12 | minSdkVersion rootProject.ext.android.minSdkVersion 13 | targetSdkVersion rootProject.ext.android.targetSdkVersion 14 | versionCode rootProject.ext.android.versionCode 15 | versionName rootProject.ext.android.versionName 16 | } 17 | 18 | compileOptions { 19 | sourceCompatibility JavaVersion.VERSION_1_8 20 | targetCompatibility JavaVersion.VERSION_1_8 21 | } 22 | } 23 | 24 | install { 25 | repositories.mavenInstaller { 26 | pom { 27 | project { 28 | packaging 'aar' 29 | name rootProject.ext.jcenter.description 30 | url rootProject.ext.jcenter.siteUrl 31 | licenses rootProject.ext.jcenter.licenses 32 | developers { 33 | developer { 34 | id rootProject.ext.jcenter.authorId 35 | name rootProject.ext.jcenter.authorName 36 | email rootProject.ext.jcenter.authorEmail 37 | } 38 | } 39 | scm { 40 | connection rootProject.ext.jcenter.gitUrl 41 | developerConnection rootProject.ext.jcenter.gitUrl 42 | url rootProject.ext.jcenter.siteUrl 43 | } 44 | } 45 | } 46 | } 47 | } 48 | 49 | // 生成jar包的task 50 | task sourcesJar(type: Jar) { 51 | from android.sourceSets.main.java.srcDirs 52 | classifier = 'sources' 53 | } 54 | 55 | // 生成javaDoc的jar 56 | task javadoc(type: Javadoc) { 57 | source = android.sourceSets.main.java.srcDirs 58 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 59 | } 60 | task javadocJar(type: Jar, dependsOn: javadoc) { 61 | classifier = 'javadoc' 62 | from javadoc.destinationDir 63 | } 64 | artifacts { 65 | archives javadocJar 66 | archives sourcesJar 67 | } 68 | 69 | //设置编码格式,如果不设置可能会在gradlew install的时候出现GBK编码映射错误 70 | javadoc { 71 | options { 72 | encoding "UTF-8" 73 | charSet 'UTF-8' 74 | author true 75 | version true 76 | links "http://docs.oracle.com/javase/8/docs/api" 77 | } 78 | } 79 | Properties properties = new Properties() 80 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 81 | bintray { 82 | user = properties.getProperty("bintray.user") 83 | key = properties.getProperty("bintray.apikey") 84 | configurations = ['archives'] 85 | pkg { 86 | repo = "maven" 87 | name = rootProject.ext.jcenter.name 88 | websiteUrl = rootProject.ext.jcenter.siteUrl 89 | vcsUrl = rootProject.ext.jcenter.gitUrl 90 | licenses = [rootProject.ext.jcenter.licenseName] 91 | publish = true 92 | } 93 | } -------------------------------------------------------------------------------- /item-touch-move-helper/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply from: "bintray.gradle" 3 | 4 | dependencies { 5 | compileOnly "com.android.support:appcompat-v7:26.1.0" 6 | compileOnly "com.android.support:recyclerview-v7:26.1.0" 7 | } 8 | -------------------------------------------------------------------------------- /item-touch-move-helper/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /item-touch-move-helper/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /item-touch-move-helper/src/main/java/com/dyhdyh/helper/itemtouch/ItemTouchMoveHelper.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.MotionEvent; 5 | import android.view.View; 6 | 7 | /** 8 | * 滑动触摸辅助 9 | * 10 | * @author dengyuhan 11 | * created 2018/4/8 14:24 12 | */ 13 | public class ItemTouchMoveHelper { 14 | private boolean mInterceptEnable; 15 | private OnItemTouchMoveListener mOnItemTouchMoveListener; 16 | 17 | public boolean onTouchEvent(RecyclerView rv, MotionEvent e) { 18 | if (!mInterceptEnable) { 19 | return false; 20 | } 21 | 22 | //Log.d("ItemTouchMoveHelper", "onTouchEvent----->" + e); 23 | 24 | View childView = rv.findChildViewUnder(e.getX(), e.getY()); 25 | if (childView == null) { 26 | if (mOnItemTouchMoveListener != null) { 27 | mOnItemTouchMoveListener.onItemTouchMove(false, null, -1, e); 28 | return true; 29 | } 30 | } 31 | 32 | int childPosition = rv.getChildLayoutPosition(childView); 33 | if (childPosition < 0) { 34 | if (mOnItemTouchMoveListener != null) { 35 | mOnItemTouchMoveListener.onItemTouchMove(false, null, -1, e); 36 | return true; 37 | } 38 | } 39 | 40 | if (e.getAction() == MotionEvent.ACTION_DOWN || e.getAction() == MotionEvent.ACTION_MOVE) { 41 | if (mOnItemTouchMoveListener != null) { 42 | mOnItemTouchMoveListener.onItemTouchMove(true, childView, childPosition, e); 43 | return true; 44 | } 45 | } else if (e.getAction() == MotionEvent.ACTION_UP) { 46 | if (mOnItemTouchMoveListener != null) { 47 | mOnItemTouchMoveListener.onItemTouchMove(true, childView, childPosition, e); 48 | return true; 49 | } 50 | } 51 | return false; 52 | } 53 | 54 | public void setOnItemTouchMoveListener(OnItemTouchMoveListener onItemTouchMoveListener) { 55 | this.mOnItemTouchMoveListener = onItemTouchMoveListener; 56 | } 57 | 58 | public void setInterceptEnable(boolean interceptEnable) { 59 | this.mInterceptEnable = interceptEnable; 60 | } 61 | 62 | /** 63 | * 是否在触摸 64 | * 65 | * @param event 66 | * @return 67 | */ 68 | public static boolean isActionTouch(MotionEvent event) { 69 | return event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE; 70 | } 71 | 72 | /** 73 | * 是否触摸结束 74 | * 75 | * @param event 76 | * @return 77 | */ 78 | public static boolean isActionEnd(MotionEvent event) { 79 | return event.getAction() == MotionEvent.ACTION_UP; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /item-touch-move-helper/src/main/java/com/dyhdyh/helper/itemtouch/OnItemTouchMoveListener.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch; 2 | 3 | import android.view.MotionEvent; 4 | import android.view.View; 5 | 6 | /** 7 | * @author dengyuhan 8 | * created 2018/4/8 14:29 9 | */ 10 | public interface OnItemTouchMoveListener { 11 | 12 | /** 13 | * 滑动监听的回调 14 | * 15 | * @param isTouchChild true表示触摸坐标在childView之内,false表示在childView之外,并且childView与childPosition值无效 16 | * @param childView 触摸的子View 17 | * @param childPosition 触摸的Item位置 18 | * @param event 触摸信息 19 | */ 20 | void onItemTouchMove(boolean isTouchChild, View childView, int childPosition, MotionEvent event); 21 | } 22 | -------------------------------------------------------------------------------- /item-touch-move-helper/src/main/java/com/dyhdyh/helper/itemtouch/SimpleItemTouchMoveListener.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.MotionEvent; 5 | import android.view.View; 6 | 7 | /** 8 | * 普通的滑动触摸监听 9 | * 10 | * @author dengyuhan 11 | * created 2018/4/8 14:22 12 | */ 13 | public abstract class SimpleItemTouchMoveListener extends RecyclerView.SimpleOnItemTouchListener implements OnItemTouchMoveListener { 14 | private ItemTouchMoveHelper mItemTouchMoveHelper; 15 | 16 | public SimpleItemTouchMoveListener() { 17 | mItemTouchMoveHelper = new ItemTouchMoveHelper(); 18 | mItemTouchMoveHelper.setOnItemTouchMoveListener(this); 19 | } 20 | 21 | @Override 22 | public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { 23 | return onInterceptEnable(); 24 | } 25 | 26 | @Override 27 | public void onTouchEvent(RecyclerView rv, MotionEvent e) { 28 | mItemTouchMoveHelper.setInterceptEnable(onInterceptEnable()); 29 | mItemTouchMoveHelper.onTouchEvent(rv, e); 30 | } 31 | 32 | @Override 33 | public void onItemTouchMove(boolean isTouchChild, View childView, int childPosition, MotionEvent event) { 34 | 35 | } 36 | 37 | public abstract boolean onInterceptEnable(); 38 | } 39 | -------------------------------------------------------------------------------- /item-touch-move-helper/src/main/java/com/dyhdyh/helper/itemtouch/simple/OnMovePreviewListener.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.simple; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * @author dengyuhan 7 | * created 2018/4/9 09:23 8 | */ 9 | public interface OnMovePreviewListener { 10 | 11 | void onPreview(View childView, int childPosition); 12 | 13 | void onCancelPreview(); 14 | } 15 | -------------------------------------------------------------------------------- /item-touch-move-helper/src/main/java/com/dyhdyh/helper/itemtouch/simple/SimpleMovePreviewListener.java: -------------------------------------------------------------------------------- 1 | package com.dyhdyh.helper.itemtouch.simple; 2 | 3 | import android.support.v4.view.GestureDetectorCompat; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.GestureDetector; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | 9 | import com.dyhdyh.helper.itemtouch.ItemTouchMoveHelper; 10 | import com.dyhdyh.helper.itemtouch.SimpleItemTouchMoveListener; 11 | 12 | /** 13 | * 简单的滑动预览监听 14 | * 15 | * @author dengyuhan 16 | * created 2018/4/9 09:20 17 | */ 18 | public class SimpleMovePreviewListener extends SimpleItemTouchMoveListener { 19 | private int mLastPosition = -1; 20 | private boolean mPreviewEnable;//开启预览 21 | private GestureDetectorCompat mGestureDetector; 22 | private OnMovePreviewListener mOnMovePreviewListener; 23 | 24 | public SimpleMovePreviewListener(RecyclerView rv, OnMovePreviewListener listener) { 25 | this.mOnMovePreviewListener = listener; 26 | this.mGestureDetector = new GestureDetectorCompat(rv.getContext(), new GestureDetector.SimpleOnGestureListener() { 27 | @Override 28 | public void onLongPress(MotionEvent e) { 29 | //长按开启预览 30 | mPreviewEnable = true; 31 | onTouchEvent(rv, e); 32 | } 33 | }); 34 | } 35 | 36 | @Override 37 | public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { 38 | mGestureDetector.onTouchEvent(e); 39 | return super.onInterceptTouchEvent(rv, e); 40 | } 41 | 42 | @Override 43 | public void onItemTouchMove(boolean isTouchChild, View childView, int childPosition, MotionEvent event) { 44 | if (ItemTouchMoveHelper.isActionTouch(event)) { 45 | //如果在触摸点在View上 46 | if (isTouchChild) { 47 | //判断位置 防止多次回调 48 | if (mLastPosition != childPosition) { 49 | mLastPosition = childPosition; 50 | if (mOnMovePreviewListener != null) { 51 | mOnMovePreviewListener.onPreview(childView, childPosition); 52 | } 53 | } 54 | } 55 | } else { 56 | //手指抬起时取消 57 | mLastPosition = -1; 58 | mPreviewEnable = false; 59 | if (mOnMovePreviewListener != null) { 60 | mOnMovePreviewListener.onCancelPreview(); 61 | } 62 | } 63 | } 64 | 65 | @Override 66 | public boolean onInterceptEnable() { 67 | return mPreviewEnable; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiandanin/ItemTouchMoveHelper/4bb9747d1fce334972038baa58564d692b5fca61/screenshot.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':item-touch-move-helper' 2 | --------------------------------------------------------------------------------