├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── desnyki
│ │ └── infinitymenuexample
│ │ └── MainActivity.java
│ └── res
│ ├── drawable
│ ├── arrow_right.png
│ ├── bar.9.png
│ ├── ic_bug_report_white_3x.png
│ ├── ic_build_white_3x.png
│ ├── ic_code_white_3x.png
│ └── ic_credit_card_white_3x.png
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_main_relative.xml
│ └── my_menu_item.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── art
└── demo.gif
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── desnyki
│ │ └── library
│ │ └── infinitymenu
│ │ ├── ChildScrollView.java
│ │ ├── LayoutBase.java
│ │ └── RootScrollView.java
│ └── res
│ └── values
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | InfinityMenu
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
25 |
26 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Android API 19 Platform
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # InfinityMenu
2 |
3 | [](http://www.apache.org/licenses/LICENSE-2.0.html)
4 | [](https://jitpack.io/#desnyki/InfinityMenu)
5 | [](http://android-arsenal.com/details/1/4510)
6 |
7 | InfinityMenu is an Android Library implementing an accordion style menu. You can place any view with any size in the menu. To close the menu you can drag to close or tap outside the menu. You can have only one menu open at a time.
8 |
9 | Add it to your build.gradle with:
10 | ```gradle
11 | allprojects {
12 | repositories {
13 | maven { url "https://jitpack.io" }
14 | }
15 | }
16 | ```
17 | and:
18 |
19 | ```gradle
20 | dependencies {
21 | compile 'com.github.desnyki:InfinityMenu:1.0.3'
22 | }
23 | ```
24 |
25 | ![Demo][1]
26 |
27 |
28 |
29 |
30 | How to use:
31 |
32 | You can look at the sample app to see how to use this library in detail.
33 |
34 | In your layout create a FrameLayout which will hold the RootScrollView that contains the menu title bars. As well as the ChildScrollView that holds the menu item. It is important to set fillViewport for RootScrollView, and to set ChildScrollView as invisible.
35 |
36 | ```xml
37 |
40 |
46 |
47 |
53 |
54 |
55 | ```
56 |
57 | You can style and place menu title bars as children of the RootScrollView. If you want to animate the arrow like in the gif, you will need to have an element with tag "arrow" which will then spin 90 degrees based on state.
58 |
59 | ``` xml
60 |
62 |
72 |
73 |
74 | ```
75 | In your main Activity you will have to get a reference to both the ChildScrollView and RootScrollView as well as the bar views.
76 |
77 | ```java
78 | childScrollView.setBackgroundScrollView(rootScrollView);
79 | childScrollView.setCloseDistance(50);
80 |
81 | RelativeLayout bar1 = (RelativeLayout) findViewById(R.id.bar1);
82 | bar1.setOnClickListener(new View.OnClickListener() {
83 | @Override
84 | public void onClick(View view) {
85 | childScrollView.addView((LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null), 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
86 | childScrollView.openWithAnim(bar1,true,false);
87 | }
88 | });
89 | ```
90 |
91 | .openWithAnim(param 1: title bar object, param 2: is child full screen, param 3: do you want to show the title bar if full screen) is the call that opens your accordion.
92 |
93 |
94 | License
95 | -------
96 |
97 | Copyright 2016 Marcin Deszczynski
98 |
99 | Licensed under the Apache License, Version 2.0 (the "License");
100 | you may not use this file except in compliance with the License.
101 | You may obtain a copy of the License at
102 |
103 | http://www.apache.org/licenses/LICENSE-2.0
104 |
105 | Unless required by applicable law or agreed to in writing, software
106 | distributed under the License is distributed on an "AS IS" BASIS,
107 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
108 | See the License for the specific language governing permissions and
109 | limitations under the License.
110 |
111 |
112 | [1]: ./art/demo.gif
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.desnyki.infinitymenu"
9 | minSdkVersion 19
10 | targetSdkVersion 24
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 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:24.0.0'
26 | compile project(':library')
27 | }
28 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Program Files (x86)\Android\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/desnyki/infinitymenuexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.desnyki.infinitymenuexample;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.LinearLayout;
10 | import android.widget.RelativeLayout;
11 |
12 | import com.desnyki.library.infinitymenu.ChildScrollView;
13 | import com.desnyki.library.infinitymenu.RootScrollView;
14 |
15 | public class MainActivity extends AppCompatActivity {
16 |
17 | RelativeLayout bar1;
18 | RelativeLayout bar2;
19 | RelativeLayout bar3;
20 | RelativeLayout bar4;
21 | ChildScrollView childScrollView;
22 | RootScrollView rootScrollView;
23 | final LinearLayout[] childContainer = new LinearLayout[5]; //used to cache and access child views, no children have been hurt in this container
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_main_relative);
29 |
30 | rootScrollView = (RootScrollView) findViewById(R.id.menu_scroll_view);
31 | childScrollView = (ChildScrollView) findViewById(R.id.child_scroll_view);
32 |
33 | childScrollView.setBackgroundScrollView(rootScrollView);
34 | childScrollView.setCloseDistance(50);
35 |
36 | bar1 = (RelativeLayout) findViewById(R.id.bar1);
37 | childContainer[0]=(LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
38 | bar1.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View view) {
41 | childScrollView.addView(childContainer[0], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
42 | childScrollView.openWithAnim(bar1,true,false);
43 | }
44 | });
45 | bar2 = (RelativeLayout) findViewById(R.id.bar2);
46 | childContainer[1] = (LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
47 | bar2.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View view) {
50 | childScrollView.addView(childContainer[1], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
51 | childScrollView.openWithAnim(bar2, false, true);
52 | }
53 | });
54 | bar3 = (RelativeLayout) findViewById(R.id.bar3);
55 | childContainer[2] = (LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
56 | bar3.setOnClickListener(new View.OnClickListener() {
57 | @Override
58 | public void onClick(View view) {
59 | childScrollView.addView(childContainer[2], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
60 | childScrollView.openWithAnim(bar3, false, true);
61 | }
62 | // }
63 | });
64 | bar4 = (RelativeLayout) findViewById(R.id.bar4);
65 | childContainer[3] = (LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
66 | bar4.setOnClickListener(new View.OnClickListener() {
67 | @Override
68 | public void onClick(View view) {
69 | childScrollView.addView(childContainer[3], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
70 | childScrollView.openWithAnim(bar4, false, true);
71 | }
72 | });
73 |
74 |
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/arrow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/drawable/arrow_right.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bar.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/drawable/bar.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_bug_report_white_3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/drawable/ic_bug_report_white_3x.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_build_white_3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/drawable/ic_build_white_3x.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_code_white_3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/drawable/ic_code_white_3x.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_credit_card_white_3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/drawable/ic_credit_card_white_3x.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
19 |
24 |
27 |
37 |
47 |
58 |
59 |
62 |
73 |
83 |
95 |
96 |
97 |
100 |
111 |
121 |
133 |
134 |
137 |
148 |
158 |
170 |
171 |
172 |
173 |
180 |
181 |
182 |
183 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main_relative.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
19 |
24 |
27 |
37 |
47 |
58 |
59 |
63 |
74 |
84 |
96 |
97 |
98 |
102 |
113 |
123 |
135 |
136 |
140 |
151 |
161 |
173 |
174 |
175 |
176 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/my_menu_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF4081
4 | #212121
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | InfinityMenu
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/art/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/art/demo.gif
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.0'
9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/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/desnyki/InfinityMenu/0fa36fd8724e84c95929e2e065733134c8a24648/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | group='com.github.desnyki'
5 |
6 | android {
7 | compileSdkVersion 24
8 | buildToolsVersion "24.0.0"
9 |
10 | defaultConfig {
11 | minSdkVersion 19
12 | targetSdkVersion 24
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | // compile 'com.android.support:appcompat-v7:24.0.0'
27 | }
28 |
--------------------------------------------------------------------------------
/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 C:\Program Files (x86)\Android\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/library/src/main/java/com/desnyki/library/infinitymenu/ChildScrollView.java:
--------------------------------------------------------------------------------
1 | package com.desnyki.library.infinitymenu;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.ScrollView;
7 |
8 | /**
9 | * Created by MDeszczynski on 08/07/2016.
10 | */
11 | public class ChildScrollView extends LayoutBase {
12 |
13 | public ChildScrollView(Context context) {
14 | this(context, null);
15 | }
16 |
17 | public ChildScrollView(Context context, AttributeSet attrs) {
18 | this(context, attrs, 0);
19 | }
20 |
21 | public ChildScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
22 | super(context, attrs, defStyleAttr);
23 | }
24 |
25 | @Override
26 | protected ScrollView createDragableView(Context context, AttributeSet attrs) {
27 | return new ScrollView(context);
28 | }
29 |
30 | @Override
31 | protected boolean isReadyForDragStart() {
32 | return mDragableView.getScrollY() == 0;
33 | }
34 |
35 | @Override
36 | protected boolean isReadyForDragEnd() {
37 | View scrollViewChild = mDragableView.getChildAt(0);
38 | return null != scrollViewChild && mDragableView.getScrollY()
39 | >= (scrollViewChild.getHeight() - getHeight());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/com/desnyki/library/infinitymenu/LayoutBase.java:
--------------------------------------------------------------------------------
1 | package com.desnyki.library.infinitymenu;
2 |
3 | import android.animation.AnimatorSet;
4 | import android.animation.ObjectAnimator;
5 | import android.content.Context;
6 | import android.os.Build;
7 | import android.util.AttributeSet;
8 | import android.util.DisplayMetrics;
9 | import android.util.Log;
10 | import android.util.Property;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.view.animation.DecelerateInterpolator;
15 | import android.view.animation.Interpolator;
16 | import android.widget.FrameLayout;
17 | import android.widget.ImageView;
18 | import android.widget.LinearLayout;
19 | import android.widget.RelativeLayout;
20 | import android.widget.ScrollView;
21 |
22 | /**
23 | * Created by MDeszczynski on 06/07/2016.
24 | */
25 | public abstract class LayoutBase extends FrameLayout {
26 |
27 | public final static int LINEAR_PARAMS = 1;
28 | public final static int RELATIVE_PARAMS = 2;
29 |
30 | public static final String ARROW = "arrow";
31 |
32 | private View topView;
33 | private RootScrollView mScrollView;
34 | private ViewGroup.LayoutParams layoutParams;
35 | private LinearLayout.LayoutParams linearLayoutParams;
36 | private RelativeLayout.LayoutParams relativeLayoutParams;
37 | private View bottomView;
38 | private int params = 0;
39 | private int heightRange;
40 | private int beginBottomMargin;
41 | private int beginScrollY, endScrollY;
42 | private ObjectAnimator mHeightAnimator;
43 | private ObjectAnimator mScrollYAnimator;
44 | private int ANIMDURA = 300;
45 | private AnimatorSet animatorSet = new AnimatorSet();
46 | boolean isAnimating = false;
47 | boolean fullScreen = false;
48 | private int paddingTop;
49 | private int paddingBottom;
50 | private int paddingLeft;
51 | private int paddingRight;
52 | private DisplayMetrics displayMetrics;
53 |
54 | private Runnable showRunnable = new Runnable() {
55 | @Override
56 | public void run() {
57 | animate().alpha(1.0f).setDuration(100);
58 |
59 | isAnimating = false;
60 | }
61 | };
62 |
63 | private Runnable hideRunnable = new Runnable() {
64 | @Override
65 | public void run() {
66 | setVisibility(View.INVISIBLE);
67 | mHeightAnimator.setIntValues(heightRange, beginBottomMargin);
68 | mScrollYAnimator.setIntValues(mScrollView.getScrollY(), beginScrollY);
69 | ImageView arrow = (ImageView) topView.findViewWithTag(ARROW);
70 | if (arrow != null)
71 | arrow.animate().rotation(0f);
72 | animatorSet.start();
73 | postDelayed(new Runnable() {
74 | @Override
75 | public void run() {
76 | ((ViewGroup) topView.getParent()).removeView(bottomView);
77 | isAnimating = false;
78 | ((ScrollView) getChildAt(0)).getChildAt(0).setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); //reset padding
79 | }
80 | }, ANIMDURA + 10);
81 | }
82 | };
83 |
84 | private Interpolator mInterpolator = new DecelerateInterpolator();
85 | private int mHeight = 0;
86 | private int iScrollY;
87 | protected T mDragableView;
88 |
89 | public LayoutBase(Context context) {
90 | this(context, null);
91 | }
92 |
93 | public LayoutBase(Context context, AttributeSet attrs) {
94 | this(context, attrs, 0);
95 | }
96 |
97 | public LayoutBase(Context context, AttributeSet attrs, int defStyleAttr) {
98 | super(context, attrs, defStyleAttr);
99 |
100 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
101 | this.setLayerType(View.LAYER_TYPE_HARDWARE, null);
102 | }
103 |
104 | mHeightAnimator = ObjectAnimator.ofInt(this, aHeight, 0, 0);
105 | mScrollYAnimator = ObjectAnimator.ofInt(this, aScrollY, 0, 0);
106 | mHeightAnimator.setDuration(ANIMDURA);
107 | mScrollYAnimator.setDuration(ANIMDURA);
108 | animatorSet.playTogether(mHeightAnimator, mScrollYAnimator);
109 | animatorSet.setInterpolator(mInterpolator);
110 | mDragableView = createDragableView(context, attrs);
111 |
112 | addDragableView(mDragableView);
113 | }
114 |
115 | @Override
116 | public void addView(View child, int index, ViewGroup.LayoutParams params) {
117 | if (isOpen() | isAnimating)
118 | return;
119 |
120 | final T refreshableView = getDragableView();
121 | displayMetrics = getResources().getDisplayMetrics();
122 |
123 | if (child == refreshableView) {
124 | super.addView(child, index, params);
125 | return;
126 | }
127 |
128 | if (refreshableView instanceof ViewGroup) {
129 | ((ViewGroup) refreshableView).removeAllViews(); // will break if view isn t scrollview
130 | ((ViewGroup) refreshableView).addView(child, index, params);
131 | } else {
132 | throw new UnsupportedOperationException("Draggable View is not a ViewGroup");
133 | }
134 | }
135 |
136 | public void setBackgroundScrollView(RootScrollView scrollView) {
137 | mScrollView = scrollView;
138 | mScrollView.setOnTouchListener(new OnTouchListener() {
139 | @Override
140 | public boolean onTouch(View view, MotionEvent motionEvent) {
141 |
142 | final int action = motionEvent.getAction();
143 |
144 | switch (action) {
145 | case MotionEvent.ACTION_DOWN:
146 | handleRootViewTouch();
147 | }
148 | return true;
149 | }
150 | });
151 | }
152 |
153 | private boolean mIsBeingDragged = false;
154 | private float mLastMotionX, mLastMotionY;
155 | private float mInitialMotionY;
156 |
157 | private enum Mode {
158 | PULL_FROM_START(0x1),
159 | PULL_FROM_END(0x2),
160 | BOTH(0x3);
161 | private int mIntValue;
162 |
163 | Mode(int modeInt) {
164 | mIntValue = modeInt;
165 | }
166 |
167 | static Mode getDefault() {
168 | return BOTH;
169 | }
170 | }
171 |
172 | private Mode mMode = Mode.getDefault();
173 | private Mode mCurrentMode;
174 | static final float FRICTION = 2.0f;
175 | private SmoothScrollRunnable mCurrentSmoothScrollRunnable;
176 | private int closeDistance = dp2px(60);
177 | private boolean shouldRollback;
178 | private Interpolator mScrollAnimationInterpolator = new DecelerateInterpolator();
179 | private boolean xDrag = false;
180 |
181 | @Override
182 | public boolean onInterceptTouchEvent(MotionEvent ev) {
183 | if (isAnimating) {
184 | return false;
185 | }
186 |
187 | final int action = ev.getAction();
188 |
189 | if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
190 | if ((ev.getY() < topView.getMeasuredHeight() || ev.getY() > ((ScrollView) getChildAt(0)).getChildAt(0).getMeasuredHeight()) & !xDrag & !fullScreen) {
191 | closeWithAnim();
192 | }
193 | xDrag = false;
194 | mIsBeingDragged = false;
195 | return false;
196 | }
197 |
198 | if (action != MotionEvent.ACTION_DOWN && mIsBeingDragged) {
199 | return true;
200 | }
201 |
202 | switch (action) {
203 | case MotionEvent.ACTION_DOWN:
204 | if (isReadyForPull()) {
205 | mLastMotionY = mInitialMotionY = ev.getY();
206 | mLastMotionX = ev.getX();
207 | mIsBeingDragged = false;
208 | }
209 | break;
210 | case MotionEvent.ACTION_MOVE:
211 | if (isReadyForPull()) {
212 | final float y = ev.getY(), x = ev.getX();
213 | final float diff, oppositeDiff, absDiff;
214 |
215 | diff = y - mLastMotionY;
216 | oppositeDiff = x - mLastMotionX;
217 | absDiff = Math.abs(diff);
218 | if (Math.abs(oppositeDiff) > 3) {
219 | xDrag = true;
220 | }
221 | if ((absDiff > Math.abs(oppositeDiff))) {
222 | if ((diff >= 4f) && isReadyForDragStart()) {
223 | mLastMotionY = y;
224 | mLastMotionX = x;
225 | mIsBeingDragged = true;
226 | if (mMode == Mode.BOTH) {
227 | mCurrentMode = Mode.PULL_FROM_START;
228 | }
229 | } else if ((diff <= -4f) && isReadyForDragEnd()) {
230 | mLastMotionY = y;
231 | mLastMotionX = x;
232 | mIsBeingDragged = true;
233 | if (mMode == Mode.BOTH) {
234 | mCurrentMode = Mode.PULL_FROM_END;
235 | }
236 | }
237 | }
238 | }
239 | break;
240 | }
241 | return mIsBeingDragged;
242 | }
243 |
244 | @Override
245 | public boolean onTouchEvent(MotionEvent event) {
246 |
247 | switch (event.getAction()) {
248 | case MotionEvent.ACTION_MOVE:
249 | if (mIsBeingDragged) {
250 | mLastMotionY = event.getY();
251 | mLastMotionX = event.getX();
252 | pullEvent();
253 | return true;
254 | }
255 | break;
256 | case MotionEvent.ACTION_DOWN: {
257 | if (isReadyForPull()) {
258 | mLastMotionY = mInitialMotionY = event.getY();
259 | mLastMotionX = event.getX();
260 | return true;
261 | }
262 | break;
263 | }
264 | case MotionEvent.ACTION_CANCEL:
265 | case MotionEvent.ACTION_UP: {
266 | xDrag = false;
267 | if (mIsBeingDragged) {
268 | mIsBeingDragged = false;
269 | smoothScrollTo(0, 200, 0);
270 | prevOffSetY = 0;
271 |
272 | return true;
273 | }
274 | break;
275 | }
276 | }
277 | return false;
278 | }
279 |
280 | private void pullEvent() {
281 | final int newScrollValue;
282 | final float initialMotionValue, lastMotionValue;
283 | initialMotionValue = mInitialMotionY;
284 | lastMotionValue = mLastMotionY;
285 |
286 | switch (mCurrentMode) {
287 | case PULL_FROM_END:
288 | newScrollValue = Math.round(Math.max(initialMotionValue - lastMotionValue, 0) / FRICTION);
289 | break;
290 | case PULL_FROM_START:
291 | default:
292 | newScrollValue = Math.round(Math.min(initialMotionValue - lastMotionValue, 0) / FRICTION);
293 | break;
294 | }
295 | moveContent(newScrollValue);
296 | }
297 |
298 | private void smoothScrollTo(int newScrollValue, long duration, long delayMillis) {
299 | if (null != mCurrentSmoothScrollRunnable) {
300 | mCurrentSmoothScrollRunnable.stop();
301 | }
302 | final int oldScrollValue;
303 | oldScrollValue = getScrollY();
304 | if (oldScrollValue < -closeDistance || oldScrollValue > closeDistance) {
305 | closeWithAnim();
306 | delayMillis = 100;
307 | switch (mCurrentMode) {
308 | case PULL_FROM_END:
309 | shouldRollback = true;
310 | break;
311 | case PULL_FROM_START:
312 | shouldRollback = false;
313 | default:
314 | break;
315 | }
316 | } else {
317 | shouldRollback = true;
318 | }
319 |
320 | if (oldScrollValue != newScrollValue) {
321 | mCurrentSmoothScrollRunnable = new SmoothScrollRunnable(oldScrollValue, newScrollValue, duration);
322 | if (delayMillis > 0) {
323 | postDelayed(mCurrentSmoothScrollRunnable, delayMillis);
324 | } else {
325 | post(mCurrentSmoothScrollRunnable);
326 | }
327 | }
328 | }
329 |
330 | private int realOffsetY;
331 | private int prevOffSetY = 0;
332 | private int dy;
333 | int prevScrollY = 0;
334 |
335 | private int moveContent(int offsetY) {
336 |
337 | realOffsetY = (int) (offsetY / 1.4f);
338 | dy = prevOffSetY - realOffsetY;
339 |
340 | if (mScrollView.getScrollY() != 0) {
341 | scrollTo(0, realOffsetY);
342 | prevOffSetY = realOffsetY;
343 |
344 | }
345 | prevScrollY = mScrollView.getScrollY();
346 | mScrollView.scrollBy(0, -dy);
347 | mScrollView.invalidate();
348 | return realOffsetY;
349 | }
350 |
351 | private boolean isReadyForPull() {
352 | switch (mMode) {
353 | case PULL_FROM_START:
354 | return isReadyForDragStart();
355 | case PULL_FROM_END:
356 | return isReadyForDragEnd();
357 | case BOTH:
358 | return isReadyForDragEnd() || isReadyForDragStart();
359 | default:
360 | return false;
361 | }
362 | }
363 |
364 | final class SmoothScrollRunnable implements Runnable {
365 | private final Interpolator mInterpolator;
366 | private final int mScrollToY;
367 | private final int mScrollFromY;
368 | private final long mDuration;
369 |
370 | private boolean mContinueRunning = true;
371 | private long mStartTime = -1;
372 | private int mCurrentY = -1;
373 | private int PrevY = 0;
374 | private int offsetY = 0;
375 |
376 | public SmoothScrollRunnable(int fromY, int toY, long duration) {
377 | mScrollFromY = fromY;
378 | mScrollToY = toY;
379 | mInterpolator = mScrollAnimationInterpolator;
380 | mDuration = duration;
381 | }
382 |
383 | @Override
384 | public void run() {
385 | if (mStartTime == -1) {
386 | mStartTime = System.currentTimeMillis();
387 | } else {
388 | long normalizedTime = (1000 * (System.currentTimeMillis() - mStartTime)) / mDuration;
389 | normalizedTime = Math.max(Math.min(normalizedTime, 1000), 0);
390 |
391 | final int deltaY = Math.round((mScrollFromY - mScrollToY)
392 | * mInterpolator.getInterpolation(normalizedTime / 1000f));
393 | mCurrentY = mScrollFromY - deltaY;
394 |
395 | if (PrevY == 0) { /*the PrevY will be 0 at first time */
396 | PrevY = mScrollFromY;
397 | }
398 |
399 | offsetY = PrevY - mCurrentY;
400 | PrevY = mCurrentY;
401 |
402 | scrollTo(0, mCurrentY);
403 |
404 | if (shouldRollback) {
405 | mScrollView.scrollBy(0, -offsetY);
406 | }
407 | }
408 |
409 | if (mContinueRunning && mScrollToY != mCurrentY) {
410 | LayoutBase.this.postDelayed(this, 17);
411 | }
412 | }
413 |
414 | public void stop() {
415 | mContinueRunning = false;
416 | removeCallbacks(this);
417 | }
418 | }
419 |
420 | public void setCloseDistance(int dp) {
421 | closeDistance = dp2px(dp);
422 | }
423 |
424 | public void openWithAnim(final View topView, final boolean fullScreen, final boolean showTitle) {
425 |
426 | if (isOpen()) {
427 | closeWithAnim();
428 | }
429 |
430 | if (isAnimating)
431 | return;
432 |
433 | this.topView = topView;
434 | this.fullScreen = fullScreen;
435 |
436 | isAnimating = true;
437 |
438 | bottomView = new View(getContext());
439 |
440 | layoutParams = topView.getLayoutParams();
441 |
442 | if (layoutParams instanceof LinearLayout.LayoutParams) {
443 | LinearLayout.LayoutParams myParams = new LinearLayout.LayoutParams(0, 0);
444 | myParams.setMargins(0, displayMetrics.heightPixels, 0, 0);
445 | bottomView.setLayoutParams(myParams);
446 | params = LINEAR_PARAMS;
447 | linearLayoutParams = (LinearLayout.LayoutParams) layoutParams;
448 | beginBottomMargin = linearLayoutParams.bottomMargin;
449 | ((LinearLayout) topView.getParent()).addView(bottomView);
450 | } else if (layoutParams instanceof RelativeLayout.LayoutParams) {
451 | RelativeLayout.LayoutParams myParams = new RelativeLayout.LayoutParams(0, 0);
452 | myParams.setMargins(0, displayMetrics.heightPixels * 2, 0, 0);
453 | bottomView.setLayoutParams(myParams);
454 | params = RELATIVE_PARAMS;
455 | relativeLayoutParams = (RelativeLayout.LayoutParams) layoutParams;
456 | beginBottomMargin = relativeLayoutParams.bottomMargin;
457 | ((RelativeLayout) topView.getParent()).addView(bottomView);
458 | } else {
459 | Log.e("error", "topView's parent should be linearlayout or relativelayout");
460 | return;
461 | }
462 |
463 | if (animatorSet.isRunning()) {
464 | animatorSet.cancel();
465 | }
466 |
467 | post(new Runnable() {
468 | @Override
469 | public void run() {
470 | setVisibility(View.VISIBLE);
471 | setAlpha(0.0f);
472 |
473 | if (fullScreen) {
474 | heightRange = mScrollView.getHeight();
475 | beginBottomMargin = 0;
476 | } else {
477 | heightRange = ((ScrollView) getChildAt(0)).getChildAt(0).getMeasuredHeight();
478 | }
479 |
480 | if (showTitle) {
481 | endScrollY = topView.getTop();
482 | paddingTop = ((ScrollView) getChildAt(0)).getChildAt(0).getPaddingTop();
483 | paddingBottom = ((ScrollView) getChildAt(0)).getChildAt(0).getPaddingBottom();
484 | paddingLeft = ((ScrollView) getChildAt(0)).getChildAt(0).getPaddingLeft();
485 | paddingRight = ((ScrollView) getChildAt(0)).getChildAt(0).getPaddingRight();
486 | ((ScrollView) getChildAt(0)).getChildAt(0).setPadding(paddingLeft, paddingTop + topView.getHeight(), paddingRight, paddingBottom);
487 | } else {
488 | ((LayoutParams) getLayoutParams()).topMargin = 0;
489 | endScrollY = topView.getBottom();
490 | }
491 |
492 | mHeightAnimator.setIntValues(beginBottomMargin, heightRange);
493 | beginScrollY = mScrollView.getScrollY();
494 | mScrollYAnimator.setIntValues(beginScrollY, endScrollY);
495 | animatorSet.start();
496 | ImageView arrow = (ImageView) topView.findViewWithTag(ARROW);
497 | if (arrow != null)
498 | arrow.animate().rotation(90f);
499 | postDelayed(showRunnable, ANIMDURA);
500 | }
501 | });
502 | }
503 |
504 | public void closeWithAnim() {
505 | if (!isOpen())
506 | return;
507 |
508 | isAnimating = true;
509 |
510 | if (animatorSet.isRunning()) {
511 | animatorSet.cancel();
512 | }
513 |
514 | postDelayed(hideRunnable, 100);
515 |
516 | animate().alpha(0f).setDuration(100);
517 | }
518 |
519 | private void handleRootViewTouch() {
520 | if (isOpen()) {
521 | closeWithAnim();
522 | }
523 | }
524 |
525 | private Property aHeight = new Property(Integer.class, "mHeight") {
526 | @Override
527 | public Integer get(LayoutBase object) {
528 | return object.mHeight;
529 | }
530 |
531 | @Override
532 | public void set(LayoutBase object, Integer value) {
533 | object.mHeight = value;
534 | heightChangeAnim();
535 | }
536 | };
537 | private Property aScrollY = new Property(Integer.class, "iScrollY") {
538 | @Override
539 | public Integer get(LayoutBase object) {
540 | return object.iScrollY;
541 | }
542 |
543 | @Override
544 | public void set(LayoutBase object, Integer value) {
545 | object.iScrollY = value;
546 | scrollYChangeAnim();
547 | }
548 | };
549 |
550 | private void heightChangeAnim() {
551 | switch (params) {
552 | case LINEAR_PARAMS:
553 | linearLayoutParams.bottomMargin = mHeight;
554 | break;
555 | case RELATIVE_PARAMS:
556 | relativeLayoutParams.bottomMargin = mHeight;
557 | }
558 |
559 | if (topView != null)
560 | topView.setLayoutParams(layoutParams);
561 | }
562 |
563 | private void scrollYChangeAnim() {
564 | mScrollView.scrollTo(0, iScrollY);
565 | mScrollView.invalidate();
566 | }
567 |
568 | public final T getDragableView() {
569 | return mDragableView;
570 | }
571 |
572 | protected abstract T createDragableView(Context context, AttributeSet attrs);
573 |
574 | protected abstract boolean isReadyForDragStart();
575 |
576 | protected abstract boolean isReadyForDragEnd();
577 |
578 | private void addDragableView(T DragableView) {
579 | addView(DragableView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
580 | }
581 |
582 | private int dp2px(float dp) {
583 | return (int) (dp * getContext().getResources().getDisplayMetrics().density + 0.5f);
584 | }
585 |
586 | public boolean isOpen() {
587 | return getVisibility() == View.VISIBLE;
588 | }
589 |
590 | public boolean isAnimating(){
591 | return isAnimating;
592 | }
593 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/desnyki/library/infinitymenu/RootScrollView.java:
--------------------------------------------------------------------------------
1 | package com.desnyki.library.infinitymenu;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.util.AttributeSet;
6 | import android.widget.ScrollView;
7 |
8 | /**
9 | * Created by MDeszczynski on 06/07/2016.
10 | */
11 | public class RootScrollView extends ScrollView {
12 |
13 | private final static String TAG = "RootScrollView";
14 | private boolean mTouchable = true;
15 |
16 |
17 | public RootScrollView(Context context) {
18 | this(context,null);
19 | }
20 |
21 | public RootScrollView(Context context, AttributeSet attrs) {
22 | this(context,attrs,0);
23 | }
24 |
25 | public RootScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
26 | super(context, attrs, defStyleAttr);
27 | }
28 |
29 | @Override
30 | protected void dispatchDraw(Canvas canvas) {
31 | super.dispatchDraw(canvas);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------