├── .gitignore
├── .gradle
└── 1.6
│ └── taskArtifacts
│ ├── cache.properties
│ ├── cache.properties.lock
│ ├── fileHashes.bin
│ ├── fileSnapshots.bin
│ ├── outputFileStates.bin
│ └── taskArtifacts.bin
├── AndroidManifest.xml
├── LICENSE
├── README.md
├── build.gradle
├── gradle
└── wrapper
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── proguard-project.txt
├── project.properties
├── res
├── drawable-xhdpi
│ └── ic_launcher.png
├── layout
│ ├── activity_horizontal.xml
│ ├── activity_main.xml
│ ├── activity_youtube.xml
│ └── listitem_simple.xml
├── menu
│ └── main.xml
├── values-sw600dp
│ └── dimens.xml
├── values-sw720dp-land
│ └── dimens.xml
├── values-v11
│ └── styles.xml
├── values-v14
│ └── styles.xml
└── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── src
└── tree
└── love
└── draglayout
├── HorizontalDragActivity.java
├── MainActivity.java
├── YoutubeActivity.java
└── drag
├── DragLayout.java
└── YoutubeLayout.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 |
15 | # Local configuration file (sdk path, etc)
16 | local.properties
17 |
18 | # Eclipse project files
19 | .classpath
20 | .project
21 |
--------------------------------------------------------------------------------
/.gradle/1.6/taskArtifacts/cache.properties:
--------------------------------------------------------------------------------
1 | #Sat Aug 31 11:08:27 CST 2013
2 |
--------------------------------------------------------------------------------
/.gradle/1.6/taskArtifacts/cache.properties.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gradle/1.6/taskArtifacts/fileHashes.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuyexiong/android-youtube-drag-layout/11ff8d0562fc1f883d02fcd9dcba54d75edeed58/.gradle/1.6/taskArtifacts/fileHashes.bin
--------------------------------------------------------------------------------
/.gradle/1.6/taskArtifacts/fileSnapshots.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuyexiong/android-youtube-drag-layout/11ff8d0562fc1f883d02fcd9dcba54d75edeed58/.gradle/1.6/taskArtifacts/fileSnapshots.bin
--------------------------------------------------------------------------------
/.gradle/1.6/taskArtifacts/outputFileStates.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuyexiong/android-youtube-drag-layout/11ff8d0562fc1f883d02fcd9dcba54d75edeed58/.gradle/1.6/taskArtifacts/outputFileStates.bin
--------------------------------------------------------------------------------
/.gradle/1.6/taskArtifacts/taskArtifacts.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuyexiong/android-youtube-drag-layout/11ff8d0562fc1f883d02fcd9dcba54d75edeed58/.gradle/1.6/taskArtifacts/taskArtifacts.bin
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction, and
10 | distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright
13 | owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all other entities
16 | that control, are controlled by, or are under common control with that entity.
17 | For the purposes of this definition, "control" means (i) the power, direct or
18 | indirect, to cause the direction or management of such entity, whether by
19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20 | outstanding shares, or (iii) beneficial ownership of such entity.
21 |
22 | "You" (or "Your") shall mean an individual or Legal Entity exercising
23 | permissions granted by this License.
24 |
25 | "Source" form shall mean the preferred form for making modifications, including
26 | but not limited to software source code, documentation source, and configuration
27 | files.
28 |
29 | "Object" form shall mean any form resulting from mechanical transformation or
30 | translation of a Source form, including but not limited to compiled object code,
31 | generated documentation, and conversions to other media types.
32 |
33 | "Work" shall mean the work of authorship, whether in Source or Object form, made
34 | available under the License, as indicated by a copyright notice that is included
35 | in or attached to the work (an example is provided in the Appendix below).
36 |
37 | "Derivative Works" shall mean any work, whether in Source or Object form, that
38 | is based on (or derived from) the Work and for which the editorial revisions,
39 | annotations, elaborations, or other modifications represent, as a whole, an
40 | original work of authorship. For the purposes of this License, Derivative Works
41 | shall not include works that remain separable from, or merely link (or bind by
42 | name) to the interfaces of, the Work and Derivative Works thereof.
43 |
44 | "Contribution" shall mean any work of authorship, including the original version
45 | of the Work and any modifications or additions to that Work or Derivative Works
46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work
47 | by the copyright owner or by an individual or Legal Entity authorized to submit
48 | on behalf of the copyright owner. For the purposes of this definition,
49 | "submitted" means any form of electronic, verbal, or written communication sent
50 | to the Licensor or its representatives, including but not limited to
51 | communication on electronic mailing lists, source code control systems, and
52 | issue tracking systems that are managed by, or on behalf of, the Licensor for
53 | the purpose of discussing and improving the Work, but excluding communication
54 | that is conspicuously marked or otherwise designated in writing by the copyright
55 | owner as "Not a Contribution."
56 |
57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58 | of whom a Contribution has been received by Licensor and subsequently
59 | incorporated within the Work.
60 |
61 | 2. Grant of Copyright License.
62 |
63 | Subject to the terms and conditions of this License, each Contributor hereby
64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65 | irrevocable copyright license to reproduce, prepare Derivative Works of,
66 | publicly display, publicly perform, sublicense, and distribute the Work and such
67 | Derivative Works in Source or Object form.
68 |
69 | 3. Grant of Patent License.
70 |
71 | Subject to the terms and conditions of this License, each Contributor hereby
72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73 | irrevocable (except as stated in this section) patent license to make, have
74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75 | such license applies only to those patent claims licensable by such Contributor
76 | that are necessarily infringed by their Contribution(s) alone or by combination
77 | of their Contribution(s) with the Work to which such Contribution(s) was
78 | submitted. If You institute patent litigation against any entity (including a
79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80 | Contribution incorporated within the Work constitutes direct or contributory
81 | patent infringement, then any patent licenses granted to You under this License
82 | for that Work shall terminate as of the date such litigation is filed.
83 |
84 | 4. Redistribution.
85 |
86 | You may reproduce and distribute copies of the Work or Derivative Works thereof
87 | in any medium, with or without modifications, and in Source or Object form,
88 | provided that You meet the following conditions:
89 |
90 | You must give any other recipients of the Work or Derivative Works a copy of
91 | this License; and
92 | You must cause any modified files to carry prominent notices stating that You
93 | changed the files; and
94 | You must retain, in the Source form of any Derivative Works that You distribute,
95 | all copyright, patent, trademark, and attribution notices from the Source form
96 | of the Work, excluding those notices that do not pertain to any part of the
97 | Derivative Works; and
98 | If the Work includes a "NOTICE" text file as part of its distribution, then any
99 | Derivative Works that You distribute must include a readable copy of the
100 | attribution notices contained within such NOTICE file, excluding those notices
101 | that do not pertain to any part of the Derivative Works, in at least one of the
102 | following places: within a NOTICE text file distributed as part of the
103 | Derivative Works; within the Source form or documentation, if provided along
104 | with the Derivative Works; or, within a display generated by the Derivative
105 | Works, if and wherever such third-party notices normally appear. The contents of
106 | the NOTICE file are for informational purposes only and do not modify the
107 | License. You may add Your own attribution notices within Derivative Works that
108 | You distribute, alongside or as an addendum to the NOTICE text from the Work,
109 | provided that such additional attribution notices cannot be construed as
110 | modifying the License.
111 | You may add Your own copyright statement to Your modifications and may provide
112 | additional or different license terms and conditions for use, reproduction, or
113 | distribution of Your modifications, or for any such Derivative Works as a whole,
114 | provided Your use, reproduction, and distribution of the Work otherwise complies
115 | with the conditions stated in this License.
116 |
117 | 5. Submission of Contributions.
118 |
119 | Unless You explicitly state otherwise, any Contribution intentionally submitted
120 | for inclusion in the Work by You to the Licensor shall be under the terms and
121 | conditions of this License, without any additional terms or conditions.
122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of
123 | any separate license agreement you may have executed with Licensor regarding
124 | such Contributions.
125 |
126 | 6. Trademarks.
127 |
128 | This License does not grant permission to use the trade names, trademarks,
129 | service marks, or product names of the Licensor, except as required for
130 | reasonable and customary use in describing the origin of the Work and
131 | reproducing the content of the NOTICE file.
132 |
133 | 7. Disclaimer of Warranty.
134 |
135 | Unless required by applicable law or agreed to in writing, Licensor provides the
136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138 | including, without limitation, any warranties or conditions of TITLE,
139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140 | solely responsible for determining the appropriateness of using or
141 | redistributing the Work and assume any risks associated with Your exercise of
142 | permissions under this License.
143 |
144 | 8. Limitation of Liability.
145 |
146 | In no event and under no legal theory, whether in tort (including negligence),
147 | contract, or otherwise, unless required by applicable law (such as deliberate
148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be
149 | liable to You for damages, including any direct, indirect, special, incidental,
150 | or consequential damages of any character arising as a result of this License or
151 | out of the use or inability to use the Work (including but not limited to
152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153 | any and all other commercial damages or losses), even if such Contributor has
154 | been advised of the possibility of such damages.
155 |
156 | 9. Accepting Warranty or Additional Liability.
157 |
158 | While redistributing the Work or Derivative Works thereof, You may choose to
159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160 | other liability obligations and/or rights consistent with this License. However,
161 | in accepting such obligations, You may act only on Your own behalf and on Your
162 | sole responsibility, not on behalf of any other Contributor, and only if You
163 | agree to indemnify, defend, and hold each Contributor harmless for any liability
164 | incurred by, or claims asserted against, such Contributor by reason of your
165 | accepting any such warranty or additional liability.
166 |
167 | END OF TERMS AND CONDITIONS
168 |
169 | APPENDIX: How to apply the Apache License to your work
170 |
171 | To apply the Apache License to your work, attach the following boilerplate
172 | notice, with the fields enclosed by brackets "[]" replaced with your own
173 | identifying information. (Don't include the brackets!) The text should be
174 | enclosed in the appropriate comment syntax for the file format. We also
175 | recommend that a file or class name and description of purpose be included on
176 | the same "printed page" as the copyright notice for easier identification within
177 | third-party archives.
178 |
179 | Copyright [yyyy] [name of copyright owner]
180 |
181 | Licensed under the Apache License, Version 2.0 (the "License");
182 | you may not use this file except in compliance with the License.
183 | You may obtain a copy of the License at
184 |
185 | http://www.apache.org/licenses/LICENSE-2.0
186 |
187 | Unless required by applicable law or agreed to in writing, software
188 | distributed under the License is distributed on an "AS IS" BASIS,
189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190 | See the License for the specific language governing permissions and
191 | limitations under the License.
192 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | android-youtube-drag-layout
2 | ===========================
3 |
4 | 这是外国友人无私奉献的结晶。模仿的是最新版本Android-Youtube的视频播放布局拖动效果
5 |
6 | study form here: http://flavienlaurent.com/blog/2013/08/28/each-navigation-drawer-hides-a-viewdraghelper/
7 |
8 | 关于导入项目。
9 |
10 | - 可以使用Android Studio的gradle导入
11 | - 也可以使用Android Studio的源码导入,自己添加一下SupportV4包
12 | - Eclipse正常导入
13 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 | dependencies {
6 | classpath 'com.android.tools.build:gradle:0.5.+'
7 | }
8 | }
9 |
10 | tasks.withType(Compile) {
11 | options.encoding = "UTF-8"
12 | }
13 |
14 | apply plugin: 'android'
15 |
16 | dependencies {
17 | // compile fileTree(dir: 'libs', include: '*.jar')
18 | compile 'com.android.support:support-v4:18.0.0'
19 | }
20 |
21 | android {
22 | compileSdkVersion 16
23 | buildToolsVersion "18.0.1"
24 |
25 | sourceSets {
26 | main {
27 | manifest.srcFile 'AndroidManifest.xml'
28 | java.srcDirs = ['src']
29 | resources.srcDirs = ['src']
30 | aidl.srcDirs = ['src']
31 | renderscript.srcDirs = ['src']
32 | res.srcDirs = ['res']
33 | assets.srcDirs = ['assets']
34 | }
35 |
36 | // Move the tests to tests/java, tests/res, etc...
37 | instrumentTest.setRoot('tests')
38 |
39 | // Move the build types to build-types/
40 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
41 | // This moves them out of them default location under src//... which would
42 | // conflict with src/ being used by the main source set.
43 | // Adding new build types or product flavors should be accompanied
44 | // by a similar customization.
45 | debug.setRoot('build-types/debug')
46 | release.setRoot('build-types/release')
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.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 |
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-16
15 |
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wuyexiong/android-youtube-drag-layout/11ff8d0562fc1f883d02fcd9dcba54d75edeed58/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/activity_horizontal.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
21 |
22 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | -->
40 |
41 |
42 |
--------------------------------------------------------------------------------
/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
16 |
17 |
22 |
23 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/res/layout/activity_youtube.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
20 |
21 |
32 |
33 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/res/layout/listitem_simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
23 |
24 |
--------------------------------------------------------------------------------
/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | DragLayout
5 | Settings
6 | Hello world!
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/tree/love/draglayout/HorizontalDragActivity.java:
--------------------------------------------------------------------------------
1 | package tree.love.draglayout;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 |
8 | /** Created by wuyexiong on 13-8-31. */
9 | public class HorizontalDragActivity extends Activity {
10 |
11 | public static void launch(Context context)
12 | {
13 | Intent intent = new Intent(context, HorizontalDragActivity.class);
14 | context.startActivity(intent);
15 | }
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_horizontal);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/tree/love/draglayout/MainActivity.java:
--------------------------------------------------------------------------------
1 | package tree.love.draglayout;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | public class MainActivity extends Activity implements View.OnClickListener {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState)
11 | {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 | setupViews();
15 | }
16 |
17 | private void setupViews() {
18 | findViewById(R.id.horizontal).setOnClickListener(this);
19 | findViewById(R.id.youtube_layout).setOnClickListener(this);
20 | }
21 |
22 | @Override
23 | public void onClick(View v) {
24 | switch(v.getId())
25 | {
26 | case R.id.horizontal:
27 | HorizontalDragActivity.launch(this);
28 | break;
29 | case R.id.youtube_layout:
30 | YoutubeActivity.launch(this);
31 | break;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/tree/love/draglayout/YoutubeActivity.java:
--------------------------------------------------------------------------------
1 | package tree.love.draglayout;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ArrayAdapter;
11 | import android.widget.ImageView;
12 | import android.widget.ListView;
13 | import android.widget.TextView;
14 |
15 | /** Created by wuyexiong on 13-9-1. */
16 | public class YoutubeActivity extends Activity {
17 |
18 | private ListView mListView;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_youtube);
24 | setupListView();
25 | }
26 |
27 | private void setupListView() {
28 | mListView = (ListView) findViewById(R.id.listView);
29 | SampleAdapter adapter = new SampleAdapter(this);
30 | for (int i = 0; i < 20; i++) {
31 | adapter.add(new SampleItem("Love Android", android.R.drawable.star_on));
32 | }
33 | mListView.setAdapter(adapter);
34 | }
35 |
36 | public static void launch(Context context) {
37 | Intent intent = new Intent(context, YoutubeActivity.class);
38 | context.startActivity(intent);
39 | }
40 |
41 | private class SampleItem {
42 | public String tag;
43 | public int iconRes;
44 | public SampleItem(String tag, int iconRes) {
45 | this.tag = tag;
46 | this.iconRes = iconRes;
47 | }
48 | }
49 |
50 | public class SampleAdapter extends ArrayAdapter {
51 |
52 | public SampleAdapter(Context context) {
53 | super(context, 0);
54 | }
55 |
56 | public View getView(int position, View convertView, ViewGroup parent) {
57 | if (convertView == null) {
58 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.listitem_simple, null);
59 | }
60 | ImageView icon = (ImageView) convertView.findViewById(R.id.row_icon);
61 | icon.setImageResource(getItem(position).iconRes);
62 | TextView title = (TextView) convertView.findViewById(R.id.row_title);
63 | title.setText(getItem(position).tag);
64 |
65 | return convertView;
66 | }
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/tree/love/draglayout/drag/DragLayout.java:
--------------------------------------------------------------------------------
1 | package tree.love.draglayout.drag;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.MotionEventCompat;
5 | import android.support.v4.widget.ViewDragHelper;
6 | import android.util.AttributeSet;
7 | import android.util.Log;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 | import android.widget.LinearLayout;
11 | import android.widget.Toast;
12 |
13 | /** Created by wuyexiong on 13-8-31. */
14 | public class DragLayout extends LinearLayout{
15 |
16 | private static final String TAG = "DragLayout";
17 |
18 | private ViewDragHelper mDragHelper;
19 | private View mDragView;
20 |
21 | public DragLayout(Context context) {
22 | super(context);
23 | init();
24 | }
25 |
26 | public DragLayout(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | init();
29 | }
30 |
31 | public DragLayout(Context context, AttributeSet attrs, int defStyle) {
32 | super(context, attrs, defStyle);
33 | }
34 |
35 | private void init() {
36 | mDragHelper = ViewDragHelper.create(this, 1.0f, new DragHelperCallback());
37 | mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
38 | }
39 |
40 | @Override
41 | protected void onFinishInflate() {
42 | super.onFinishInflate();
43 | mDragView = getChildAt(0);
44 | }
45 |
46 | private class DragHelperCallback extends ViewDragHelper.Callback
47 | {
48 | @Override
49 | public boolean tryCaptureView(View child, int pointerId) {//返回true则表示启动拖拽
50 | return child == mDragView;
51 | }
52 |
53 | @Override
54 | public int clampViewPositionHorizontal(View child, int left, int dx) {//重新计算当前子View的X坐标
55 | Log.d(TAG, "clampViewPositionHorizontal " + left + "," + dx);
56 | final int leftBound = getPaddingLeft();
57 | final int rightBound = getWidth() - mDragView.getWidth() - leftBound;
58 | final int newLeft = Math.min(Math.max(left, leftBound), rightBound);
59 |
60 | return newLeft;
61 | }
62 |
63 | @Override
64 | public int clampViewPositionVertical(View child, int top, int dy) {//重新计算当前子View的Y坐标
65 | Log.d(TAG, "clampViewPositionVertical " + top + "," + dy);
66 | final int topBound = getPaddingTop();
67 | final int bottomBound = getHeight() - mDragView.getHeight() - topBound;
68 | final int newTop = Math.min(Math.max(top, topBound), bottomBound);
69 |
70 | return newTop;
71 | }
72 |
73 | @Override
74 | public void onEdgeTouched(int edgeFlags, int pointerId) {//触发角接收到了触摸事件
75 | super.onEdgeTouched(edgeFlags, pointerId);
76 | Toast.makeText(getContext(), "edgeTouched:" + edgeFlags, Toast.LENGTH_SHORT).show();
77 | }
78 |
79 | @Override
80 | public void onEdgeDragStarted(int edgeFlags, int pointerId) {
81 | mDragHelper.captureChildView(mDragView,pointerId);
82 | }
83 | }
84 |
85 |
86 | @Override
87 | public boolean onInterceptTouchEvent(MotionEvent ev) {
88 | final int action = MotionEventCompat.getActionMasked(ev);
89 | if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
90 | mDragHelper.cancel();
91 | return false;
92 | }
93 | return mDragHelper.shouldInterceptTouchEvent(ev);
94 | }
95 |
96 | @Override
97 | public boolean onTouchEvent(MotionEvent event) {
98 | boolean mINeedTouch = true;
99 | mDragHelper.processTouchEvent(event);
100 | return mINeedTouch;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/tree/love/draglayout/drag/YoutubeLayout.java:
--------------------------------------------------------------------------------
1 | package tree.love.draglayout.drag;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.MotionEventCompat;
5 | import android.support.v4.view.ViewCompat;
6 | import android.support.v4.widget.ViewDragHelper;
7 | import android.util.AttributeSet;
8 | import android.util.Log;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 |
13 | import tree.love.draglayout.R;
14 |
15 | /** Created by wuyexiong on 13-8-31. */
16 | public class YoutubeLayout extends ViewGroup{
17 |
18 | private static final String TAG = "YoutubeLayout";
19 |
20 | private static final int MIN_FLING_VELOCITY = 400; // dips per second
21 |
22 | private View mHeaderView;
23 | private View mDescView;
24 |
25 | private float mInitialMotionX;
26 | private float mInitialMotionY;
27 |
28 | private int mDragRange;
29 | private int mTop;
30 | private float mDragOffset;
31 |
32 | private ViewDragHelper mDragHelper;
33 |
34 |
35 |
36 | public YoutubeLayout(Context context) {
37 | super(context);
38 | init(context);
39 | }
40 |
41 | public YoutubeLayout(Context context, AttributeSet attrs) {
42 | super(context, attrs);
43 | init(context);
44 | }
45 |
46 | public YoutubeLayout(Context context, AttributeSet attrs, int defStyle) {
47 | super(context, attrs, defStyle);
48 | init(context);
49 | }
50 |
51 | private void init(Context context) {
52 | final float density = context.getResources().getDisplayMetrics().density;
53 | mDragHelper = ViewDragHelper.create(this, 1.0f, new DragHelperCallback());
54 | mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * density);
55 | }
56 |
57 | public void maximize()
58 | {
59 | smoothSlideTo(0.0f);
60 | }
61 |
62 | public void minimize()
63 | {
64 | smoothSlideTo(1.0f);
65 | }
66 |
67 | private boolean smoothSlideTo(float slideOffset) {
68 | final int topBound = getPaddingTop();
69 | int y = (int) (topBound + slideOffset * mDragRange);
70 |
71 | if(mDragHelper.smoothSlideViewTo(mHeaderView, mHeaderView.getLeft(), y))
72 | {
73 | ViewCompat.postInvalidateOnAnimation(this);
74 | return true;
75 | }
76 | return false;
77 | }
78 |
79 | @Override
80 | protected void onFinishInflate() {
81 | Log.d(TAG, "onFInishInflate");
82 | mHeaderView = findViewById(R.id.viewHeader);
83 | mDescView = findViewById(R.id.viewDesc);
84 | }
85 |
86 | @Override
87 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
88 | // Log.d(TAG, "onMeasure");
89 | measureChildren(widthMeasureSpec, heightMeasureSpec);
90 |
91 | int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
92 | int maxHeight = MeasureSpec.getSize(heightMeasureSpec);
93 |
94 | setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, 0), resolveSizeAndState(maxHeight, heightMeasureSpec, 0));
95 |
96 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
97 | }
98 |
99 | @Override
100 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
101 | int parentViewHeight = getHeight();
102 | int dragViewHeight = mHeaderView.getMeasuredHeight();
103 | mDragRange = parentViewHeight - dragViewHeight;
104 | // Log.d(TAG, "onLayout:" + "changed:" + changed + ",l:" + l + ",t:" + t + ",r:" + r + ",b:" + b + ",mDragRange" + mDragRange);
105 |
106 | mHeaderView.layout(
107 | 0,
108 | mTop,
109 | r,
110 | mTop + mHeaderView.getMeasuredHeight());
111 |
112 | mDescView.layout(
113 | 0,
114 | mTop + mHeaderView.getMeasuredHeight(),
115 | r,
116 | mTop + b);
117 | }
118 |
119 | private class DragHelperCallback extends ViewDragHelper.Callback
120 | {
121 | @Override
122 | public boolean tryCaptureView(View child, int pointerId) {
123 | return child == mHeaderView;
124 | }
125 |
126 | @Override
127 | public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
128 | // Log.i(TAG, "onViewPositionChanged:" + "left:" + left + ",top:" + top + ",dx:" + dx + ",dy:" + dy);
129 | mTop = top;
130 | mDragOffset = (float) top / mDragRange;
131 |
132 | // Log.i(TAG, "onViewPositionChanged:" + "mDragOffset:" + mDragOffset);
133 |
134 | mHeaderView.setPivotX(mHeaderView.getWidth());
135 | mHeaderView.setPivotY(mHeaderView.getHeight());
136 | mHeaderView.setScaleX(1 - mDragOffset / 2);
137 | mHeaderView.setScaleY(1 - mDragOffset / 2);
138 |
139 | mDescView.setAlpha(1 - mDragOffset);
140 |
141 | requestLayout();
142 | }
143 |
144 | @Override
145 | public int clampViewPositionVertical(View child, int top, int dy) {
146 | final int topBound = getPaddingTop();
147 | final int bottomBound = getHeight() - mHeaderView.getHeight() - mHeaderView.getPaddingBottom();
148 |
149 | final int newTop = Math.min(Math.max(top, topBound), bottomBound);
150 | return newTop;
151 | }
152 |
153 | @Override
154 | public void onViewReleased(View releasedChild, float xvel, float yvel) {
155 | // Log.i(TAG, "onViewReleased:" + "xvel:" + xvel + ",yvel:" + yvel);
156 | //yvel Fling产生的值,yvel > 0 则是快速往下Fling || yvel < 0 则是快速往上Fling
157 |
158 | int top = getPaddingTop();
159 | if (yvel > 0 || (yvel == 0 && mDragOffset > 0.4f)/* 后面这个小括号里判断处理拖动之后停下来但是未松手的情况 */) {
160 | top += mDragRange;
161 | }
162 | mDragHelper.settleCapturedViewAt(releasedChild.getLeft(), top);
163 | invalidate();//important 不加,就不会刷新View的位置 尼玛。。。。你试试注释掉看看。弄死我了,睡觉。
164 | }
165 |
166 | @Override
167 | public int getViewVerticalDragRange(View child) {
168 | return mDragRange;
169 | }
170 |
171 | }
172 |
173 | @Override
174 | public void computeScroll() {
175 | if(mDragHelper.continueSettling(true))
176 | {
177 | ViewCompat.postInvalidateOnAnimation(this);
178 | }
179 | }
180 |
181 | @Override
182 | public boolean onInterceptTouchEvent(MotionEvent ev) {
183 | final int action = MotionEventCompat.getActionMasked(ev);
184 |
185 | if(action != MotionEvent.ACTION_DOWN)
186 | {
187 | mDragHelper.cancel();
188 | return super.onInterceptTouchEvent(ev);
189 | }
190 |
191 | if(action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP)
192 | {
193 | mDragHelper.cancel();
194 | return false;
195 | }
196 |
197 | final float x = ev.getX();
198 | final float y = ev.getY();
199 | boolean interceptTap = false;
200 |
201 | switch(action)
202 | {
203 | case MotionEvent.ACTION_DOWN:
204 | mInitialMotionX = x;
205 | mInitialMotionY = y;
206 | interceptTap = mDragHelper.isViewUnder(mHeaderView, (int) x, (int) y);
207 | break;
208 |
209 | case MotionEvent.ACTION_MOVE:
210 | final float adx = Math.abs(x - mInitialMotionX);
211 | final float ady = Math.abs(y - mInitialMotionY);
212 | final int slop = mDragHelper.getTouchSlop();
213 | if(ady > slop && adx > ady)
214 | {
215 | mDragHelper.cancel();
216 | return false;
217 | }
218 | break;
219 | }
220 |
221 | return mDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
222 | }
223 |
224 | @Override
225 | public boolean onTouchEvent(MotionEvent event) {
226 | mDragHelper.processTouchEvent(event);
227 |
228 | final int action = event.getAction();
229 | final float x = event.getX();
230 | final float y = event.getY();
231 |
232 | //触摸点是否落在HeaderView上
233 | boolean isHeaderViewUnder = mDragHelper.isViewUnder(mHeaderView, (int)x, (int)y);
234 |
235 | switch(action & MotionEventCompat.ACTION_MASK)
236 | {
237 | case MotionEvent.ACTION_DOWN:
238 | {
239 | mInitialMotionX = x;
240 | mInitialMotionY = y;
241 | break;
242 | }
243 | case MotionEvent.ACTION_UP:
244 | {
245 | final float dx = x - mInitialMotionX;
246 | final float dy = y - mInitialMotionY;
247 | final float slop = mDragHelper.getTouchSlop();
248 |
249 | // Log.i(TAG, "dx * dx + dy * dy = " + dx * dx + dy * dy);
250 | // Log.i(TAG, "slop * slop = " + slop * slop);
251 | // Log.i(TAG, "mDragOffset:" + mDragOffset);
252 | if(dx * dx + dy * dy < slop * slop && isHeaderViewUnder)
253 | {
254 | if (mDragOffset == 0) {
255 | minimize();
256 | } else {
257 | maximize();
258 | }
259 | }
260 | break;
261 | }
262 | }
263 |
264 | return isHeaderViewUnder && isViewHit(mHeaderView, (int) x, (int) y) || isViewHit(mDescView, (int) x, (int) y);
265 | }
266 |
267 | private boolean isViewHit(View view, int x, int y) {
268 | int[] viewLocation = new int[2];
269 | view.getLocationOnScreen(viewLocation);
270 | int[] parentLocation = new int[2];
271 | this.getLocationOnScreen(parentLocation);
272 | int screenX = parentLocation[0] + x;
273 | int screenY = parentLocation[1] + y;
274 | return screenX >= viewLocation[0] && screenX < viewLocation[0] + view.getWidth() &&
275 | screenY >= viewLocation[1] && screenY < viewLocation[1] + view.getHeight();
276 | }
277 | }
278 |
--------------------------------------------------------------------------------