├── .gitignore
├── .idea
├── .name
├── caches
│ ├── build_file_checksums.ser
│ └── gradle_models.ser
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── AndroidLoadingAnimation.iml
├── CustomView.iml
├── README.md
├── TaiJIView.iml
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── bcgtgjyb
│ │ └── huanwen
│ │ └── customview
│ │ └── customview
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── bcgtgjyb
│ │ └── huanwen
│ │ └── customview
│ │ └── customview
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── mylibrary
├── .gitignore
├── build.gradle
├── mylibrary.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── bcgtgjyb
│ │ └── huanwen
│ │ └── customview
│ │ └── mylibrary
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── bcgtgjyb
│ │ └── huanwen
│ │ └── customview
│ │ └── mylibrary
│ │ ├── FiveLine.java
│ │ ├── FourCirlceRotate.java
│ │ ├── LoadingLine.java
│ │ ├── ManyCircle.java
│ │ ├── PPTVLoading.java
│ │ ├── PointToLineRotate.java
│ │ ├── SquareLine.java
│ │ ├── TaiJiButton.java
│ │ ├── WindowsLoad.java
│ │ ├── spring
│ │ ├── GameMap.java
│ │ ├── GameStart.java
│ │ └── SpringView.java
│ │ ├── star
│ │ ├── StarCircle.java
│ │ └── StarView.java
│ │ ├── tool
│ │ ├── BWCallback.java
│ │ ├── BWValueAnimator.java
│ │ ├── Move.java
│ │ ├── Rotate.java
│ │ └── ScreenUtil.java
│ │ └── view58
│ │ ├── Loading58Path.java
│ │ └── Loding58View.java
│ └── res
│ ├── drawable
│ └── ic_launcher.png
│ ├── layout
│ ├── game_start.xml
│ ├── loding58view.xml
│ └── star_circle.xml
│ ├── menu
│ └── menu_main.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ └── strings.xml
├── screenshots
└── taiji1.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | AndroidLoadingAnimation
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.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 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AndroidLoadingAnimation.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/CustomView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](http://www.android-gems.com/lib/guohuanwen/TaiJIView)
2 |
3 | # AndroidLoadingAnimation
4 | #Demo
5 |
6 | 
7 |
8 |
9 |
10 | #Usage
11 | cope mylibrary to your project
12 |
13 | #License
14 | Copyright 2015 guohuanwen
15 |
16 | Licensed under the Apache License, Version 2.0 (the "License");
17 | you may not use this file except in compliance with the License.
18 | You may obtain a copy of the License at
19 |
20 | http://www.apache.org/licenses/LICENSE-2.0
21 |
22 | Unless required by applicable law or agreed to in writing, software
23 | distributed under the License is distributed on an "AS IS" BASIS,
24 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 | See the License for the specific language governing permissions and
26 | limitations under the License.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/TaiJIView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | buildToolsVersion "28.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.bcgtgjyb.huanwen.customview.customview"
9 | minSdkVersion 15
10 | targetSdkVersion 26
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(include: ['*.jar'], dir: 'libs')
24 | implementation 'com.android.support:appcompat-v7:23.0.0'
25 | implementation project(':mylibrary')
26 | }
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/bcgtgjyb/huanwen/customview/customview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.customview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bcgtgjyb/huanwen/customview/customview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.customview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.view.WindowManager;
7 | import android.widget.Button;
8 |
9 | import com.bcgtgjyb.huanwen.customview.mylibrary.TaiJiButton;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 | private Button button;
13 | private TaiJiButton taiJiButton;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
19 | WindowManager.LayoutParams. FLAG_FULLSCREEN);
20 | setContentView(R.layout.activity_main);
21 | init();
22 | // setContentView(new GameStart(this));
23 | }
24 |
25 | private void init() {
26 | taiJiButton = (TaiJiButton) findViewById(R.id.taiJiButton);
27 | taiJiButton.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View view) {
30 | if (!taiJiButton.isLoading()) {
31 | taiJiButton.startLoad();
32 | }
33 | }
34 | });
35 | button = (Button) findViewById(R.id.button);
36 | button.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View view) {
39 | if (taiJiButton != null && taiJiButton.isLoading()) {
40 | taiJiButton.stopLoad();
41 | }
42 | }
43 | });
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
14 |
15 |
19 |
20 |
24 |
25 |
30 |
31 |
34 |
37 |
38 |
41 |
42 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
57 |
58 |
63 |
64 |
68 |
69 |
72 |
73 |
76 |
77 |
80 |
81 |
82 |
86 |
91 |
92 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidLoading
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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 | mavenCentral()
6 | jcenter()
7 | maven {
8 | url 'https://maven.google.com/'
9 | name 'Google'
10 | }
11 | google()
12 | }
13 | dependencies {
14 | classpath 'com.android.tools.build:gradle:3.4.2'
15 |
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | jcenter()
24 | mavenCentral()
25 | jcenter()
26 | maven {
27 | url 'https://maven.google.com/'
28 | name 'Google'
29 | }
30 | google()
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Apr 23 15:10:01 CST 2016
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.10-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/mylibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/mylibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 28
5 | buildToolsVersion "28.0.3"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:23.0.0'
24 | implementation 'com.nineoldandroids:library:2.4.0'
25 | }
26 |
--------------------------------------------------------------------------------
/mylibrary/mylibrary.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/mylibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\adt-bundle-windows-x86_64-20140702\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 |
--------------------------------------------------------------------------------
/mylibrary/src/androidTest/java/com/bcgtgjyb/huanwen/customview/mylibrary/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/mylibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/FiveLine.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 guohuanwen
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.bcgtgjyb.huanwen.customview.mylibrary;
18 |
19 | import android.animation.ValueAnimator;
20 | import android.content.Context;
21 | import android.graphics.Canvas;
22 | import android.graphics.Color;
23 | import android.graphics.Paint;
24 | import android.util.AttributeSet;
25 | import android.view.View;
26 | import android.view.animation.LinearInterpolator;
27 |
28 | /**
29 | * Created by Administrator on 2015/11/9.
30 | */
31 | public class FiveLine extends View {
32 | private Paint paint;
33 | private boolean init = false;
34 | private float width = 0;
35 | private float height = 0;
36 | private ValueAnimator valueAnimator;
37 | private float numb = 0;
38 | private boolean stop = false;
39 | private float[] initLine = new float[]{0.6f, 0.3f, 0, 0.3f, 0.6f};
40 |
41 | public FiveLine(Context context, AttributeSet attrs) {
42 | super(context, attrs);
43 | paint = new Paint(Paint.ANTI_ALIAS_FLAG);
44 | paint.setStrokeWidth(10);
45 | paint.setColor(Color.parseColor("#ff0099cc"));
46 | }
47 |
48 | public void initLine(float[] floats) {
49 | if (floats.length >= 5) {
50 | this.initLine = floats;
51 | }
52 | }
53 |
54 | @Override
55 | protected void onDraw(Canvas canvas) {
56 | super.onDraw(canvas);
57 | if (!init) {
58 | width = getWidth();
59 | height = getHeight();
60 | init = true;
61 | start();
62 | }
63 | numb = (float) valueAnimator.getAnimatedValue();
64 | //三
65 | canvas.drawLine(width / 2, 0f + fx(numb + initLine[2]) * width, width / 2, height - fx(numb) * width, paint);
66 | //二
67 | canvas.drawLine(width / 3, 0f + fx(numb + initLine[1]) * width, width / 3, height - fx(numb + 0.3f) * width, paint);
68 | //一
69 | canvas.drawLine(width / 6, 0f + fx(numb + initLine[0]) * width, width / 6, height - fx(numb + 0.6f) * width, paint);
70 | //四
71 | canvas.drawLine(width / 3 * 2, 0f + fx(numb + initLine[3]) * width, width / 3 * 2, height - fx(numb + 0.3f) * width, paint);
72 | //第五根
73 | canvas.drawLine(width / 6 * 5, 0f + fx(numb + initLine[4]) * width, width / 6 * 5, height - fx(numb + 0.6f) * width, paint);
74 | if (valueAnimator.isRunning()) {
75 | invalidate();
76 | }
77 | }
78 |
79 |
80 | //分段周期函数,做为偏移量
81 | private float fx(float numb) {
82 | if (numb <= 0 && numb > -1) {
83 | numb = Math.abs(numb);
84 | }
85 | if (numb <= -1) {
86 | numb = numb + 2;
87 | }
88 | if (numb > 1) {
89 | numb = -numb + 2;
90 | }
91 | return numb;
92 | }
93 |
94 | public void start() {
95 | if (valueAnimator == null) {
96 | valueAnimator = getValueAnimator();
97 | } else {
98 | valueAnimator.start();
99 | }
100 | if (stop == false) {
101 | postDelayed(new Runnable() {
102 | @Override
103 | public void run() {
104 | start();
105 | invalidate();
106 | }
107 | }, valueAnimator.getDuration());
108 | }
109 | }
110 |
111 | public void stop() {
112 | this.stop = true;
113 | }
114 |
115 | private ValueAnimator getValueAnimator() {
116 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(-1f, 1f);
117 | valueAnimator.setDuration(1500);
118 | valueAnimator.setInterpolator(new LinearInterpolator());
119 | valueAnimator.start();
120 | return valueAnimator;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/FourCirlceRotate.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 | import android.view.animation.LinearInterpolator;
11 |
12 | /**
13 | * Created by guohuanwen on 2015/10/6.
14 | */
15 | public class FourCirlceRotate extends View {
16 | private String TAG = "FourCirlceRotate";
17 | private Paint paint1;
18 | private Paint paint2;
19 | private Paint paint3;
20 | private Paint paint4;
21 | private Paint paint5;
22 | private ValueAnimator valueAnimator;
23 | private int delay = 500;
24 | private boolean init = false;
25 | private float R = 0;
26 | private boolean stop = false;
27 |
28 | private float where = 0;
29 | private boolean isStart = false;
30 | private int show = 0;
31 |
32 | public FourCirlceRotate(Context context, AttributeSet attrs) {
33 | super(context, attrs);
34 | paint1 = new Paint();
35 | paint2 = new Paint();
36 | paint3 = new Paint();
37 | paint4 = new Paint();
38 | paint5 = new Paint();
39 | paint1.setColor(Color.parseColor("#ff0099cc"));
40 | paint2.setColor(Color.parseColor("#ff669900"));
41 | paint3.setColor(Color.parseColor("#ffcc0000"));
42 | paint4.setColor(Color.parseColor("#ffaa66cc"));
43 | paint5.setColor(Color.parseColor("#ffffbb33"));
44 | }
45 |
46 | @Override
47 | protected void onDraw(Canvas canvas) {
48 | super.onDraw(canvas);
49 | // Log.i(TAG, "onDraw " + where);
50 | if (!init) {
51 | startAnimation();
52 |
53 | }
54 | //显示固定的圆,逐个出现
55 | if (show <= 4) {
56 | canvas.drawCircle(R, R, R, paint2);
57 | }
58 | if (show <= 3) {
59 | canvas.drawCircle(getWidth() - R, R, R, paint3);
60 | }
61 | if (show <= 2) {
62 | canvas.drawCircle(getWidth() - R, getHeight() - R, R, paint4);
63 | }
64 | if (show <= 1) {
65 | canvas.drawCircle(R, getHeight() - R, R, paint5);
66 | }
67 | //逐个消失
68 | if (show > 4) {
69 | if (show <= 4) {
70 | canvas.drawCircle(R, R, R, paint2);
71 | }
72 | if (show <= 5) {
73 | canvas.drawCircle(getWidth() - R, R, R, paint3);
74 | }
75 | if (show <= 6) {
76 | canvas.drawCircle(getWidth() - R, getHeight() - R, R, paint4);
77 | }
78 | if (show <= 7) {
79 | canvas.drawCircle(R, getHeight() - R, R, paint5);
80 | }
81 | }
82 | //移动
83 | if (where < 1 && where > 0) {
84 | canvas.drawCircle(R + (getWidth() - 2 * R) * where, R, R, paint1);
85 | show = 4;
86 | }
87 | if (where < 2 && where > 1) {
88 | canvas.drawCircle(getHeight() - R, R + (getHeight() - 2 * R) * (where - 1), R, paint1);
89 | show = 3;
90 | }
91 | if (where < 3 && where > 2) {
92 | canvas.drawCircle(getWidth() - R - (getWidth() - 2 * R) * (where - 2), getHeight() - R, R, paint1);
93 | show = 2;
94 | }
95 | if (where < 4 && where > 3) {
96 | canvas.drawCircle(R, getHeight() - R - (getHeight() - 2 * R) * (where - 3), R, paint1);
97 | show = 1;
98 | }
99 | if (where > 4 && where < 5) {
100 | canvas.drawCircle(R + (getWidth() - 2 * R) * (where - 4), R, R, paint1);
101 | show = 5;
102 | }
103 | if (where > 5 && where < 6) {
104 | canvas.drawCircle(getHeight() - R, R + (getHeight() - 2 * R) * (where - 5), R, paint1);
105 | show = 6;
106 | }
107 | if (where > 6 && where < 7) {
108 | canvas.drawCircle(getWidth() - R - (getWidth() - 2 * R) * (where - 6), getHeight() - R, R, paint1);
109 | show = 7;
110 | }
111 | if (where > 7 && where < 8) {
112 | canvas.drawCircle(R, getHeight() - R - (getHeight() - 2 * R) * (where - 7), R, paint1);
113 | show = 8;
114 | }
115 |
116 |
117 | if (isStart) {
118 | where = (float) valueAnimator.getAnimatedValue();
119 | }
120 | if (valueAnimator.isRunning()) {
121 | isStart = true;
122 | invalidate();
123 | }
124 |
125 |
126 | }
127 |
128 |
129 | public void startAnimation() {
130 | if (valueAnimator == null) {
131 | valueAnimator = getValueAnimator();
132 | } else {
133 | valueAnimator.start();
134 | }
135 | R = getWidth() / 6;
136 | postDelayed(new Runnable() {
137 | @Override
138 | public void run() {
139 | if (!stop) {
140 | startAnimation();
141 | invalidate();
142 | }
143 | }
144 | }, valueAnimator.getDuration());
145 | init = true;
146 | }
147 |
148 | public void stop() {
149 | this.stop = true;
150 | }
151 |
152 | private ValueAnimator getValueAnimator() {
153 | // Log.i(TAG, "getValueAnimator ");
154 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(0f, 8f);
155 | valueAnimator.setDuration(4000);
156 | valueAnimator.setInterpolator(new LinearInterpolator());
157 | valueAnimator.start();
158 | // invalidate();
159 | return valueAnimator;
160 | }
161 |
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/LoadingLine.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 | import android.view.animation.LinearInterpolator;
11 |
12 | /**
13 | * Created by bigwen on 2016/1/14.
14 | */
15 | public class LoadingLine extends View {
16 |
17 | private Paint paint;
18 | private Paint backPaint;
19 | private Paint textPaint;
20 | private boolean init = false;
21 | private ValueAnimator valueAnimator;
22 | private float param = 0;
23 | private int length = 0;
24 |
25 | public LoadingLine(Context context) {
26 | super(context);
27 | init();
28 | }
29 |
30 |
31 | public LoadingLine(Context context, AttributeSet attrs) {
32 | super(context, attrs);
33 | init();
34 | }
35 |
36 | private void init() {
37 | paint = new Paint();
38 | paint.setColor(Color.BLUE);
39 | paint.setStrokeWidth(20);
40 | backPaint = new Paint();
41 | backPaint.setColor(Color.RED);
42 | backPaint.setStrokeWidth(25);
43 | textPaint = new Paint();
44 | textPaint.setColor(Color.WHITE);
45 | textPaint.setTextSize(20);
46 | }
47 |
48 | @Override
49 | protected void onDraw(Canvas canvas) {
50 | super.onDraw(canvas);
51 | if (!init) {
52 | start();
53 | init = true;
54 | }
55 | int width = getWidth();
56 | int height = getHeight();
57 | canvas.drawLine(0, height / 2, width, height / 2, backPaint);
58 | canvas.drawLine(0, height / 2, length * width / 100, height / 2, paint);
59 | canvas.drawText(length + "", length * width / 100 - 22, height / 2 + 6, textPaint);
60 | if (valueAnimator.isRunning()) {
61 | param = (float) valueAnimator.getAnimatedValue();
62 | setLength((int) param);
63 | }
64 | }
65 |
66 | /**
67 | * 也可在外部手动控制进度条,自行关闭valueAnimator
68 | *
69 | * @param param
70 | */
71 | public void setLength(int param) {
72 | this.length = param;
73 | invalidate();
74 | }
75 |
76 | private void start() {
77 | if (valueAnimator == null) {
78 | valueAnimator = ValueAnimator.ofFloat(0, 100);
79 | valueAnimator.setInterpolator(new LinearInterpolator());
80 | valueAnimator.setDuration(6000);
81 | valueAnimator.start();
82 | } else {
83 | valueAnimator.start();
84 | }
85 | postDelayed(new Runnable() {
86 | @Override
87 | public void run() {
88 | start();
89 | invalidate();
90 | }
91 | }, valueAnimator.getDuration());
92 | invalidate();
93 | }
94 |
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/ManyCircle.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 | import android.view.animation.LinearInterpolator;
11 |
12 | /**
13 | * Created by bigwen on 2016/1/14.
14 | */
15 | public class ManyCircle extends View {
16 | private Paint paint;
17 | private int maxRadius = 16;
18 | private ValueAnimator valueAnimator;
19 | private boolean init = false;
20 | private float radiu = 10;
21 |
22 | public ManyCircle(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | init();
25 | }
26 |
27 | public ManyCircle(Context context) {
28 | super(context);
29 | init();
30 | }
31 |
32 | private void init() {
33 | paint = new Paint();
34 | paint.setColor(Color.RED);
35 | }
36 |
37 | private int width;
38 | private int height;
39 | private float pi2;
40 | private float r;
41 | @Override
42 | protected void onDraw(Canvas canvas) {
43 | super.onDraw(canvas);
44 | if (!init) {
45 | init = true;
46 | start();
47 | width = getWidth() / 2;
48 | height = getHeight() / 2;
49 | pi2 = 2*(float)Math.PI;
50 | r = width-maxRadius;
51 | }
52 |
53 | canvas.drawCircle((float) (width + r * Math.sin(0)), (float) (height + r * Math.cos(0)), f(radiu+0), paint);
54 | canvas.drawCircle((float) (width + r * Math.sin(pi2 /8)), (float) (height + r * Math.cos(pi2 /8)), f(radiu+2), paint);
55 | canvas.drawCircle((float) (width + r * Math.sin(pi2 /8*2)), (float) (height + r * Math.cos(pi2 /8*2)), f(radiu+4), paint);
56 | canvas.drawCircle((float) (width + r * Math.sin(pi2 /8*3)), (float) (height + r * Math.cos(pi2 /8*3)), f(radiu+6), paint);
57 |
58 | canvas.drawCircle((float) (width + r * Math.sin(pi2 /8*4)), (float) (height + r * Math.cos(pi2 /8*4)), f(radiu+8), paint);
59 | canvas.drawCircle((float) (width + r * Math.sin(pi2 /8*5)), (float) (height + r * Math.cos(pi2 /8*5)), f(radiu+10), paint);
60 | canvas.drawCircle((float) (width + r * Math.sin(pi2 /8*6)), (float) (height + r * Math.cos(pi2 /8*6)), f(radiu+12), paint);
61 | canvas.drawCircle((float) (width + r * Math.sin(pi2 /8*7)), (float) (height + r * Math.cos(pi2 /8*7)), f(radiu+14), paint);
62 |
63 | if (valueAnimator.isRunning()) {
64 | radiu = (float) valueAnimator.getAnimatedValue();
65 | invalidate();
66 | }
67 |
68 |
69 | }
70 |
71 |
72 | private void start() {
73 | if (valueAnimator == null) {
74 | valueAnimator = ValueAnimator.ofFloat(0, maxRadius);
75 | valueAnimator.setInterpolator(new LinearInterpolator());
76 | valueAnimator.setDuration(1000);
77 | valueAnimator.start();
78 | }else {
79 | valueAnimator.start();
80 | }
81 | postDelayed(new Runnable() {
82 | @Override
83 | public void run() {
84 | start();
85 | invalidate();
86 | }
87 | }, valueAnimator.getDuration());
88 | invalidate();
89 | }
90 |
91 | //分段函数
92 | private float f(float x) {
93 | if (x <=maxRadius / 2) {
94 | return x;
95 | } else if(x 1.0) {
103 | param = 1.0f;
104 | }
105 | float a = (float) Math.asin(param);
106 | if (x1 >= x0 && y1 >= y0) {
107 | a = a;
108 | } else if (x1 < x0 && y1 >= y0) {
109 | a = pi - a;
110 | } else if (x1 < x0 && y1 < y0) {
111 | a = a + pi;
112 | } else {
113 | a = 2 * pi - a;
114 | }
115 | ValueAnimator circleAnimator = ValueAnimator.ofFloat(a, a + 2 * pi);
116 | circleAnimator.setDuration(1500);
117 | circleAnimator.setInterpolator(new LinearInterpolator());
118 | circleAnimator.setStartDelay(delay);
119 | circleAnimator.start();
120 | return circleAnimator;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/SquareLine.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 | import android.view.animation.LinearInterpolator;
10 |
11 | import com.nineoldandroids.animation.ValueAnimator;
12 |
13 | /**
14 | * Created by bigwen on 2015/12/31.
15 | */
16 | public class SquareLine extends View {
17 | private Context mContext;
18 | private Paint paint;
19 | private ValueAnimator valueA;
20 | private int delayTime=500;
21 | private boolean initView = false;
22 |
23 | public SquareLine(Context context) {
24 | super(context);
25 | mContext = context;
26 | init();
27 | }
28 |
29 | public SquareLine(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | mContext = context;
32 | init();
33 | }
34 |
35 | private void init() {
36 | paint = new Paint();
37 | paint.setColor(Color.parseColor("#259b24"));
38 | paint.setStrokeWidth(10);
39 |
40 | }
41 | float f = 0;
42 | @Override
43 | protected void onDraw(Canvas canvas) {
44 | super.onDraw(canvas);
45 | if(!initView){
46 | start();
47 | initView=true;
48 | }
49 | int height = getMeasuredHeight();
50 | int width = getMeasuredWidth();
51 | int length = width/9;
52 |
53 | if (valueA.isRunning()) {
54 | f = (float) valueA.getAnimatedValue();
55 | }
56 | canvas.drawLines(new float[]{yValue(f, length), height / 2, length * 4 + yValue(f, length), height / 2}, paint);
57 | canvas.drawLines(new float[]{yValue(f, length) - width, height / 2, length * 4 + yValue(f, length) - width, height / 2}, paint);
58 | if (valueA.isRunning()) {
59 | invalidate();
60 | }
61 | }
62 |
63 | private void start(){
64 | if (valueA == null) {
65 | valueA = getValueAnimator();
66 | }else {
67 | valueA.start();
68 | }
69 | invalidate();
70 | postDelayed(new Runnable() {
71 | @Override
72 | public void run() {
73 | start();
74 | invalidate();
75 | }
76 | }, valueA.getDuration());
77 | }
78 |
79 | private ValueAnimator getValueAnimator() {
80 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(0,1);
81 | valueAnimator.setDuration(delayTime);
82 | valueAnimator.setInterpolator(new LinearInterpolator());
83 | valueAnimator.start();
84 | invalidate();
85 | return valueAnimator;
86 | }
87 |
88 | private float yValue(float x, int length) {
89 | float s = length / getMeasuredWidth();
90 | float allLength = getMeasuredWidth();
91 | return allLength/ 1 * x;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/TaiJiButton.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Rect;
8 | import android.graphics.RectF;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.view.animation.LinearInterpolator;
13 |
14 | import com.nineoldandroids.animation.ValueAnimator;
15 |
16 | /**
17 | * Created by huanwen on 2015/9/1.
18 | */
19 | public class TaiJiButton extends View {
20 | private final String TAG = "TaiJiButton";
21 | private float rolate = 360;
22 | private Paint mWhitePaint;
23 | private Paint mBlackPaint;
24 | private Paint backgroundPaint;
25 | private Paint arcPaint;
26 | private Rect mRect;
27 | private RectF backRectF;
28 | private ValueAnimator animator;
29 | private ValueAnimator smallAnimator;
30 | private ValueAnimator lineToArcAnimator;
31 | private ValueAnimator arcToLineAnimator;
32 | private boolean init = false;
33 | private float ratio = 0;
34 | private boolean stopAnimator = false;
35 | private float raduis = 0;
36 | private int velocity = 1000;
37 | private int color1 = Color.BLACK;
38 | private int color2 = Color.GRAY;
39 | private float R = 0;
40 | private float raduisX1 = 0;
41 | private float raduisY1 = 0;
42 | private float raduisX2 = 0;
43 | private float raduisY2 = 0;
44 | private RectF rectF;
45 | private RectF rectF2;
46 | private boolean loading = false;
47 |
48 |
49 | public TaiJiButton(Context context, AttributeSet attributeSet) {
50 | super(context, attributeSet);
51 | mWhitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
52 | mBlackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
53 | backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
54 | arcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
55 | mRect = new Rect();
56 | backRectF = new RectF();
57 | rectF = new RectF();
58 | rectF2 = new RectF();
59 | }
60 |
61 | /**
62 | * set the animation start
63 | */
64 | public void startLoad() {
65 | loading = true;
66 | stopAnimator = false;
67 | setLineToArcAnimator();
68 | setAppearAnimator();
69 | loading();
70 | }
71 |
72 | /**
73 | * set the animation stop
74 | */
75 | public void stopLoad() {
76 | loading = false;
77 | this.stopAnimator = true;
78 | setArcToLineAnimator();
79 | setDisAppearAnimator();
80 | }
81 |
82 | public boolean isLoading(){
83 | return loading;
84 | }
85 |
86 | /**
87 | * set the velocity of animation
88 | *
89 | * @param velocity
90 | */
91 | public void setVelocity(int velocity) {
92 | this.velocity = velocity;
93 | }
94 |
95 | /**
96 | * set the view's color
97 | *
98 | * @param color1
99 | * @param color2
100 | */
101 | public void setColor(int color1, int color2) {
102 | this.color1 = color1;
103 | this.color2 = color2;
104 | }
105 |
106 |
107 | @Override
108 | protected void onDraw(Canvas canvas) {
109 | super.onDraw(canvas);
110 | //初始化
111 | if (!init) {
112 | mWhitePaint.setColor(color2);
113 | mBlackPaint.setColor(color1);
114 | R = getWidth() / 2 - 5;
115 | raduisX1 = getWidth() / 2 + R / 2;
116 | raduisY1 = getHeight() / 2;
117 | raduisX2 = getWidth() / 2 - R / 2;
118 | raduisY2 = getHeight() / 2;
119 | init=true;
120 | }
121 | //旋转刷新
122 | if (animator != null && animator.isRunning()) {
123 | float ratio = (Float) animator.getAnimatedValue();
124 | canvas.rotate(rolate * ratio, getWidth() / 2, getHeight() / 2);
125 | invalidate();
126 | }
127 |
128 | //画出背景半圆
129 | backRectF.set(getWidth() / 2 - R, getHeight() / 2 - R, getWidth() / 2 + R, getHeight() / 2 + R);
130 | mRect.set(getWidth(), getHeight(), 0, 0);
131 | canvas.drawArc(backRectF, 0, 180, true, mWhitePaint);
132 | canvas.drawArc(backRectF, 0, -180, true, mBlackPaint);
133 |
134 |
135 | // Log.d(TAG, "onDraw() returned: " + ratio+" "+(getHeight() / 2 - ratio * R / 2)+" "+(getHeight() / 2 + ratio * R / 2));
136 | //椭圆渐变
137 | rectF.set(getWidth() / 2 - R, getHeight() / 2 - ratio *R / 2, getWidth() / 2, getHeight() / 2 + ratio *R / 2);
138 | rectF2.set(getWidth() / 2, getHeight() / 2 - ratio * R / 2, getWidth() / 2 + R, getHeight() / 2 + ratio * R / 2);
139 | canvas.drawArc(rectF, 0, -180, true, mWhitePaint);
140 | canvas.drawArc(rectF2, 0, 180, true, mBlackPaint);
141 | if ((lineToArcAnimator != null && lineToArcAnimator.isRunning())) {
142 | ratio = (Float) lineToArcAnimator.getAnimatedValue();
143 | invalidate();
144 | }
145 | if (arcToLineAnimator != null && arcToLineAnimator.isRunning()) {
146 | ratio = (Float) arcToLineAnimator.getAnimatedValue();
147 | invalidate();
148 | }
149 |
150 | //圆心放大
151 | canvas.drawCircle(raduisX1, raduisY1, raduis * R / 5, mWhitePaint);
152 | canvas.drawCircle(raduisX2, raduisY2, raduis * R / 5, mBlackPaint);
153 | if (smallAnimator != null && smallAnimator.isRunning()) {
154 | raduis = (float) smallAnimator.getAnimatedValue();
155 | invalidate();
156 | }
157 | }
158 |
159 | private void loading() {
160 | if (animator == null) {
161 | loadAnimator();
162 | }else {
163 | animator.start();
164 | }
165 | if (!stopAnimator) {
166 | postDelayed(new Runnable() {
167 | @Override
168 | public void run() {
169 | loading();
170 | }
171 | }, animator.getDuration());
172 | }
173 | }
174 |
175 | private void loadAnimator() {
176 | animator = ValueAnimator.ofFloat(0f, 1f);
177 | animator.setDuration(velocity);
178 | animator.setInterpolator(new LinearInterpolator());
179 | animator.start();
180 | invalidate();
181 | }
182 |
183 | private void setLineToArcAnimator() {
184 | Log.i(TAG, "setLineToArcAnimator ");
185 | lineToArcAnimator = ValueAnimator.ofFloat(0f, 1f);
186 | lineToArcAnimator.setDuration(velocity);
187 | lineToArcAnimator.setInterpolator(new LinearInterpolator());
188 | lineToArcAnimator.start();
189 | invalidate();
190 | }
191 |
192 | private void setArcToLineAnimator() {
193 | Log.i(TAG, "setArcToLineAnimator ");
194 | arcToLineAnimator = ValueAnimator.ofFloat(1f, 0f);
195 | arcToLineAnimator.setDuration(velocity);
196 | arcToLineAnimator.setInterpolator(new LinearInterpolator());
197 | arcToLineAnimator.start();
198 | invalidate();
199 | }
200 |
201 | private void setAppearAnimator() {
202 | smallAnimator = ValueAnimator.ofFloat(0f, 1f);
203 | smallAnimator.setDuration(velocity);
204 | smallAnimator.start();
205 | invalidate();
206 | }
207 |
208 | private void setDisAppearAnimator() {
209 | smallAnimator = ValueAnimator.ofFloat(1f, 0f);
210 | smallAnimator.setDuration(velocity);
211 | smallAnimator.start();
212 | invalidate();
213 | }
214 | }
215 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/WindowsLoad.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 | import android.view.animation.Interpolator;
11 |
12 | /**
13 | * Created by guohuanwen on 2015/10/5.
14 | */
15 | public class WindowsLoad extends View {
16 | private float pi = (float) Math.PI;
17 | private String TAG = "WindowsLoad";
18 | private Paint paint;
19 | private int R;
20 | private float circleR;
21 | private ValueAnimator circleAnimator1;
22 | private ValueAnimator circleAnimator2;
23 | private ValueAnimator circleAnimator3;
24 | private boolean init = true;
25 | float x1, x2, x3, y1, y2, y3;
26 |
27 | public WindowsLoad(Context context, AttributeSet attrs) {
28 | super(context, attrs);
29 | paint = new Paint(Paint.ANTI_ALIAS_FLAG);
30 | paint.setColor(Color.parseColor("#ffff4444"));
31 | R = 10;
32 | }
33 |
34 |
35 | float[] circleCentre;
36 | float[] start1;
37 | float[] start2;
38 | float[] start3;
39 |
40 | @Override
41 | protected void onDraw(Canvas canvas) {
42 | super.onDraw(canvas);
43 | //初始化
44 | if (init) {
45 | circleCentre = new float[]{getWidth() / 2, getHeight() / 2};
46 | start1 = new float[]{getWidth() / 2, R};
47 | start2 = onCiecleCoordinate(-0.5f, start1, circleCentre);
48 | start3 = onCiecleCoordinate(-0.5f, start2, circleCentre);
49 | init = false;
50 | loading();
51 | }
52 | // canvas.drawCircle(start1[0], start1[1], R, paint);
53 | // Log.d(TAG, "onDraw() returned: "+ start1[0]+" "+start1[1] +" "+ start2[0]+" "+start2[1]);
54 |
55 | //第一个点初始位置
56 | if (!circleAnimator1.isRunning()) {
57 | canvas.drawCircle(start1[0], start1[1], R, paint);
58 | }
59 | //第二个点初始位置
60 | if (!circleAnimator2.isRunning()) {
61 | canvas.drawCircle(start2[0], start2[1], R, paint);
62 | }
63 | //第三个点初始位置
64 | if (!circleAnimator3.isRunning()) {
65 | canvas.drawCircle(start3[0], start3[1], R, paint);
66 | }
67 |
68 | if (circleAnimator1.isRunning()) {
69 | x1 = (float) (circleCentre[0] + circleR * Math.cos((float) circleAnimator1.getAnimatedValue()));
70 | y1 = (float) (circleCentre[1] + circleR * Math.sin((float) circleAnimator1.getAnimatedValue()));
71 | canvas.drawCircle(x1, y1, R, paint);
72 | }
73 | if (circleAnimator2.isRunning()) {
74 | x2 = (float) (circleCentre[0] + circleR * Math.cos((float) circleAnimator2.getAnimatedValue()));
75 | y2 = (float) (circleCentre[1] + circleR * Math.sin((float) circleAnimator2.getAnimatedValue()));
76 | canvas.drawCircle(x2, y2, R, paint);
77 | }
78 | if (circleAnimator3.isRunning()) {
79 | x3 = (float) (circleCentre[0] + circleR * Math.cos((float) circleAnimator3.getAnimatedValue()));
80 | y3 = (float) (circleCentre[1] + circleR * Math.sin((float) circleAnimator3.getAnimatedValue()));
81 | canvas.drawCircle(x3, y3, R, paint);
82 | }
83 | if (circleAnimator1.isRunning() || circleAnimator2.isRunning() || circleAnimator3.isRunning()) {
84 | invalidate();
85 | }
86 | }
87 |
88 |
89 | private void loading() {
90 | circleAnimator1 = getCircleData(start1, circleCentre, 0);
91 | circleAnimator1.start();
92 | circleAnimator2 = getCircleData(start2, circleCentre, 300);
93 | circleAnimator2.start();
94 | circleAnimator3 = getCircleData(start3, circleCentre, 600);
95 | circleAnimator3.start();
96 | postDelayed(new Runnable() {
97 | @Override
98 | public void run() {
99 | loading();
100 | invalidate();
101 | }
102 | }, circleAnimator3.getDuration() + 600);
103 | }
104 |
105 | private SlowToQuick slowToQuick = new SlowToQuick();
106 |
107 | private ValueAnimator getCircleData(float[] startCoordinate, float[] RCoordinate, int delay) {
108 | float x1 = startCoordinate[0];
109 | float y1 = startCoordinate[1];
110 | float x0 = RCoordinate[0];
111 | float y0 = RCoordinate[1];
112 | // Log.i(TAG, "getCircleData x y: " + x1+" ,"+y1+" x0 "+x0+ " y0 "+y0);
113 | circleR = (float) Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
114 | float param = (float) (Math.abs(y1 - y0) / circleR);
115 | if (param < -1.0) {
116 | param = -1.0f;
117 | } else if (param > 1.0) {
118 | param = 1.0f;
119 | }
120 | float a = (float) Math.asin(param);
121 | if (x1 >= x0 && y1 >= y0) {
122 | a = a;
123 | } else if (x1 < x0 && y1 >= y0) {
124 | a = pi - a;
125 | } else if (x1 < x0 && y1 < y0) {
126 | a = a + pi;
127 | } else {
128 | a = 2 * pi - a;
129 | }
130 | ValueAnimator circleAnimator = ValueAnimator.ofFloat(a, a + 2 * pi);
131 | circleAnimator.setDuration(1500);
132 | circleAnimator.setInterpolator(slowToQuick);
133 | circleAnimator.setStartDelay(delay);
134 | return circleAnimator;
135 | }
136 |
137 | //获取同一个圆上,间隔固定角度的点坐标
138 | private float[] onCiecleCoordinate(float angle, float[] start, float[] center) {
139 | float x1 = start[0];
140 | float y1 = start[1];
141 | float x0 = center[0];
142 | float y0 = center[1];
143 | float R = (float) Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
144 | float param = (float) (Math.abs(y1 - y0) / R);
145 | if (param < -1.0) {
146 | param = -1.0f;
147 | } else if (param > 1.0) {
148 | param = 1.0f;
149 | }
150 | float a = (float) Math.asin(param);
151 | if (x1 >= x0 && y1 >= y0) {
152 | a = a;
153 | } else if (x1 < x0 && y1 >= y0) {
154 | a = pi - a;
155 | } else if (x1 < x0 && y1 < y0) {
156 | a = a + pi;
157 | } else {
158 | a = 2 * pi - a;
159 | }
160 | float x = (float) (center[0] + R * Math.cos(a + angle));
161 | float y = (float) (center[1] + R * Math.sin(a + angle));
162 | return new float[]{x, y};
163 | }
164 |
165 | class SlowToQuick implements Interpolator {
166 | @Override
167 | public float getInterpolation(float input) {
168 | return input * input;
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/spring/GameMap.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.spring;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.Point;
10 | import android.util.AttributeSet;
11 | import android.util.Log;
12 | import android.view.View;
13 |
14 | import com.bcgtgjyb.huanwen.customview.mylibrary.R;
15 | import com.bcgtgjyb.huanwen.customview.mylibrary.tool.ScreenUtil;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 | import java.util.Random;
20 |
21 | /**
22 | * Created by bigwen on 2016/4/25.
23 | */
24 | public class GameMap extends View {
25 |
26 | private Context mContext;
27 | private int mapW, mapH, screenW, screenH;
28 | private Bitmap bitmap;
29 | private List mapInfos = new ArrayList<>();
30 | private Paint mPaint;
31 | private int d;
32 | private String TAG = GameMap.class.getName();
33 | private Random random = new Random();
34 | private List randomPoints = new ArrayList<>();
35 | private int scale = 0;
36 | private float nowScale = 1;
37 |
38 | public GameMap(Context context) {
39 | super(context);
40 | mContext = context;
41 | init();
42 | }
43 |
44 | public GameMap(Context context, AttributeSet attrs) {
45 | super(context, attrs);
46 | mContext = context;
47 | init();
48 | }
49 |
50 | private void init() {
51 | scale = ScreenUtil.getScreenWidth(mContext) / 5;
52 | mPaint = new Paint();
53 | mPaint.setColor(Color.BLACK);
54 | mPaint.setStrokeWidth(ScreenUtil.dip2px(mContext, 5));
55 | d = ScreenUtil.dip2px(mContext, 1);
56 | screenW = ScreenUtil.getScreenWidth(mContext);
57 | screenH = ScreenUtil.getScreenHeight(mContext);
58 |
59 | bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
60 | mapW = bitmap.getWidth();
61 | mapH = bitmap.getHeight();
62 |
63 | int n = screenW / mapW;
64 | int m = screenH / mapH;
65 |
66 | int startX = -20 * mapW, startY = -20 * mapH;
67 | for (int i = 0; i < (n + 40); i++) {
68 | for (int j = 0; j < (m + 40); j++) {
69 | MapInfo mapInfo = new MapInfo();
70 | mapInfo.bitmap = bitmap;
71 | mapInfo.x = startX;
72 | mapInfo.y = startY;
73 | startY += mapH;
74 | mapInfos.add(mapInfo);
75 | }
76 | startX += mapW;
77 | startY = -20 * mapH;
78 | }
79 | initThread();
80 | addRandomPoint(100);
81 | }
82 |
83 |
84 | private class MapInfo {
85 | Bitmap bitmap;
86 | int x;
87 | int y;
88 | }
89 |
90 | private List removePoint = new ArrayList<>();
91 |
92 | @Override
93 | protected void onDraw(Canvas canvas) {
94 | super.onDraw(canvas);
95 | canvas.translate(tx, ty);
96 |
97 | if (SpringView.springW > scale) {
98 | int scalePamra = (int)(SpringView.springW / scale);
99 | canvas.scale(1f / scalePamra, 1f / scalePamra, screenW / 2, screenH / 2);
100 | if (springCallback != null) {
101 | springCallback.canvasScale(1f / scalePamra);
102 | }
103 | nowScale = 1f / scalePamra;
104 | }
105 | // for (MapInfo m : mapInfos) {
106 | // canvas.drawBitmap(m.bitmap, m.x, m.y, null);
107 | // }
108 | float sw = SpringView.springW / 2 * nowScale;
109 | float sh = SpringView.springW / 2 * nowScale;
110 | for (Point point : randomPoints) {
111 | float x = point.x + tx;
112 | float y = point.y + ty;
113 | if (!(x > 0 && x < screenW && y > 0 && y < screenH)) {
114 | // continue;
115 | }
116 | // Log.i(TAG, "onDraw: " + x + " " + y + screenW + " " + screenH);
117 |
118 | if ((x >= (screenW / 2 - sw) && x <= (screenW / 2 + sw)) &&
119 | (y >= (screenH / 2 - sh) && y <= (screenH / 2 + sh))) {
120 | removePoint.add(point);
121 | if (springCallback != null) {
122 | springCallback.changePoint();
123 | }
124 | } else {
125 | canvas.drawPoint(point.x, point.y, mPaint);
126 | }
127 | }
128 | if (removePoint.size() != 0) {
129 | Log.i(TAG, "onDraw: remove");
130 | int numb = removePoint.size();
131 | randomPoints.removeAll(removePoint);
132 | removePoint.clear();
133 | addRandomPoint(numb);
134 | }
135 |
136 | }
137 |
138 | private void addRandomPoint(int param) {
139 | for (int i = 0; i < param; i++) {
140 | Point point = new Point();
141 | int kk = random.nextBoolean() ? 1 : -1;
142 | int k = random.nextBoolean() ? 1 : -1;
143 | point.x = kk * random.nextInt(5 * mapW);
144 | point.y = k * random.nextInt(5 * mapH);
145 | randomPoints.add(point);
146 | }
147 | }
148 |
149 | private float latsX, lastY, tx = 0, ty = 0;
150 |
151 | // @Override
152 | // public boolean onTouchEvent(MotionEvent event) {
153 | // float x = event.getX();
154 | // float y = event.getY();
155 | // if (event.getAction() == MotionEvent.ACTION_DOWN) {
156 | // latsX = x;
157 | // lastY = y;
158 | // return false;
159 | // }
160 | // if (event.getAction() == MotionEvent.ACTION_MOVE) {
161 | //// translate(x-latsX,y-lastY);
162 | // translateCanvas(x - lastY, y - lastY);
163 | // invalidate();
164 | // latsX = x;
165 | // lastY = y;
166 | // }
167 | // return super.onTouchEvent(event);
168 | // }
169 |
170 | public void translateCanvas(float x, float y) {
171 | tx = tx + x;
172 | ty = ty + y;
173 | postInvalidate();
174 | }
175 |
176 | private float degree = 0;
177 |
178 | public void move(double d) {
179 | // int piVal = (int) (d / (2 * Math.PI));
180 | float pi = (float) Math.PI;
181 | if (d < 0) {
182 | d = d + pi * 2;
183 | }
184 | float unit = 0.125f * pi;
185 | if (d > 15 * unit || d < unit) {
186 | this.degree = 0;
187 | } else if (d > unit && d < 3 * unit) {
188 | this.degree = 2 * unit;
189 | } else if (d > 3 * unit && d < 5 * unit) {
190 | this.degree = 4 * unit;
191 | } else if (d > 5 * unit && d < 7 * unit) {
192 | this.degree = 6 * unit;
193 | } else if (d > 7 * unit && d < 9 * unit) {
194 | this.degree = 8 * unit;
195 | } else if (d > 9 * unit && d < 11 * unit) {
196 | this.degree = 10 * unit;
197 | } else if (d > 11 * unit && d < 13 * unit) {
198 | this.degree = 12 * unit;
199 | } else if (d > 13 * unit && d < 15 * unit) {
200 | this.degree = 14 * unit;
201 | }
202 | // Log.i(TAG, "move: " + d + " " + unit);
203 | }
204 |
205 | public float getDegree() {
206 | return degree;
207 | }
208 |
209 | private Thread mThread;
210 | private boolean play = false;
211 |
212 | private void initThread() {
213 | mThread = new Thread(new Runnable() {
214 | @Override
215 | public void run() {
216 | while (play) {
217 | float x = -(float) (Math.cos(getDegree()) * d);
218 | float y = -(float) (Math.sin(getDegree()) * d);
219 | translateCanvas(x, y);
220 | try {
221 | Thread.sleep(16);
222 | } catch (InterruptedException e) {
223 | e.printStackTrace();
224 | }
225 | }
226 | }
227 | });
228 | }
229 |
230 | public void start() {
231 | play = true;
232 | mThread.start();
233 | }
234 |
235 | public void stop() {
236 | play = false;
237 | }
238 |
239 | @Override
240 | protected void onAttachedToWindow() {
241 | super.onAttachedToWindow();
242 | start();
243 | }
244 |
245 | @Override
246 | protected void onDetachedFromWindow() {
247 | super.onDetachedFromWindow();
248 | stop();
249 | }
250 |
251 | public void setSpringCallback(SpringCallback springCallback) {
252 | this.springCallback = springCallback;
253 | }
254 |
255 | private SpringCallback springCallback = null;
256 |
257 | public interface SpringCallback {
258 | void changePoint();
259 |
260 | void canvasScale(float parma);
261 | }
262 | }
263 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/spring/GameStart.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.spring;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.MotionEvent;
8 | import android.widget.LinearLayout;
9 |
10 | import com.bcgtgjyb.huanwen.customview.mylibrary.R;
11 |
12 | /**
13 | * Created by bigwen on 2016/4/25.
14 | */
15 | public class GameStart extends LinearLayout {
16 |
17 | private Context mContext;
18 | private GameMap mGameMap;
19 | private String TAG = GameStart.class.getName();
20 | private SpringView mSpringView;
21 |
22 |
23 | public GameStart(Context context) {
24 | super(context);
25 | mContext = context;
26 | init();
27 | }
28 |
29 | public GameStart(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | mContext = context;
32 | init();
33 | }
34 |
35 | private void init() {
36 | LayoutInflater.from(mContext).inflate(R.layout.game_start, this);
37 | mGameMap = (GameMap) findViewById(R.id.game_map);
38 | mSpringView = (SpringView) findViewById(R.id.springView);
39 | mGameMap.setSpringCallback(new GameMap.SpringCallback() {
40 | @Override
41 | public void changePoint() {
42 | // mSpringView.changeSpring();
43 | mSpringView.addPoint();
44 | }
45 |
46 | @Override
47 | public void canvasScale(float parma) {
48 | }
49 | });
50 | }
51 |
52 | private float downX, downY;
53 | private boolean isMove = false;
54 |
55 | @Override
56 | public boolean dispatchTouchEvent(MotionEvent ev) {
57 | return super.dispatchTouchEvent(ev);
58 | }
59 |
60 | @Override
61 | public boolean onInterceptTouchEvent(MotionEvent ev) {
62 | return true;
63 | }
64 |
65 | private double lastD = 0;
66 |
67 | @Override
68 | public boolean onTouchEvent(MotionEvent event) {
69 | float x = event.getRawX();
70 | float y = event.getRawY();
71 | // Log.i(TAG, "onTouchEvent: "+x);
72 | if (event.getAction() == MotionEvent.ACTION_DOWN) {
73 | downX = x;
74 | downY = y;
75 | isMove = true;
76 | return true;
77 | }
78 | if (event.getAction() == MotionEvent.ACTION_MOVE) {
79 | if (isMove) {
80 | double d = RectToPolar(x - downX, y - downY);
81 | Log.i(TAG, "onTouchEvent: " + d);
82 | mGameMap.move(d);
83 | mSpringView.setDegree(d);
84 | lastD = d;
85 | }
86 | }
87 | return super.onTouchEvent(event);
88 | }
89 |
90 | // 实现直角坐标系转换为极坐标系的方法
91 | public double RectToPolar(double x, double y) {
92 | return Math.atan2(y, x);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/spring/SpringView.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.spring;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.graphics.Point;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.View;
12 |
13 | import com.bcgtgjyb.huanwen.customview.mylibrary.tool.ScreenUtil;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | /**
19 | * Created by bigwen on 2016/4/25.
20 | */
21 | public class SpringView extends View {
22 |
23 | private Context mContext;
24 | private List points = new ArrayList();
25 | private Paint mPaint;
26 | private int height, width;
27 | private int d;
28 | private boolean play = false;
29 | private String TAG = SpringView.class.getName();
30 | public static float springW = 0;
31 | public static float springH = 0;
32 | private float scale = 1f;
33 | private int moveUnit = 0;
34 | private Point lastPoint;
35 | private double degree = 0;
36 |
37 | public SpringView(Context context) {
38 | super(context);
39 | mContext = context;
40 | init();
41 | }
42 |
43 | public SpringView(Context context, AttributeSet attrs) {
44 | super(context, attrs);
45 | mContext = context;
46 | init();
47 | }
48 |
49 | private void init() {
50 | moveUnit = ScreenUtil.dip2px(mContext, 5);
51 | width = ScreenUtil.getScreenWidth(mContext);
52 | height = ScreenUtil.getScreenHeight(mContext);
53 | d = ScreenUtil.dip2px(mContext, 10);
54 | mPaint = new Paint();
55 | mPaint.setColor(Color.RED);
56 | mPaint.setStyle(Paint.Style.STROKE);
57 | mPaint.setAntiAlias(true);
58 | mPaint.setStrokeWidth(d);
59 | springH = d;
60 | springW = d;
61 | initPoint();
62 | initPath();
63 | // initNowPoint();
64 | initThread();
65 | // initRandomPoint();
66 |
67 | }
68 |
69 | private Path path = new Path();
70 |
71 | private void initPath() {
72 | path.reset();
73 | if (points.size() == 0) {
74 | return;
75 | }
76 | for (int i = 0; i < points.size(); i++) {
77 | if (i == 0) {
78 | path.moveTo(points.get(i).x, points.get(i).y);
79 | } else {
80 | path.lineTo(points.get(i).x, points.get(i).y);
81 | }
82 | }
83 | }
84 |
85 | private void initPoint() {
86 | for (int i = 0; i < 10; i++) {
87 | Point point = new Point();
88 | point.x = width / 2 + i * d;
89 | point.y = height / 2;
90 | points.add(point);
91 | }
92 | }
93 |
94 | public void addPoint() {
95 | points.add(lastPoint);
96 | }
97 |
98 | Point addP = new Point();
99 | public synchronized void pointMove() {
100 | if (points.size() == 0) {
101 | return;
102 | }
103 | lastPoint = points.get(points.size() - 1);
104 | int x = (int) (Math.cos(degree) * moveUnit);
105 | int y = (int) (Math.sin(degree) * moveUnit);
106 | Log.i(TAG, "pointMove: "+points.size());
107 | Point firstP = points.get(0);
108 | addP.x = firstP.x + x;
109 | addP.y = firstP.y + y;
110 | points.add(0, addP);
111 | points.remove(points.size()-1);
112 | // for (Point p:points) {
113 | // p.x = p.x - x;
114 | // p.y = p.y - y;
115 | // }
116 | }
117 |
118 | public void setDegree(double d) {
119 | float pi = (float) Math.PI;
120 | if (d < 0) {
121 | d = d + pi * 2;
122 | }
123 | float unit = 0.125f * pi;
124 | if (d > 15 * unit || d < unit) {
125 | this.degree = 0;
126 | } else if (d > unit && d < 3 * unit) {
127 | this.degree = 2 * unit;
128 | } else if (d > 3 * unit && d < 5 * unit) {
129 | this.degree = 4 * unit;
130 | } else if (d > 5 * unit && d < 7 * unit) {
131 | this.degree = 6 * unit;
132 | } else if (d > 7 * unit && d < 9 * unit) {
133 | this.degree = 8 * unit;
134 | } else if (d > 9 * unit && d < 11 * unit) {
135 | this.degree = 10 * unit;
136 | } else if (d > 11 * unit && d < 13 * unit) {
137 | this.degree = 12 * unit;
138 | } else if (d > 13 * unit && d < 15 * unit) {
139 | this.degree = 14 * unit;
140 | }
141 | }
142 |
143 | @Override
144 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
145 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
146 | }
147 |
148 | @Override
149 | protected void onDraw(Canvas canvas) {
150 | super.onDraw(canvas);
151 | // canvas.scale(scale,scale,width / 2, height / 2);
152 | // canvas.drawPoint(width / 2, height / 2, mPaint);
153 | // canvas.drawPath(path, mPaint);
154 | // for (Point point:pointList) {
155 | // canvas.drawPoint(point.x,point.y,mPaint);
156 | // point.x+=move[0];
157 | // point.y+=move[1];
158 | // }
159 |
160 | for (int i = 0; i < points.size(); i++) {
161 | Point p = points.get(i);
162 | canvas.drawPoint(p.x, p.y, mPaint);
163 | }
164 | }
165 |
166 | private Thread mThread;
167 |
168 | private void initThread() {
169 | mThread = new Thread(new Runnable() {
170 | @Override
171 | public void run() {
172 | while (play) {
173 | pointMove();
174 | initPath();
175 | postInvalidate();
176 | try {
177 | Thread.sleep(500);
178 | } catch (Exception e) {
179 | e.printStackTrace();
180 | }
181 | }
182 | }
183 | });
184 | }
185 |
186 | @Override
187 | protected void onAttachedToWindow() {
188 | super.onAttachedToWindow();
189 | start();
190 | }
191 |
192 | @Override
193 | protected void onDetachedFromWindow() {
194 | super.onDetachedFromWindow();
195 | stop();
196 | }
197 |
198 | private void start() {
199 | play = true;
200 | mThread.start();
201 | }
202 |
203 | private void stop() {
204 | play = false;
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/star/StarCircle.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.star;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.LayoutInflater;
6 | import android.widget.LinearLayout;
7 |
8 | import com.bcgtgjyb.huanwen.customview.mylibrary.R;
9 | import com.bcgtgjyb.huanwen.customview.mylibrary.tool.ScreenUtil;
10 |
11 | /**
12 | * Created by bigwen on 2016/4/23.
13 | */
14 | public class StarCircle extends LinearLayout {
15 |
16 | private Context mContext;
17 | private StarView starView1;
18 | private StarView starView2;
19 | private int viewWidth;
20 | private int viewHeight;
21 | private Thread thread;
22 | private boolean play = false;
23 | private float degree = 0;
24 | private String TAG = StarCircle.class.getName();
25 | private int padding;
26 | private double circleDegree;
27 | private int circleX, circleY, circleR;
28 | private int[] coordinate1, coordinate2;
29 |
30 | public StarCircle(Context context) {
31 | super(context);
32 | mContext = context;
33 | init();
34 | }
35 |
36 | public StarCircle(Context context, AttributeSet attrs) {
37 | super(context, attrs);
38 | mContext = context;
39 | init();
40 | }
41 |
42 | private void init() {
43 | LayoutInflater.from(mContext).inflate(R.layout.star_circle, this);
44 | starView1 = (StarView) findViewById(R.id.star_view_1);
45 | starView2 = (StarView) findViewById(R.id.star_view_2);
46 | padding = ScreenUtil.dip2px(mContext, 8);
47 | initThread();
48 | }
49 |
50 | @Override
51 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
52 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
53 | viewWidth = getWidth() - ScreenUtil.dip2px(mContext, 30);
54 | viewHeight = getHeight() - ScreenUtil.dip2px(mContext, 30);
55 | }
56 |
57 | private void initThread() {
58 | if (thread != null && thread.isAlive()) {
59 | return;
60 | }
61 | thread = new Thread(new Runnable() {
62 | @Override
63 | public void run() {
64 | while (play) {
65 | degree += 0.1f;
66 | setXy(degree);
67 | try {
68 | Thread.sleep(16);
69 | } catch (InterruptedException e) {
70 | e.printStackTrace();
71 | }
72 | postInvalidate();
73 | }
74 | }
75 | });
76 | play = true;
77 | thread.start();
78 | }
79 |
80 | private void setXy(float d) {
81 | coordinate1 = caculateDegree(d);
82 | coordinate2 = caculateDegree(d);
83 | post(new Runnable() {
84 | @Override
85 | public void run() {
86 | starView1.setTranslationX(coordinate1[0]);
87 | starView1.setTranslationY(coordinate1[1]);
88 | starView2.setTranslationX(coordinate2[0]);
89 | starView2.setTranslationY(coordinate2[1]);
90 | }
91 | });
92 | }
93 |
94 | private int[] caculateDegree(float d) {
95 | circleDegree = d / Math.PI;
96 | circleX = viewWidth / 2 - padding;
97 | circleY = viewHeight / 2 - padding;
98 | circleR = viewWidth / 2;
99 | int[] xy = new int[2];
100 | xy[0] = (int) (circleX + circleR * Math.cos(circleDegree));
101 | xy[1] = (int) (circleY + circleR * Math.sin(circleDegree));
102 | return xy;
103 | }
104 |
105 | @Override
106 | protected void onAttachedToWindow() {
107 | super.onAttachedToWindow();
108 | start();
109 | }
110 |
111 | @Override
112 | protected void onDetachedFromWindow() {
113 | super.onDetachedFromWindow();
114 | stop();
115 | }
116 |
117 |
118 | public void start() {
119 | play = true;
120 | initThread();
121 | }
122 |
123 | public void stop() {
124 | play = false;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/star/StarView.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.star;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | /**
12 | * Created by bigwen on 2016/4/14.
13 | */
14 | public class StarView extends View {
15 |
16 | private int width = 100;
17 | private int height = 100;
18 | private Paint paint;
19 | private Path pathBig;
20 | private Context mContext;
21 | private int alpha = 255;
22 | private boolean direction = true;
23 | //颜色变化率
24 | private int v = 3;
25 | private boolean init = false;
26 | private Thread thread;
27 | private boolean play = false;
28 | private float degree = 0;
29 |
30 |
31 | public StarView(Context context) {
32 | super(context);
33 | mContext = context;
34 | init();
35 | }
36 |
37 | public StarView(Context context, AttributeSet attrs) {
38 | super(context, attrs);
39 | mContext = context;
40 | init();
41 | }
42 |
43 | private void init() {
44 | paint = new Paint();
45 | paint.setColor(Color.WHITE);
46 | play = true;
47 | initThread();
48 | }
49 |
50 | private void initThread() {
51 | thread = new Thread(new Runnable() {
52 | @Override
53 | public void run() {
54 | while (play) {
55 | degree += 4;
56 | try {
57 | Thread.sleep(30);
58 | } catch (InterruptedException e) {
59 | e.printStackTrace();
60 | }
61 | postInvalidate();
62 | }
63 | }
64 | });
65 | }
66 |
67 | private void initPath() {
68 | int unit = width / 10;
69 | pathBig = new Path();
70 | pathBig.moveTo(unit * 5, 0);
71 | pathBig.lineTo(6 * unit, 4 * unit);
72 | pathBig.lineTo(10 * unit, 5 * unit);
73 | pathBig.lineTo(6 * unit, 6 * unit);
74 | pathBig.lineTo(5 * unit, 10 * unit);
75 | pathBig.lineTo(4 * unit, 6 * unit);
76 | pathBig.lineTo(0, 5 * unit);
77 | pathBig.lineTo(4 * unit, 4 * unit);
78 | pathBig.close();
79 | }
80 |
81 | @Override
82 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
83 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
84 |
85 | }
86 |
87 | @Override
88 | protected void onDraw(Canvas canvas) {
89 | super.onDraw(canvas);
90 | if (!init) {
91 | //支持padding,不然padding属性无效
92 | int paddingLeft = getPaddingLeft();
93 | int paddingTop = getPaddingTop();
94 | int paddingRight = getPaddingRight();
95 | int paddingBottom = getPaddingBottom();
96 | width = getWidth() - paddingLeft - paddingRight;
97 | height = getHeight() - paddingTop - paddingBottom;
98 | initPath();
99 | init = true;
100 | }
101 | if (direction) {
102 | alpha -= v;
103 | } else {
104 | alpha += v;
105 | }
106 | if (alpha <= 0) {
107 | alpha = 0;
108 | direction = false;
109 | } else if (alpha >= 255) {
110 | alpha = 255;
111 | direction = true;
112 | }
113 | paint.setARGB(255, 255, 255, alpha);
114 | canvas.rotate(degree, width / 2, height / 2);
115 | canvas.drawPath(pathBig, paint);
116 | }
117 |
118 | public void setDegree(final float d) {
119 | post(new Runnable() {
120 | @Override
121 | public void run() {
122 | degree = d;
123 | invalidate();
124 | }
125 | });
126 | }
127 |
128 |
129 | @Override
130 | protected void onAttachedToWindow() {
131 | super.onAttachedToWindow();
132 | start();
133 | }
134 |
135 | @Override
136 | protected void onDetachedFromWindow() {
137 | super.onDetachedFromWindow();
138 | stop();
139 | }
140 |
141 |
142 | public void start() {
143 | play = true;
144 | thread.start();
145 | }
146 |
147 | public void stop() {
148 | play = false;
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/tool/BWCallback.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.tool;
2 |
3 |
4 | import com.nineoldandroids.animation.ValueAnimator;
5 |
6 | /**
7 | * Created by bigwen on 2016/3/1.
8 | */
9 | public interface BWCallback {
10 | void onFinish(ValueAnimator... valueAnimator);
11 | void onFinish();
12 | }
13 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/tool/BWValueAnimator.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.tool;
2 |
3 | import android.view.animation.LinearInterpolator;
4 |
5 | import com.nineoldandroids.animation.ValueAnimator;
6 |
7 | /**
8 | * Created by bigwen on 2016/3/1.
9 | */
10 | public class BWValueAnimator {
11 | public static ValueAnimator getValueAnimator(float param,int time){
12 | ValueAnimator valueX = ValueAnimator.ofFloat(0,param);
13 | valueX.setInterpolator(new LinearInterpolator());
14 | valueX.setDuration(time);
15 | return valueX;
16 | }
17 |
18 | public static ValueAnimator getValueAnimator(float start,float end, int time){
19 | ValueAnimator valueX = ValueAnimator.ofFloat(start,end);
20 | valueX.setInterpolator(new LinearInterpolator());
21 | valueX.setDuration(time);
22 | return valueX;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/tool/Move.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.tool;
2 |
3 | import android.graphics.RectF;
4 | import android.util.Log;
5 |
6 | import com.nineoldandroids.animation.ValueAnimator;
7 |
8 | /**
9 | * Created by bigwen on 2016/2/29.
10 | */
11 | public class Move {
12 |
13 | private String TAG = Move.class.getName();
14 | //默认1秒
15 | private static final int TIME = 1000;
16 | private ValueAnimator vAX = null;
17 | private ValueAnimator vAY = null;
18 | public BWCallback bwCallback;
19 |
20 |
21 | public Move() {
22 | }
23 |
24 | public RectF xy(RectF rectF, int x, int y) {
25 | return xy(rectF, x, y, TIME);
26 | }
27 |
28 |
29 | public float[] xy(float coodinateX, float coodinateY, int x, int y, int time) {
30 | float[] xy = new float[2];
31 | if (vAX == null) {
32 | vAX = BWValueAnimator.getValueAnimator(x, time);
33 | vAX.start();
34 | }
35 | if (vAY == null) {
36 | vAY = BWValueAnimator.getValueAnimator(y, time);
37 | vAY.start();
38 | }
39 | if (!vAX.isRunning()) {
40 | float[] endXY = new float[2];
41 | endXY[0] = coodinateX + x;
42 | endXY[1] = coodinateY + y;
43 | vAX = null;
44 | vAY = null;
45 | if (bwCallback != null) bwCallback.onFinish();
46 | return endXY;
47 | }
48 | float xx = (float) vAX.getAnimatedValue();
49 | float yy = (float) vAY.getAnimatedValue();
50 | Log.i(TAG, "xy " + xx + " " + yy);
51 | xy[0] = coodinateX + xx;
52 | xy[1] = coodinateY + yy;
53 | return xy;
54 | }
55 |
56 | public RectF xy(RectF rectF, int x, int y, int time) {
57 | if (vAX == null) {
58 | vAX = BWValueAnimator.getValueAnimator(x, time);
59 | vAX.start();
60 | }
61 | if (vAY == null) {
62 | vAY = BWValueAnimator.getValueAnimator(y, time);
63 | vAY.start();
64 | }
65 | if (!vAX.isRunning()) {
66 | RectF f = new RectF(0, 0, 0, 0);
67 | if (bwCallback != null) bwCallback.onFinish(circleVA);
68 | return f;
69 | }
70 | float xx = (float) vAX.getAnimatedValue();
71 | float yy = (float) vAY.getAnimatedValue();
72 | rectF.left = rectF.left + xx;
73 | rectF.right = rectF.right + xx;
74 | rectF.top = rectF.top + yy;
75 | rectF.bottom = rectF.bottom + yy;
76 | return rectF;
77 | }
78 |
79 |
80 | private ValueAnimator circleVA = null;
81 | private static final int CIRCLEDEGREE = 360;
82 |
83 | public float[] circleMove(int radioX, int radioY, int x, int y, int time, int degree) {
84 | float r = (float) Math.sqrt((radioX - x) * (radioX - x) + (radioY - y) * (radioY - y));
85 | float nowDegree = (float) Math.atan((y - radioY) / (x - radioX)) * 360;
86 | if (circleVA == null) {
87 | circleVA = BWValueAnimator.getValueAnimator(degree, time);
88 | }
89 | if (!circleVA.isRunning()) {
90 | float[] end = new float[2];
91 | float endDegree = nowDegree + degree;
92 | end[0] = (float) (r * Math.sin(endDegree / CIRCLEDEGREE));
93 | end[1] = (float) (r * Math.cos(endDegree / CIRCLEDEGREE));
94 | if (bwCallback != null) bwCallback.onFinish(circleVA);
95 | return end;
96 | } else {
97 | float[] end = new float[2];
98 | float endDegree = (float) circleVA.getAnimatedValue() + degree;
99 | end[0] = (float) (r * Math.sin(endDegree / CIRCLEDEGREE));
100 | end[1] = (float) (r * Math.cos(endDegree / CIRCLEDEGREE));
101 | return end;
102 | }
103 | }
104 |
105 | public void setCallback(BWCallback callback) {
106 | this.bwCallback = callback;
107 | }
108 |
109 | public boolean isRunning() {
110 | if (circleVA != null && circleVA.isRunning()) {
111 | return true;
112 | }
113 | if (vAX != null && vAX.isRunning()) {
114 | return true;
115 | }
116 | if (vAY != null && vAY.isRunning()) {
117 | return true;
118 | }
119 | return false;
120 | }
121 |
122 | public void clear() {
123 | circleVA = null;
124 | vAY = null;
125 | vAX = null;
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/tool/Rotate.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.tool;
2 |
3 | /**
4 | * Created by bigwen on 2016/2/29.
5 | */
6 | public class Rotate {
7 |
8 | private static final int CIRCLEDEGREE = 360;
9 |
10 | public float[] rotatePoint(float[] point, float[] coodinate, int degree) {
11 | float radioX = coodinate[0];
12 | float radioY = coodinate[1];
13 | float x = point[0];
14 | float y = point[1];
15 | float r = (float) Math.sqrt((radioX - x) * (radioX - x) + (radioY - y) * (radioY - y));
16 | float nowDegree = (float) Math.atan((y - radioY) / (x - radioX)) * 360;
17 | float[] end = new float[2];
18 | float endDegree = nowDegree + degree;
19 | end[0] = (float) (r * Math.sin(endDegree / CIRCLEDEGREE));
20 | end[1] = (float) (r * Math.cos(endDegree / CIRCLEDEGREE));
21 | return end;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/tool/ScreenUtil.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.tool;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.util.DisplayMetrics;
6 |
7 | import java.lang.reflect.Field;
8 |
9 | public class ScreenUtil {
10 | /**
11 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
12 | */
13 | public static int dip2px(Context context, float dpValue) {
14 | final float scale = context.getResources().getDisplayMetrics().density;
15 | return (int) (dpValue * scale + 0.5f);
16 | }
17 | /**
18 | * 将px值转换为sp值,保证文字大小不变
19 | *
20 | * @param context
21 | * @param pxValue
22 | * (DisplayMetrics类中属性scaledDensity)
23 | * @return
24 | */
25 | public static int px2sp(Context context, float pxValue) {
26 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
27 | return (int) (pxValue / fontScale + 0.5f);
28 | }
29 |
30 | /**
31 | * 将sp值转换为px值,保证文字大小不变
32 | *
33 | * @param context
34 | * @param spValue
35 | * (DisplayMetrics类中属性scaledDensity)
36 | * @return
37 | */
38 | public static int sp2px(Context context, float spValue) {
39 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
40 | return (int) (spValue * fontScale + 0.5f);
41 | }
42 |
43 | /**
44 | * 获取屏幕宽度
45 | */
46 | private static int screenWidth = 0;
47 |
48 | public static int getScreenWidth(Context context) {
49 | if (screenWidth == 0) {
50 | DisplayMetrics dm = new DisplayMetrics();
51 | ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
52 | screenWidth = dm.widthPixels;
53 | }
54 | return screenWidth;
55 | }
56 |
57 |
58 | /**
59 | * 获取屏幕高度
60 | */
61 | private static int screenHeight = 0;
62 |
63 | public static int getScreenHeight(Context context) {
64 | if (screenHeight == 0) {
65 | DisplayMetrics dm = new DisplayMetrics();
66 | ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
67 | screenHeight = dm.heightPixels;
68 | }
69 | return screenHeight;
70 | }
71 |
72 | /**
73 | * 获取状态栏高度
74 | */
75 | public static int getStatusBarHeight(Context context) {
76 | Class> c = null;
77 | Object obj = null;
78 | Field field = null;
79 | int x = 0, statusBarHeight = 0;
80 | try {
81 | c = Class.forName("com.android.internal.R$dimen");
82 | obj = c.newInstance();
83 | field = c.getField("status_bar_height");
84 | x = Integer.parseInt(field.get(obj).toString());
85 | statusBarHeight = context.getResources().getDimensionPixelSize(x);
86 | } catch (Exception e1) {
87 | e1.printStackTrace();
88 | }
89 | return statusBarHeight;
90 | }
91 |
92 |
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/view58/Loading58Path.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.view58;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.util.AttributeSet;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.view.animation.LinearInterpolator;
12 |
13 | import com.bcgtgjyb.huanwen.customview.mylibrary.tool.BWValueAnimator;
14 | import com.nineoldandroids.animation.ValueAnimator;
15 |
16 | /**
17 | * Created by bigwen on 2016/3/2.
18 | */
19 | public class Loading58Path extends View {
20 | private int w = 0;
21 | private int h = 0;
22 | private Paint paint;
23 | private String TAG = Loading58Path.class.getName();
24 | private Path pathTri = new Path();
25 | private static final float SQRT3 = 1.7f;
26 | private static final float SQRT2 = 1.414f;
27 | private int runParam = -1;
28 | private int ST = 0;
29 | private int TC = 0;
30 | private int CS = 0;
31 | private Path pathSqure = new Path();
32 | private ValueAnimator colorVA;
33 | private Path cirToSque = new Path();
34 | private ValueAnimator cirToSqueVA;
35 | private Path triToCir = new Path();
36 | private ValueAnimator triToCirVA;
37 | private Path squeToTri = new Path();
38 | private ValueAnimator squeToTriVA = null;
39 | private Path pathCir = new Path();
40 |
41 | public Loading58Path(Context context) {
42 | super(context);
43 | init();
44 | }
45 |
46 | public Loading58Path(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | init();
49 | }
50 |
51 | private void init() {
52 | paint = new Paint();
53 | paint.setColor(Color.RED);
54 | initColorChange();
55 | }
56 |
57 | // 正->三角->保持三角->圆->保持圆->正->保持正->循环
58 | @Override
59 | protected void onDraw(Canvas canvas) {
60 | super.onDraw(canvas);
61 | initWH(getWidth(), getHeight());
62 | if (runParam == 0) {
63 | if (colorVA != null && colorVA.isRunning()) {
64 | int d = (Integer) colorVA.getAnimatedValue();
65 | paint.setARGB(255, 255 - d, d, 0);
66 | } else {
67 | colorVA.start();
68 | }
69 | drawSquToTri();
70 | canvas.drawPath(squeToTri, paint);
71 | if (squeToTriVA != null && squeToTriVA.isRunning()) {
72 | invalidate();
73 | } else {
74 | runParam = 1;
75 | invalidate();
76 | }
77 | }
78 |
79 | if (runParam == 1) {
80 | drawPathTriangle();
81 | canvas.drawPath(pathTri, paint);
82 | }
83 |
84 | if (runParam == 2) {
85 | if (colorVA != null && colorVA.isRunning()) {
86 | int d = (Integer) colorVA.getAnimatedValue();
87 | paint.setARGB(255, 0, 255 - d, d);
88 | } else {
89 | colorVA.start();
90 | }
91 | drawTriToCir();
92 | canvas.drawPath(triToCir, paint);
93 | if (triToCirVA != null && triToCirVA.isRunning()) {
94 | invalidate();
95 | } else {
96 | runParam = 3;
97 | invalidate();
98 | }
99 | }
100 |
101 | if (runParam == 3) {
102 | drawPathCir();
103 | canvas.drawPath(pathCir, paint);
104 | }
105 |
106 | if (runParam == 4) {
107 | if (colorVA != null && colorVA.isRunning()) {
108 | int d = (Integer) colorVA.getAnimatedValue();
109 | paint.setARGB(255, d, 0, 255 - d);
110 | } else {
111 | colorVA.start();
112 | }
113 | drawCirToSque();
114 | canvas.drawPath(cirToSque, paint);
115 | if (cirToSqueVA.isRunning()) {
116 | invalidate();
117 | } else {
118 | runParam = 5;
119 | invalidate();
120 | }
121 | }
122 |
123 | if (runParam == 5) {
124 | drawPathSqure();
125 | canvas.drawPath(pathSqure, paint);
126 | }
127 | }
128 |
129 | public void start() {
130 | if (runParam == -1) {
131 | runParam = 0;
132 | invalidate();
133 | }
134 | }
135 |
136 | public void stop() {
137 | runParam = -1;
138 | clear();
139 | }
140 |
141 | public void nextPath() {
142 | Log.i(TAG, "nextPath: " + runParam);
143 | runParam++;
144 | if (runParam == 6) {
145 | runParam = 0;
146 | clear();
147 | }
148 | invalidate();
149 | }
150 |
151 | private void initWH(int width, int height) {
152 | this.w = width;
153 | this.h = height;
154 | }
155 |
156 | private void drawPathTriangle() {
157 | Log.i(TAG, "drawPathTriangle: ");
158 | pathTri.reset();
159 | pathTri.moveTo(w / 2, 0);
160 | pathTri.lineTo(w / 2 + SQRT3 / 4 * w, 0.75f * h);
161 | pathTri.lineTo(w / 2 - SQRT3 / 4 * w, 0.75f * h);
162 | pathTri.lineTo(w / 2, 0);
163 | pathTri.close();
164 | }
165 |
166 | private void drawPathSqure() {
167 | Log.i(TAG, "drawPathSqure: ");
168 | pathSqure.reset();
169 | pathSqure.moveTo(0, 0);
170 | pathSqure.lineTo(w, 0);
171 | pathSqure.lineTo(w, h);
172 | pathSqure.lineTo(0, h);
173 | pathSqure.close();
174 | }
175 |
176 |
177 | private void drawPathCir() {
178 | Log.i(TAG, "drawPathCir: ");
179 | pathCir.reset();
180 | pathCir.addCircle(w / 2, h / 2, h / 2, Path.Direction.CCW);
181 | }
182 |
183 | private void drawSquToTri() {
184 | squeToTri.reset();
185 | if (squeToTriVA == null) {
186 | ST = 2;
187 | squeToTriVA = BWValueAnimator.getValueAnimator(0, w / 2, 500);
188 | squeToTriVA.start();
189 | } else if (ST == 1) {
190 | ST = 2;
191 | squeToTriVA.start();
192 | } else {
193 |
194 | }
195 | if (squeToTriVA != null && squeToTriVA.isRunning()) {
196 | float value = (float) squeToTriVA.getAnimatedValue();
197 | float value1 = (1 - SQRT3 / 2) * value;
198 | float value2 = value / 2;
199 | //左下点
200 | float x1 = value1;
201 | float y1 = h - value2;
202 | //右下点
203 | float x2 = w - value1;
204 | float y2 = h - value2;
205 | //顶点左
206 | float x3 = value;
207 | float y3 = 0;
208 | //定点右
209 | float x4 = w - value;
210 | float y4 = 0;
211 | squeToTri.moveTo(x1, y1);
212 | squeToTri.lineTo(x2, y2);
213 | squeToTri.lineTo(x4, y4);
214 | squeToTri.lineTo(x3, y3);
215 | squeToTri.close();
216 | return;
217 | } else {
218 | return;
219 | }
220 | }
221 |
222 | private void drawTriToCir() {
223 | triToCir.reset();
224 | //变化值 0-一个shu
225 | float num = 0.4f * w;
226 | if (triToCirVA == null) {
227 | triToCirVA = BWValueAnimator.getValueAnimator(0, num, 500);
228 | triToCirVA.start();
229 | TC = 2;
230 | } else if (TC == 1) {
231 | triToCirVA.start();
232 | TC = 2;
233 | } else {
234 |
235 | }
236 | if (triToCirVA.isRunning()) {
237 | float param = (float) triToCirVA.getAnimatedValue();
238 | //三角形 左下定点
239 | float x1 = w / 2 - SQRT3 / 4 * w;
240 | float y1 = 0.75f * h;
241 | //三角形 右下顶点
242 | float x2 = w / 2 + SQRT3 / 4 * w;
243 | float y2 = 0.75f * h;
244 | //三角形 顶部顶点
245 | float x3 = w / 2;
246 | float y3 = 0;
247 | //左上 调节点
248 | float[] point1 = fx1((x3 + x1) / 2 - param);
249 | //右上 调节点
250 | float[] point2 = fx2((x3 + x2) / 2 + param);
251 | //下部 调节点
252 | float[] point3 = new float[2];
253 | point3[0] = w / 2;
254 | point3[1] = h + param / SQRT3;
255 |
256 | triToCir.moveTo(x3, y3);
257 | triToCir.quadTo(point1[0], point1[1], x1, y1);
258 | triToCir.quadTo(point3[0], point3[1], x2, y2);
259 | triToCir.quadTo(point2[0], point2[1], x3, y3);
260 | Log.i(TAG, "drawTriToCir: " + y1 + " " + y2 + " " + y3);
261 | triToCir.close();
262 | }
263 | }
264 |
265 | //三角形一边的垂直平分线函数
266 | private float[] fx1(float x) {
267 | float[] point = new float[2];
268 | point[0] = x;
269 | point[1] = SQRT3 / 3 * x + (0.5f - SQRT3 / 6) * h;
270 | return point;
271 | }
272 |
273 | //三角形一边的垂直平分线函数
274 | private float[] fx2(float x) {
275 | float[] point = new float[2];
276 | point[0] = x;
277 | point[1] = -SQRT3 / 3 * x + (0.5f + SQRT3 / 6) * h;
278 | return point;
279 | }
280 |
281 | private void drawCirToSque() {
282 | cirToSque.reset();
283 | if (cirToSqueVA == null) {
284 | float num = 0.45f * w;
285 | cirToSqueVA = BWValueAnimator.getValueAnimator(0.27f * w, num, 500);
286 | cirToSqueVA.start();
287 | CS = 2;
288 | } else if (CS == 1) {
289 | cirToSqueVA.start();
290 | CS = 2;
291 | } else {
292 |
293 | }
294 | if (cirToSqueVA.isRunning()) {
295 | float param = (float) cirToSqueVA.getAnimatedValue();
296 | //顶部点
297 | float x1 = w / 2;
298 | float y1 = 0;
299 | //右顶点
300 | float x2 = w;
301 | float y2 = h / 2;
302 | //下顶点
303 | float x3 = w / 2;
304 | float y3 = h;
305 | //左顶点
306 | float x4 = 0;
307 | float y4 = h / 2;
308 |
309 | //调节参数
310 | float par = 0.8f;
311 | //右上调节点
312 | float xx1 = par * w + param;
313 | float[] point1 = fx4(xx1);
314 | //右下调节点
315 | float xx2 = par * w + param;
316 | float[] point2 = fx3(xx2);
317 | //左下调节点
318 | float xx3 = (1 - par) * w - param;
319 | float[] point3 = fx4(xx3);
320 | //左上调节点
321 | float xx4 = (1 - par) * w - param;
322 | float[] point4 = fx3(xx4);
323 |
324 | cirToSque.moveTo(x1, y1);
325 | cirToSque.quadTo(point1[0], point1[1], x2, y2);
326 | cirToSque.quadTo(point2[0], point2[1], x3, y3);
327 | cirToSque.quadTo(point3[0], point3[1], x4, y4);
328 | cirToSque.quadTo(point4[0], point4[1], x1, y1);
329 | cirToSque.close();
330 | }
331 | }
332 |
333 | //调节点 函数
334 | private float[] fx3(float x) {
335 | float[] param = new float[2];
336 | param[0] = x;
337 | param[1] = x;
338 | return param;
339 | }
340 |
341 | //调节点 函数
342 | private float[] fx4(float x) {
343 | float[] param = new float[2];
344 | param[0] = x;
345 | param[1] = w - x;
346 | return param;
347 | }
348 |
349 | public void clear() {
350 | ST = 1;
351 | TC = 1;
352 | CS = 1;
353 | }
354 |
355 | private void initColorChange() {
356 | colorVA = ValueAnimator.ofInt(0, 255);
357 | colorVA.setDuration(500);
358 | colorVA.setInterpolator(new LinearInterpolator());
359 | }
360 |
361 | }
362 |
--------------------------------------------------------------------------------
/mylibrary/src/main/java/com/bcgtgjyb/huanwen/customview/mylibrary/view58/Loding58View.java:
--------------------------------------------------------------------------------
1 | package com.bcgtgjyb.huanwen.customview.mylibrary.view58;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.animation.AccelerateInterpolator;
8 | import android.view.animation.DecelerateInterpolator;
9 | import android.widget.LinearLayout;
10 |
11 | import com.bcgtgjyb.huanwen.customview.mylibrary.R;
12 | import com.bcgtgjyb.huanwen.customview.mylibrary.tool.ScreenUtil;
13 | import com.nineoldandroids.animation.Animator;
14 | import com.nineoldandroids.animation.AnimatorSet;
15 | import com.nineoldandroids.animation.ObjectAnimator;
16 | import com.nineoldandroids.animation.PropertyValuesHolder;
17 |
18 | /**
19 | * Created by bigwen on 2016/3/2.
20 | */
21 | public class Loding58View extends LinearLayout {
22 |
23 | private Context mContext;
24 | private Loading58Path view;
25 | private int dropHeight = 0;
26 | private String TAG = Loding58View.class.getName();
27 | private boolean play = false;
28 | private AnimatorSet riseSet;
29 | private AnimatorSet dropSet;
30 | private AnimatorSet rolation90, rolation120, rolation180;
31 | private AnimatorSet aList1, aList2, aList3, aList4;
32 | private int duration = 600;
33 | private long time = 0;
34 | private AnimatorSet riseSet1, riseSet2, riseSet3, dropSet1, dropSet2, dropSet3, dropSet4;
35 |
36 | public Loding58View(Context context) {
37 | super(context);
38 | this.mContext = context;
39 | init();
40 | }
41 |
42 | public Loding58View(Context context, AttributeSet attrs) {
43 | super(context, attrs);
44 | this.mContext = context;
45 | init();
46 | }
47 |
48 | private void init() {
49 | LayoutInflater.from(mContext).inflate(R.layout.loding58view, this);
50 | dropHeight = ScreenUtil.dip2px(mContext, 50);
51 | view = (Loading58Path) findViewById(R.id.loading58);
52 |
53 | initAnimList();
54 | }
55 |
56 | private void animStart() {
57 | aList1.start();
58 | view.start();
59 |
60 | aList1.addListener(new AnimEnd() {
61 | @Override
62 | public void onAnimationEnd(Animator animation) {
63 | super.onAnimationEnd(animation);
64 | dropSet1.start();
65 | view.nextPath();
66 | }
67 | });
68 |
69 | dropSet1.addListener(new AnimEnd() {
70 | @Override
71 | public void onAnimationEnd(Animator animation) {
72 | Log.i(TAG, "onAnimationEnd: aList2");
73 | aList2.start();
74 | }
75 | });
76 |
77 | aList2.addListener(new AnimEnd() {
78 | @Override
79 | public void onAnimationEnd(Animator animation) {
80 | Log.i(TAG, "onAnimationEnd: dropSet");
81 | dropSet2.start();
82 | view.nextPath();
83 | }
84 | });
85 |
86 | dropSet2.addListener(new AnimEnd() {
87 | @Override
88 | public void onAnimationEnd(Animator animation) {
89 | aList3.start();
90 | }
91 | });
92 |
93 | aList3.addListener(new AnimEnd() {
94 | @Override
95 | public void onAnimationEnd(Animator animation) {
96 | dropSet3.start();
97 | view.nextPath();
98 | }
99 | });
100 | dropSet3.addListener(new AnimEnd() {
101 | @Override
102 | public void onAnimationEnd(Animator animation) {
103 | if (play) {
104 | aList1.start();
105 | view.start();
106 | }
107 | }
108 | });
109 | }
110 |
111 | private void initAnimList() {
112 | dropSet = dropVA(0, dropHeight);
113 | dropSet1 = dropVA(0, dropHeight);
114 | dropSet2 = dropVA(0, dropHeight);
115 | dropSet3 = dropVA(0, dropHeight);
116 | aList1 = new AnimatorSet();
117 | rolation90 = rotation(240);
118 | riseSet1 = riseVA(0, -dropHeight);
119 | aList1.playTogether(riseSet1, rolation90);
120 | aList1.setDuration(duration);
121 |
122 | aList2 = new AnimatorSet();
123 | rolation120 = rotation(90);
124 | riseSet2 = riseVA(0, -dropHeight);
125 | aList2.playTogether(riseSet2, rolation120);
126 | aList2.setDuration(duration);
127 |
128 | aList3 = new AnimatorSet();
129 | rolation180 = rotation(180);
130 | riseSet3 = riseVA(0, -dropHeight);
131 | aList3.playTogether(riseSet3, rolation180);
132 | aList3.setDuration(duration);
133 | }
134 |
135 | private AnimatorSet riseVA(float x, float y) {
136 | AnimatorSet animatorSet = new AnimatorSet();
137 | PropertyValuesHolder p1 = PropertyValuesHolder.ofFloat("translationX", x);
138 | PropertyValuesHolder p2 = PropertyValuesHolder.ofFloat("translationY", y);
139 | animatorSet.play(ObjectAnimator.ofPropertyValuesHolder(view, p1, p2));
140 | //setDuration在play后面设置
141 | animatorSet.setDuration(500);
142 | animatorSet.setInterpolator(new DecelerateInterpolator());
143 | return animatorSet;
144 | }
145 |
146 | private AnimatorSet dropVA(float x, float y) {
147 | AnimatorSet animatorSet = new AnimatorSet();
148 | PropertyValuesHolder p1 = PropertyValuesHolder.ofFloat("translationX", x);
149 | PropertyValuesHolder p2 = PropertyValuesHolder.ofFloat("translationY", y);
150 | animatorSet.play(ObjectAnimator.ofPropertyValuesHolder(view, p1, p2));
151 | //setDuration在play后面设置
152 | animatorSet.setDuration(duration);
153 | animatorSet.setInterpolator(new AccelerateInterpolator());
154 | return animatorSet;
155 | }
156 |
157 | private AnimatorSet rotation(float param) {
158 | AnimatorSet animatorSet = new AnimatorSet();
159 | animatorSet.play(
160 | ObjectAnimator.ofFloat(view, "rotation", param)
161 | );
162 | animatorSet.setDuration(duration);
163 | animatorSet.setInterpolator(new DecelerateInterpolator());
164 | return animatorSet;
165 | }
166 |
167 | @Override
168 | protected void onDetachedFromWindow() {
169 | super.onDetachedFromWindow();
170 | stop();
171 | }
172 |
173 | @Override
174 | protected void onAttachedToWindow() {
175 | super.onAttachedToWindow();
176 | start();
177 | }
178 |
179 | public void start() {
180 | play = true;
181 | animStart();
182 | }
183 |
184 | public void stop() {
185 | play = false;
186 | }
187 |
188 | private class AnimEnd implements Animator.AnimatorListener {
189 | @Override
190 | public void onAnimationStart(Animator animation) {
191 |
192 | }
193 |
194 | @Override
195 | public void onAnimationEnd(Animator animation) {
196 |
197 | }
198 |
199 | @Override
200 | public void onAnimationCancel(Animator animation) {
201 |
202 | }
203 |
204 | @Override
205 | public void onAnimationRepeat(Animator animation) {
206 |
207 | }
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/mylibrary/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/mylibrary/src/main/res/layout/game_start.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
14 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/layout/loding58view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
12 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/layout/star_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/mylibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | My Library
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/screenshots/taiji1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohuanwen/AndroidLoadingAnimation/fe464fe0b7bee87b1d95fe8a5c28f7cc0b41b2ea/screenshots/taiji1.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':mylibrary'
2 |
--------------------------------------------------------------------------------