├── .gitignore
├── .travis.yml
├── README.md
├── build.gradle
├── demo
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── daimajia
│ │ └── androidviewhover
│ │ └── demo
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ ├── daimajia.jpg
│ ├── eye.png
│ ├── heart.png
│ ├── ic_launcher.png
│ ├── image2.jpg
│ ├── kid.jpg
│ ├── mail.png
│ ├── more.png
│ ├── octocat.png
│ ├── php.jpg
│ ├── pix.jpg
│ ├── share.png
│ └── strawberries.jpg
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── layout
│ ├── activity_main.xml
│ ├── hover_sample.xml
│ ├── hover_sample2.xml
│ ├── hover_sample3.xml
│ └── hover_sample4.xml
│ ├── menu
│ └── main.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── gradle-mvn-push.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── daimajia
│ └── androidviewhover
│ ├── BlurLayout.java
│ ├── proxy
│ └── AnimationProxy.java
│ └── tools
│ ├── Blur.java
│ └── Util.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | .DS_Store
5 | /build
6 | # built application files
7 | *.apk
8 | *.ap_
9 |
10 | # files for the dex VM
11 | *.dex
12 |
13 | # Java class files
14 | *.class
15 | .DS_Store
16 |
17 | # generated files
18 | bin/
19 | gen/
20 | Wiki/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Eclipse project files
26 | .classpath
27 | .project
28 | .settings/
29 |
30 | # Proguard folder generated by Eclipse
31 | proguard/
32 |
33 | #Android Studio
34 | build/
35 |
36 | # Intellij project files
37 | *.iml
38 | *.ipr
39 | *.iws
40 | .idea/
41 |
42 | #gradle
43 | .gradle/
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk: oraclejdk7
3 | env:
4 | matrix:
5 | - ANDROID_TARGET=android-20 ANDROID_ABI=armeabi-v7a
6 |
7 | before_install:
8 | # Install base Android SDK
9 | - sudo apt-get update -qq
10 | - if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch > /dev/null; fi
11 | - wget http://dl.google.com/android/android-sdk_r23-linux.tgz
12 | - tar xzf android-sdk_r23-linux.tgz
13 | - export ANDROID_HOME=$PWD/android-sdk-linux
14 | - export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
15 |
16 | # Gradle
17 | - wget http://services.gradle.org/distributions/gradle-1.12-bin.zip
18 | - unzip gradle-1.12-bin.zip
19 | - export GRADLE_HOME=$PWD/gradle-1.12
20 | - export PATH=$GRADLE_HOME/bin:$PATH
21 |
22 | # Install required components
23 | # For a full list, run `android list sdk -a --extended`
24 | # Note that sysimg-19 downloads only ARM, because only the first license query is accepted.
25 | - echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
26 | - echo yes | android update sdk --all --filter build-tools-20.0.0 --no-ui --force > /dev/null
27 | - echo yes | android update sdk --filter android-20 --no-ui --force > /dev/null
28 | - echo yes | android update sdk --filter sys-img-x86-android-19 --no-ui --force > /dev/null
29 | - echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null
30 | - echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null
31 |
32 | install:
33 | - ./gradlew assemble
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android View Hover [](https://travis-ci.org/daimajia/AndroidViewHover)
2 |
3 | In my opinion, jumping to a new activity to show your menu is a kind of wasting time and life.
4 |
5 | So,
6 |
7 | I think, we need a hover view, to show menu, to show messages.
8 |
9 | ## Demo
10 |
11 | 
12 |
13 | Watch HD in [YouTube](http://www.youtube.com/watch?v=bsDQbMTtPvM).
14 |
15 | Download [Apk](https://github.com/daimajia/AndroidViewHover/releases/download/v1.0.0/AndroidViewHover-v1.0.0.apk)
16 |
17 | ## Usage
18 |
19 | ### Step0
20 |
21 | Set up RenderScript
22 |
23 | - Eclipse, please visit [official tutorial](http://developer.android.com/guide/topics/renderscript/compute.html#access-rs-apis).
24 | - Android Studio, add
25 | ```groovy
26 |
27 | renderscriptTargetApi 19
28 | renderscriptSupportMode true
29 | ```
30 | in `build.gradle` `defaultConfig`, here is a [sample](https://github.com/daimajia/AndroidViewHover/blob/master/library/build.gradle#L12-L13)
31 |
32 |
33 | ### Step1
34 |
35 | #### Gradle
36 | ```groovy
37 | dependencies {
38 | compile "com.android.support:support-v4:20.+"
39 | compile 'com.nineoldandroids:library:2.4.0'
40 | compile 'com.daimajia.easing:library:1.0.0@aar'
41 | compile 'com.daimajia.androidanimations:library:1.1.2@aar'
42 | compile 'com.daimajia.androidviewhover:library:1.0.4@aar'
43 | }
44 | ```
45 |
46 | #### Maven
47 |
48 | ```xml
49 |
50 | com.nineoldandroids
51 | library
52 | 2.4.0
53 |
54 |
55 | com.daimajia.androidanimation
56 | library
57 | 1.1.2
58 | apklib
59 |
60 |
61 | com.daimajia.easing
62 | library
63 | 1.0.0
64 | apklib
65 |
66 |
67 | com.daimajia.androidviewhover
68 | library
69 | 1.0.4
70 | apklib
71 |
72 | ```
73 |
74 |
75 | #### Eclipse
76 | - SupportLibrary v4
77 | - [NineOldAndroids-2.4.0](https://github.com/downloads/JakeWharton/NineOldAndroids/nineoldandroids-2.4.0.jar)
78 | - [AndroidViewAnimations-1.1.2](https://github.com/daimajia/AndroidViewAnimations/releases/download/v1.1.2/AndroidViewAnimations-1.1.2.jar)
79 | - [AndroidEasingFunctions-1.0.0](https://github.com/daimajia/AndroidViewAnimations/releases/download/v1.0.6/AndroidEasingFunctions-1.0.0.jar)
80 | - [AndroidViewHover-1.0.3](https://github.com/daimajia/AndroidViewHover/releases/download/v1.0.3/AndroidViewHover-v1.0.3.jar)
81 |
82 | ### Step2
83 |
84 | 
85 |
86 | 1. Create an original view, and make sure it was wrapped by `BlurLayout`
87 |
88 | for example:
89 | ```xml
90 |
94 |
99 |
100 | ```
101 | Note: `BlurLayout` is entended from `RelativeLayout`. You can use the `RelativeLayout` rules to layout your view.
102 |
103 |
104 | 2. Create a hover view, there is no rules to obey. Just please remember that this view will be stretched as large as the original view you have created.
105 |
106 | 3. Bind a hover view to `BlurLayout`
107 |
108 |
109 | ```java
110 | BlurLayout sampleLayout = (BlurLayout)findViewById(R.id.sample);
111 | View hover = LayoutInflater.from(mContext).inflate(R.layout.hover, null);
112 | sampleLayout.setHoverView(hover);
113 | ```
114 |
115 | and don't forget that you can add various animations just in one line code. For example:
116 | ```java
117 | //View (R.id.heart) appear animation.
118 | sampleLayout.addChildAppearAnimator(hover, R.id.heart, Techniques.FlipInX);
119 | //View (R.id.heart) disappear animation.
120 | sampleLayout.addChildDisappearAnimator(hover, R.id.heart, Techniques.FlipOutX);
121 | ```
122 |
123 | You can view the samples in my [preset examples](https://github.com/daimajia/AndroidViewHover/blob/master/demo/src/main/java/com/daimajia/androidviewhover/demo/MainActivity.java).
124 |
125 | # Animations
126 |
127 | This project provides a lot of animations you can choose. Animations are from my another open-source project [AndroidViewAnimations](https://github.com/daimajia/AndroidViewAnimations#effects). And you can aslo using [easing funcitons](https://github.com/daimajia/AnimationEasingFunctions) to make your animations more real. Please enjoy it.
128 |
129 | # Thanks
130 |
131 | - [NineOldAndroids](https://github.com/JakeWharton/NineOldAndroids) by JakeWharton
132 | - [AndroidViewAnimations](https://github.com/daimajia/AndroidViewAnimations) by me
133 | - [AnimationEasingFunctions](https://github.com/daimajia/AnimationEasingFunctions) by me
134 |
135 | # About me
136 |
137 | A student in mainland China.
138 |
139 | Welcome to [offer me an internship](mailto:daimajia@gmail.com).
140 | If you have any new idea about this project, feel free to [contact me](mailto:daimajia@gmail.com).
141 |
142 |
143 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | maven {
8 | url "https://oss.sonatype.org/content/repositories/snapshots"
9 | }
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:1.1.0'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | mavenCentral()
22 | maven {
23 | url 'https://oss.sonatype.org/content/repositories/snapshots'
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 |
4 |
5 | android {
6 | compileSdkVersion 20
7 | buildToolsVersion "20.0.0"
8 |
9 | defaultConfig {
10 | applicationId "com.daimajia.androidviewmenu.demo"
11 | minSdkVersion 8
12 | targetSdkVersion 20
13 | renderscriptTargetApi 19
14 | renderscriptSupportModeEnabled true
15 | versionCode 2
16 | versionName "1.0.1"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | lintOptions {
25 | abortOnError false
26 | }
27 | }
28 |
29 | dependencies {
30 | compile fileTree(dir: 'libs', include: ['*.jar'])
31 | compile project(':library')
32 | compile 'com.android.support:appcompat-v7:20.+'
33 | compile 'com.makeramen:roundedimageview:1.3.0'
34 | }
--------------------------------------------------------------------------------
/demo/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 /Applications/Android Studio.app/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 |
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/daimajia/androidviewhover/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.daimajia.androidviewhover.demo;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.support.v7.app.ActionBarActivity;
8 | import android.view.LayoutInflater;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.widget.Toast;
13 |
14 | import com.daimajia.androidanimations.library.Techniques;
15 | import com.daimajia.androidanimations.library.YoYo;
16 | import com.daimajia.androidviewhover.BlurLayout;
17 |
18 | public class MainActivity extends ActionBarActivity {
19 |
20 | private Context mContext;
21 | private BlurLayout mSampleLayout, mSampleLayout2, mSampleLayout3, mSampleLayout4;
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | mContext = this;
26 | setContentView(R.layout.activity_main);
27 | BlurLayout.setGlobalDefaultDuration(450);
28 | mSampleLayout = (BlurLayout)findViewById(R.id.blur_layout);
29 | View hover = LayoutInflater.from(mContext).inflate(R.layout.hover_sample, null);
30 | hover.findViewById(R.id.heart).setOnClickListener(new View.OnClickListener() {
31 | @Override
32 | public void onClick(View v) {
33 | YoYo.with(Techniques.Tada)
34 | .duration(550)
35 | .playOn(v);
36 | }
37 | });
38 | hover.findViewById(R.id.share).setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View v) {
41 | YoYo.with(Techniques.Swing)
42 | .duration(550)
43 | .playOn(v);
44 | }
45 | });
46 | mSampleLayout.setHoverView(hover);
47 | mSampleLayout.setBlurDuration(550);
48 | mSampleLayout.addChildAppearAnimator(hover, R.id.heart, Techniques.FlipInX, 550, 0);
49 | mSampleLayout.addChildAppearAnimator(hover, R.id.share, Techniques.FlipInX, 550, 250);
50 | mSampleLayout.addChildAppearAnimator(hover, R.id.more, Techniques.FlipInX, 550, 500);
51 |
52 | mSampleLayout.addChildDisappearAnimator(hover, R.id.heart, Techniques.FlipOutX, 550, 500);
53 | mSampleLayout.addChildDisappearAnimator(hover, R.id.share, Techniques.FlipOutX, 550, 250);
54 | mSampleLayout.addChildDisappearAnimator(hover, R.id.more, Techniques.FlipOutX, 550, 0);
55 |
56 | mSampleLayout.addChildAppearAnimator(hover, R.id.description, Techniques.FadeInUp);
57 | mSampleLayout.addChildDisappearAnimator(hover, R.id.description, Techniques.FadeOutDown);
58 |
59 | //sample 2
60 |
61 | mSampleLayout2 = (BlurLayout)findViewById(R.id.blur_layout2);
62 | View hover2 = LayoutInflater.from(mContext).inflate(R.layout.hover_sample2, null);
63 | hover2.findViewById(R.id.avatar).setOnClickListener(new View.OnClickListener() {
64 | @Override
65 | public void onClick(View v) {
66 | Toast.makeText(mContext, "Pretty Cool, Right?", Toast.LENGTH_SHORT).show();
67 | }
68 | });
69 | mSampleLayout2.setHoverView(hover2);
70 |
71 | mSampleLayout2.addChildAppearAnimator(hover2, R.id.description, Techniques.FadeInUp);
72 | mSampleLayout2.addChildDisappearAnimator(hover2, R.id.description, Techniques.FadeOutDown);
73 | mSampleLayout2.addChildAppearAnimator(hover2, R.id.avatar, Techniques.DropOut, 1200);
74 | mSampleLayout2.addChildDisappearAnimator(hover2, R.id.avatar, Techniques.FadeOutUp);
75 | mSampleLayout2.setBlurDuration(1000);
76 |
77 | //sample3
78 | mSampleLayout3 = (BlurLayout)findViewById(R.id.blur_layout3);
79 | View hover3 = LayoutInflater.from(mContext).inflate(R.layout.hover_sample3, null);
80 | mSampleLayout3.setHoverView(hover3);
81 | mSampleLayout3.addChildAppearAnimator(hover3, R.id.eye, Techniques.Landing);
82 | mSampleLayout3.addChildDisappearAnimator(hover3, R.id.eye, Techniques.TakingOff);
83 | mSampleLayout3.enableZoomBackground(true);
84 | mSampleLayout3.setBlurDuration(1200);
85 |
86 | //sample 4
87 |
88 | mSampleLayout4 = (BlurLayout)findViewById(R.id.blur_layout4);
89 | View hover4 = LayoutInflater.from(mContext).inflate(R.layout.hover_sample4,null);
90 | mSampleLayout4.setHoverView(hover4);
91 | mSampleLayout4.addChildAppearAnimator(hover4, R.id.cat, Techniques.SlideInLeft);
92 | mSampleLayout4.addChildAppearAnimator(hover4, R.id.mail, Techniques.SlideInRight);
93 |
94 | mSampleLayout4.addChildDisappearAnimator(hover4, R.id.cat, Techniques.SlideOutLeft);
95 | mSampleLayout4.addChildDisappearAnimator(hover4, R.id.mail, Techniques.SlideOutRight);
96 |
97 | mSampleLayout4.addChildAppearAnimator(hover4, R.id.content, Techniques.BounceIn);
98 | mSampleLayout4.addChildDisappearAnimator(hover4, R.id.content, Techniques.FadeOutUp);
99 |
100 |
101 | hover4.findViewById(R.id.cat).setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View v) {
104 | Intent getWebPage = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/daimajia"));
105 | startActivity(getWebPage);
106 | }
107 | });
108 |
109 | hover4.findViewById(R.id.mail).setOnClickListener(new View.OnClickListener() {
110 | @Override
111 | public void onClick(View v) {
112 | final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
113 |
114 | emailIntent.setType("plain/text");
115 | emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"daimajia@gmail.com"});
116 | emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "About AndroidViewHover");
117 | emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I have a good idea about this project..");
118 |
119 | startActivity(Intent.createChooser(emailIntent, "Send mail..."));
120 | }
121 | });
122 | }
123 |
124 |
125 | @Override
126 | public boolean onCreateOptionsMenu(Menu menu) {
127 | // Inflate the menu; this adds items to the action bar if it is present.
128 | getMenuInflater().inflate(R.menu.main, menu);
129 | return true;
130 | }
131 |
132 | @Override
133 | public boolean onOptionsItemSelected(MenuItem item) {
134 | // Handle action bar item clicks here. The action bar will
135 | // automatically handle clicks on the Home/Up button, so long
136 | // as you specify a parent activity in AndroidManifest.xml.
137 | int id = item.getItemId();
138 | if (id == R.id.action_settings) {
139 | return true;
140 | }
141 | return super.onOptionsItemSelected(item);
142 | }
143 |
144 | }
145 |
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/daimajia.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/daimajia.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/eye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/eye.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/heart.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/image2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/image2.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/kid.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/kid.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/mail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/mail.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/more.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/octocat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/octocat.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/php.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/php.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/pix.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/pix.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/share.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/strawberries.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-hdpi/strawberries.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/demo/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
14 |
19 |
25 |
26 |
33 |
41 |
42 |
43 |
50 |
58 |
59 |
60 |
67 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/hover_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
13 |
19 |
25 |
30 |
31 |
40 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/hover_sample2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
19 |
28 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/hover_sample3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
15 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/hover_sample4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
15 |
22 |
28 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/demo/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/demo/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 12dp
4 | 12dp
5 |
6 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AndroidViewHover
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
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
19 |
20 |
21 | VERSION_NAME=1.0.3
22 | VERSION_CODE=4
23 | GROUP=com.daimajia.androidviewhover
24 |
25 | POM_DESCRIPTION=Android awesome hover.
26 | POM_URL=https://github.com/daimajia/AndroidViewHover
27 | POM_SCM_URL=https://github.com/daimajia/AndroidViewHover
28 | POM_SCM_CONNECTION=scm:https://github.com/daimajia/AndroidViewHover.git
29 | POM_SCM_DEV_CONNECTION=scm:https://github.com/daimajia/AndroidViewHover.git
30 | POM_LICENCE_NAME=MIT
31 | POM_LICENCE_URL=http://opensource.org/licenses/MIT
32 | POM_LICENCE_DIST=repo
33 | POM_DEVELOPER_ID=daimajia
34 | POM_DEVELOPER_NAME=daimajia
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daimajia/AndroidViewHover/7b1bc51b75500a761760fb6038c67adc4816bc16/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Apr 05 11:10:58 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # 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 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 |
4 | android {
5 | compileSdkVersion 20
6 | buildToolsVersion "20.0.0"
7 |
8 | defaultConfig {
9 | minSdkVersion 8
10 | targetSdkVersion 20
11 | renderscriptTargetApi 19
12 | renderscriptSupportModeEnabled true
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | lintOptions {
21 | abortOnError false
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | compile "com.android.support:support-v4:20.+"
28 | compile 'com.nineoldandroids:library:2.4.0'
29 | compile 'com.daimajia.easing:library:1.0.0@aar'
30 | compile 'com.daimajia.androidanimations:library:1.1.2@aar'
31 | }
32 | apply from: './gradle-mvn-push.gradle'
--------------------------------------------------------------------------------
/library/gradle-mvn-push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
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 | apply plugin: 'maven'
18 | apply plugin: 'signing'
19 |
20 | def isReleaseBuild() {
21 | return VERSION_NAME.contains("SNAPSHOT") == false
22 | }
23 |
24 | def getReleaseRepositoryUrl() {
25 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27 | }
28 |
29 | def getSnapshotRepositoryUrl() {
30 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31 | : "https://oss.sonatype.org/content/repositories/snapshots/"
32 | }
33 |
34 | def getRepositoryUsername() {
35 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
36 | }
37 |
38 | def getRepositoryPassword() {
39 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
40 | }
41 |
42 | afterEvaluate { project ->
43 | uploadArchives {
44 | repositories {
45 | mavenDeployer {
46 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
47 |
48 | pom.groupId = GROUP
49 | pom.artifactId = POM_ARTIFACT_ID
50 | pom.version = VERSION_NAME
51 |
52 | repository(url: getReleaseRepositoryUrl()) {
53 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
54 | }
55 | snapshotRepository(url: getSnapshotRepositoryUrl()) {
56 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57 | }
58 |
59 | pom.project {
60 | name POM_NAME
61 | packaging POM_PACKAGING
62 | description POM_DESCRIPTION
63 | url POM_URL
64 |
65 | scm {
66 | url POM_SCM_URL
67 | connection POM_SCM_CONNECTION
68 | developerConnection POM_SCM_DEV_CONNECTION
69 | }
70 |
71 | licenses {
72 | license {
73 | name POM_LICENCE_NAME
74 | url POM_LICENCE_URL
75 | distribution POM_LICENCE_DIST
76 | }
77 | }
78 |
79 | developers {
80 | developer {
81 | id POM_DEVELOPER_ID
82 | name POM_DEVELOPER_NAME
83 | }
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
90 | signing {
91 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
92 | sign configurations.archives
93 | }
94 |
95 | task apklib(type: Zip){
96 | appendix = extension = 'apklib'
97 |
98 | from 'AndroidManifest.xml'
99 | into('res') {
100 | from 'res'
101 | }
102 | into('src') {
103 | from 'src'
104 | }
105 | }
106 |
107 | task jar(type: Jar) {
108 | from android.sourceSets.main.java.srcDirs
109 | }
110 |
111 | task androidJavadocs(type: Javadoc) {
112 | source = android.sourceSets.main.java.srcDirs
113 | classpath += project.files(android.getBootClasspath() .join(File.pathSeparator))
114 | }
115 |
116 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
117 | classifier = 'javadoc'
118 | from androidJavadocs.destinationDir
119 | }
120 |
121 | task androidSourcesJar(type: Jar) {
122 | classifier = 'sources'
123 | from android.sourceSets.main.java.srcDirs
124 | }
125 |
126 | artifacts {
127 | archives androidSourcesJar
128 | archives androidJavadocsJar
129 | archives apklib
130 | }
131 | }
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
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
19 |
20 | POM_NAME=AndroidViewHover Library
21 | POM_ARTIFACT_ID=library
22 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/library/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 /Applications/Android Studio.app/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 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library/src/main/java/com/daimajia/androidviewhover/BlurLayout.java:
--------------------------------------------------------------------------------
1 | package com.daimajia.androidviewhover;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.os.Build;
6 | import android.util.AttributeSet;
7 | import android.view.GestureDetector;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.view.ViewTreeObserver;
12 | import android.view.animation.Interpolator;
13 | import android.widget.ImageView;
14 | import android.widget.RelativeLayout;
15 |
16 | import com.daimajia.androidanimations.library.Techniques;
17 | import com.daimajia.androidanimations.library.YoYo;
18 | import com.daimajia.androidviewhover.proxy.AnimationProxy;
19 | import com.daimajia.androidviewhover.tools.Blur;
20 | import com.daimajia.androidviewhover.tools.Util;
21 | import com.nineoldandroids.animation.Animator;
22 | import com.nineoldandroids.animation.AnimatorSet;
23 | import com.nineoldandroids.animation.ObjectAnimator;
24 |
25 | import java.util.ArrayList;
26 | import java.util.HashMap;
27 | import java.util.Map;
28 |
29 | public class BlurLayout extends RelativeLayout {
30 |
31 |
32 | private View mHoverView;
33 |
34 | private boolean enableBlurBackground = true;
35 | private int mBlurRadius = 10;
36 | private ImageView mBlurImage;
37 |
38 | private static long DURATION = 500;
39 |
40 | private ArrayList mPlayingAnimators = new ArrayList();
41 |
42 | private ArrayList mAppearingAnimators = new ArrayList();
43 | private ArrayList mDisappearingAnimators = new ArrayList();
44 |
45 | private ArrayList mAppearListeners = new ArrayList();
46 | private ArrayList mDisappearListeners = new ArrayList();
47 |
48 | private boolean enableBackgroundZoom = false;
49 | private float mZoomRatio = 1.14f;
50 |
51 | private boolean enableTouchEvent = true;
52 |
53 | private Animator mHoverAppearAnimator;
54 | private YoYo.AnimationComposer mHoverAppearAnimationComposer;
55 |
56 | private Animator mHoverDisappearAnimator;
57 | private YoYo.AnimationComposer mHoverDisappearAnimationComposer;
58 |
59 | private HashMap> mChildAppearAnimators = new HashMap>();
60 | private HashMap> mChildDisappearAnimators = new HashMap>();
61 |
62 | private long mBlurDuration = DURATION;
63 |
64 | public enum HOVER_STATUS {
65 | APPEARING, APPEARED, DISAPPEARING, DISAPPEARED
66 | };
67 |
68 | private HOVER_STATUS mHoverStatus = HOVER_STATUS.DISAPPEARED;
69 |
70 | public BlurLayout(Context context) {
71 | super(context);
72 | }
73 |
74 | public BlurLayout(Context context, AttributeSet attrs) {
75 | super(context, attrs);
76 | }
77 |
78 | public BlurLayout(Context context, AttributeSet attrs, int defStyle) {
79 | super(context, attrs, defStyle);
80 | }
81 |
82 | @Override
83 | public boolean onTouchEvent(MotionEvent event) {
84 | return enableTouchEvent && gestureDetector.onTouchEvent(event);
85 | }
86 |
87 | private GestureDetector gestureDetector = new GestureDetector(getContext(), new BlurLayoutDetector());
88 |
89 | class BlurLayoutDetector extends GestureDetector.SimpleOnGestureListener {
90 |
91 | @Override
92 | public boolean onDown(MotionEvent e) {
93 | return true;
94 | }
95 |
96 | @Override
97 | public boolean onSingleTapUp(MotionEvent e) {
98 | if(hover())
99 | return true;
100 | else
101 | return super.onSingleTapConfirmed(e);
102 | }
103 | };
104 |
105 | public void showHover(){
106 | hover();
107 | }
108 |
109 | /**
110 | * Let hover show.
111 | * @return
112 | */
113 | private boolean hover(){
114 | if(mHoverView == null) return false;
115 |
116 | if(getHoverStatus() != HOVER_STATUS.DISAPPEARED || !mPlayingAnimators.isEmpty()) return true;
117 |
118 | removeView(mBlurImage);
119 | if(enableBlurBackground)
120 | addBlurImage();
121 |
122 | if(mHoverView.getParent() != null){
123 | ((ViewGroup)(mHoverView.getParent())).removeView(mHoverView);
124 | }
125 |
126 | addView(mHoverView, getFullParentSizeLayoutParams());
127 |
128 | mHoverView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
129 | @Override
130 | public void onGlobalLayout() {
131 |
132 | startChildrenAppearAnimations();
133 |
134 | startBlurImageAppearAnimator();
135 |
136 | startHoverAppearAnimator();
137 |
138 | if(Build.VERSION.SDK_INT >= 16)
139 | mHoverView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
140 | else
141 | mHoverView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
142 | }
143 | });
144 | return true;
145 |
146 | }
147 |
148 | /**
149 | * Let hover view dismiss.
150 | * Notice: only when hover view status is appeared, then, this may work.
151 | */
152 | public void dismissHover(){
153 | if(getHoverStatus() != HOVER_STATUS.APPEARED || !mPlayingAnimators.isEmpty())
154 | return;
155 |
156 | startBlurImageDisappearAnimator();
157 |
158 | startHoverDisappearAnimator();
159 |
160 | startChildrenDisappearAnimations();
161 | }
162 |
163 | public void toggleHover(){
164 | if(getHoverStatus() == HOVER_STATUS.DISAPPEARED)
165 | showHover();
166 | else if(getHoverStatus() == HOVER_STATUS.APPEARED)
167 | dismissHover();
168 | }
169 |
170 | /**
171 | * get currently hover status.
172 | * @return
173 | */
174 | public HOVER_STATUS getHoverStatus(){
175 | return mHoverStatus;
176 | }
177 |
178 | private void addBlurImage(){
179 | Bitmap b = Util.getViewBitmap(this);
180 | if(b == null)
181 | return;
182 | Bitmap bm = Blur.apply(getContext(), b, mBlurRadius);
183 | ImageView im = new ImageView(getContext());
184 | im.setImageBitmap(bm);
185 | mBlurImage = im;
186 | this.addView(im);
187 | }
188 |
189 | /**
190 | * set background blur duration.
191 | * @param duration
192 | */
193 | public void setBlurDuration(long duration){
194 | if(duration > 100)
195 | mBlurDuration = duration;
196 | }
197 |
198 |
199 | /**
200 | * set background blur radius.
201 | * @param radius radius to be used for the gaussian blur operation, integer between 0 and 25 (inclusive)
202 | */
203 | public void setBlurRadius(int radius) {
204 | if(radius < 0 || radius > 25){
205 | throw new IllegalArgumentException("Radius must be between 0 and 25 (inclusive)");
206 | }
207 | this.mBlurRadius = radius;
208 | }
209 |
210 | /**
211 | * bind a hover view with BlurLayout.
212 | * @param hover
213 | */
214 | public void setHoverView(final View hover){
215 | mHoverView = hover;
216 |
217 | if(mHoverView == null) return;
218 |
219 | if(mHoverAppearAnimator != null)
220 | mHoverAppearAnimator.setTarget(mHoverView);
221 |
222 | mHoverView.setOnClickListener(new OnClickListener() {
223 | @Override
224 | public void onClick(View v) {
225 |
226 | dismissHover();
227 |
228 | }
229 | });
230 | }
231 |
232 | /**
233 | * Sets whether or not touching the BlurLayout will trigger the Hover View and blur effect
234 | * @param enableTouchEvent
235 | */
236 | public void enableTouchEvent(boolean enableTouchEvent) {
237 | this.enableTouchEvent = enableTouchEvent;
238 | }
239 |
240 | public void enableBlurBackground(boolean enable){
241 | enableBlurBackground = enable;
242 | }
243 |
244 | public void enableZoomBackground(boolean enable) {
245 | enableBackgroundZoom = enable;
246 | }
247 |
248 | public void setBlurZoomRatio(float ratio){
249 | if(ratio < 0)
250 | throw new IllegalArgumentException("Can not set ratio less than 0");
251 | mZoomRatio = ratio;
252 | }
253 |
254 | private void startBlurImageAppearAnimator(){
255 | if(!enableBlurBackground || mBlurImage == null) return;
256 |
257 | AnimatorSet set = new AnimatorSet();
258 | if(enableBackgroundZoom){
259 | set.playTogether(
260 | ObjectAnimator.ofFloat(mBlurImage, "alpha", 0.8f, 1f),
261 | ObjectAnimator.ofFloat(mBlurImage, "scaleX", 1f, mZoomRatio),
262 | ObjectAnimator.ofFloat(mBlurImage, "scaleY", 1f, mZoomRatio)
263 | );
264 | }
265 | else{
266 | set.playTogether(
267 | ObjectAnimator.ofFloat(mBlurImage, "alpha", 0f, 1f)
268 | );
269 | }
270 | set.addListener(mGlobalListener);
271 | set.addListener(mGlobalAppearingAnimators);
272 | set.setDuration(mBlurDuration);
273 | set.start();
274 | }
275 |
276 | private void startBlurImageDisappearAnimator(){
277 | if(!enableBlurBackground || mBlurImage == null) return;
278 |
279 | AnimatorSet set = new AnimatorSet();
280 | if(enableBackgroundZoom)
281 | set.playTogether(
282 | ObjectAnimator.ofFloat(mBlurImage, "alpha", 1f, 0.8f),
283 | ObjectAnimator.ofFloat(mBlurImage, "scaleX", mZoomRatio, 1f),
284 | ObjectAnimator.ofFloat(mBlurImage, "scaleY", mZoomRatio, 1f)
285 | );
286 | else
287 | set.playTogether(
288 | ObjectAnimator.ofFloat(mBlurImage, "alpha", 1f, 0f)
289 | );
290 |
291 | set.addListener(mGlobalListener);
292 | set.addListener(mGlobalDisappearAnimators);
293 | set.setDuration(mBlurDuration);
294 | set.start();
295 | }
296 |
297 | private void startHoverAppearAnimator(){
298 | if(mHoverAppearAnimator != null)
299 | mHoverAppearAnimator.start();
300 |
301 | if(mHoverAppearAnimationComposer != null)
302 | mHoverAppearAnimationComposer.playOn(mHoverView);
303 | }
304 |
305 | private void startHoverDisappearAnimator(){
306 | if(mHoverDisappearAnimator != null)
307 | mHoverDisappearAnimator.start();
308 | if(mHoverDisappearAnimationComposer != null)
309 | mHoverDisappearAnimationComposer.playOn(mHoverView);
310 | }
311 |
312 | private void startChildrenAppearAnimations(){
313 | for(Map.Entry> entry : mChildAppearAnimators.entrySet()){
314 | for(AnimationProxy animator : entry.getValue()){
315 | animator.start();
316 | }
317 | }
318 | }
319 |
320 | private void startChildrenDisappearAnimations(){
321 | for(View view : mChildDisappearAnimators.keySet()){
322 | for(AnimationProxy animator : mChildDisappearAnimators.get(view)){
323 | animator.start();
324 | }
325 | }
326 | }
327 |
328 | public interface AppearListener {
329 | public void onStart();
330 | public void onEnd();
331 | }
332 |
333 | public interface DisappearListener {
334 | public void onStart();
335 | public void onEnd();
336 | }
337 |
338 | public void addAppearListener(AppearListener l){
339 | mAppearListeners.add(l);
340 | }
341 |
342 | public void removeAppearListener(AppearListener l){
343 | mAppearListeners.remove(l);
344 | }
345 |
346 | public void addDisappearListener(DisappearListener l){
347 | mDisappearListeners.add(l);
348 | }
349 |
350 | public void removeDisappearListener(DisappearListener l){
351 | mDisappearingAnimators.remove(l);
352 | }
353 |
354 | public Animator.AnimatorListener mGlobalAppearingAnimators = new Animator.AnimatorListener() {
355 | @Override
356 | public void onAnimationStart(Animator animation) {
357 | mAppearingAnimators.add(animation);
358 | if(mAppearingAnimators.size() == 1){
359 | mHoverStatus = HOVER_STATUS.APPEARING;
360 | for(AppearListener l : mAppearListeners){
361 | l.onStart();
362 | }
363 | }
364 | }
365 |
366 | @Override
367 | public void onAnimationEnd(Animator animation) {
368 | mAppearingAnimators.remove(animation);
369 | mHoverStatus = HOVER_STATUS.APPEARED;
370 | if(!mAppearListeners.isEmpty()){
371 | for(AppearListener l : mAppearListeners){
372 | l.onEnd();
373 | }
374 | }
375 | }
376 |
377 | @Override
378 | public void onAnimationCancel(Animator animation) {
379 |
380 | }
381 |
382 | @Override
383 | public void onAnimationRepeat(Animator animation) {
384 |
385 | }
386 | };
387 |
388 | public Animator.AnimatorListener mGlobalDisappearAnimators = new Animator.AnimatorListener() {
389 | @Override
390 | public void onAnimationStart(Animator animation) {
391 | mDisappearingAnimators.add(animation);
392 | if(mDisappearListeners.size() == 1){
393 | for(DisappearListener l : mDisappearListeners){
394 | mHoverStatus = HOVER_STATUS.DISAPPEARING;
395 | l.onStart();
396 | }
397 | }
398 | }
399 |
400 | @Override
401 | public void onAnimationEnd(Animator animation) {
402 | mDisappearingAnimators.remove(animation);
403 | if(mPlayingAnimators.isEmpty()){
404 | mHoverStatus = HOVER_STATUS.DISAPPEARED;
405 | removeView(mBlurImage);
406 | removeView(mHoverView);
407 | for(DisappearListener l : mDisappearListeners){
408 | l.onEnd();
409 | }
410 | }
411 | }
412 |
413 | @Override
414 | public void onAnimationCancel(Animator animation) {
415 |
416 | }
417 |
418 | @Override
419 | public void onAnimationRepeat(Animator animation) {
420 |
421 | }
422 | };
423 |
424 | public Animator.AnimatorListener mGlobalListener = new Animator.AnimatorListener() {
425 | @Override
426 | public void onAnimationStart(Animator animation) {
427 | mPlayingAnimators.add(animation);
428 | }
429 |
430 | @Override
431 | public void onAnimationEnd(Animator animation) {
432 | mPlayingAnimators.remove(animation);
433 | }
434 |
435 | @Override
436 | public void onAnimationCancel(Animator animation) {
437 |
438 | }
439 |
440 | @Override
441 | public void onAnimationRepeat(Animator animation) {
442 |
443 | }
444 | };
445 |
446 | public void setHoverAppearAnimator(Techniques technique){
447 | setHoverAppearAnimator(technique, DURATION);
448 | }
449 |
450 | public void setHoverAppearAnimator(Techniques technique, long duration){
451 | setHoverAppearAnimator(technique, duration, 0, null);
452 | }
453 |
454 | public void setHoverAppearAnimator(Techniques technique, long duration, long delay, Interpolator interpolator){
455 | setHoverAppearAnimator(technique, duration, delay, interpolator, new Animator.AnimatorListener[]{});
456 | }
457 |
458 | public void setHoverAppearAnimator(Techniques technique, long duration, long delay, Interpolator interpolator, Animator.AnimatorListener... listeners){
459 | mHoverAppearAnimator = null;
460 | mHoverAppearAnimationComposer = YoYo.with(technique).delay(delay).duration(duration).interpolate(interpolator);
461 |
462 | for(Animator.AnimatorListener l : listeners)
463 | mHoverAppearAnimationComposer.withListener(l);
464 | mHoverAppearAnimationComposer.withListener(mGlobalListener);
465 | mHoverAppearAnimationComposer.withListener(mGlobalAppearingAnimators);
466 | }
467 |
468 | public void setHoverAppearAnimator(Animator animator){
469 | mHoverAppearAnimationComposer = null;
470 | mHoverAppearAnimator = animator;
471 |
472 | animator.addListener(mGlobalListener);
473 | animator.addListener(mGlobalAppearingAnimators);
474 | }
475 |
476 |
477 |
478 | public void setHoverDisappearAnimator(Techniques technique){
479 | setHoverDisappearAnimator(technique, DURATION);
480 | }
481 |
482 | public void setHoverDisappearAnimator(Techniques technique, long duration){
483 | setHoverDisappearAnimator(technique, duration, 0, null);
484 | }
485 |
486 | public void setHoverDisappearAnimator(Techniques technique, long duration, long delay, Interpolator interpolator){
487 | setHoverDisappearAnimator(technique, duration, delay, interpolator, new Animator.AnimatorListener[]{});
488 | }
489 |
490 | public void setHoverDisappearAnimator(Techniques technique, long duration, long delay, Interpolator interpolator, Animator.AnimatorListener... listeners){
491 | mHoverDisappearAnimator = null;
492 | mHoverDisappearAnimationComposer = YoYo.with(technique).delay(delay).duration(duration).interpolate(interpolator);
493 |
494 | for(Animator.AnimatorListener l : listeners)
495 | mHoverDisappearAnimationComposer.withListener(l);
496 |
497 | mHoverDisappearAnimationComposer.withListener(mGlobalListener);
498 | mHoverDisappearAnimationComposer.withListener(mGlobalDisappearAnimators);
499 | }
500 |
501 | public void setHoverDisappearAnimator(Animator animator){
502 | mHoverDisappearAnimationComposer = null;
503 | mHoverDisappearAnimator = animator;
504 | mHoverDisappearAnimator.addListener(mGlobalListener);
505 | mHoverDisappearAnimator.addListener(mGlobalDisappearAnimators);
506 | }
507 |
508 |
509 |
510 | public void addChildAppearAnimator(View hoverView, int resId, Techniques technique){
511 | addChildAppearAnimator(hoverView, resId, technique, DURATION);
512 | }
513 |
514 | public void addChildAppearAnimator(View hoverView, int resId, Techniques technique, long duration){
515 | addChildAppearAnimator(hoverView, resId, technique, duration, 0);
516 | }
517 |
518 | public void addChildAppearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay){
519 | addChildAppearAnimator(hoverView, resId, technique, duration, delay, true, null);
520 | }
521 |
522 | public void addChildAppearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay, boolean hiddenWhenDelaying){
523 | addChildAppearAnimator(hoverView, resId, technique, duration, delay, hiddenWhenDelaying, null);
524 | }
525 |
526 | public void addChildAppearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay, boolean hiddenWhenDelaying, Interpolator interpolator){
527 | addChildAppearAnimator(hoverView, resId, technique, duration, delay, hiddenWhenDelaying, interpolator, new Animator.AnimatorListener[]{});
528 | }
529 |
530 | public void addChildAppearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay, boolean hiddenWhenDelaying, Interpolator interpolator, Animator.AnimatorListener... listeners){
531 | AnimationProxy executor = AnimationProxy.build(hoverView, resId, technique, duration, delay, hiddenWhenDelaying, interpolator, listeners);
532 |
533 | View child = executor.getTarget();
534 |
535 | if(mChildAppearAnimators.get(child) == null)
536 | mChildAppearAnimators.put(child, new ArrayList());
537 |
538 | executor.withListener(mGlobalListener);
539 | executor.withListener(mGlobalAppearingAnimators);
540 | child.setVisibility(INVISIBLE);
541 |
542 | mChildAppearAnimators.get(child).add(executor);
543 | }
544 |
545 | public void addChildAppearAnimator(View hoverView, int childId, Animator animator){
546 | AnimationProxy executor = AnimationProxy.build(hoverView, childId, animator);
547 |
548 | View child = executor.getTarget();
549 |
550 | if(mChildAppearAnimators.get(child) == null)
551 | mChildAppearAnimators.put(child, new ArrayList());
552 |
553 | executor.withListener(mGlobalListener);
554 | executor.withListener(mGlobalAppearingAnimators);
555 | mChildAppearAnimators.get(child).add(executor);
556 | }
557 |
558 | public void addChildDisappearAnimator(View hoverView, int resId, Techniques technique){
559 | addChildDisappearAnimator(hoverView, resId, technique, DURATION);
560 | }
561 |
562 | public void addChildDisappearAnimator(View hoverView, int resId, Techniques technique, long duration){
563 | addChildDisappearAnimator(hoverView, resId, technique, duration, 0, false);
564 | }
565 |
566 | public void addChildDisappearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay){
567 | addChildDisappearAnimator(hoverView, resId, technique, duration, delay, false, null);
568 | }
569 |
570 | public void addChildDisappearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay, boolean invisibleWhenDelaying){
571 | addChildDisappearAnimator(hoverView, resId, technique, duration, delay,invisibleWhenDelaying, null);
572 | }
573 |
574 | public void addChildDisappearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay, boolean invisibleWhenDelaying, Interpolator interpolator){
575 | addChildDisappearAnimator(hoverView, resId, technique, duration, delay, invisibleWhenDelaying, interpolator, new Animator.AnimatorListener[]{});
576 | }
577 |
578 | public void addChildDisappearAnimator(View hoverView, int resId, Techniques technique, long duration, long delay, boolean invisibleWhenDelaying, Interpolator interpolator, Animator.AnimatorListener... listeners){
579 |
580 | AnimationProxy executor = AnimationProxy.build(hoverView, resId, technique, duration, delay, invisibleWhenDelaying, interpolator, listeners);
581 |
582 | View child = executor.getTarget();
583 | if(mChildDisappearAnimators.containsKey(child) == false)
584 | mChildDisappearAnimators.put(child, new ArrayList());
585 |
586 | executor.withListener(mGlobalListener);
587 | executor.withListener(mGlobalDisappearAnimators);
588 | mChildDisappearAnimators.get(child).add(executor);
589 | }
590 |
591 | public void addChildDisappearAnimator(View hoverView, int childId, Animator animator){
592 | AnimationProxy executor = AnimationProxy.build(hoverView, childId, animator);
593 |
594 | View child = executor.getTarget();
595 |
596 | if(mChildDisappearAnimators.get(child) == null)
597 | mChildDisappearAnimators.put(child, new ArrayList());
598 |
599 | executor.withListener(mGlobalListener);
600 | executor.withListener(mGlobalDisappearAnimators);
601 | mChildDisappearAnimators.get(child).add(executor);
602 | }
603 |
604 | public LayoutParams getFullParentSizeLayoutParams(){
605 | LayoutParams pm = (LayoutParams)this.generateDefaultLayoutParams();
606 | pm.width = this.getWidth();
607 | pm.height = this.getHeight();
608 | return pm;
609 | }
610 |
611 | public static void setGlobalDefaultDuration(long duration){
612 | if(duration < 100)
613 | throw new IllegalArgumentException("Duration can not be set to less than 100");
614 | DURATION = duration;
615 | }
616 |
617 |
618 | }
619 |
--------------------------------------------------------------------------------
/library/src/main/java/com/daimajia/androidviewhover/proxy/AnimationProxy.java:
--------------------------------------------------------------------------------
1 | package com.daimajia.androidviewhover.proxy;
2 |
3 | import android.view.View;
4 | import android.view.animation.Interpolator;
5 |
6 | import com.daimajia.androidanimations.library.Techniques;
7 | import com.daimajia.androidanimations.library.YoYo;
8 | import com.nineoldandroids.animation.Animator;
9 |
10 | public class AnimationProxy implements Runnable {
11 |
12 | private YoYo.AnimationComposer composer = null;
13 | private Animator animator = null;
14 |
15 | private long delay;
16 | private long duration;
17 | private boolean invisibleWhenDelaying;
18 | private View targetView;
19 | private Interpolator interpolator;
20 |
21 | private long startTime = -1;
22 |
23 | private AnimationProxy(View hoverView, int resId, Techniques technique, long duration, long delay, boolean invisibleWhenDelaying, Interpolator interpolator, Animator.AnimatorListener... listeners){
24 | if(hoverView == null)
25 | throw new IllegalStateException("Hover view is null");
26 |
27 | View child = hoverView.findViewById(resId);
28 |
29 | if(child == null)
30 | throw new IllegalStateException("Can not find the child view");
31 |
32 | if(duration < 0)
33 | throw new IllegalArgumentException("Duration can not be less than 0");
34 |
35 | if(delay < 0)
36 | throw new IllegalArgumentException("Delay can not be less than 0");
37 |
38 | this.composer = YoYo.with(technique).duration(duration).delay(delay).interpolate(interpolator);
39 |
40 | this.targetView = child;
41 | this.interpolator = interpolator;
42 | this.delay = delay;
43 | this.duration = duration;
44 | this.invisibleWhenDelaying = invisibleWhenDelaying;
45 |
46 | for(Animator.AnimatorListener l : listeners)
47 | this.composer.withListener(l);
48 | }
49 |
50 | public static AnimationProxy build(View hoverView, int resId, Techniques technique, long duration, long delay, boolean invisibleWhenDelaying, Interpolator interpolator, Animator.AnimatorListener... listeners){
51 | return new AnimationProxy(hoverView, resId, technique, duration, delay, invisibleWhenDelaying, interpolator, listeners);
52 | }
53 |
54 | public static AnimationProxy build(View hoverView, int childId, Animator animator){
55 | return new AnimationProxy(hoverView, childId, animator);
56 | }
57 |
58 | private AnimationProxy(View hoverView, int childId, Animator animator){
59 | if(animator == null)
60 | throw new IllegalArgumentException("Animator can not be null");
61 |
62 | if(hoverView == null)
63 | throw new IllegalArgumentException("hoverView can not be null");
64 |
65 | View child = hoverView.findViewById(childId);
66 | if(child == null)
67 | throw new IllegalArgumentException("Can not find child");
68 |
69 | this.targetView = child;
70 | this.duration = animator.getDuration();
71 | this.delay = animator.getStartDelay();
72 | this.interpolator = null;
73 | this.animator = animator;
74 | }
75 |
76 | public void start(){
77 | startTime = System.currentTimeMillis();
78 | targetView.post(this);
79 | }
80 |
81 | public boolean isDelaying(){
82 | long current = System.currentTimeMillis();
83 | if(current - startTime <= delay)
84 | return true;
85 | else
86 | return false;
87 | }
88 |
89 | @Override
90 | public void run() {
91 | if(startTime == -1)
92 | throw new IllegalStateException("You can not call run directly, you should call start!");
93 |
94 | if(!isDelaying()){
95 | if(targetView.getVisibility() != View.VISIBLE)
96 | targetView.setVisibility(View.VISIBLE);
97 |
98 | if(composer!=null){
99 | composer.delay(0);
100 | composer.playOn(targetView);
101 | }
102 | if(animator != null){
103 | animator.setStartDelay(0);
104 | animator.start();
105 | }
106 | }else{
107 | if(invisibleWhenDelaying && targetView.getVisibility() != View.INVISIBLE){
108 | targetView.setVisibility(View.INVISIBLE);
109 | }
110 | targetView.post(this);
111 | }
112 | }
113 |
114 | public View getTarget(){
115 | return this.targetView;
116 | }
117 |
118 | public void withListener(Animator.AnimatorListener l){
119 | if(composer != null)
120 | composer.withListener(l);
121 | if(animator != null)
122 | animator.addListener(l);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/library/src/main/java/com/daimajia/androidviewhover/tools/Blur.java:
--------------------------------------------------------------------------------
1 | package com.daimajia.androidviewhover.tools;
2 | import android.graphics.Bitmap;
3 | import android.content.Context;
4 | import android.support.v8.renderscript.Allocation;
5 | import android.support.v8.renderscript.Element;
6 | import android.support.v8.renderscript.RenderScript;
7 | import android.support.v8.renderscript.ScriptIntrinsicBlur;
8 |
9 |
10 | public class Blur {
11 |
12 | private static final int DEFAULT_BLUR_RADIUS = 10;
13 |
14 | public static Bitmap apply(Context context, Bitmap sentBitmap) {
15 | return apply(context, sentBitmap, DEFAULT_BLUR_RADIUS);
16 | }
17 |
18 | public static Bitmap apply(Context context, Bitmap sentBitmap, int radius) {
19 | final Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
20 | final RenderScript rs = RenderScript.create(context);
21 | final Allocation input = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
22 | final Allocation output = Allocation.createTyped(rs, input.getType());
23 | final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
24 |
25 | script.setRadius(radius);
26 | script.setInput(input);
27 | script.forEach(output);
28 | output.copyTo(bitmap);
29 |
30 | sentBitmap.recycle();
31 | rs.destroy();
32 | input.destroy();
33 | output.destroy();
34 | script.destroy();
35 |
36 | return bitmap;
37 | }
38 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/daimajia/androidviewhover/tools/Util.java:
--------------------------------------------------------------------------------
1 | package com.daimajia.androidviewhover.tools;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.Canvas;
5 | import android.view.View;
6 |
7 | import com.nineoldandroids.view.ViewHelper;
8 |
9 | public class Util {
10 |
11 | public static Bitmap getViewBitmap(View v) {
12 | if(v.getWidth() == 0 || v.getHeight() == 0)
13 | return null;
14 | Bitmap b = Bitmap.createBitmap( v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
15 | Canvas c = new Canvas(b);
16 | v.draw(c);
17 | return b;
18 | }
19 |
20 | public static void reset(View target) {
21 | ViewHelper.setAlpha(target, 1);
22 | ViewHelper.setScaleX(target, 1);
23 | ViewHelper.setScaleY(target, 1);
24 | ViewHelper.setTranslationX(target, 0);
25 | ViewHelper.setTranslationY(target, 0);
26 | ViewHelper.setRotation(target, 0);
27 | ViewHelper.setRotationY(target, 0);
28 | ViewHelper.setRotationX(target, 0);
29 | ViewHelper.setPivotX(target, target.getMeasuredWidth() / 2.0f);
30 | ViewHelper.setPivotY(target, target.getMeasuredHeight() / 2.0f);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library', ':demo'
--------------------------------------------------------------------------------