├── .circleci └── config.yml ├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── .travis.yml ├── LICENSE.txt ├── README.md ├── build.gradle ├── circle.yml ├── dragpointview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── javonlee │ │ └── dragpointview │ │ ├── OnPointDragListener.java │ │ ├── PointViewAnimObject.java │ │ ├── util │ │ └── MathUtils.java │ │ └── view │ │ ├── AbsDragPointView.java │ │ ├── ClearViewHelper.java │ │ ├── DragPointView.java │ │ ├── DragPointViewWindow.java │ │ └── DragViewHelper.java │ └── res │ └── values │ └── attr.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── javonlee │ │ └── sample │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── javonlee │ │ │ └── sample │ │ │ ├── ConversationEntity.java │ │ │ ├── ItemConversationAdapter.java │ │ │ └── SampleActivity.java │ └── res │ │ ├── drawable │ │ ├── divider.xml │ │ ├── list_item_selector.xml │ │ ├── shape_drag_point_blue.xml │ │ ├── shape_drag_point_item.xml │ │ ├── shape_drag_point_red.xml │ │ └── shape_drag_point_yellow.xml │ │ ├── layout │ │ ├── activity_sample.xml │ │ └── item_conversation.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── explode1.png │ │ ├── explode2.png │ │ ├── explode3.png │ │ ├── explode4.png │ │ ├── explode5.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ ├── avatar.png │ │ ├── chat.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── javonlee │ └── sample │ └── ExampleUnitTest.java ├── settings.gradle └── static ├── example_1.gif ├── example_2.gif └── example_3.gif /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: drazisil/android-sdk:1.0.41 6 | working_directory: ~/androidlearn 7 | steps: 8 | # Ensure your image has git, otherwise the checkout step will fail 9 | # - run: apt-get -qq update; apt-get -y install git 10 | - checkout 11 | - run: mkdir artifacts 12 | - run: 13 | name: List what is currently installed 14 | command: sdkmanager --list 15 | - run: 16 | name: Create AVD 17 | command: | 18 | echo "n" | avdmanager -v create avd -n androidlearn -k "system-images;android-25;google_apis;armeabi-v7a" -c 512M -g google_apis -d "Nexus 7 2013" 19 | - run: 20 | name: Run Emulator 21 | background: true 22 | command: | 23 | $ANDROID_SDK_ROOT/tools/emulator -no-window -noaudio -no-boot-anim -gpu swiftshader @androidlearn 24 | - run: 25 | name: Wait for Emulator 26 | no_output_timeout: 15m 27 | command: | 28 | sleep 15 29 | $ANDROID_SDK_ROOT/platform-tools/adb devices 30 | sleep 10 31 | - run: 32 | name: Fetch logcat and props 33 | background: true 34 | command: | 35 | $ANDROID_SDK_ROOT/platform-tools/adb logcat >> ./artifacts/logcat.txt 36 | $ANDROID_SDK_ROOT/platform-tools/adb shell getprop >> ./artifacts/props.txt 37 | - run: 38 | name: Run Android Connected Tests 39 | command: | 40 | export ADB_INSTALL_TIMEOUT=120 41 | export ANDROID_HOME=$ANDROID_SDK_ROOT 42 | # ./scripts/test.sh 43 | ./gradlew assembleDebug 44 | # Wait for emulator to fully boot 45 | # TODO: Need to create a good check 46 | sleep 60 47 | 48 | # Is the emulator still running? 49 | adb devices 50 | 51 | # Check if package manager is running 52 | adb shell pm list packages 53 | 54 | # Install package 55 | $ANDROID_SDK_ROOT/platform-tools/adb install /home/android/androidlearn/app/build/outputs/apk/app-debug.apk 56 | ./gradlew connectedAndroidTest 57 | - store_artifacts: 58 | path: ~/androidlearn/artifacts 59 | destination: env -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.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 | 18 | 19 | -------------------------------------------------------------------------------- /.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 | 47 | 48 | 49 | 50 | 1.8 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | sudo: false 4 | 5 | android: 6 | components: 7 | - tools 8 | - build-tools-25.0.2 9 | - android-25 10 | - extra-android-m2repository 11 | - extra-android-support 12 | licenses: 13 | - android-sdk-license-.+ 14 | - '.+' 15 | 16 | before_install: 17 | - chmod +x gradlew 18 | - mkdir "$ANDROID_HOME/licenses" || true 19 | - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license" 20 | - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license" 21 | 22 | script: 23 | - ./gradlew assembleRelease -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DragPointView 2 | 3 | [![](https://jitpack.io/v/javonleee/DragPointView.svg)](https://jitpack.io/#javonleee/DragPointView) [![Build Status](https://travis-ci.org/javonleee/DragPointView.svg?branch=master)](https://travis-ci.org/javonleee/DragPointView) [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) [![作者](https://img.shields.io/badge/author-javonlee-green.svg)](http://www.gdky005.com) 4 | 5 | 6 | This is a handy developer to quickly implement drag and drop unread messages, widget, which you can use as you do with TextView, and customize detail effects with extra attributes and method. 7 | 8 | ![](static/example_1.gif) ![](static/example_2.gif) ![](static/example_3.gif) 9 | 10 | ## Dependency 11 | 12 | Add this in your project `build.gradle` file: 13 | 14 | ```gradle 15 | allprojects { 16 | repositories { 17 | maven { url "https://jitpack.io" } 18 | } 19 | } 20 | ``` 21 | 22 | Then, add the library to your module `build.gradle` 23 | ```gradle 24 | dependencies { 25 | compile 'com.github.javonleee:DragPointView:latest.release' 26 | } 27 | ``` 28 | 29 | ## Features 30 | - Inherited from TextView, easy to use. 31 | - Bessel curve is used to achieve tensile effect. 32 | - Provide you with rich attributes to customize various effects, such as maximum length of drag and drop, front and rear round radius, curve part color, radius scaling coefficient, etc. 33 | - Drag and drop actions are not restricted by the parent container, and the screen is free to drag and drop. 34 | - Allows settings to release animation, Animator or AnimationDrawable. 35 | - External development status monitoring, monitoring the status of the widget. 36 | - Convenient to clear the widget of the same sign. 37 | 38 | ## Usage 39 | There is a [sample](https://github.com/javonleee/DragPointView/tree/master/sample) provided which shows how to use the library in a more advanced way, but for completeness, here is all that is required to get DragPointView working: 40 | ```xml 41 | 56 | ``` 57 | ```java 58 | DragPointView dragPointView = (DragPointView) findViewById(R.id.drag_point_view); 59 | pointView.setRemoveAnim(animationDrawable); 60 | pointView.setOnPointDragListener(listener); 61 | ``` 62 | That's it! 63 | 64 | ### Attribute 65 | You can customize the desired effect by setting the following properties in the layout file. 66 | - **maxDragLength**:Within this range, the Bessel rendering section will be shown, with the default value of Math.min (w, h)*3. 67 | - **centerCircleRadius**:The initial radius of the center circle. 68 | - **dragCircleRadius**:The initial radius of the drag circle. 69 | - **centerMinRatio**:When dragging, the center circle becomes smaller and smaller with distance, and the property controls its minimum coefficient range: 0.5f~1.0f. 70 | - r**ecoveryAnimDuration**:If the stretch length is not up to the threshold, the animation will be recovery, specifying the length of the animation. 71 | - **recoveryAnimBounce**:recovery animation bounce factor, range 0.0f~1.0f. 72 | - **colorStretching**:Bessel painted some colors, recommended consistent with the widget background. 73 | - **sign**:Mark the category of this control and use it with clearSign. 74 | - **clearSign**:The clearSign specified widgets are removed at the same time as they are removed. 75 | - **canDrag**:Controls whether or not to allow drag and drop. 76 | 77 | 78 | ## Caution 79 | When the DragPointView that sets the clearSign property is removed, be sure to update the relevant object information in the onRemoveStart or onRemoveEnd callback.For example, set all chat sessions to read. 80 | ```java 81 | @Override 82 | public void onRemoveStart(AbsDragPointView view) { 83 | for (ConversationEntity entity : conversationEntities) { 84 | entity.setRead(true); 85 | entity.setMessageNum(0); 86 | } 87 | } 88 | ``` 89 | 90 | 91 | Author 92 | ------ 93 | javonlee@163.com 94 | 95 | javonlee999@gmail.com 96 | 97 | 98 | License 99 | -------- 100 | 101 | Copyright 2017 javonlee 102 | 103 | Licensed under the Apache License, Version 2.0 (the "License"); 104 | you may not use this file except in compliance with the License. 105 | You may obtain a copy of the License at 106 | 107 | http://www.apache.org/licenses/LICENSE-2.0 108 | 109 | Unless required by applicable law or agreed to in writing, software 110 | distributed under the License is distributed on an "AS IS" BASIS, 111 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 112 | See the License for the specific language governing permissions and 113 | limitations under the License. 114 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.2' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | # Java Gradle CircleCI 2.0 configuration file 2 | # 3 | # Check https://circleci.com/docs/2.0/language-java/ for more details 4 | # 5 | version: 2 6 | jobs: 7 | build: 8 | docker: 9 | # specify the version you desire here 10 | - image: circleci/openjdk:8-jdk 11 | 12 | # Specify service dependencies here if necessary 13 | # CircleCI maintains a library of pre-built images 14 | # documented at https://circleci.com/docs/2.0/circleci-images/ 15 | # - image: circleci/postgres:9.4 16 | 17 | working_directory: ~/repo 18 | 19 | environment: 20 | # Customize the JVM maximum heap limit 21 | JVM_OPTS: -Xmx3200m 22 | TERM: dumb 23 | 24 | steps: 25 | - checkout 26 | 27 | # Download and cache dependencies 28 | - restore_cache: 29 | keys: 30 | - v1-dependencies-{{ checksum "build.gradle" }} 31 | # fallback to using the latest cache if no exact match is found 32 | - v1-dependencies- 33 | 34 | - run: gradle dependencies 35 | 36 | - save_cache: 37 | paths: 38 | - ~/.m2 39 | key: v1-dependencies-{{ checksum "build.gradle" }} 40 | 41 | # run tests! 42 | - run: gradle test 43 | -------------------------------------------------------------------------------- /dragpointview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /dragpointview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion '25.0.2' 6 | 7 | defaultConfig { 8 | minSdkVersion 11 9 | targetSdkVersion 25 10 | } 11 | } -------------------------------------------------------------------------------- /dragpointview/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 F:\studio_sdk\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 | -------------------------------------------------------------------------------- /dragpointview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/OnPointDragListener.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview; 2 | 3 | import com.javonlee.dragpointview.view.AbsDragPointView; 4 | 5 | /** 6 | * Created by lijinfeng on 2017/7/29. 7 | */ 8 | 9 | public interface OnPointDragListener { 10 | void onRemoveStart(AbsDragPointView view); 11 | 12 | void onRemoveEnd(AbsDragPointView view); 13 | 14 | void onRecovery(AbsDragPointView view); 15 | } 16 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/PointViewAnimObject.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.graphics.drawable.AnimationDrawable; 6 | import android.graphics.drawable.Drawable; 7 | import android.os.Build; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.view.animation.Animation; 11 | 12 | import com.javonlee.dragpointview.view.ClearViewHelper; 13 | import com.javonlee.dragpointview.view.AbsDragPointView; 14 | 15 | /** 16 | * Created by lijinfeng on 2017/7/24. 17 | */ 18 | 19 | public class PointViewAnimObject { 20 | 21 | private Object object; 22 | private AbsDragPointView view; 23 | private Drawable background; 24 | 25 | public PointViewAnimObject setView(AbsDragPointView view) { 26 | this.view = view; 27 | return this; 28 | } 29 | 30 | public PointViewAnimObject(Object object, AbsDragPointView view) { 31 | this.object = object; 32 | this.view = view; 33 | } 34 | 35 | public void start(OnPointDragListener removeListener) { 36 | if (object == null) 37 | throw new RuntimeException("remove anim is null."); 38 | if (removeListener != null) 39 | removeListener.onRemoveStart(view); 40 | view.setPivotX(view.getWidth() / 2); 41 | view.setPivotY(view.getHeight() / 2); 42 | if (object instanceof AnimationDrawable) { 43 | background = view.getBackground(); 44 | start((AnimationDrawable) object, removeListener); 45 | } else if (object instanceof Animator) { 46 | start((Animator) object, removeListener); 47 | } else if (object instanceof Animation) { 48 | start((Animation) object, removeListener); 49 | } 50 | } 51 | 52 | private void start(AnimationDrawable object, final OnPointDragListener removeListener) { 53 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 54 | int duration = 0; 55 | for (int i = 0; i < object.getNumberOfFrames(); i++) { 56 | duration += object.getDuration(i); 57 | } 58 | view.postDelayed(new Runnable() { 59 | @Override 60 | public void run() { 61 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 62 | view.setBackground(background); 63 | } 64 | end(removeListener); 65 | } 66 | }, duration + 5); 67 | view.setText(""); 68 | int drawableL = (view.getWidth() + view.getHeight()) / 2; 69 | ViewGroup.LayoutParams lp = view.getLayoutParams(); 70 | lp.height = lp.width = drawableL; 71 | view.setLayoutParams(lp); 72 | view.setBackground(object); 73 | if (object.isRunning()) 74 | object.stop(); 75 | object.start(); 76 | } else { 77 | end(removeListener); 78 | } 79 | } 80 | 81 | private void start(Animator object, final OnPointDragListener removeListener) { 82 | view.setVisibility(View.VISIBLE); 83 | Animator copy = object.clone(); 84 | copy.setTarget(view); 85 | copy.removeAllListeners(); 86 | copy.addListener(new AnimatorListenerAdapter() { 87 | 88 | @Override 89 | public void onAnimationEnd(Animator animation) { 90 | animation.removeListener(this); 91 | end(removeListener); 92 | } 93 | }); 94 | copy.start(); 95 | } 96 | 97 | private void start(Animation object, final OnPointDragListener removeListener) { 98 | long duration = object.getDuration(); 99 | object.cancel(); 100 | view.startAnimation(object); 101 | view.postDelayed(new Runnable() { 102 | @Override 103 | public void run() { 104 | view.clearAnimation(); 105 | end(removeListener); 106 | } 107 | }, duration); 108 | } 109 | 110 | private void end(OnPointDragListener listener) { 111 | view.setVisibility(View.INVISIBLE); 112 | view.reset(); 113 | if (listener != null) 114 | listener.onRemoveEnd(view); 115 | AbsDragPointView nextRemoveView = view.getNextRemoveView(); 116 | if (nextRemoveView != null) { 117 | view.setNextRemoveView(null); 118 | nextRemoveView.startRemove(); 119 | } else { 120 | ClearViewHelper.getInstance().clearSignOver(view.getSign()); 121 | } 122 | } 123 | 124 | public void cancel() { 125 | if (object == null) 126 | throw new RuntimeException("remove anim is null."); 127 | if (object instanceof AnimationDrawable) { 128 | ((AnimationDrawable) object).stop(); 129 | } else if (object instanceof Animator) { 130 | ((Animator) object).cancel(); 131 | } else if (object instanceof Animation) { 132 | ((Animation) object).cancel(); 133 | } 134 | } 135 | 136 | public boolean isRunning() { 137 | if (object == null) 138 | return false; 139 | if (object instanceof AnimationDrawable) { 140 | return ((AnimationDrawable) object).isRunning(); 141 | } else if (object instanceof Animator) { 142 | return ((Animator) object).isRunning(); 143 | } else if (object instanceof Animation) { 144 | if (((Animation) object).hasStarted()) { 145 | return !((Animation) object).hasEnded(); 146 | } else { 147 | return false; 148 | } 149 | } 150 | return false; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/util/MathUtils.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview.util; 2 | 3 | import android.content.Context; 4 | import android.graphics.PointF; 5 | 6 | /** 7 | * Created by Administrator on 2017/7/15. 8 | */ 9 | public class MathUtils { 10 | 11 | /** 12 | * Get the point of intersection between circle and line. 13 | * 14 | * @param radius The circle radius. 15 | * @param lineK The slope of line which cross the pMiddle. 16 | * @return 17 | */ 18 | public static PointF[] getIntersectionPoints(float cx,float cy, float radius, Double lineK) { 19 | PointF[] points = new PointF[2]; 20 | 21 | float radian, xOffset = 0, yOffset = 0; 22 | if(lineK != null){ 23 | 24 | radian= (float) Math.atan(lineK); 25 | xOffset = (float) (Math.cos(radian) * radius); 26 | yOffset = (float) (Math.sin(radian) * radius); 27 | }else { 28 | xOffset = radius; 29 | yOffset = 0; 30 | } 31 | points[0] = new PointF(cx + xOffset, cy + yOffset); 32 | points[1] = new PointF(cx - xOffset, cy - yOffset); 33 | 34 | return points; 35 | } 36 | 37 | /** 38 | * Gets the distance between two points. 39 | * 40 | * @param p1 41 | * @param p2 42 | * @return 43 | */ 44 | public static double getDistance(PointF p1,PointF p2){ 45 | return Math.sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)); 46 | } 47 | 48 | public static int dip2px(Context context, float dpValue) { 49 | final float scale = context.getResources().getDisplayMetrics().density; 50 | return (int) (dpValue * scale + 0.5f); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/view/AbsDragPointView.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview.view; 2 | 3 | import android.animation.Animator; 4 | import android.content.Context; 5 | import android.graphics.drawable.AnimationDrawable; 6 | import android.util.AttributeSet; 7 | import android.view.animation.Interpolator; 8 | import android.widget.TextView; 9 | 10 | import com.javonlee.dragpointview.OnPointDragListener; 11 | import com.javonlee.dragpointview.PointViewAnimObject; 12 | 13 | /** 14 | * Created by lijinfeng on 2017/7/29. 15 | */ 16 | 17 | public abstract class AbsDragPointView extends TextView{ 18 | 19 | protected float mCenterRadius; 20 | protected float mDragRadius; 21 | protected float mCenterMinRatio; 22 | protected float mRecoveryAnimBounce; 23 | protected int mMaxDragLength; 24 | protected int colorStretching; 25 | protected int mRecoveryAnimDuration; 26 | protected String sign; 27 | protected String clearSign; 28 | protected boolean canDrag; 29 | 30 | protected PointViewAnimObject mRemoveAnim; 31 | protected Interpolator mRecoveryAnimInterpolator; 32 | protected OnPointDragListener mOnPointDragListener; 33 | protected AbsDragPointView mNextRemoveView; 34 | 35 | public AbsDragPointView(Context context) { 36 | super(context); 37 | } 38 | 39 | public AbsDragPointView(Context context, AttributeSet attrs) { 40 | super(context, attrs); 41 | } 42 | 43 | public AbsDragPointView(Context context, AttributeSet attrs, int defStyleAttr) { 44 | super(context, attrs, defStyleAttr); 45 | } 46 | 47 | public PointViewAnimObject getRemoveAnim(){ 48 | return mRemoveAnim; 49 | } 50 | 51 | public AbsDragPointView setRemoveAnim(PointViewAnimObject removeAnim){ 52 | this.mRemoveAnim = removeAnim; 53 | return this; 54 | } 55 | 56 | public AbsDragPointView setRemoveAnim(Animator mRemoveAnim) { 57 | this.mRemoveAnim = new PointViewAnimObject(mRemoveAnim,this); 58 | return this; 59 | } 60 | 61 | public AbsDragPointView setRemoveAnim(AnimationDrawable mRemoveAnim) { 62 | this.mRemoveAnim = new PointViewAnimObject(mRemoveAnim,this); 63 | return this; 64 | } 65 | 66 | public OnPointDragListener getOnPointDragListener() { 67 | return mOnPointDragListener; 68 | } 69 | 70 | public String getClearSign() { 71 | return clearSign; 72 | } 73 | 74 | public AbsDragPointView setClearSign(String clearSign) { 75 | this.clearSign = clearSign; 76 | return this; 77 | } 78 | 79 | public float getCenterRadius() { 80 | return mCenterRadius; 81 | } 82 | 83 | public AbsDragPointView setCenterRadius(float mCenterRadius) { 84 | this.mCenterRadius = mCenterRadius; 85 | postInvalidate(); 86 | return this; 87 | } 88 | 89 | public float getDragRadius() { 90 | return mDragRadius; 91 | } 92 | 93 | public AbsDragPointView setDragRadius(float mDragRadius) { 94 | this.mDragRadius = mDragRadius; 95 | postInvalidate(); 96 | return this; 97 | } 98 | 99 | public int getMaxDragLength() { 100 | return mMaxDragLength; 101 | } 102 | 103 | public AbsDragPointView setMaxDragLength(int mMaxDragLength) { 104 | this.mMaxDragLength = mMaxDragLength; 105 | return this; 106 | } 107 | 108 | public float getCenterMinRatio() { 109 | return mCenterMinRatio; 110 | } 111 | 112 | public AbsDragPointView setCenterMinRatio(float mCenterMinRatio) { 113 | this.mCenterMinRatio = mCenterMinRatio; 114 | postInvalidate(); 115 | return this; 116 | } 117 | 118 | public int getRecoveryAnimDuration() { 119 | return mRecoveryAnimDuration; 120 | } 121 | 122 | public AbsDragPointView setRecoveryAnimDuration(int mRecoveryAnimDuration) { 123 | this.mRecoveryAnimDuration = mRecoveryAnimDuration; 124 | return this; 125 | } 126 | 127 | public float getRecoveryAnimBounce() { 128 | return mRecoveryAnimBounce; 129 | } 130 | 131 | public AbsDragPointView setRecoveryAnimBounce(float mRecoveryAnimBounce) { 132 | this.mRecoveryAnimBounce = mRecoveryAnimBounce; 133 | return this; 134 | } 135 | 136 | public int getColorStretching() { 137 | return colorStretching; 138 | } 139 | 140 | public AbsDragPointView setColorStretching(int colorStretching) { 141 | this.colorStretching = colorStretching; 142 | postInvalidate(); 143 | return this; 144 | } 145 | 146 | public String getSign() { 147 | return sign; 148 | } 149 | 150 | public AbsDragPointView setSign(String sign) { 151 | this.sign = sign; 152 | return this; 153 | } 154 | 155 | public void setRecoveryAnimInterpolator(Interpolator mRecoveryAnimInterpolator) { 156 | this.mRecoveryAnimInterpolator = mRecoveryAnimInterpolator; 157 | } 158 | 159 | public Interpolator getRecoveryAnimInterpolator() { 160 | return mRecoveryAnimInterpolator; 161 | } 162 | 163 | public void clearRemoveAnim() { 164 | this.mRemoveAnim = null; 165 | } 166 | 167 | public AbsDragPointView setOnPointDragListener(OnPointDragListener onDragListener) { 168 | this.mOnPointDragListener = onDragListener; 169 | return this; 170 | } 171 | 172 | public boolean isCanDrag() { 173 | return canDrag; 174 | } 175 | 176 | public AbsDragPointView setCanDrag(boolean canDrag) { 177 | this.canDrag = canDrag; 178 | return this; 179 | } 180 | 181 | public AbsDragPointView getNextRemoveView() { 182 | return mNextRemoveView; 183 | } 184 | 185 | public void setNextRemoveView(AbsDragPointView mNextRemoveView) { 186 | this.mNextRemoveView = mNextRemoveView; 187 | } 188 | 189 | public abstract void reset(); 190 | public abstract void startRemove(); 191 | 192 | 193 | } 194 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/view/ClearViewHelper.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview.view; 2 | 3 | import android.text.TextUtils; 4 | import android.util.SparseArray; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by lijinfeng on 2017/7/24. 13 | */ 14 | 15 | public class ClearViewHelper { 16 | 17 | private void ClearViewHelper(){} 18 | 19 | public static ClearViewHelper getInstance(){ 20 | return ClearViewHelperHolder.clearViewHelper; 21 | } 22 | 23 | private SparseArray clearSigning = new SparseArray<>(); 24 | 25 | public void clearPointViewBySign(AbsDragPointView dragPointView, String clearSign) { 26 | List list = new ArrayList<>(); 27 | list.add(dragPointView); 28 | getAllPointViewVisible(dragPointView.getRootView(), list, clearSign); 29 | if (list.contains(dragPointView)) 30 | list.remove(dragPointView); 31 | list.add(0, dragPointView); 32 | for (int i = 0; i < list.size() - 1; i++) { 33 | list.get(i).setNextRemoveView(list.get(i + 1)); 34 | } 35 | clearSigning.put(clearSign.hashCode(), true); 36 | list.get(0).startRemove(); 37 | } 38 | 39 | public void clearSignOver(String clearSign) { 40 | if (TextUtils.isEmpty(clearSign)) return; 41 | clearSigning.put(clearSign.hashCode(), false); 42 | } 43 | 44 | public boolean isClearSigning(String clearSign) { 45 | if (TextUtils.isEmpty(clearSign)) return false; 46 | Boolean clear = clearSigning.get(clearSign.hashCode()); 47 | return clear == null ? false : clear.booleanValue(); 48 | } 49 | 50 | private void getAllPointViewVisible(View view, List list, String clearSign) { 51 | if (view instanceof ViewGroup) { 52 | for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { 53 | View child = ((ViewGroup) view).getChildAt(i); 54 | getAllPointViewVisible(child, list, clearSign); 55 | } 56 | } else if (view instanceof AbsDragPointView) { 57 | AbsDragPointView v = (AbsDragPointView) view; 58 | if (v.getVisibility() == View.VISIBLE 59 | && clearSign.equals(v.getSign()) 60 | && !list.contains(view)) 61 | list.add((AbsDragPointView) view); 62 | } 63 | } 64 | 65 | private static class ClearViewHelperHolder{ 66 | public static ClearViewHelper clearViewHelper = new ClearViewHelper(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/view/DragPointView.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.util.AttributeSet; 6 | 7 | import com.javonlee.dragpointview.demo.R; 8 | import com.javonlee.dragpointview.util.MathUtils; 9 | 10 | /** 11 | * Created by Administrator on 2017/7/15. 12 | */ 13 | public class DragPointView extends AbsDragPointView { 14 | 15 | public static final float DEFAULT_CENTER_MIN_RATIO = 0.5f; 16 | public static final int DEFAULT_RECOVERY_ANIM_DURATION = 200; 17 | 18 | private DragViewHelper dragViewHelper; 19 | 20 | public DragPointView(Context context) { 21 | super(context); 22 | init(); 23 | } 24 | 25 | @Override 26 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 27 | super.onSizeChanged(w, h, oldw, oldh); 28 | int flowMaxRadius = Math.min(getMeasuredWidth() / 2, getMeasuredHeight() / 2); 29 | mCenterRadius = mCenterRadius == 0 ? flowMaxRadius : Math.min(mCenterRadius, flowMaxRadius); 30 | mDragRadius = mDragRadius == 0 ? flowMaxRadius : Math.min(mDragRadius, flowMaxRadius); 31 | mMaxDragLength = mMaxDragLength == 0 ? flowMaxRadius * 10 : mMaxDragLength; 32 | } 33 | 34 | public DragPointView(Context context, AttributeSet attrs) { 35 | this(context, attrs, 0); 36 | } 37 | 38 | public DragPointView(Context context, AttributeSet attrs, int defStyleAttr) { 39 | super(context, attrs, defStyleAttr); 40 | TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.DragPointView, defStyleAttr, 0); 41 | mMaxDragLength = array.getDimensionPixelSize(R.styleable. 42 | DragPointView_maxDragLength, MathUtils.dip2px(context, 0)); 43 | mCenterRadius = array.getDimensionPixelSize(R.styleable.DragPointView_centerCircleRadius, 0); 44 | mDragRadius = array.getDimensionPixelSize(R.styleable.DragPointView_centerCircleRadius, 0); 45 | mCenterMinRatio = array.getFloat(R.styleable.DragPointView_centerMinRatio, DEFAULT_CENTER_MIN_RATIO); 46 | mRecoveryAnimDuration = array.getInt(R.styleable. 47 | DragPointView_recoveryAnimDuration, DEFAULT_RECOVERY_ANIM_DURATION); 48 | colorStretching = array.getColor(R.styleable.DragPointView_colorStretching, 0); 49 | mRecoveryAnimBounce = array.getFloat(R.styleable.DragPointView_recoveryAnimBounce, 0f); 50 | sign = array.getString(R.styleable.DragPointView_sign); 51 | clearSign = array.getString(R.styleable.DragPointView_clearSign); 52 | canDrag = array.getBoolean(R.styleable.DragPointView_canDrag, true); 53 | init(); 54 | } 55 | 56 | @Override 57 | public void startRemove() { 58 | dragViewHelper.startRemove(); 59 | } 60 | 61 | private void init() { 62 | dragViewHelper = new DragViewHelper(getContext(),this); 63 | } 64 | 65 | @Override 66 | public void reset() { 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/view/DragPointViewWindow.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview.view; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.content.Context; 6 | import android.graphics.Bitmap; 7 | import android.graphics.Canvas; 8 | import android.graphics.Paint; 9 | import android.graphics.Path; 10 | import android.graphics.PointF; 11 | import android.text.TextUtils; 12 | import android.util.AttributeSet; 13 | import android.view.MotionEvent; 14 | 15 | import com.javonlee.dragpointview.util.MathUtils; 16 | 17 | /** 18 | * Created by lijinfeng on 2017/7/15. 19 | */ 20 | class DragPointViewWindow extends AbsDragPointView implements ValueAnimator.AnimatorUpdateListener, Animator.AnimatorListener { 21 | 22 | private DragPointView origView; 23 | private Bitmap origBitmap; 24 | private Paint mPaint; 25 | private Path mPath; 26 | protected int mWidthHalf, mHeightHalf; 27 | private float mRatioRadius; 28 | private int mMaxRadiusTrebling; 29 | private boolean isInCircle; 30 | private float downX, downY; 31 | private PointF[] mDragTangentPoint; 32 | private PointF[] mCenterTangentPoint; 33 | private PointF mCenterCircle; 34 | private PointF mCenterCircleCopy; 35 | private PointF mDragCircle; 36 | private PointF mDragCircleCopy; 37 | private double mDistanceCircles; 38 | private PointF mControlPoint; 39 | private boolean mIsDragOut; 40 | private ValueAnimator mRecoveryAnim; 41 | private float origX, origY, upX, upY; 42 | 43 | public void setOrigBitmap(Bitmap origBitmap) { 44 | this.origBitmap = origBitmap; 45 | } 46 | 47 | public String getClearSign() { 48 | return clearSign; 49 | } 50 | 51 | public DragPointViewWindow setClearSign(String clearSign) { 52 | this.clearSign = clearSign; 53 | return this; 54 | } 55 | 56 | public DragPointViewWindow setCenterRadius(float mCenterRadius) { 57 | this.mCenterRadius = mCenterRadius; 58 | return this; 59 | } 60 | 61 | public DragPointViewWindow setDragRadius(float mDragRadius) { 62 | this.mDragRadius = mDragRadius; 63 | return this; 64 | } 65 | 66 | public DragPointViewWindow(Context context) { 67 | super(context); 68 | init(); 69 | } 70 | 71 | public DragPointViewWindow(Context context, AttributeSet attrs) { 72 | this(context, attrs, 0); 73 | } 74 | 75 | public DragPointViewWindow(Context context, AttributeSet attrs, int defStyleAttr) { 76 | super(context, attrs, defStyleAttr); 77 | init(); 78 | } 79 | 80 | @Override 81 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 82 | super.onSizeChanged(w, h, oldw, oldh); 83 | mCenterCircle.x = mDragCircle.x = mWidthHalf = getMeasuredWidth() / 2; 84 | mCenterCircle.y = mDragCircle.y = mHeightHalf = getMeasuredHeight() / 2; 85 | int flowMaxRadius = Math.min(mWidthHalf, mHeightHalf); 86 | mMaxRadiusTrebling = flowMaxRadius * 3; 87 | origX = getX(); 88 | origY = getY(); 89 | } 90 | 91 | private void init() { 92 | mPath = new Path(); 93 | mPaint = new Paint(); 94 | mPaint.setStyle(Paint.Style.FILL); 95 | mPaint.setTextSize(18f); 96 | mPaint.setColor(colorStretching); 97 | mPaint.setAntiAlias(true); 98 | mPaint.setDither(true); 99 | mDragTangentPoint = new PointF[2]; 100 | mCenterTangentPoint = new PointF[2]; 101 | mControlPoint = new PointF(); 102 | mCenterCircle = new PointF(); 103 | mCenterCircleCopy = new PointF(); 104 | mDragCircle = new PointF(); 105 | mDragCircleCopy = new PointF(); 106 | } 107 | 108 | @Override 109 | protected void onDraw(Canvas canvas) { 110 | if (getBackground() != null) 111 | return; 112 | drawCenterCircle(canvas); 113 | if (isInCircle) { 114 | drawBezierLine(canvas); 115 | drawOriginBitmap(canvas); 116 | } 117 | } 118 | 119 | private void drawOriginBitmap(Canvas canvas) { 120 | if (origBitmap != null && !origBitmap.isRecycled()) 121 | canvas.drawBitmap(origBitmap, 0, 0, mPaint); 122 | } 123 | 124 | private void drawCenterCircle(Canvas canvas) { 125 | if (mIsDragOut || !isInCircle) return; 126 | mPaint.setColor(colorStretching); 127 | mRatioRadius = Math.min(mCenterRadius, Math.min(mWidthHalf, mHeightHalf)); 128 | if (isInCircle && Math.abs(mCenterMinRatio) < 1.f) { 129 | mRatioRadius = (float) (Math.max((mMaxDragLength - mDistanceCircles) * 1.f / mMaxDragLength, Math.abs(mCenterMinRatio)) * mCenterRadius); 130 | mRatioRadius = Math.min(mRatioRadius, Math.min(mWidthHalf, mHeightHalf)); 131 | } 132 | canvas.drawCircle(mCenterCircle.x, mCenterCircle.y, mRatioRadius, mPaint); 133 | } 134 | 135 | public void setOrigView(DragPointView origView) { 136 | this.origView = origView; 137 | } 138 | 139 | private void drawBezierLine(Canvas canvas) { 140 | if (mIsDragOut) return; 141 | mPaint.setColor(colorStretching); 142 | float dx = mDragCircle.x - mCenterCircle.x; 143 | float dy = mDragCircle.y - mCenterCircle.y; 144 | // 控制点 145 | mControlPoint.set((mDragCircle.x + mCenterCircle.x) / 2, 146 | (mDragCircle.y + mCenterCircle.y) / 2); 147 | // 四个切点 148 | if (dx != 0) { 149 | float k1 = dy / dx; 150 | float k2 = -1 / k1; 151 | mDragTangentPoint = MathUtils.getIntersectionPoints( 152 | mDragCircle.x, mDragCircle.y, mDragRadius, (double) k2); 153 | mCenterTangentPoint = MathUtils.getIntersectionPoints( 154 | mCenterCircle.x, mCenterCircle.y, mRatioRadius, (double) k2); 155 | } else { 156 | mDragTangentPoint = MathUtils.getIntersectionPoints( 157 | mDragCircle.x, mDragCircle.y, mDragRadius, (double) 0); 158 | mCenterTangentPoint = MathUtils.getIntersectionPoints( 159 | mCenterCircle.x, mCenterCircle.y, mRatioRadius, (double) 0); 160 | } 161 | // 路径构建 162 | mPath.reset(); 163 | mPath.moveTo(mCenterTangentPoint[0].x, mCenterTangentPoint[0].y); 164 | mPath.quadTo(mControlPoint.x, mControlPoint.y, mDragTangentPoint[0].x, mDragTangentPoint[0].y); 165 | mPath.lineTo(mDragTangentPoint[1].x, mDragTangentPoint[1].y); 166 | mPath.quadTo(mControlPoint.x, mControlPoint.y, 167 | mCenterTangentPoint[1].x, mCenterTangentPoint[1].y); 168 | mPath.close(); 169 | canvas.drawPath(mPath, mPaint); 170 | } 171 | 172 | @Override 173 | public boolean onTouchEvent(MotionEvent event) { 174 | if (!canDrag || ClearViewHelper.getInstance().isClearSigning(sign) 175 | || (mRecoveryAnim != null && mRecoveryAnim.isRunning()) 176 | || (mRemoveAnim != null && mRemoveAnim.isRunning())) { 177 | return super.onTouchEvent(event); 178 | } 179 | if (mRecoveryAnim == null || !mRecoveryAnim.isRunning()) { 180 | switch (event.getAction()) { 181 | case MotionEvent.ACTION_DOWN: 182 | if(getParent() != null) 183 | getParent().requestDisallowInterceptTouchEvent(true); 184 | downX = event.getRawX(); 185 | downY = event.getRawY(); 186 | isInCircle = true; 187 | postInvalidate(); 188 | break; 189 | case MotionEvent.ACTION_MOVE: 190 | float dx = (int) event.getRawX() - downX; 191 | float dy = (int) event.getRawY() - downY; 192 | mCenterCircle.x = mWidthHalf - dx; 193 | mCenterCircle.y = mHeightHalf - dy; 194 | mDistanceCircles = MathUtils.getDistance(mCenterCircle, mDragCircle); 195 | mIsDragOut = mIsDragOut ? mIsDragOut : mDistanceCircles > mMaxDragLength; 196 | setX(origX + dx); 197 | setY(origY + dy); 198 | postInvalidate(); 199 | break; 200 | case MotionEvent.ACTION_UP: 201 | case MotionEvent.ACTION_CANCEL: 202 | getParent().requestDisallowInterceptTouchEvent(false); 203 | upX = getX(); 204 | upY = getY(); 205 | upAndCancelEvent(); 206 | break; 207 | } 208 | } 209 | return true; 210 | } 211 | 212 | private void upAndCancelEvent() { 213 | if (isInCircle && mDistanceCircles == 0) { 214 | reset(); 215 | if (mOnPointDragListener != null) { 216 | mOnPointDragListener.onRecovery(this); 217 | } 218 | } else if (!mIsDragOut) { 219 | mCenterCircleCopy.set(mCenterCircle.x, mCenterCircle.y); 220 | mDragCircleCopy.set(mDragCircle.x, mDragCircle.y); 221 | if (mRecoveryAnim == null) { 222 | mRecoveryAnim = ValueAnimator.ofFloat(1.f, -Math.abs(mRecoveryAnimBounce)); 223 | mRecoveryAnim.setDuration(mRecoveryAnimDuration); 224 | mRecoveryAnim.addUpdateListener(this); 225 | mRecoveryAnim.addListener(this); 226 | } 227 | if (mRecoveryAnimInterpolator != null) 228 | mRecoveryAnim.setInterpolator(mRecoveryAnimInterpolator); 229 | mRecoveryAnim.start(); 230 | } else { 231 | if (mDistanceCircles <= mMaxRadiusTrebling) { 232 | reset(); 233 | if (mOnPointDragListener != null) { 234 | mOnPointDragListener.onRecovery(this); 235 | } 236 | } else if (!TextUtils.isEmpty(clearSign)) { 237 | ClearViewHelper.getInstance().clearPointViewBySign(origView, clearSign); 238 | } else { 239 | startRemove(); 240 | } 241 | } 242 | } 243 | 244 | @Override 245 | public void startRemove() { 246 | if (mRemoveAnim == null) { 247 | setVisibility(GONE); 248 | if (mNextRemoveView != null) 249 | mNextRemoveView.startRemove(); 250 | if (mOnPointDragListener != null) { 251 | mOnPointDragListener.onRemoveStart(this); 252 | mOnPointDragListener.onRemoveEnd(this); 253 | } 254 | } else { 255 | mRemoveAnim.start(mOnPointDragListener); 256 | } 257 | } 258 | 259 | @Override 260 | protected void onDetachedFromWindow() { 261 | super.onDetachedFromWindow(); 262 | if (mRecoveryAnim != null && mRecoveryAnim.isRunning()) { 263 | mRecoveryAnim.cancel(); 264 | } 265 | if (mRemoveAnim != null) { 266 | mRemoveAnim.cancel(); 267 | } 268 | } 269 | 270 | @Override 271 | public void reset() { 272 | mIsDragOut = false; 273 | isInCircle = false; 274 | mDragCircle.x = mCenterCircle.x = mWidthHalf; 275 | mDragCircle.y = mCenterCircle.y = mHeightHalf; 276 | mDistanceCircles = 0; 277 | setTranslationX(0); 278 | setTranslationY(0); 279 | origX = getX(); 280 | origY = getY(); 281 | postInvalidate(); 282 | } 283 | 284 | @Override 285 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 286 | float value = (float) valueAnimator.getAnimatedValue(); 287 | float dx = (origX - upX); 288 | float dy = (origY - upY); 289 | mCenterCircle.x = dx * value + mWidthHalf; 290 | mCenterCircle.y = dy * value + mHeightHalf; 291 | setX(upX + dx * (1 - value)); 292 | setY(upY + dy * (1 - value)); 293 | postInvalidate(); 294 | } 295 | 296 | @Override 297 | public void onAnimationStart(Animator animator) { 298 | 299 | } 300 | 301 | @Override 302 | public void onAnimationEnd(Animator animator) { 303 | reset(); 304 | if (mOnPointDragListener != null) { 305 | mOnPointDragListener.onRecovery(this); 306 | } 307 | } 308 | 309 | @Override 310 | public void onAnimationCancel(Animator animator) { 311 | 312 | } 313 | 314 | @Override 315 | public void onAnimationRepeat(Animator animator) { 316 | 317 | } 318 | } 319 | -------------------------------------------------------------------------------- /dragpointview/src/main/java/com/javonlee/dragpointview/view/DragViewHelper.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.dragpointview.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.PixelFormat; 6 | import android.view.Gravity; 7 | import android.view.MotionEvent; 8 | import android.view.View; 9 | import android.view.ViewParent; 10 | import android.view.WindowManager; 11 | import android.widget.FrameLayout; 12 | 13 | import com.javonlee.dragpointview.OnPointDragListener; 14 | 15 | /** 16 | * 原始View的ouTouch事件与自定义View关联 17 | * Created by lijinfeng on 2017/07/26. 18 | */ 19 | public class DragViewHelper implements View.OnTouchListener, OnPointDragListener { 20 | 21 | private Context context; 22 | private FrameLayout container; 23 | private DragPointView originView; 24 | private DragPointViewWindow windowView; 25 | private OnPointDragListener onPointDragListener; 26 | private Runnable animRunnable; 27 | 28 | private WindowManager windowManager; 29 | private WindowManager.LayoutParams windowParams; 30 | private FrameLayout.LayoutParams layoutParams; 31 | 32 | public void startRemove() { 33 | if (container == null 34 | || container.getParent() == null) 35 | addViewToWindow(); 36 | windowView.setNextRemoveView(originView.getNextRemoveView()); 37 | windowView.post(animRunnable); 38 | } 39 | 40 | public DragViewHelper(Context context, final DragPointView originView) { 41 | this.context = context; 42 | this.originView = originView; 43 | this.originView.setOnTouchListener(this); 44 | animRunnable = new Runnable() { 45 | @Override 46 | public void run() { 47 | windowView.startRemove(); 48 | } 49 | }; 50 | } 51 | 52 | private void initParams() { 53 | windowParams = new WindowManager.LayoutParams(); 54 | windowParams.gravity = Gravity.LEFT | Gravity.TOP; 55 | windowParams.format = PixelFormat.TRANSLUCENT; 56 | windowParams.type = WindowManager.LayoutParams.TYPE_TOAST; 57 | windowParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; 58 | windowParams.width = WindowManager.LayoutParams.MATCH_PARENT; 59 | windowParams.height = WindowManager.LayoutParams.MATCH_PARENT; 60 | layoutParams = new FrameLayout.LayoutParams(originView.getWidth(), originView.getHeight()); 61 | } 62 | 63 | @Override 64 | public boolean onTouch(View v, MotionEvent event) { 65 | int action = event.getAction() & MotionEvent.ACTION_MASK; 66 | if (action == MotionEvent.ACTION_DOWN) { 67 | ViewParent parent = v.getParent(); 68 | if (parent == null) { 69 | return false; 70 | } 71 | parent.requestDisallowInterceptTouchEvent(true); 72 | addViewToWindow(); 73 | } 74 | return windowView.onTouchEvent(event); 75 | } 76 | 77 | public void addViewToWindow() { 78 | if (windowManager == null) { 79 | windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 80 | } 81 | if (windowView == null) { 82 | createWindowView(); 83 | } 84 | if (windowParams == null || 85 | layoutParams == null) { 86 | initParams(); 87 | } 88 | if (container == null) { 89 | container = new FrameLayout(context); 90 | container.setClipChildren(false); 91 | container.setClipToPadding(false); 92 | windowView.setLayoutParams(layoutParams); 93 | container.addView(windowView, layoutParams); 94 | } 95 | int[] ps = new int[2]; 96 | originView.getLocationInWindow(ps); 97 | layoutParams.setMargins(ps[0], ps[1], 0, 0); 98 | layoutParams.width = originView.getWidth(); 99 | layoutParams.height = originView.getHeight(); 100 | windowView.setOrigView(originView); 101 | originView.setDrawingCacheEnabled(true); 102 | Bitmap bitmap = Bitmap.createBitmap(originView.getDrawingCache()); 103 | originView.setDrawingCacheEnabled(false); 104 | windowView.setOrigBitmap(bitmap); 105 | onPointDragListener = originView.getOnPointDragListener(); 106 | windowView.setVisibility(View.VISIBLE); 107 | if(container.getParent() != null) 108 | windowManager.removeView(container); 109 | windowManager.addView(container, windowParams); 110 | originView.setVisibility(View.INVISIBLE); 111 | } 112 | 113 | private void createWindowView() { 114 | windowView = new DragPointViewWindow(context); 115 | windowView.setCanDrag(originView.isCanDrag()); 116 | windowView.setCenterMinRatio(originView.getCenterMinRatio()); 117 | windowView.setCenterRadius(originView.getCenterRadius()); 118 | windowView.setColorStretching(originView.getColorStretching()); 119 | windowView.setDragRadius(originView.getDragRadius()); 120 | windowView.setClearSign(originView.getClearSign()); 121 | windowView.setSign(originView.getSign()); 122 | windowView.setMaxDragLength(originView.getMaxDragLength()); 123 | windowView.setRecoveryAnimBounce(originView.getRecoveryAnimBounce()); 124 | windowView.setRecoveryAnimDuration(originView.getRecoveryAnimDuration()); 125 | windowView.setRecoveryAnimInterpolator(originView.getRecoveryAnimInterpolator()); 126 | if (originView.getRemoveAnim() != null) 127 | windowView.setRemoveAnim(originView.getRemoveAnim().setView(windowView)); 128 | windowView.setOnPointDragListener(this); 129 | } 130 | 131 | @Override 132 | public void onRemoveStart(AbsDragPointView view) { 133 | if (onPointDragListener != null) { 134 | onPointDragListener.onRemoveStart(originView); 135 | } 136 | } 137 | 138 | @Override 139 | public void onRemoveEnd(AbsDragPointView view) { 140 | if (windowManager != null && container != null) { 141 | windowManager.removeView(container); 142 | } 143 | if (onPointDragListener != null) { 144 | onPointDragListener.onRemoveEnd(originView); 145 | } 146 | if (originView != null) { 147 | originView.setVisibility(View.GONE); 148 | } 149 | } 150 | 151 | @Override 152 | public void onRecovery(AbsDragPointView view) { 153 | if (windowManager != null && container != null) { 154 | windowManager.removeView(container); 155 | } 156 | if (originView != null) { 157 | originView.setVisibility(View.VISIBLE); 158 | } 159 | if (onPointDragListener != null) { 160 | onPointDragListener.onRecovery(originView); 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /dragpointview/src/main/res/values/attr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /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/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.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 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.javonlee.dragpointview_master" 8 | minSdkVersion 19 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(':dragpointview') 30 | compile 'com.github.bumptech.glide:glide:4.0.0-RC1' 31 | compile 'com.alibaba:fastjson:1.2.35' 32 | } 33 | -------------------------------------------------------------------------------- /sample/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 D:\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 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/javonlee/sample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.sample; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.javonlee.dragpointview_master", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/src/main/java/com/javonlee/sample/ConversationEntity.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.sample; 2 | 3 | /** 4 | * Created by lijinfeng on 2017/7/26. 5 | */ 6 | 7 | public class ConversationEntity { 8 | 9 | public static final String TEST_JSON = "[{\"username\":\"1\",\"nickname\":\"Jam\",\"avatar\":" + 10 | "\"http://img3.imgtn.bdimg.com/it/u=2113581648,1740074228&fm=214&gp=0.jpg\",\"messageN" + 11 | "um\":6,\"lastMessage\":\"It's a nice day today.\",\"lastTime\":\"13:50\",\"isRead\":fa" + 12 | "lse},{\"username\":\"2\",\"nickname\":\"Aaron\",\"avatar\":\"http://dynamic-image.yes" + 13 | "ky.com/600x-/uploadImages/upload/20140909/upload/201409/0txy3iz3byujpg.jpg\",\"messa" + 14 | "geNum\":13,\"lastMessage\":\"Do you have time today?\",\"lastTime\":\"13:50\",\"isRea" + 15 | "d\":false},{\"username\":\"3\",\"nickname\":\"Yannik\",\"avatar\":\"http://pic.qqtn.c" + 16 | "om/up/2016-3/2016031510554162452.jpg\",\"messageNum\":22,\"lastMessage\":\"Why didn't" + 17 | " you come to the party?\",\"lastTime\":\"13:10\",\"isRead\":false},{\"username\":\"4\"" + 18 | ",\"nickname\":\"Cadence\",\"avatar\":\"http://p.3761.com/pic/52311409792413.jpg\",\"mes" + 19 | "sageNum\":3,\"lastMessage\":\"What was the homework assigned by the teacher yesterday?\"" + 20 | ",\"lastTime\":\"12:05\",\"isRead\":false},{\"username\":\"5\",\"nickname\":\"Fairfax\",\"" + 21 | "avatar\":\"http://img2.touxiang.cn/file/20160311/4a20942690f10bdf8fb71c98db274fd2.jpg\"," + 22 | "\"messageNum\":6,\"lastMessage\":\"Okay, i know.\",\"lastTime\":\"11:28\",\"isRead\":fal" + 23 | "se},{\"username\":\"6\",\"nickname\":\"Wafa\",\"avatar\":\"http://img4.imgtn.bdimg.com/it" + 24 | "/u=3925914968,3821812098&fm=214&gp=0.jpg\",\"messageNum\":9,\"lastMessage\":\"Happy birth" + 25 | "day to you!\",\"lastTime\":\"8:30\",\"isRead\":false},{\"username\":\"7\",\"nickname\":" + 26 | "\"Pable\",\"avatar\":\"http://www.qq745.com/uploads/allimg/150201/1-150201114300-50.jpg\"," + 27 | "\"messageNum\":0,\"lastMessage\":\"Has your sister graduated yet?\",\"lastTime\":\"8:29\"," + 28 | "\"isRead\":false},{\"username\":\"8\",\"nickname\":\"Oakes\",\"avatar\":\"http://www.ld12." + 29 | "com/upimg358/allimg/c141115/1416041b31B30-43BA.jpg\",\"messageNum\":50,\"lastMessage\":\"I'" + 30 | "d like to see the Titanic.\",\"lastTime\":\"00:10\",\"isRead\":false},{\"username\":\"9\"," + 31 | "\"nickname\":\"Mabel\",\"avatar\":\"http://img.qqtouxiang8.net/uploads/allimg/c140510/13cH6" + 32 | "2461JF-35508.jpg\",\"messageNum\":38,\"lastMessage\":\"See you at 8 tomorrow.\",\"lastTime" + 33 | "\":\"昨天\",\"isRead\":false},{\"username\":\"10\",\"nickname\":\"Alima\",\"avatar\":\"http" + 34 | "://www.itouxiang.net/uploads/allimg/20160616/gpzzlp54qic243089.jpg\",\"messageNum\":1,\"las" + 35 | "tMessage\":\"The cake is delicious, thank you.\",\"lastTime\":\"昨天\",\"isRead\":false},{" + 36 | "\"username\":\"11\",\"nickname\":\"Tacy\",\"avatar\":\"http://img0.imgtn.bdimg.com/it/u=41" + 37 | "09618721,269328371&fm=214&gp=0.jpg\",\"messageNum\":76,\"lastMessage\":\"Uh huh.\",\"lastTi" + 38 | "me\":\"前天\",\"isRead\":false},{\"username\":\"12\",\"nickname\":\"Ulema\",\"avatar\":\"htt" + 39 | "p://www.qq745.com/uploads/allimg/141128/1-14112Q14035-51.jpg\",\"messageNum\":99,\"lastMes" + 40 | "sage\":\"You look smart today and look young.\",\"lastTime\":\"星期日\",\"isRead\":false}," + 41 | "{\"username\":\"13\",\"nickname\":\"Queena\",\"avatar\":\"http://img1.imgtn.bdimg.com/it/u=" + 42 | "2315043706,2270288250&fm=214&gp=0.jpg\",\"messageNum\":109,\"lastMessage\":\"Let's go see t" + 43 | "he sunrise.\",\"lastTime\":\"星期六\",\"isRead\":false}]"; 44 | 45 | private String username; 46 | private String nickname; 47 | private String avatar; 48 | private int messageNum; 49 | private String lastMessage; 50 | private String lastTime; 51 | private boolean isRead; 52 | 53 | public String getUsername() { 54 | return username; 55 | } 56 | 57 | public void setUsername(String username) { 58 | this.username = username; 59 | } 60 | 61 | public String getNickname() { 62 | return nickname; 63 | } 64 | 65 | public void setNickname(String nickname) { 66 | this.nickname = nickname; 67 | } 68 | 69 | public String getAvatar() { 70 | return avatar; 71 | } 72 | 73 | public void setAvatar(String avatar) { 74 | this.avatar = avatar; 75 | } 76 | 77 | public int getMessageNum() { 78 | return messageNum; 79 | } 80 | 81 | public void setMessageNum(int messageNum) { 82 | this.messageNum = messageNum; 83 | } 84 | 85 | public String getLastMessage() { 86 | return lastMessage; 87 | } 88 | 89 | public void setLastMessage(String lastMessage) { 90 | this.lastMessage = lastMessage; 91 | } 92 | 93 | public String getLastTime() { 94 | return lastTime; 95 | } 96 | 97 | public void setLastTime(String lastTime) { 98 | this.lastTime = lastTime; 99 | } 100 | 101 | public boolean isRead() { 102 | return isRead; 103 | } 104 | 105 | public void setRead(boolean read) { 106 | isRead = read; 107 | } 108 | 109 | public void setRead(){ 110 | setRead(true); 111 | setMessageNum(0); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /sample/src/main/java/com/javonlee/sample/ItemConversationAdapter.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.sample; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.AnimationDrawable; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.BaseAdapter; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.bumptech.glide.Glide; 13 | import com.javonlee.dragpointview.view.AbsDragPointView; 14 | import com.javonlee.dragpointview.view.DragPointView; 15 | import com.javonlee.dragpointview.OnPointDragListener; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | public class ItemConversationAdapter extends BaseAdapter implements OnPointDragListener { 21 | 22 | private List objects = new ArrayList<>(); 23 | 24 | private Context context; 25 | private LayoutInflater layoutInflater; 26 | private AnimationDrawable animationDrawable; 27 | 28 | public ItemConversationAdapter(Context context, List objects) { 29 | this.context = context; 30 | this.layoutInflater = LayoutInflater.from(context); 31 | this.objects = objects; 32 | 33 | animationDrawable = new AnimationDrawable(); 34 | animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode1), 100); 35 | animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode2), 100); 36 | animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode3), 100); 37 | animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode4), 100); 38 | animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode5), 100); 39 | animationDrawable.setOneShot(true); 40 | animationDrawable.setExitFadeDuration(300); 41 | animationDrawable.setEnterFadeDuration(100); 42 | } 43 | 44 | @Override 45 | public int getCount() { 46 | return objects.size(); 47 | } 48 | 49 | @Override 50 | public ConversationEntity getItem(int position) { 51 | return objects.get(position); 52 | } 53 | 54 | @Override 55 | public long getItemId(int position) { 56 | return position; 57 | } 58 | 59 | @Override 60 | public View getView(int position, View convertView, ViewGroup parent) { 61 | parent.setClipChildren(false); 62 | parent.setClipToPadding(false); 63 | if (convertView == null) { 64 | convertView = layoutInflater.inflate(R.layout.item_conversation, null); 65 | convertView.setTag(new ViewHolder(convertView)); 66 | } 67 | initializeViews(getItem(position), (ViewHolder) convertView.getTag()); 68 | return convertView; 69 | } 70 | 71 | private void initializeViews(ConversationEntity object, ViewHolder holder) { 72 | Glide.with(context).load(object.getAvatar()).into(holder.avatar); 73 | holder.message.setText(object.getLastMessage()); 74 | holder.name.setText(object.getNickname()); 75 | holder.time.setText(object.getLastTime()); 76 | holder.pointView.setTag(object); 77 | holder.pointView.setOnPointDragListener(this); 78 | holder.pointView.setRemoveAnim(animationDrawable); 79 | if (object.isRead() || object.getMessageNum() <= 0) { 80 | holder.pointView.setVisibility(View.GONE); 81 | } else { 82 | holder.pointView.setVisibility(View.VISIBLE); 83 | if (object.getMessageNum() <= 99) 84 | holder.pointView.setText(object.getMessageNum() + ""); 85 | else 86 | holder.pointView.setText("99"); 87 | } 88 | } 89 | 90 | @Override 91 | public void onRemoveStart(AbsDragPointView view) { 92 | 93 | } 94 | 95 | @Override 96 | public void onRemoveEnd(AbsDragPointView view) { 97 | ConversationEntity entity = 98 | (ConversationEntity) view.getTag(); 99 | entity.setMessageNum(0); 100 | entity.setRead(true); 101 | ((SampleActivity)context).updateUnreadCount(); 102 | } 103 | 104 | @Override 105 | public void onRecovery(AbsDragPointView view) { 106 | 107 | } 108 | 109 | protected class ViewHolder { 110 | private ImageView avatar; 111 | private TextView name; 112 | private TextView time; 113 | private TextView message; 114 | private DragPointView pointView; 115 | 116 | public ViewHolder(View view) { 117 | avatar = (ImageView) view.findViewById(R.id.avatar); 118 | name = (TextView) view.findViewById(R.id.name); 119 | time = (TextView) view.findViewById(R.id.time); 120 | message = (TextView) view.findViewById(R.id.message); 121 | pointView = (DragPointView) view.findViewById(R.id.drag_point_view); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /sample/src/main/java/com/javonlee/sample/SampleActivity.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.sample; 2 | 3 | import android.animation.AnimatorSet; 4 | import android.animation.ObjectAnimator; 5 | import android.graphics.drawable.AnimationDrawable; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.View; 10 | import android.widget.ListView; 11 | 12 | import com.alibaba.fastjson.JSONArray; 13 | import com.javonlee.dragpointview.OnPointDragListener; 14 | import com.javonlee.dragpointview.view.AbsDragPointView; 15 | import com.javonlee.dragpointview.view.DragPointView; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * Created by lijinfeng on 2017/7/25. 21 | */ 22 | 23 | public class SampleActivity extends AppCompatActivity implements OnPointDragListener { 24 | 25 | public List conversationEntities; 26 | 27 | private DragPointView pointView1; 28 | private DragPointView pointView2; 29 | private DragPointView pointView3; 30 | private ListView listView; 31 | 32 | private AnimationDrawable animationDrawable; 33 | private AnimatorSet animatorSet; 34 | private ObjectAnimator objectAnimator; 35 | 36 | @Override 37 | protected void onCreate(@Nullable Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_sample); 40 | init(); 41 | } 42 | 43 | private void init() { 44 | initView(); 45 | initAnim(); 46 | initSetting(); 47 | initList(); 48 | } 49 | 50 | private void initView() { 51 | pointView1 = (DragPointView) findViewById(R.id.drag_point_view1); 52 | pointView2 = (DragPointView) findViewById(R.id.drag_point_view2); 53 | pointView3 = (DragPointView) findViewById(R.id.drag_point_view3); 54 | listView = (ListView) findViewById(R.id.list); 55 | } 56 | 57 | private void initAnim() { 58 | 59 | animationDrawable = new AnimationDrawable(); 60 | animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode1), 100); 61 | animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode2), 100); 62 | animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode3), 100); 63 | animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode4), 100); 64 | animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode5), 100); 65 | animationDrawable.setOneShot(true); 66 | animationDrawable.setExitFadeDuration(300); 67 | animationDrawable.setEnterFadeDuration(100); 68 | 69 | ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(null, "scaleX", 1.f, 0.f); 70 | ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(null, "scaleY", 1.f, 0.f); 71 | animatorSet = new AnimatorSet(); 72 | animatorSet.setDuration(300l); 73 | animatorSet.playTogether(objectAnimator1, objectAnimator2); 74 | 75 | objectAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.f, 0.f); 76 | objectAnimator.setDuration(2000l); 77 | } 78 | 79 | private void initSetting() { 80 | pointView1.setRemoveAnim(animationDrawable); 81 | pointView2.setRemoveAnim(objectAnimator); 82 | pointView3.setRemoveAnim(animatorSet); 83 | pointView1.setOnPointDragListener(this); 84 | } 85 | 86 | private void initList() { 87 | conversationEntities = JSONArray.parseArray(ConversationEntity.TEST_JSON, ConversationEntity.class); 88 | listView.setAdapter(new ItemConversationAdapter(this, conversationEntities)); 89 | updateUnreadCount(); 90 | } 91 | 92 | public void updateUnreadCount() { 93 | int totalUnreadCount = 0; 94 | for (ConversationEntity entity : conversationEntities) { 95 | totalUnreadCount += entity.getMessageNum(); 96 | } 97 | if (totalUnreadCount > 0) { 98 | pointView1.setVisibility(View.VISIBLE); 99 | if (totalUnreadCount <= 99) { 100 | pointView1.setText(totalUnreadCount + ""); 101 | } else { 102 | pointView1.setText("99+"); 103 | } 104 | } else { 105 | pointView1.setVisibility(View.GONE); 106 | } 107 | } 108 | 109 | @Override 110 | public void onRemoveStart(AbsDragPointView view) { 111 | for (ConversationEntity entity : conversationEntities) { 112 | entity.setRead(true); 113 | entity.setMessageNum(0); 114 | } 115 | } 116 | 117 | @Override 118 | public void onRemoveEnd(AbsDragPointView view) { 119 | 120 | } 121 | 122 | @Override 123 | public void onRecovery(AbsDragPointView view) { 124 | 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/list_item_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/shape_drag_point_blue.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/shape_drag_point_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/shape_drag_point_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/shape_drag_point_yellow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 22 | 23 | 29 | 30 | 34 | 35 | 40 | 41 | 59 | 60 | 61 | 62 | 66 | 67 | 72 | 73 | 89 | 90 | 91 | 92 | 96 | 97 | 102 | 103 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_conversation.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 24 | 25 | 26 | 27 | 40 | 41 | 51 | 52 | 68 | 69 | 87 | 88 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/explode1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xhdpi/explode1.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/explode2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xhdpi/explode2.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/explode3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xhdpi/explode3.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/explode4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xhdpi/explode4.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/explode5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xhdpi/explode5.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xxhdpi/avatar.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xxhdpi/chat.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #ebebeb 7 | #f7f8f8 8 | #ffffff 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DragPointView-master 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/test/java/com/javonlee/sample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.javonlee.sample; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':dragpointview' 2 | -------------------------------------------------------------------------------- /static/example_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/static/example_1.gif -------------------------------------------------------------------------------- /static/example_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/static/example_2.gif -------------------------------------------------------------------------------- /static/example_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javonleee/DragPointView/4805cc1aef4521aa92af98528c09b0dee1dfad88/static/example_3.gif --------------------------------------------------------------------------------