├── .gitignore
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── iconcountview
├── .gitignore
├── bintray.gradle
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── sunbinqiang
│ │ └── iconcountview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── sunbinqiang
│ │ │ └── iconcountview
│ │ │ ├── CountConstract.java
│ │ │ ├── CountPresenter.java
│ │ │ ├── CountView.java
│ │ │ ├── IconCountView.java
│ │ │ └── Utils.java
│ └── res
│ │ ├── drawable-xxhdpi
│ │ ├── icon_praise_normal.png
│ │ └── icon_praise_selected.png
│ │ ├── layout
│ │ └── icon_count_view.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── sunbinqiang
│ └── iconcountview
│ └── ExampleUnitTest.java
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── sunbinqiang
│ │ └── praiseviewdemo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── sunbinqiang
│ │ │ └── praiseviewdemo
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-xxhdpi
│ │ ├── icon_collect_normal.png
│ │ ├── icon_collect_normal1.png
│ │ ├── icon_collect_selected.png
│ │ ├── icon_collect_selected1.png
│ │ ├── icon_praise_normal.png
│ │ ├── icon_praise_normal2.png
│ │ ├── icon_praise_selected.png
│ │ └── icon_praise_selected2.png
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── sunbinqiang
│ └── praiseviewdemo
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | /.idea/
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 | .*/
12 |
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IconCountView
2 | 该项目是社区类APP点赞,收藏等按钮操作后的数字动画效果的View
3 |
4 | #### 效果
5 | 
6 |
7 |
8 | #### 2017.10.23更新
9 | 为了增强实际的应用性, 增加了当数量为0的时候, 显示文字的功能,效果如下:
10 | 
11 |
12 | #### 2017.10.25更新
13 | 增加文字颜色的设置:
14 | 
15 |
16 | #### 2017.10.30更新
17 | 分离Model,View层,应用MVP架构
18 |
19 | ### 配置
20 | gradle
21 | ```
22 | implementation 'com.sunbq:iconcountview:1.0.1'
23 | ```
24 | xml
25 | ```
26 |
39 | ```
40 |
--------------------------------------------------------------------------------
/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 | google()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.0.1'
10 |
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Sun Nov 12 14:15:19 CST 2017
16 | PROJ_GROUP=com.sunbq
17 | PROJ_NAME=IconView
18 | DEVELOPER_NAME=sunbq
19 | PROJ_ISSUETRACKERURL=
20 | LICENSE_URL='http\://www.apache.org/licenses/LICENSE-2.0.txt'
21 | PROJ_ARTIFACTID=IconView
22 | LICENSE_NAME='The Apache Software License, Version 2.0'
23 | org.gradle.jvmargs=-Xmx1536m
24 | PROJ_VCSURL=https\://github.com/binqiangsun/IconCountView.git
25 | PROJ_WEBSITEURL=https\://github.com/binqiangsun/IconCountView
26 | PROJ_VERSION=1.0.1
27 | DEVELOPER_EMAIL=sunbq110@163.com
28 | DEVELOPER_ID=sunbq
29 | PROJ_DESCRIPTION=Icon Count View
30 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Oct 29 20:15:34 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/iconcountview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | #
3 | *.iml
4 | .idea
5 | .gradle
6 | local.properties
7 |
--------------------------------------------------------------------------------
/iconcountview/bintray.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.github.dcendents.android-maven'
2 | apply plugin: 'com.jfrog.bintray'
3 | // This is the library version used when deploying the artifact
4 | version = PROJ_VERSION
5 | // Maven Group ID for the artifact
6 | group = PROJ_GROUP
7 |
8 | install {
9 | repositories.mavenInstaller {
10 | // This generates POM.xml with proper parameters
11 | pom {
12 | project {
13 | packaging 'aar'
14 |
15 | // Add your description here
16 | name PROJ_NAME
17 | description PROJ_DESCRIPTION
18 | url PROJ_WEBSITEURL
19 |
20 | // Set your license
21 | licenses {
22 | license {
23 | name LICENSE_NAME
24 | url LICENSE_URL
25 | }
26 | }
27 | developers {
28 | developer {
29 | id DEVELOPER_ID
30 | name DEVELOPER_NAME
31 | email DEVELOPER_EMAIL
32 | }
33 | }
34 | scm {
35 | connection PROJ_VCSURL
36 | developerConnection PROJ_VCSURL
37 | url PROJ_WEBSITEURL
38 | }
39 | }
40 | }
41 | }
42 | }
43 |
44 | task sourcesJar(type: Jar) {
45 | from android.sourceSets.main.java.srcDirs
46 | classifier = 'sources'
47 | }
48 |
49 | task javadoc(type: Javadoc) {
50 | source = android.sourceSets.main.java.srcDirs
51 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
52 | }
53 |
54 | task javadocJar(type: Jar, dependsOn: javadoc) {
55 | classifier = 'javadoc'
56 | from javadoc.destinationDir
57 | }
58 |
59 | javadoc {
60 | options {
61 | encoding "UTF-8"
62 | charSet 'UTF-8'
63 | author true
64 | version true
65 | links "http://docs.oracle.com/javase/7/docs/api"
66 | }
67 | }
68 |
69 | artifacts {
70 | archives javadocJar
71 | archives sourcesJar
72 | }
73 |
74 | Properties properties = new Properties()
75 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
76 | bintray {
77 | user = properties.getProperty("bintray.user")
78 | key = properties.getProperty("bintray.apikey")
79 |
80 | configurations = ['archives']
81 | pkg {
82 | userOrg = "sunbq"
83 | repo = "IconView"
84 | // it is the name that appears in bintray when logged
85 | name = PROJ_NAME
86 | desc = PROJ_DESCRIPTION
87 | websiteUrl = PROJ_WEBSITEURL
88 | issueTrackerUrl = PROJ_ISSUETRACKERURL
89 | vcsUrl = PROJ_VCSURL
90 | publicDownloadNumbers = true
91 | licenses = ["Apache-2.0"]
92 | publish = true
93 | version {
94 | mavenCentralSync {
95 | sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
96 | user = properties.getProperty("bintray.oss.user") //OSS user token
97 | password = properties.getProperty("bintray.oss.password") //OSS user password
98 | close = '1'
99 | //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
100 | }
101 | }
102 | }
103 | }
104 |
105 |
106 |
--------------------------------------------------------------------------------
/iconcountview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 |
4 | android {
5 | compileSdkVersion 26
6 | buildToolsVersion '26.0.2'
7 |
8 | defaultConfig {
9 | minSdkVersion 14
10 | targetSdkVersion 26
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | lintOptions {
24 | abortOnError false
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
31 | exclude group: 'com.android.support', module: 'support-annotations'
32 | })
33 | compile 'com.android.support:appcompat-v7:26.+'
34 | testCompile 'junit:junit:4.12'
35 | }
36 |
37 | apply from: 'bintray.gradle'
38 |
39 |
--------------------------------------------------------------------------------
/iconcountview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/sunbinqiang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/iconcountview/src/androidTest/java/com/sunbinqiang/iconcountview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.iconcountview;
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.sunbinqiang.iconcountview.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/iconcountview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/iconcountview/src/main/java/com/sunbinqiang/iconcountview/CountConstract.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.iconcountview;
2 |
3 | import android.graphics.Canvas;
4 |
5 | /**
6 | * Created by sunbinqiang on 30/10/2017.
7 | */
8 |
9 | public interface CountConstract {
10 |
11 | interface Presenter {
12 |
13 | void start();
14 |
15 | /**
16 | * 初始化数值
17 | * @param count
18 | */
19 | void initCount(long count);
20 |
21 | /**
22 | * 动画结束, 更新当前数值
23 | */
24 | void updateCount();
25 |
26 | /**
27 | * 设置当数字为0时, 相应的文字
28 | * @param zeroText
29 | */
30 | void setZeroText(String zeroText);
31 |
32 | /**
33 | * 数字发生变化
34 | * @param change
35 | */
36 | void changeCount(long change);
37 |
38 | /**
39 | * 绘制
40 | * @param canvas
41 | */
42 | void draw(Canvas canvas, float initX, float initY, float unitX, float curAniValue);
43 |
44 | /**
45 | *
46 | * @param isSelected
47 | */
48 | void setIsSelected(boolean isSelected);
49 |
50 | String getText();
51 |
52 | void end();
53 |
54 | }
55 |
56 | interface View {
57 |
58 | void setPresenter(Presenter presenter);
59 |
60 | void initView();
61 |
62 | void initAnimator();
63 |
64 | void startAnimator();
65 |
66 | void endAnimator();
67 |
68 | void drawText(Canvas canvas, String strDigital, float x, float y, boolean isSelected);
69 |
70 | void drawIn(Canvas canvas, String digital, float x, float y, boolean isSelected);
71 |
72 | void drawOut(Canvas canvas, String digital, float x, float y, boolean isSelected);
73 |
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/iconcountview/src/main/java/com/sunbinqiang/iconcountview/CountPresenter.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.iconcountview;
2 |
3 | import android.graphics.Canvas;
4 | import android.text.TextUtils;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * Created by sunbinqiang on 30/10/2017.
11 | */
12 |
13 | public class CountPresenter implements CountConstract.Presenter {
14 |
15 | private static final int PADDING_WIDTH = 12;
16 | private static final int PADDING_HEIGHT = 60;
17 | private static final int PADDING_SPACE = 3;
18 |
19 | private long mCurCount; // 当前数量
20 | private long mNewCount; // 即将变化的数量
21 | private String mStrNewCount = "0";
22 | private String mZeroText = "0"; //当数字为0时显示文字
23 | private List mCurDigitalList = new ArrayList<>(); // 当前数量各位数字的列表
24 | private List mNewDigitalList = new ArrayList<>(); // 即将变化数量各位数字列表
25 | private boolean mIsSelected; //当前状态是否选中
26 |
27 | private CountConstract.View mView;
28 |
29 | public CountPresenter(CountConstract.View view) {
30 | mView = view;
31 | mView.setPresenter(this);
32 | }
33 |
34 | @Override
35 | public void start() {
36 | mView.initAnimator();
37 | }
38 |
39 | @Override
40 | public void initCount(long count) {
41 | mCurCount = count;
42 | changeCount(0);
43 | }
44 |
45 | @Override
46 | public void updateCount() {
47 | mCurCount = mNewCount;
48 | }
49 |
50 | @Override
51 | public void setZeroText(String zeroText) {
52 | if (zeroText == null) {
53 | return;
54 | }
55 | mZeroText = zeroText;
56 | }
57 |
58 | @Override
59 | public void changeCount(long change) {
60 | //先结束当前动画
61 | mView.endAnimator();
62 | this.mNewCount = mCurCount + change;
63 | toDigitals(mCurCount, mCurDigitalList);
64 | toDigitals(mNewCount, mNewDigitalList);
65 | if (mNewCount > 0) {
66 | mStrNewCount = String.valueOf(mNewCount);
67 | } else {
68 | mStrNewCount = mZeroText;
69 | }
70 | if (mNewCount != mCurCount) {
71 | mView.startAnimator();
72 | } else {
73 | mView.initView();
74 | }
75 | }
76 |
77 | @Override
78 | public void draw(Canvas canvas, float initX, float initY, float unitX, float curAniValue) {
79 | int len = mNewDigitalList.size();
80 | for (int i = 0; i < len; i++) {
81 | String newDigital = mNewDigitalList.get(i);
82 | String oldDigital = "";
83 | if (mCurDigitalList.size() > i) {
84 | oldDigital = mCurDigitalList.get(i);
85 | }
86 | float x = unitX * i + initX;
87 | if (newDigital.equals(oldDigital)) {
88 | //只绘制新的数字
89 | mView.drawText(canvas, String.valueOf(newDigital), x, initY, mIsSelected);
90 | } else if (mNewCount > mCurCount) {
91 | //旧数字消失动画
92 | if (!TextUtils.isEmpty(oldDigital)) {
93 | mView.drawOut(canvas, oldDigital, x, initY - (curAniValue * PADDING_HEIGHT), mIsSelected);
94 | }
95 | //新数字进入动画绘制
96 | mView.drawIn(canvas, newDigital, x, initY + (PADDING_HEIGHT - curAniValue * PADDING_HEIGHT), mIsSelected);
97 | } else {
98 | if (!TextUtils.isEmpty(oldDigital)) {
99 | mView.drawOut(canvas, oldDigital, x, initY + (curAniValue * PADDING_HEIGHT), mIsSelected);
100 | }
101 | mView.drawIn(canvas, newDigital, x, initY - (PADDING_HEIGHT - curAniValue * PADDING_HEIGHT), mIsSelected);
102 | }
103 | }
104 | }
105 |
106 | @Override
107 | public void setIsSelected(boolean isSelected) {
108 | mIsSelected = isSelected;
109 | }
110 |
111 | @Override
112 | public String getText() {
113 | return mStrNewCount;
114 | }
115 |
116 | @Override
117 | public void end() {
118 |
119 | }
120 |
121 | /**
122 | * 数字转为字符串列表
123 | * @param num
124 | * @param digitalList
125 | */
126 | private void toDigitals(long num, List digitalList) {
127 | digitalList.clear();
128 | if (num == 0) {
129 | digitalList.add(mZeroText);
130 | }
131 | while (num > 0) {
132 | digitalList.add(0, String.valueOf(num % 10));
133 | num = num / 10;
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/iconcountview/src/main/java/com/sunbinqiang/iconcountview/CountView.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.iconcountview;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ValueAnimator;
5 | import android.content.Context;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 | import android.graphics.Rect;
9 | import android.support.annotation.Nullable;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 |
13 | /**
14 | * Created by sunbinqiang on 15/10/2017.
15 | */
16 |
17 | public class CountView extends View implements CountConstract.View {
18 |
19 | private static final int PADDING_WIDTH = 12;
20 | private static final int PADDING_HEIGHT = 60;
21 | private static final int PADDING_SPACE = 3;
22 | private final int DEFAULT_TEXT_SIZE = getResources().getDimensionPixelSize(R.dimen.text_normal_size);
23 |
24 | private CountConstract.Presenter mPresenter;
25 |
26 | private ValueAnimator mObjectAnimator;
27 | private float mCurAniValue; //当前属性动画数值
28 |
29 | private Rect mRect = new Rect(); // 当前文字的区域
30 | private Rect mDigitalRect = new Rect(); // 单个数字的区域
31 |
32 | private Paint mTextNormalPaint;
33 | private Paint mTextSelectedPaint;
34 |
35 | public CountView(Context context) {
36 | this(context, null);
37 | }
38 |
39 | public CountView(Context context, @Nullable AttributeSet attrs) {
40 | this(context, attrs, 0);
41 | }
42 |
43 | public CountView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
44 | super(context, attrs, defStyleAttr);
45 | mTextNormalPaint = new Paint();
46 | mTextSelectedPaint = new Paint();
47 | mTextNormalPaint.setColor(getResources().getColor(R.color.text_gray));
48 | mTextNormalPaint.setTextSize(DEFAULT_TEXT_SIZE);
49 | mTextNormalPaint.setStyle(Paint.Style.FILL);
50 | mTextNormalPaint.setAntiAlias(true);
51 | mTextSelectedPaint.setColor(getResources().getColor(R.color.text_gray));
52 | mTextSelectedPaint.setTextSize(DEFAULT_TEXT_SIZE);
53 | mTextSelectedPaint.setStyle(Paint.Style.FILL);
54 | mTextSelectedPaint.setAntiAlias(true);
55 | mTextNormalPaint.getTextBounds("0", 0, 1, mDigitalRect);
56 | new CountPresenter(this);
57 | mPresenter.start();
58 | }
59 |
60 | @Override
61 | public void setPresenter(CountConstract.Presenter presenter) {
62 | mPresenter = presenter;
63 | }
64 |
65 | @Override
66 | public void initView() {
67 | requestLayout();
68 | }
69 |
70 | @Override
71 | public void initAnimator() {
72 | mObjectAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
73 | mObjectAnimator.setDuration(500);
74 | mObjectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
75 | @Override
76 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
77 | mCurAniValue = (float) valueAnimator.getAnimatedValue();
78 | invalidate();
79 | }
80 | });
81 | mObjectAnimator.addListener(new Animator.AnimatorListener() {
82 | @Override
83 | public void onAnimationStart(Animator animator) {
84 |
85 | }
86 |
87 | @Override
88 | public void onAnimationEnd(Animator animator) {
89 | //动画结束, 数值更新
90 | mPresenter.updateCount();
91 | }
92 |
93 | @Override
94 | public void onAnimationCancel(Animator animator) {
95 |
96 | }
97 |
98 | @Override
99 | public void onAnimationRepeat(Animator animator) {
100 |
101 | }
102 | });
103 | }
104 |
105 | @Override
106 | public void startAnimator() {
107 | if (mObjectAnimator != null) {
108 | mObjectAnimator.start();
109 | }
110 | }
111 |
112 | @Override
113 | public void endAnimator() {
114 | if (mObjectAnimator != null && mObjectAnimator.isRunning()) {
115 | mObjectAnimator.end();
116 | }
117 | }
118 |
119 | @Override
120 | public void drawText(Canvas canvas, String strDigital, float x, float y, boolean isSelected) {
121 | canvas.drawText(strDigital, x, y, getCurPaint(isSelected));
122 | }
123 |
124 | /**
125 | * initial mCurCount
126 | *
127 | * @param count
128 | */
129 | public void setCount(long count) {
130 | mPresenter.initCount(count);
131 | }
132 |
133 | /**
134 | * 设置数字为0时的文本
135 | * @param zeroText
136 | */
137 | public void setZeroText(String zeroText) {
138 | mPresenter.setZeroText(zeroText);
139 | }
140 |
141 | public void setTextNormalColor(int normalColor) {
142 | mTextNormalPaint.setColor(normalColor);
143 | }
144 |
145 | public void setTextSelectedColor(int selectedColor) {
146 | mTextSelectedPaint.setColor(selectedColor);
147 | }
148 |
149 | public void setTextSize(int textSize) {
150 | mTextNormalPaint.setTextSize(textSize);
151 | mTextSelectedPaint.setTextSize(textSize);
152 | }
153 |
154 | public void setIsSelected(boolean isSelected) {
155 | mPresenter.setIsSelected(isSelected);
156 | }
157 |
158 | /**
159 | * +1
160 | */
161 | public void addCount() {
162 | mPresenter.changeCount(1);
163 | }
164 |
165 | /**
166 | * -1
167 | */
168 | public void minusCount() {
169 | mPresenter.changeCount(-1);
170 | }
171 |
172 | @Override
173 | protected void onDraw(Canvas canvas) {
174 | super.onDraw(canvas);
175 | float y = PADDING_HEIGHT + mDigitalRect.height();
176 | mPresenter.draw(canvas, 0.0f, y, mDigitalRect.width() + PADDING_SPACE, mCurAniValue);
177 | }
178 |
179 | /**
180 | * @param canvas
181 | * @param digital
182 | * @param x
183 | * @param y
184 | */
185 | @Override
186 | public void drawIn(Canvas canvas, String digital, float x, float y, boolean isSelected) {
187 | Paint inPaint = getCurPaint(isSelected);
188 | inPaint.setAlpha((int) (mCurAniValue * 255));
189 | inPaint.setTextSize(DEFAULT_TEXT_SIZE * (mCurAniValue * 0.5f + 0.5f));
190 | canvas.drawText(digital, x, y, inPaint);
191 | inPaint.setAlpha(255);
192 | inPaint.setTextSize(DEFAULT_TEXT_SIZE);
193 | }
194 |
195 | /**
196 | * @param canvas
197 | * @param digital
198 | * @param x
199 | * @param y
200 | */
201 | @Override
202 | public void drawOut(Canvas canvas, String digital, float x, float y, boolean isSelected) {
203 | Paint outPaint = getCurPaint(!isSelected);
204 | outPaint.setAlpha(255 - (int) (mCurAniValue * 255));
205 | outPaint.setTextSize(DEFAULT_TEXT_SIZE * (1.0f - mCurAniValue * 0.5f));
206 | canvas.drawText(digital, x, y, outPaint);
207 | outPaint.setAlpha(255);
208 | outPaint.setTextSize(DEFAULT_TEXT_SIZE);
209 | }
210 |
211 | @Override
212 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
213 | mRect.setEmpty();
214 | mTextNormalPaint.getTextBounds(mPresenter.getText(), 0, mPresenter.getText().length(), mRect);
215 | int textWidth = mRect.width() + PADDING_WIDTH * 2;
216 | int textHeight = mRect.height() + PADDING_HEIGHT * 2;
217 | final int dw = resolveSizeAndState(textWidth, widthMeasureSpec, 0);
218 | final int dh = resolveSizeAndState(textHeight, heightMeasureSpec, 0);
219 | setMeasuredDimension(dw, dh);
220 | }
221 |
222 | @Override
223 | protected void onAttachedToWindow() {
224 | super.onAttachedToWindow();
225 | }
226 |
227 | @Override
228 | protected void onDetachedFromWindow() {
229 | super.onDetachedFromWindow();
230 | mObjectAnimator.end();
231 | }
232 |
233 |
234 |
235 | private Paint getCurPaint(boolean isSelected) {
236 | return isSelected ? mTextSelectedPaint : mTextNormalPaint;
237 | }
238 | }
239 |
--------------------------------------------------------------------------------
/iconcountview/src/main/java/com/sunbinqiang/iconcountview/IconCountView.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.iconcountview;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.animation.PropertyValuesHolder;
5 | import android.content.Context;
6 | import android.content.res.TypedArray;
7 | import android.support.annotation.Nullable;
8 | import android.util.AttributeSet;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.widget.ImageView;
12 | import android.widget.LinearLayout;
13 |
14 | /**
15 | * Created by sunbinqiang on 16/10/2017.
16 | */
17 |
18 | public class IconCountView extends LinearLayout {
19 |
20 | private boolean mIsSelected;
21 | private ImageView mImageView;
22 | private CountView mCountView;
23 | private int mNormalRes;
24 | private int mSelectedRes;
25 | private OnSelectedStateChangedListener mSelectedStateChanged;
26 |
27 | public IconCountView(Context context) {
28 | this(context, null);
29 | }
30 |
31 | public IconCountView(Context context, @Nullable AttributeSet attrs) {
32 | this(context, attrs, 0);
33 | }
34 |
35 | public IconCountView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
36 | super(context, attrs, defStyleAttr);
37 |
38 | View view = LayoutInflater.from(context).inflate(R.layout.icon_count_view, this);
39 | mCountView = view.findViewById(R.id.count_view);
40 | mImageView = view.findViewById(R.id.image_view);
41 |
42 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconCountView, defStyleAttr, 0);
43 | boolean isChecked = a.getBoolean(R.styleable.IconCountView_checked, false);
44 | int normalRes = a.getResourceId(R.styleable.IconCountView_normalRes, R.drawable.icon_praise_normal);
45 | int selectedRes = a.getResourceId(R.styleable.IconCountView_selectedRes, R.drawable.icon_praise_selected);
46 | long count = a.getInt(R.styleable.IconCountView_count, 0);
47 | String zeroText = a.getString(R.styleable.IconCountView_zeroText);
48 | int textNormalColor = a.getColor(R.styleable.IconCountView_textNormalColor, getResources().getColor(R.color.text_gray));
49 | int textSelectedColor = a.getColor(R.styleable.IconCountView_textSelectedColor, getResources().getColor(R.color.text_gray));
50 | int textSize = a.getDimensionPixelSize(R.styleable.IconCountView_textSize, getResources().getDimensionPixelOffset(R.dimen.text_normal_size));
51 | a.recycle();
52 |
53 | //设置初始状态
54 | setIconRes(normalRes, selectedRes);
55 | initCountView(zeroText, count, textNormalColor, textSelectedColor, textSize, isChecked);
56 | setSelected(isChecked);
57 |
58 |
59 | view.setOnClickListener(new OnClickListener() {
60 | @Override
61 | public void onClick(View view) {
62 | praiseChange(!mIsSelected);
63 | }
64 | });
65 | }
66 |
67 | //初始化icon
68 | public void setIconRes(int normalRes, int selectedRes) {
69 | mNormalRes = normalRes;
70 | mSelectedRes = selectedRes;
71 | mImageView.setImageResource(mNormalRes);
72 | }
73 |
74 | //初始化countView
75 | private void initCountView(String zeroText,
76 | long count,
77 | int textNormalColor,
78 | int textSelectedColor,
79 | int textSize,
80 | boolean isSelected) {
81 | mCountView.setZeroText(zeroText);
82 | mCountView.setCount(count);
83 | mCountView.setTextNormalColor(textNormalColor);
84 | mCountView.setTextSelectedColor(textSelectedColor);
85 | mCountView.setTextSize(textSize);
86 | mCountView.setIsSelected(isSelected);
87 | }
88 |
89 | //初始化数量
90 | public void setCount(long count) {
91 | mCountView.setCount(count);
92 | }
93 |
94 | //初始化数量为0时的文字
95 | public void setZeroText(String zeroText) {
96 | mCountView.setZeroText(zeroText);
97 | }
98 |
99 | //初始化状态
100 | public void setState(boolean isSelected) {
101 | mIsSelected = isSelected;
102 | mImageView.setImageResource(mIsSelected ? mSelectedRes : mNormalRes);
103 | }
104 |
105 | /**
106 | * 设置回调接口
107 | * @param onStateChangedListener
108 | */
109 | public void setOnStateChangedListener (OnSelectedStateChangedListener onStateChangedListener) {
110 | mSelectedStateChanged = onStateChangedListener;
111 | }
112 |
113 | //状态变化
114 | private void praiseChange(boolean isPraised) {
115 | mIsSelected = isPraised;
116 | //icon变化
117 | mImageView.setImageResource(isPraised ? mSelectedRes : mNormalRes);
118 | animImageView(isPraised);
119 | //数字变化
120 | if (isPraised) {
121 | mCountView.addCount();
122 | } else {
123 | mCountView.minusCount();
124 | }
125 | mCountView.setIsSelected(isPraised);
126 | //接口回调
127 | if (mSelectedStateChanged != null) {
128 | mSelectedStateChanged.select(mIsSelected);
129 | }
130 | }
131 |
132 | /**
133 | * 点赞icon动画
134 | * @param isPraised
135 | */
136 | private void animImageView(boolean isPraised) {
137 | //图片动画
138 | float toScale = isPraised ? 1.2f : 0.9f;
139 | PropertyValuesHolder propertyValuesHolderX = PropertyValuesHolder.ofFloat("scaleX", 1.0f, toScale, 1.0f);
140 | PropertyValuesHolder propertyValuesHolderY = PropertyValuesHolder.ofFloat("scaleY", 1.0f, toScale, 1.0f);
141 | ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(mImageView,
142 | propertyValuesHolderX, propertyValuesHolderY);
143 | objectAnimator.start();
144 | }
145 |
146 | /**
147 | * 外部回调
148 | * 例如:处理点赞事件的网络请求
149 | */
150 | public interface OnSelectedStateChangedListener {
151 | void select(boolean isSelected);
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/iconcountview/src/main/java/com/sunbinqiang/iconcountview/Utils.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.iconcountview;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by sunbinqiang on 16/10/2017.
7 | */
8 |
9 | public class Utils {
10 | public static int dip2px(Context context, float dipValue) {
11 | if (context == null) {
12 | return (int) dipValue;
13 | }
14 | final float scale = context.getResources().getDisplayMetrics().density;
15 | return (int) (dipValue * scale + 0.5f);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/iconcountview/src/main/res/drawable-xxhdpi/icon_praise_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/iconcountview/src/main/res/drawable-xxhdpi/icon_praise_normal.png
--------------------------------------------------------------------------------
/iconcountview/src/main/res/drawable-xxhdpi/icon_praise_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/iconcountview/src/main/res/drawable-xxhdpi/icon_praise_selected.png
--------------------------------------------------------------------------------
/iconcountview/src/main/res/layout/icon_count_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
22 |
23 |
--------------------------------------------------------------------------------
/iconcountview/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/iconcountview/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #8a8a8a
4 |
--------------------------------------------------------------------------------
/iconcountview/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 14sp
4 |
--------------------------------------------------------------------------------
/iconcountview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | IconCountView
3 |
4 |
--------------------------------------------------------------------------------
/iconcountview/src/test/java/com/sunbinqiang/iconcountview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.iconcountview;
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 | }
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
3 | /build
4 | #
5 | *.iml
6 | .idea
7 | .gradle
8 | local.properties
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion '26.0.2'
6 | defaultConfig {
7 | applicationId "com.sunbinqiang.praiseviewdemo"
8 | minSdkVersion 14
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | multiDexEnabled = true
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | lintOptions {
22 | abortOnError false
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
29 | exclude group: 'com.android.support', module: 'support-annotations'
30 | })
31 | compile 'com.android.support:appcompat-v7:26.1.0'
32 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
33 | testCompile 'junit:junit:4.12'
34 | compile project(':iconcountview')
35 | compile 'com.android.support:multidex:1.0.2'
36 | }
37 |
--------------------------------------------------------------------------------
/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 /Users/sunbinqiang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/com/sunbinqiang/praiseviewdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.praiseviewdemo;
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.sunbinqiang.praiseviewdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/sunbinqiang/praiseviewdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.praiseviewdemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.EditText;
8 |
9 | import com.sunbinqiang.iconcountview.IconCountView;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | private IconCountView praiseView;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 | praiseView = findViewById(R.id.praise_view1);
20 | praiseView.setOnStateChangedListener(new IconCountView.OnSelectedStateChangedListener() {
21 | @Override
22 | public void select(boolean isSelected) {
23 | Log.v("selected", String.valueOf(isSelected));
24 | }
25 | });
26 | //
27 | final EditText editText = (EditText) findViewById(R.id.edit_text);
28 | findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View view) {
31 | try {
32 | long count = Long.valueOf(editText.getText().toString());
33 | praiseView.setCount(count);
34 | } catch (Exception e) {
35 |
36 | }
37 | }
38 | });
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_collect_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_collect_normal.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_collect_normal1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_collect_normal1.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_collect_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_collect_selected.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_collect_selected1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_collect_selected1.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_praise_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_praise_normal.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_praise_normal2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_praise_normal2.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_praise_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_praise_selected.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/icon_praise_selected2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/drawable-xxhdpi/icon_praise_selected2.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
26 |
27 |
44 |
45 |
58 |
59 |
60 |
72 |
73 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/binqiangsun/IconCountView/8e8223d357bf7be82de4e0e55f85031e03411a89/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #d4237a
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PraiseViewDemo
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/test/java/com/sunbinqiang/praiseviewdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.sunbinqiang.praiseviewdemo;
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', ':iconcountview'
2 |
--------------------------------------------------------------------------------