├── .gitignore
├── .travis.yml
├── README.md
├── build.gradle
├── demo.apk
├── demo
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── net
│ │ └── wujingchao
│ │ └── android
│ │ └── demo
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── net
│ │ └── wujingchao
│ │ └── android
│ │ └── demo
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ ├── eff.jpeg
│ ├── ent.jpg
│ ├── ic_launcher.png
│ ├── nuan1.jpg
│ ├── nuan2.jpg
│ └── qa.jpeg
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── drawable
│ └── title_bar.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── background_view.xml
│ └── image_item.xml
│ ├── menu
│ └── menu_main.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── multi-card-menu
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── net
│ │ └── wujingchao
│ │ └── android
│ │ └── demo
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── net
│ │ └── wujingchao
│ │ └── android
│ │ └── view
│ │ ├── DarkFrameLayout.java
│ │ └── MultiCardMenu.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── layout
│ └── multi_card_view_transparent_background_view.xml
│ └── values
│ ├── attr.xml
│ └── strings.xml
├── multi_card_menu_demo.gif
├── multi_card_menu_demo_static.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | #*.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 | *.iml
8 |
9 | # Java class files
10 | *.class
11 |
12 | # libs
13 |
14 | # generated files
15 | bin/
16 | .idea/
17 | .gradle/
18 | gen/
19 | target/
20 | build/
21 |
22 | # Local configuration file (sdk path, etc)
23 | local.properties
24 |
25 | # Eclipse project files
26 | .classpath
27 | .project
28 |
29 | # Mac os
30 | .DS_Store
31 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | android:
3 | components:
4 | - build-tools-22.0.1
5 |
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/wujingchao/MultiCardMenu)
2 | [](http://www.android-gems.com/lib/wujingchao/MultiCardMenu)
3 |
4 | # MultiCardMenu
5 | A multicard menu that can open and close with animation on android,require API level >= 11
6 |
7 | ## Demo
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | ##Usage
20 |
21 |
34 |
35 | ....(Your ChildViews)
36 |
37 |
38 |
39 | License
40 | -------
41 | MIT
42 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | jcenter()
5 | maven {
6 | url 'https://maven.google.com/'
7 | name 'Google'
8 | }
9 | google()
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:3.1.2'
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | maven {
22 | url 'https://maven.google.com/'
23 | name 'Google'
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/demo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo.apk
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion '27.0.3'
6 |
7 | defaultConfig {
8 | applicationId "net.wujingchao.android.view"
9 | minSdkVersion 14
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(dir: 'libs', include: ['*.jar'])
24 | implementation 'com.android.support:appcompat-v7:26.1.0'
25 | implementation project(':multi-card-menu')
26 | implementation 'com.android.support.constraint:constraint-layout:1.1.2'
27 | }
28 |
--------------------------------------------------------------------------------
/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 D:\Program Files (x86)\Android\android-studio\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/androidTest/java/net/wujingchao/android/demo/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package net.wujingchao.android.demo;
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 | }
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/demo/src/main/java/net/wujingchao/android/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package net.wujingchao.android.demo;
2 |
3 | import android.app.Activity;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.support.v4.view.ViewPager;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ArrayAdapter;
12 | import android.widget.CheckBox;
13 | import android.widget.CompoundButton;
14 | import android.widget.ImageView;
15 | import android.widget.ListView;
16 | import android.widget.Toast;
17 | import net.wujingchao.android.view.MultiCardMenu;
18 |
19 |
20 |
21 | public class MainActivity extends Activity {
22 |
23 | private static final String TAG = "MainActivity";
24 |
25 | MultiCardMenu mc;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_main);
31 | initView();
32 | }
33 |
34 | private void initView() {
35 | mc = (MultiCardMenu) findViewById(R.id.multi_card_menu);
36 | mc.setOnDisplayOrHideListener(new MultiCardMenu.OnDisplayOrHideListener() {
37 | @Override
38 | public void onDisplay(int which) {
39 | Log.d(TAG,"onDisplay:" + which);
40 | }
41 |
42 | @Override
43 | public void onHide(int which) {
44 | Log.d(TAG, "onHide:" + which);
45 | }
46 |
47 | @Override
48 | public void onTouchCard(int which) {
49 | Log.d(TAG,"onTouchCard:" + which);
50 | }
51 | });
52 | CheckBox fade = (CheckBox) findViewById(R.id.fade);
53 | fade.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
54 | @Override
55 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
56 | mc.setFade(isChecked);
57 | }
58 | });
59 | CheckBox boundary = (CheckBox) findViewById(R.id.boundary);
60 | boundary.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
61 | @Override
62 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
63 | mc.setBoundary(isChecked);
64 | }
65 | });
66 | // int [] imgRes = {R.drawable.ent,R.drawable.qa};
67 | final int [] imgRes = {R.drawable.nuan1,R.drawable.nuan2,R.drawable.ic_launcher,
68 | R.drawable.qa,R.drawable.ent,R.drawable.nuan1,R.drawable.nuan2,R.drawable.ic_launcher,
69 | R.drawable.qa,R.drawable.ent,R.drawable.nuan1,R.drawable.nuan2,R.drawable.ic_launcher,
70 | R.drawable.qa,R.drawable.ent};
71 | final ViewPager mViewPager = (ViewPager) findViewById(R.id.view_pager);
72 | mViewPager.setOffscreenPageLimit(imgRes.length);
73 | mViewPager.setAdapter(new PagerAdapter() {
74 | @Override
75 | public int getCount() {
76 | return imgRes.length;
77 | }
78 |
79 | @Override
80 | public boolean isViewFromObject(View view, Object object) {
81 | return view == object;
82 | }
83 |
84 | @Override
85 | public void destroyItem(ViewGroup container, int position, Object object) {
86 | mViewPager.removeView((View) object);
87 | }
88 |
89 | @Override
90 | public Object instantiateItem(ViewGroup container, int position) {
91 | ImageView imageView = new ImageView(MainActivity.this);
92 | imageView.setImageResource(imgRes[position]);
93 | container.addView(imageView);
94 | return imageView;
95 | }
96 | });
97 |
98 |
99 | ListView listView = (ListView) findViewById(R.id.lv);
100 | listView.setAdapter(new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,data));
101 |
102 | }
103 |
104 | String data [] = {"mother" ,
105 | "passion ",
106 | "smile " ,
107 | "love " ,
108 | "eternity " ,
109 | "fantastic " ,
110 | "destiny " ,
111 | "freedom " ,
112 | "liberty " ,
113 | "tranquility " ,
114 | "peace " ,
115 | "blossom " ,
116 | "sunshine " ,
117 | "sweetheart " ,
118 | "gorgeous " ,
119 | "cherish " ,
120 | "enthusiasm" ,
121 | "hope " ,
122 | "grace " ,
123 | "rainbow " ,
124 | "blue " ,
125 | "sunflower " ,
126 | "twinkle " ,
127 | "serendipity" ,
128 | "bliss " ,
129 | "lullaby " ,
130 | "sophisticated " ,
131 | "renaissance " ,
132 | "cute " ,
133 | "cosy ",
134 | "butterfly ",
135 | "galaxy ",
136 | "hilarious ",
137 | "moment",
138 | "extravaganza ",
139 | "aqua ",
140 | "sentiment ",
141 | "cosmopolitan ",
142 | "bubble ",
143 | "pumpkin",
144 | "banana",
145 | "lollipop ",
146 | "if ",
147 | "bumblebee ",
148 | "giggle ",
149 | "paradox ",
150 | "peek-a-boo ",
151 | "umbrella ",
152 | "kangaroo ",
153 | "flabbergasted" ,
154 | "hippopotamus ",
155 | "gothic ",
156 | "coconut ",
157 | "smashing ",
158 | "whoops ",
159 | "tickle ",
160 | "loquacious ",
161 | "flip-flop ",
162 | "smithereens",
163 | "hi" ,
164 | "gazebo",
165 | "hiccup",
166 | "hodgepodge" ,
167 | "shipshape",
168 | "explosion" ,
169 | "fuselage",
170 | "zing",
171 | "gum",
172 | "hen-night "};
173 |
174 | public void hide(View view) {
175 | mc.hide(mc.getDisplayingCard());
176 | }
177 |
178 | @Override
179 | public void onBackPressed() {
180 | if(mc.isDisplaying()) {
181 | mc.hide(mc.getDisplayingCard());
182 | }else {
183 | super.onBackPressed();
184 | }
185 | }
186 |
187 | public void blue(View view) {
188 | Toast.makeText(this,"Blue",Toast.LENGTH_SHORT).show();
189 | }
190 |
191 | public void fail(View view) {
192 | Toast.makeText(this,"Fail",Toast.LENGTH_SHORT).show();
193 | }
194 |
195 | public void one(View view) {
196 | mc.show(0);
197 | }
198 |
199 | public void two(View view) {
200 | mc.show(1);
201 | }
202 |
203 | public void three(View view) {
204 | mc.show(2);
205 | }
206 |
207 | public void four(View view) {
208 | mc.show(3);
209 | }
210 |
211 | }
212 |
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/eff.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-hdpi/eff.jpeg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/ent.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-hdpi/ent.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/nuan1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-hdpi/nuan1.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/nuan2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-hdpi/nuan2.jpg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-hdpi/qa.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-hdpi/qa.jpeg
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/demo/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/drawable/title_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
14 |
15 |
16 |
20 |
21 |
31 |
32 |
35 |
36 |
41 |
42 |
51 |
52 |
61 |
62 |
71 |
72 |
81 |
82 |
91 |
92 |
101 |
102 |
111 |
112 |
121 |
122 |
131 |
132 |
141 |
142 |
151 |
152 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
171 |
172 |
182 |
183 |
187 |
188 |
189 |
190 |
198 |
199 |
207 |
208 |
209 |
210 |
211 |
218 |
219 |
226 |
227 |
228 |
229 |
230 |
234 |
235 |
245 |
246 |
251 |
252 |
253 |
254 |
258 |
259 |
269 |
270 |
274 |
275 |
276 |
277 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/background_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
20 |
21 |
28 |
29 |
30 |
32 |
39 |
46 |
53 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/image_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/demo/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ff669900
4 | #ffcc0000
5 | #E0A09E
6 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | MultiCardMenu
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 | #ff0099cc
9 |
10 |
--------------------------------------------------------------------------------
/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/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jun 30 14:31:11 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-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 |
--------------------------------------------------------------------------------
/multi-card-menu/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/multi-card-menu/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion '27.0.3'
6 | resourcePrefix "multi_card_view_"
7 | defaultConfig {
8 | minSdkVersion 11
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "0.9.4"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | }
23 |
--------------------------------------------------------------------------------
/multi-card-menu/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:/Program Files (x86)/Android/android-studio/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 |
--------------------------------------------------------------------------------
/multi-card-menu/src/androidTest/java/net/wujingchao/android/demo/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package net.wujingchao.android.demo;
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 | }
--------------------------------------------------------------------------------
/multi-card-menu/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/multi-card-menu/src/main/java/net/wujingchao/android/view/DarkFrameLayout.java:
--------------------------------------------------------------------------------
1 | package net.wujingchao.android.view;
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.MotionEvent;
9 | import android.widget.FrameLayout;
10 |
11 | /**
12 | * @author wujingchao 2015-04-18 email:wujingchao@aliyun.com
13 | */
14 | class DarkFrameLayout extends FrameLayout {
15 |
16 | public final static int MAX_ALPHA = 0x9f;
17 |
18 | private Paint mFadePaint;
19 |
20 | private int alpha = 0x00;
21 |
22 | private MultiCardMenu mMultiCardMenu;
23 |
24 | public DarkFrameLayout(Context context) {
25 | this(context, null);
26 | }
27 |
28 | public DarkFrameLayout(Context context, AttributeSet attrs) {
29 | this(context, attrs, 0);
30 | }
31 |
32 |
33 | public DarkFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
34 | super(context, attrs, defStyleAttr);
35 | mFadePaint = new Paint();
36 | }
37 |
38 | @Override
39 | public boolean onInterceptTouchEvent(MotionEvent ev) {
40 | return mMultiCardMenu.isDisplaying();
41 | }
42 |
43 | @Override
44 | protected void dispatchDraw(Canvas canvas) {
45 | super.dispatchDraw(canvas);
46 | drawFade(canvas);
47 | }
48 |
49 | private void drawFade(Canvas canvas) {
50 | mFadePaint.setColor(Color.argb(alpha, 0, 0, 0));
51 | canvas.drawRect(0, 0, getMeasuredWidth(), getHeight(), mFadePaint);
52 | }
53 |
54 | public void fade(boolean fade) {
55 | this.alpha = fade ? 0x8f : 0x00;
56 | invalidate();
57 | }
58 |
59 | public void fade(int alpha) {
60 | this.alpha = alpha;
61 | invalidate();
62 | }
63 |
64 | public void setMultiCardMenu(MultiCardMenu multiCardMenu) {
65 | this.mMultiCardMenu = multiCardMenu;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/multi-card-menu/src/main/java/net/wujingchao/android/view/MultiCardMenu.java:
--------------------------------------------------------------------------------
1 | package net.wujingchao.android.view;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.ValueAnimator;
7 | import android.content.Context;
8 | import android.content.res.TypedArray;
9 | import android.os.Parcelable;
10 | import android.util.AttributeSet;
11 | import android.util.Log;
12 | import android.view.LayoutInflater;
13 | import android.view.MotionEvent;
14 | import android.view.VelocityTracker;
15 | import android.view.View;
16 | import android.view.ViewConfiguration;
17 | import android.view.ViewGroup;
18 | import android.view.animation.AccelerateInterpolator;
19 | import android.view.animation.Interpolator;
20 | import android.widget.AbsListView;
21 | import android.widget.ScrollView;
22 |
23 |
24 | import java.util.ArrayList;
25 |
26 | /**
27 | * @author wujingchao 2015-04-01 email:wujingchao@aliyun.com
28 | *
29 | */
30 | @SuppressWarnings("unused")
31 | public class MultiCardMenu extends ViewGroup {
32 |
33 | public static final String TAG = "MultiCardMenu";
34 |
35 | private static final boolean DEBUG = BuildConfig.DEBUG;
36 |
37 | private static final int DEFAULT_CARD_MARGIN_TOP = 0;
38 |
39 | private static final int DEFAULT_TITLE_BAR_HEIGHT_NO_DISPLAY = 60;
40 |
41 | private static final int DEFAULT_TITLE_BAR_HEIGHT_DISPLAY = 20;
42 |
43 | private static final int DEFAULT_MOVE_DISTANCE_TO_TRIGGER = 30;
44 |
45 | private static final int DEFAULT_DURATION = 250;
46 |
47 | private static final int MAX_CLICK_TIME = 300;
48 |
49 | private static float MAX_CLICK_DISTANCE = 5;
50 |
51 | private float mDensity;
52 |
53 | private float mTitleBarHeightNoDisplay;
54 |
55 | private float mTitleBarHeightDisplay;
56 |
57 | private VelocityTracker mVelocityTracker;
58 |
59 | private float mMarginTop;
60 |
61 | private float deltaY;
62 |
63 | private int whichCardOnTouch = -1;
64 |
65 | private float downY;
66 |
67 | private float firstDownY;
68 |
69 | private float firstDownX;
70 |
71 | private boolean isTouchOnCard = false;
72 |
73 | private int mChildCount;
74 |
75 | private boolean isDisplaying = false;
76 |
77 | private Interpolator mOpenAnimatorInterpolator = new AccelerateInterpolator();
78 |
79 | private Interpolator mCloseAnimatorInterpolator = new AccelerateInterpolator();
80 |
81 | private float mMoveDistanceToTrigger;
82 |
83 | private int mDisplayingCard = -1;
84 |
85 | private int mMaxVelocity;
86 |
87 | private int mMinVelocity;
88 |
89 | private boolean isDragging = false;
90 |
91 | private float xVelocity;
92 |
93 | private float yVelocity;
94 |
95 | private OnDisplayOrHideListener mOnDisplayOrHideListener;
96 |
97 | private int mDuration;
98 |
99 | private boolean isAnimating = false;
100 |
101 | private DarkFrameLayout mDarkFrameLayout;
102 |
103 | private boolean isFade;
104 |
105 | private int mTouchSlop;
106 |
107 | private long mPressStartTime;
108 |
109 | private boolean mBoundary;
110 |
111 | private float mTouchingViewOriginY;
112 |
113 | private Context mContext;
114 |
115 | private int mBackgroundRid;
116 |
117 | public MultiCardMenu(Context context) {
118 | this(context, null);
119 | }
120 |
121 | public MultiCardMenu(Context context, AttributeSet attrs) {
122 | this(context, attrs,0);
123 | }
124 |
125 | public MultiCardMenu(Context context, AttributeSet attrs, int defStyleAttr) {
126 | super(context, attrs, defStyleAttr);
127 | mContext = context;
128 | ViewConfiguration vc = ViewConfiguration.get(mContext);
129 | mMaxVelocity = vc.getScaledMaximumFlingVelocity();
130 | mMinVelocity = vc.getScaledMinimumFlingVelocity() * 8;
131 | mTouchSlop = vc.getScaledTouchSlop();
132 | mDensity = mContext.getResources().getDisplayMetrics().density;
133 | TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.MultiCardMenu, defStyleAttr, 0);
134 | MAX_CLICK_DISTANCE = mTitleBarHeightNoDisplay = a.getDimension(R.styleable.MultiCardMenu_title_bar_height_no_display,dip2px(DEFAULT_TITLE_BAR_HEIGHT_NO_DISPLAY));
135 | mTitleBarHeightDisplay = a.getDimension(R.styleable.MultiCardMenu_title_bar_height_display, dip2px(DEFAULT_TITLE_BAR_HEIGHT_DISPLAY));
136 | mMarginTop = a.getDimension(R.styleable.MultiCardMenu_margin_top, dip2px(DEFAULT_CARD_MARGIN_TOP));
137 | mMoveDistanceToTrigger = a.getDimension(R.styleable.MultiCardMenu_move_distance_to_trigger,dip2px(DEFAULT_MOVE_DISTANCE_TO_TRIGGER));
138 | mBackgroundRid = a.getResourceId(R.styleable.MultiCardMenu_background_layout,-1);
139 | mDuration = a.getInt(R.styleable.MultiCardMenu_animator_duration,DEFAULT_DURATION);
140 | isFade = a.getBoolean(R.styleable.MultiCardMenu_fade,true);
141 | mBoundary = a.getBoolean(R.styleable.MultiCardMenu_boundary,false);
142 | a.recycle();
143 | initBackgroundView();
144 | }
145 |
146 | private void initBackgroundView() {
147 | if(mBackgroundRid == -1) {//transparent background
148 | mBackgroundRid = R.layout.multi_card_view_transparent_background_view;
149 | }
150 | mDarkFrameLayout = new DarkFrameLayout(mContext);
151 | mDarkFrameLayout.addView(LayoutInflater.from(mContext).inflate(mBackgroundRid, null));
152 | mDarkFrameLayout.setMultiCardMenu(this);
153 | addView(mDarkFrameLayout);
154 | }
155 |
156 | @Override
157 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
158 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
159 | measureChildren(widthMeasureSpec, heightMeasureSpec);
160 | }
161 |
162 | @Override
163 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
164 | if (DEBUG) {
165 | Log.i(TAG,"onLayout:" + changed);
166 | }
167 | if(!changed) {
168 | return;
169 | }
170 | mChildCount = getChildCount();
171 | View backgroundView = getChildAt(0);//background view
172 | backgroundView.layout(0, 0, backgroundView.getMeasuredWidth(), backgroundView.getMeasuredHeight());
173 | for(int i = 1; i < mChildCount; i ++) {
174 | View childView = getChildAt(i);
175 | int t = (int) (getMeasuredHeight() - (mChildCount - i)* mTitleBarHeightNoDisplay);
176 | childView.layout(0, t, childView.getMeasuredWidth(), childView.getMeasuredHeight() + t);
177 | }
178 |
179 | }
180 |
181 |
182 | @Override
183 | public boolean dispatchTouchEvent(MotionEvent event) {
184 | initVelocityTracker(event);
185 | boolean isDispatch = false;
186 | switch (event.getAction()){
187 | case MotionEvent.ACTION_DOWN:
188 | isDispatch = handleActionDown(event);
189 | break;
190 | case MotionEvent.ACTION_MOVE:
191 | handleActionMove(event);
192 | break;
193 | case MotionEvent.ACTION_CANCEL:
194 | case MotionEvent.ACTION_UP:
195 | handleActionUp(event);
196 | releaseVelocityTracker();
197 | break;
198 | }
199 | return isDispatch || super.dispatchTouchEvent(event);
200 | }
201 |
202 | private boolean handleActionDown(MotionEvent event) {
203 | boolean isConsume = false;
204 | mPressStartTime = System.currentTimeMillis();
205 | firstDownX = event.getX();
206 | firstDownY = downY = event.getY();
207 | int realChildCount = mChildCount - 1 ;//do not contain background view
208 | //Judge which card on touching
209 | if(!isDisplaying && downY > getMeasuredHeight() - mChildCount * mTitleBarHeightNoDisplay) {
210 | for(int i = 1; i <= mChildCount; i ++) {
211 | if(downY < (getMeasuredHeight() - mChildCount * mTitleBarHeightNoDisplay + mTitleBarHeightNoDisplay * i)) {
212 | whichCardOnTouch = i-1;
213 | isTouchOnCard = true;
214 | if(mOnDisplayOrHideListener != null)
215 | mOnDisplayOrHideListener.onTouchCard(whichCardOnTouch - 1);
216 | isConsume = true;
217 | break;
218 | }
219 | }
220 | mTouchingViewOriginY = getChildAt(whichCardOnTouch).getY();
221 | }else if(isDisplaying && downY > getMeasuredHeight() - (realChildCount - 1) * mTitleBarHeightDisplay) {
222 | hideCard(mDisplayingCard);
223 | }else if(isDisplaying && downY > mMarginTop && mDisplayingCard >= 0 && downY < getChildAt(mDisplayingCard).getMeasuredHeight() + mMarginTop) {
224 | whichCardOnTouch = mDisplayingCard;
225 | isTouchOnCard = true;
226 | if(DEBUG)Log.d(TAG,"whichCardOnTouch:" + whichCardOnTouch);
227 | }else if(isDisplaying && (downY < mMarginTop || (mDisplayingCard >= 0 && (downY > mMarginTop + getChildAt(mDisplayingCard).getMeasuredHeight())))) {
228 | hideCard(mDisplayingCard);
229 | }
230 |
231 | if(whichCardOnTouch == 0){
232 | isTouchOnCard = false;
233 | }
234 | return isConsume;
235 | }
236 |
237 | private void handleActionMove(MotionEvent event) {
238 | if(whichCardOnTouch == -1 || !isTouchOnCard)return;
239 | if(mDisplayingCard != -1 && canScrollInView((int) (firstDownY - event.getY()))){
240 | if(DEBUG)Log.d(TAG,"canScrollInView:" + true);
241 | return;
242 | }
243 | computeVelocity();
244 | if(Math.abs(yVelocity) < Math.abs(xVelocity)) return;
245 | if(!isDragging && Math.abs(event.getY() - firstDownY) > mTouchSlop
246 | && Math.abs(event.getX() - firstDownX) < mTouchSlop) {
247 | isDragging = true;
248 | downY = event.getY();
249 | }
250 |
251 | if(isDragging) {
252 | deltaY = event.getY() - downY;
253 | downY = event.getY();
254 | View touchingChildView = getChildAt(whichCardOnTouch);
255 | if(!mBoundary) {
256 | touchingChildView.offsetTopAndBottom((int) deltaY);
257 | }else {
258 | float touchingViewY = touchingChildView.getY();
259 | if(touchingViewY + deltaY <= mMarginTop) {
260 | touchingChildView.offsetTopAndBottom((int) (mMarginTop - touchingViewY));
261 | }else if(touchingViewY + deltaY >= mTouchingViewOriginY) {
262 | touchingChildView.offsetTopAndBottom((int) (mTouchingViewOriginY - touchingViewY));
263 | }else {
264 | touchingChildView.offsetTopAndBottom((int) deltaY);
265 | }
266 | }
267 | }
268 |
269 | }
270 |
271 | private void handleActionUp(MotionEvent event) {
272 | if(whichCardOnTouch == -1 || !isTouchOnCard) return;
273 | long pressDuration = System.currentTimeMillis() - mPressStartTime;
274 | computeVelocity();
275 | if(!isDisplaying && ((event.getY() - firstDownY < 0 && (Math.abs(event.getY() - firstDownY) > mMoveDistanceToTrigger))
276 | || (yVelocity < 0 && Math.abs(yVelocity) > mMinVelocity && Math.abs(yVelocity)> Math.abs(xVelocity))
277 | )){
278 | displayCard(whichCardOnTouch);
279 | }else if(!isDisplaying && pressDuration < MAX_CLICK_TIME && //means click
280 | distance(firstDownX,firstDownY,event.getX(),event.getY()) < MAX_CLICK_DISTANCE) {
281 | displayCard(whichCardOnTouch);
282 | }else if(!isDisplaying && isDragging && ((event.getY() - firstDownY > 0) || Math.abs(event.getY() - firstDownY) < mMoveDistanceToTrigger)) {
283 | hideCard(whichCardOnTouch);
284 | }else if(isDisplaying) {
285 | float currentY = getChildAt(mDisplayingCard).getY();
286 | if(currentY < mMarginTop || currentY < (mMarginTop + mMoveDistanceToTrigger)) {
287 | ObjectAnimator.ofFloat(getChildAt(mDisplayingCard), "y",
288 | currentY, mMarginTop)
289 | .setDuration(mDuration)
290 | .start();
291 | }else if(currentY > (mMarginTop + mMoveDistanceToTrigger)) {
292 | hideCard(mDisplayingCard);
293 | }
294 | }
295 | isTouchOnCard = false;
296 | deltaY = 0;
297 | isDragging = false;
298 | }
299 |
300 |
301 | /**
302 | * @param direction Positive to check scrolling up, negative to check
303 | * scrolling down.
304 | * @return true if need dispatch touch event to child view,otherwise
305 | */
306 | private boolean canScrollInView(int direction) {
307 | View view = getChildAt(whichCardOnTouch);
308 | if(view instanceof ViewGroup){
309 | View childView = findTopChildUnder((ViewGroup) view, firstDownX, firstDownY - mMarginTop);
310 | if(childView == null) return false;
311 | if(childView instanceof AbsListView){
312 | return absListViewCanScrollList((AbsListView)childView,direction);
313 | }else if(childView instanceof ScrollView) {
314 | return scrollViewCanScrollVertically((ScrollView) childView,direction);
315 | }
316 | }
317 | return false;
318 | }
319 |
320 | /**
321 | * Copy From AbsListView (API Level >= 19)
322 | * @param absListView AbsListView
323 | * @param direction Positive to check scrolling up, negative to check
324 | * scrolling down.
325 | * @return true if the list can be scrolled in the specified direction,
326 | * false otherwise
327 | */
328 | private boolean absListViewCanScrollList(AbsListView absListView,int direction) {
329 | final int childCount = absListView.getChildCount();
330 | if (childCount == 0) {
331 | return false;
332 | }
333 | final int firstPosition = absListView.getFirstVisiblePosition();
334 | if (direction > 0) {//can scroll down
335 | final int lastBottom = absListView.getChildAt(childCount - 1).getBottom();
336 | final int lastPosition = firstPosition + childCount;
337 | return lastPosition < absListView.getCount() || lastBottom > absListView.getHeight() - absListView.getPaddingTop();
338 | } else {//can scroll up
339 | final int firstTop = absListView.getChildAt(0).getTop();
340 | return firstPosition > 0 || firstTop < absListView.getPaddingTop();
341 | }
342 | }
343 |
344 | /**
345 | * Copy From ScrollView (API Level >= 14)
346 | * @param direction Positive to check scrolling up, negative to check
347 | * scrolling down.
348 | * @return true if the scrollView can be scrolled in the specified direction,
349 | * false otherwise
350 | */
351 | private boolean scrollViewCanScrollVertically(ScrollView scrollView,int direction) {
352 | final int offset = Math.max(0, scrollView.getScrollY());
353 | final int range = computeVerticalScrollRange(scrollView) - scrollView.getHeight();
354 | if (range == 0) return false;
355 | if (direction < 0) { //scroll up
356 | return offset > 0;
357 | } else {//scroll down
358 | return offset < range - 1;
359 | }
360 | }
361 |
362 | /**
363 | * Copy From ScrollView (API Level >= 14)
364 | * The scroll range of a scroll view is the overall height of all of its
365 | * children.
366 | */
367 | private int computeVerticalScrollRange(ScrollView scrollView) {
368 | final int count = scrollView.getChildCount();
369 | final int contentHeight = scrollView.getHeight() - scrollView.getPaddingBottom() - scrollView.getPaddingTop();
370 | if (count == 0) {
371 | return contentHeight;
372 | }
373 |
374 | int scrollRange = scrollView.getChildAt(0).getBottom();
375 | final int scrollY = scrollView.getScrollY();
376 | final int overScrollBottom = Math.max(0, scrollRange - contentHeight);
377 | if (scrollY < 0) {
378 | scrollRange -= scrollY;
379 | } else if (scrollY > overScrollBottom) {
380 | scrollRange += scrollY - overScrollBottom;
381 | }
382 |
383 | return scrollRange;
384 | }
385 |
386 | private void computeVelocity() {
387 | mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
388 | yVelocity = mVelocityTracker.getYVelocity();
389 | xVelocity = mVelocityTracker.getXVelocity();
390 | }
391 |
392 |
393 | @Override
394 | public boolean onInterceptTouchEvent(MotionEvent ev) {
395 | if(DEBUG)Log.i(TAG,"isDragging:" + isDragging);
396 | return isDragging;
397 | }
398 |
399 | @Override
400 | public boolean onTouchEvent(MotionEvent event) {
401 | return true;
402 | }
403 |
404 | public void show(int index) {
405 | if(index >= mChildCount) throw new IllegalArgumentException("Card Index Not Exist");
406 | if(index + 1 == mDisplayingCard || isDisplaying) return;
407 | displayCard(index + 1);
408 | }
409 |
410 | public void hide(int index) {
411 | if(index >= mChildCount) throw new IllegalArgumentException("Card Index Not Exist");
412 | if(index + 1 != mDisplayingCard || !isDisplaying) return;
413 | hideCard(index + 1);
414 | }
415 |
416 | public void setOnDisplayOrHideListener(OnDisplayOrHideListener onDisplayOrHideListener) {
417 | this.mOnDisplayOrHideListener = onDisplayOrHideListener;
418 | }
419 |
420 | public void setAnimatorInterpolator(Interpolator interpolator) {
421 | this.mOpenAnimatorInterpolator = interpolator;
422 | }
423 |
424 | /**
425 | *
426 | * @return less than 0 :No Display Card
427 | */
428 | public int getDisplayingCard() {
429 | return mDisplayingCard - 1;
430 | }
431 |
432 | public boolean isDisplaying() {
433 | return isDisplaying;
434 | }
435 |
436 | public void setBoundary(boolean boundary) {
437 | this.mBoundary = boundary;
438 | }
439 |
440 | public boolean isBoundary() {
441 | return mBoundary;
442 | }
443 |
444 | public boolean isFade() {
445 | return isFade;
446 | }
447 |
448 | public void setFade(boolean isFade) {
449 | this.isFade = isFade;
450 | }
451 |
452 | /**
453 | *
454 | * @return marginTop unit:dip
455 | */
456 | public int getMarginTop() {
457 | return px2dip(mMarginTop);
458 | }
459 |
460 | /**
461 | *
462 | * @param marginTop unit:dip
463 | */
464 | public void setMarginTop(int marginTop) {
465 | this.mMarginTop = dip2px(marginTop);
466 | }
467 |
468 | /**
469 | *
470 | * @return unit:dip
471 | */
472 | public int getTitleBarHeightNoDisplay() {
473 | return px2dip(mTitleBarHeightNoDisplay);
474 | }
475 |
476 | /**
477 | *
478 | * @param titleBarHeightNoDisplay unit:dip
479 | */
480 | public void setTitleBarHeightNoDisplay(int titleBarHeightNoDisplay) {
481 | this.mTitleBarHeightNoDisplay = dip2px(titleBarHeightNoDisplay);
482 | requestLayout();
483 | }
484 |
485 | /**
486 | *
487 | * @return unit:dip
488 | */
489 | public int getTitleBarHeightDisplay() {
490 | return px2dip(mTitleBarHeightDisplay);
491 | }
492 |
493 | /**
494 | *
495 | * @param titleBarHeightDisplay unit:dip
496 | */
497 | public void setTitleBarHeightDisplay(int titleBarHeightDisplay) {
498 | this.mTitleBarHeightDisplay = titleBarHeightDisplay;
499 | requestLayout();
500 | }
501 |
502 | /**
503 | *
504 | * @return unit:dip
505 | */
506 | public int getMoveDistanceToTrigger() {
507 | return px2dip(mMoveDistanceToTrigger);
508 | }
509 |
510 | /**
511 | *
512 | * @param moveDistanceToTrigger unit:dip
513 | */
514 | public void setMoveDistanceToTrigger(int moveDistanceToTrigger) {
515 | this.mMoveDistanceToTrigger = moveDistanceToTrigger;
516 | }
517 |
518 | public void setOpenAnimatorInterpolator(Interpolator interpolator) {
519 | this.mOpenAnimatorInterpolator = interpolator;
520 | }
521 |
522 | public void setCloseAnimatorInterpolator(Interpolator interpolator) {
523 | this.mCloseAnimatorInterpolator = interpolator;
524 | }
525 |
526 | public Interpolator getOpenAnimatorInterpolator() {
527 | return this.mOpenAnimatorInterpolator;
528 | }
529 |
530 | public Interpolator getCloseAnimatorInterpolator() {
531 | return this.mCloseAnimatorInterpolator;
532 | }
533 |
534 | public void setAnimatorDuration(int duration) {
535 | this.mDuration = duration;
536 | }
537 |
538 | public int getAnimatorDuration() {
539 | return this.mDuration;
540 | }
541 |
542 | private void initVelocityTracker(MotionEvent event) {
543 | if(mVelocityTracker == null) {
544 | mVelocityTracker = VelocityTracker.obtain();
545 | }
546 | mVelocityTracker.addMovement(event);
547 | }
548 |
549 | private void releaseVelocityTracker() {
550 | if(mVelocityTracker != null) {
551 | mVelocityTracker.clear();
552 | mVelocityTracker.recycle();
553 | mVelocityTracker = null;
554 | }
555 | }
556 |
557 | private double distance(float x1, float y1, float x2, float y2) {
558 | float deltaX = x2 - x1;
559 | float deltaY = y2 - y1;
560 | return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
561 | }
562 |
563 | private void displayCard(int which) {
564 | if(isDisplaying || isAnimating)return;
565 | final View displayingCard = getChildAt(which);
566 | if(isFade && mDarkFrameLayout != null) mDarkFrameLayout.fade(true);
567 | ArrayList animators = new ArrayList<>(mChildCount);
568 | final float distance = displayingCard.getY() - mMarginTop;
569 | ValueAnimator displayAnimator = ValueAnimator.ofFloat(displayingCard.getY(), mMarginTop)
570 | .setDuration(mDuration);
571 | displayAnimator.setTarget(displayingCard);
572 | displayAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
573 | @Override
574 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
575 | float value = (float) valueAnimator.getAnimatedValue();
576 | displayingCard.setY(value);
577 | if(mDarkFrameLayout != null && isFade) {
578 | mDarkFrameLayout.fade((int) ((1-(value - mMarginTop)/distance) * DarkFrameLayout.MAX_ALPHA));
579 | }
580 | }
581 | });
582 | animators.add(displayAnimator);
583 | int n = mChildCount - 1;
584 | for(int i = 1,j = 1; i < mChildCount; i++) {
585 | if(i != which){
586 | animators.add(ObjectAnimator
587 | .ofFloat(getChildAt(i), "y", getChildAt(i).getY(),
588 | getMeasuredHeight() - mTitleBarHeightDisplay * (n - j))
589 | .setDuration(mDuration));
590 | j ++;
591 | }
592 | }
593 | AnimatorSet set = new AnimatorSet();
594 | set.addListener(new Animator.AnimatorListener() {
595 | @Override
596 | public void onAnimationStart(Animator animator) {
597 | isAnimating = true;
598 | }
599 |
600 | @Override
601 | public void onAnimationEnd(Animator animator) {
602 | isAnimating = false;
603 | if(isFade) {
604 | mDarkFrameLayout.fade(DarkFrameLayout.MAX_ALPHA);
605 | }
606 |
607 | }
608 |
609 | @Override
610 | public void onAnimationCancel(Animator animator) {
611 | isAnimating = false;
612 | }
613 |
614 | @Override
615 | public void onAnimationRepeat(Animator animator) {
616 |
617 | }
618 | });
619 | set.setInterpolator(mOpenAnimatorInterpolator);
620 | set.playTogether(animators);
621 | set.start();
622 | isDisplaying = true;
623 | mDisplayingCard = which;
624 | if(mOnDisplayOrHideListener != null)
625 | mOnDisplayOrHideListener.onDisplay(which - 1);
626 | }
627 |
628 | private void hideCard(int which) {
629 | if(isAnimating)return;
630 | ArrayList animators = new ArrayList<>(mChildCount);
631 | final View displayingCard = getChildAt(which);
632 | int t = (int) (getMeasuredHeight() - (mChildCount - which)* mTitleBarHeightNoDisplay);
633 | ValueAnimator displayAnimator = ValueAnimator.ofFloat(displayingCard.getY(), t)
634 | .setDuration(mDuration);
635 | displayAnimator.setTarget(displayingCard);
636 | final int finalT = t;
637 | displayAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
638 | @Override
639 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
640 | float value = (float) valueAnimator.getAnimatedValue();
641 | displayingCard.setY(value);
642 | if(mDarkFrameLayout != null && isFade && value < finalT) {
643 | mDarkFrameLayout.fade((int) ((1 - value/ finalT) * DarkFrameLayout.MAX_ALPHA));
644 | }
645 | }
646 | });
647 | animators.add(displayAnimator);
648 | for(int i = 1; i < mChildCount; i ++) {
649 | if(i != which) {
650 | t = (int) (getMeasuredHeight() - (mChildCount - i) * mTitleBarHeightNoDisplay);
651 | animators.add(ObjectAnimator.ofFloat(getChildAt(i), "y", getChildAt(i).getY(), t).setDuration(mDuration));
652 | }
653 | }
654 | AnimatorSet set = new AnimatorSet();
655 | set.addListener(new Animator.AnimatorListener() {
656 | @Override
657 | public void onAnimationStart(Animator animator) {
658 | isAnimating = true;
659 | }
660 |
661 | @Override
662 | public void onAnimationEnd(Animator animator) {
663 | isAnimating = false;
664 | isDisplaying = false;
665 | if(isFade) {
666 | mDarkFrameLayout.fade(0);
667 | }
668 | }
669 |
670 | @Override
671 | public void onAnimationCancel(Animator animator) {
672 | isAnimating = false;
673 | isDisplaying = false;
674 | }
675 |
676 | @Override
677 | public void onAnimationRepeat(Animator animator) {
678 |
679 | }
680 | });
681 | set.setInterpolator(mCloseAnimatorInterpolator);
682 | set.playTogether(animators);
683 | set.start();
684 | mDisplayingCard = -1;
685 | if(mOnDisplayOrHideListener != null)
686 | mOnDisplayOrHideListener.onHide(which - 1);
687 | }
688 |
689 | private View findTopChildUnder(ViewGroup parentView,float x, float y) {
690 | final int childCount = parentView.getChildCount();
691 | for (int i = childCount - 1; i >= 0; i--) {
692 | final View child = parentView.getChildAt(i);
693 | if(DEBUG)Log.d(TAG,"findTopChildUnder:" + child.getTop() + ":" + child.getBottom());
694 | if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop() && y < child.getBottom()) {
695 | return child;
696 | }
697 | }
698 | return null;
699 | }
700 |
701 | @Override
702 | protected void onRestoreInstanceState(Parcelable state) {
703 | super.onRestoreInstanceState(state);
704 | Log.e(TAG,"onRestoreInstanceState");
705 | }
706 |
707 | private int px2dip(float pxVal) {
708 | return (int)(pxVal/mDensity + 0.5f);
709 | }
710 |
711 | private int dip2px(int dipVal) {
712 | return (int)(dipVal * mDensity + 0.5f);
713 | }
714 |
715 | public interface OnDisplayOrHideListener {
716 |
717 | void onDisplay(int which);
718 |
719 | void onHide(int which);
720 |
721 | void onTouchCard(int which);
722 |
723 | }
724 |
725 | }
726 |
--------------------------------------------------------------------------------
/multi-card-menu/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/multi-card-menu/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multi-card-menu/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/multi-card-menu/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multi-card-menu/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/multi-card-menu/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multi-card-menu/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/multi-card-menu/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/multi-card-menu/src/main/res/layout/multi_card_view_transparent_background_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/multi-card-menu/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/multi-card-menu/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | multi-card-menu
3 |
4 |
--------------------------------------------------------------------------------
/multi_card_menu_demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/multi_card_menu_demo.gif
--------------------------------------------------------------------------------
/multi_card_menu_demo_static.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wujingchao/MultiCardMenu/65669909f6afe77b801b50a096c25c77a9d25af4/multi_card_menu_demo_static.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':demo', ':multi-card-menu'
2 |
--------------------------------------------------------------------------------