├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xinlan │ │ └── dragindicatorview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xinlan │ │ │ └── dragindicatorview │ │ │ ├── Bean.java │ │ │ ├── CircleTransform.java │ │ │ ├── ListAdapter.java │ │ │ ├── MainActivity.java │ │ │ └── SecondActivity.java │ └── res │ │ ├── drawable-hdpi │ │ └── ic_android_black_24dp.png │ │ ├── drawable-mdpi │ │ └── ic_android_black_24dp.png │ │ ├── drawable-xhdpi │ │ └── ic_android_black_24dp.png │ │ ├── drawable-xxhdpi │ │ └── ic_android_black_24dp.png │ │ ├── drawable-xxxhdpi │ │ └── ic_android_black_24dp.png │ │ ├── layout │ │ ├── activity_list.xml │ │ ├── activity_main.xml │ │ └── list_item.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── xinlan │ └── dragindicatorview │ └── ExampleUnitTest.java ├── build.gradle ├── dragindicator ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── xinlan │ │ └── dragindicator │ │ ├── DragIndicatorView.java │ │ ├── Point.java │ │ └── PointEvaluator.java │ └── res │ ├── drawable-xhdpi │ ├── clean_1.png │ ├── clean_2.png │ ├── clean_3.png │ ├── clean_4.png │ └── clean_5.png │ ├── drawable │ └── clean_anim.xml │ └── values │ └── strings.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── demo1.gif └── demo2.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | DragIndicatorView -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 27 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 带拖拽效果的红点提示控件 DragIndicatorView 2 |
3 | 4 |
5 | 6 |
7 | 8 |

9 | 可以通过拖拽消失的小红点提示 10 |

11 |

DragIndicatorView扩展自TextView 可当成普通TextView使用

12 | 13 |

手动触发红点消失:

14 |
15 | 
16 |     mDragIndicatorView.dismissView();
17 | 
18 | 
19 | 20 |

当需要监听红点消失事件时 可设置监听如下:

21 |
22 | 
23 |     mDragIndicatorView.setOnDismissAction(new DragIndicatorView.OnIndicatorDismiss() {
24 |                 @Override
25 |                 public void OnDismiss(DragIndicatorView view) {
26 |                     //TODO  当红点因拖拽或调用dismissView消失时
27 |                 }
28 |             });
29 | 
30 | 
31 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.xinlan.dragindicatorview" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.2.0' 26 | compile 'com.android.support:design:23.2.0' 27 | compile 'com.squareup.picasso:picasso:2.5.2' 28 | compile project(path: ':dragindicator') 29 | } 30 | -------------------------------------------------------------------------------- /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 E:\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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xinlan/dragindicatorview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xinlan.dragindicatorview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinlan/dragindicatorview/Bean.java: -------------------------------------------------------------------------------- 1 | package com.xinlan.dragindicatorview; 2 | 3 | /** 4 | * Created by panyi on 2016/4/6. 5 | */ 6 | public class Bean { 7 | public String name; 8 | public int num; 9 | public String url; 10 | public boolean isIndicatorShow = true; 11 | 12 | public Bean(String name, String url, int num) { 13 | this.name = name; 14 | this.url = url; 15 | this.num = num; 16 | } 17 | }//end class 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinlan/dragindicatorview/CircleTransform.java: -------------------------------------------------------------------------------- 1 | package com.xinlan.dragindicatorview; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapShader; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | 8 | import com.squareup.picasso.Transformation; 9 | 10 | /** 11 | * Created by panyi on 2016/4/6. 12 | */ 13 | public class CircleTransform implements Transformation { 14 | @Override 15 | public Bitmap transform(Bitmap source) { 16 | int size = Math.min(source.getWidth(), source.getHeight()); 17 | 18 | int x = (source.getWidth() - size) / 2; 19 | int y = (source.getHeight() - size) / 2; 20 | 21 | Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size); 22 | if (squaredBitmap != source) { 23 | source.recycle(); 24 | } 25 | 26 | Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig()); 27 | Canvas canvas = new Canvas(bitmap); 28 | Paint paint = new Paint(); 29 | BitmapShader shader = new BitmapShader(squaredBitmap, 30 | BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP); 31 | paint.setShader(shader); 32 | paint.setAntiAlias(true); 33 | float r = size / 2f; 34 | canvas.drawCircle(r, r, r, paint); 35 | squaredBitmap.recycle(); 36 | return bitmap; 37 | } 38 | 39 | @Override 40 | public String key() { 41 | return "circle"; 42 | } 43 | }//end class 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinlan/dragindicatorview/ListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.xinlan.dragindicatorview; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.squareup.picasso.Picasso; 12 | import com.xinlan.dragindicator.DragIndicatorView; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created by panyi on 2016/4/6. 18 | */ 19 | public class ListAdapter extends RecyclerView.Adapter { 20 | private List mDataList; 21 | private Context mContext; 22 | 23 | public ListAdapter(Context context, List data) { 24 | this.mContext = context; 25 | this.mDataList = data; 26 | } 27 | 28 | @Override 29 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 30 | final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false); 31 | ViewHolder holder = new ViewHolder(view); 32 | return holder; 33 | } 34 | 35 | @Override 36 | public void onBindViewHolder(ViewHolder holder, int position) { 37 | if (mDataList == null) 38 | return; 39 | final Bean bean = mDataList.get(position); 40 | holder.mText.setText(bean.name); 41 | Picasso.with(mContext).load(bean.url).transform(new CircleTransform()). 42 | placeholder(R.drawable.ic_android_black_24dp).into(holder.mImage); 43 | if (bean.isIndicatorShow) { 44 | holder.mDragView.setText(String.valueOf(bean.num)); 45 | holder.mDragView.setVisibility(View.VISIBLE); 46 | } else { 47 | holder.mDragView.setVisibility(View.GONE); 48 | }//end if 49 | holder.mDragView.setOnDismissAction(new DragIndicatorView.OnIndicatorDismiss() { 50 | @Override 51 | public void OnDismiss(DragIndicatorView view) { 52 | bean.isIndicatorShow = false; 53 | } 54 | }); 55 | } 56 | 57 | @Override 58 | public int getItemCount() { 59 | return mDataList.size(); 60 | } 61 | 62 | public static class ViewHolder extends RecyclerView.ViewHolder { 63 | public ImageView mImage; 64 | public TextView mText; 65 | public DragIndicatorView mDragView; 66 | 67 | public ViewHolder(View v) { 68 | super(v); 69 | mImage = (ImageView) v.findViewById(R.id.image); 70 | mText = (TextView) v.findViewById(R.id.text); 71 | mDragView = (DragIndicatorView) v.findViewById(R.id.indicator); 72 | } 73 | }//end inner class 74 | }//end class 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinlan/dragindicatorview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.xinlan.dragindicatorview; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | 7 | import com.xinlan.dragindicator.DragIndicatorView; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | private DragIndicatorView mIndiactorView; 11 | private DragIndicatorView mOtherView; 12 | private View mDismssBtn; 13 | private View mSecondBtn; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | 20 | mIndiactorView = (DragIndicatorView) findViewById(R.id.indiactor_view); 21 | mOtherView = (DragIndicatorView) findViewById(R.id.indicator); 22 | 23 | mDismssBtn = findViewById(R.id.close_btn); 24 | mDismssBtn.setOnClickListener(new View.OnClickListener() { 25 | @Override 26 | public void onClick(View v) { 27 | mIndiactorView.dismissView(); 28 | mOtherView.dismissView(); 29 | } 30 | }); 31 | 32 | mSecondBtn = findViewById(R.id.second_btn); 33 | mSecondBtn.setOnClickListener(new View.OnClickListener() { 34 | @Override 35 | public void onClick(View v) { 36 | //to list activity 37 | SecondActivity.start(MainActivity.this); 38 | } 39 | }); 40 | } 41 | 42 | }//end class 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinlan/dragindicatorview/SecondActivity.java: -------------------------------------------------------------------------------- 1 | package com.xinlan.dragindicatorview; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.RecyclerView; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * List Activity 14 | */ 15 | public class SecondActivity extends AppCompatActivity { 16 | private List mList = new ArrayList(); 17 | 18 | private RecyclerView mListView; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_list); 24 | initData(); 25 | findViews(); 26 | initListView(); 27 | } 28 | 29 | private void findViews() { 30 | mListView = (RecyclerView) findViewById(R.id.list); 31 | mListView.setHasFixedSize(true); 32 | } 33 | 34 | private void initListView() { 35 | mListView.setAdapter(new ListAdapter(this, mList)); 36 | } 37 | 38 | public static void start(Activity context) { 39 | context.startActivity(new Intent(context, SecondActivity.class)); 40 | } 41 | 42 | private void initData() { 43 | mList.add(new Bean("海边的卡夫卡", "http://img10.360buyimg.com/n0/g14/M06/06/00/rBEhV1Hog7kIAAAAAAJBoy0J-0YAABLLAO-AUoAAkG7180.jpg", 1)); 44 | mList.add(new Bean("挪威的森林", "http://img22.mtime.cn/up/2011/11/13/212010.80062662_500.jpg", 2)); 45 | mList.add(new Bean("没有女人的男人们", "http://img1.cache.netease.com/catchpic/B/B2/B221247352A242589DB2251244D9EE58.jpg", 3)); 46 | mList.add(new Bean("且听风吟", "http://images.bookuu.com/book_t/11/49/27/1149277.jpg", 3)); 47 | mList.add(new Bean("神的孩子全跳舞", "http://images.zxhsd.com/photo/book_b/C/00843/97875327484951591635-fm-b.jpg", 3)); 48 | mList.add(new Bean("海边的卡夫卡", "http://img10.360buyimg.com/n0/g14/M06/06/00/rBEhV1Hog7kIAAAAAAJBoy0J-0YAABLLAO-AUoAAkG7180.jpg", 1)); 49 | mList.add(new Bean("挪威的森林", "http://img22.mtime.cn/up/2011/11/13/212010.80062662_500.jpg", 2)); 50 | mList.add(new Bean("没有女人的男人们", "http://img1.cache.netease.com/catchpic/B/B2/B221247352A242589DB2251244D9EE58.jpg", 3)); 51 | mList.add(new Bean("且听风吟", "http://images.bookuu.com/book_t/11/49/27/1149277.jpg", 3)); 52 | mList.add(new Bean("神的孩子全跳舞", "http://images.zxhsd.com/photo/book_b/C/00843/97875327484951591635-fm-b.jpg", 3)); 53 | mList.add(new Bean("海边的卡夫卡", "http://img10.360buyimg.com/n0/g14/M06/06/00/rBEhV1Hog7kIAAAAAAJBoy0J-0YAABLLAO-AUoAAkG7180.jpg", 1)); 54 | mList.add(new Bean("挪威的森林", "http://img22.mtime.cn/up/2011/11/13/212010.80062662_500.jpg", 2)); 55 | mList.add(new Bean("没有女人的男人们", "http://img1.cache.netease.com/catchpic/B/B2/B221247352A242589DB2251244D9EE58.jpg", 3)); 56 | mList.add(new Bean("且听风吟", "http://images.bookuu.com/book_t/11/49/27/1149277.jpg", 3)); 57 | mList.add(new Bean("神的孩子全跳舞", "http://images.zxhsd.com/photo/book_b/C/00843/97875327484951591635-fm-b.jpg", 3)); 58 | } 59 | }//end class 60 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_android_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siwangqishiq/DragIndicatorView/bf937c72878bfed67f872a0fad84f680908033a4/app/src/main/res/drawable-hdpi/ic_android_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_android_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siwangqishiq/DragIndicatorView/bf937c72878bfed67f872a0fad84f680908033a4/app/src/main/res/drawable-mdpi/ic_android_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_android_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siwangqishiq/DragIndicatorView/bf937c72878bfed67f872a0fad84f680908033a4/app/src/main/res/drawable-xhdpi/ic_android_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_android_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siwangqishiq/DragIndicatorView/bf937c72878bfed67f872a0fad84f680908033a4/app/src/main/res/drawable-xxhdpi/ic_android_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_android_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siwangqishiq/DragIndicatorView/bf937c72878bfed67f872a0fad84f680908033a4/app/src/main/res/drawable-xxxhdpi/ic_android_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 18 | 24 | 34 | 35 | 36 | 42 | 47 | 53 | 64 | 65 | 66 | 67 | 68 |