├── .gitignore
├── LICENSE
├── PullToZoomView
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── ecloud
│ │ │ └── pulltozoomview
│ │ │ └── ApplicationTest.java
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── ecloud
│ │ │ └── pulltozoomview
│ │ │ └── demo
│ │ │ ├── MainActivity.java
│ │ │ ├── PullToZoomListActivity.java
│ │ │ ├── PullToZoomRecyclerViewEx.java
│ │ │ ├── PullToZoomScrollActivity.java
│ │ │ └── recyclerview
│ │ │ ├── PullToZoomRecyclerActivity.java
│ │ │ ├── RecyclerViewHeaderAdapter.java
│ │ │ └── SpannableStaggeredGridLayoutManager.java
│ │ └── res
│ │ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ ├── ic_img_line_v.png
│ │ ├── ic_img_profile_bg.jpg
│ │ ├── ic_img_user_default.png
│ │ ├── ic_launcher.png
│ │ └── splash01.jpg
│ │ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_pull_to_zoom_list_view.xml
│ │ ├── activity_pull_to_zoom_recycler_view.xml
│ │ ├── activity_pull_to_zoom_scroll_view.xml
│ │ ├── list_head_zoom_view.xml
│ │ ├── profile_content_view.xml
│ │ ├── profile_head_view.xml
│ │ └── profile_zoom_view.xml
│ │ ├── menu
│ │ ├── list_view.xml
│ │ ├── main.xml
│ │ └── scroll_view.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
│ ├── .gitignore
│ ├── build.gradle
│ ├── gradle.properties
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── ecloud
│ │ │ └── pulltozoomview
│ │ │ └── ApplicationTest.java
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── ecloud
│ │ │ └── pulltozoomview
│ │ │ ├── IPullToZoom.java
│ │ │ ├── PullToZoomBase.java
│ │ │ ├── PullToZoomListViewEx.java
│ │ │ └── PullToZoomScrollViewEx.java
│ │ └── res
│ │ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── ids.xml
│ │ └── strings.xml
└── settings.gradle
├── README.md
└── art
└── pull-to-zoom.gif
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 | /PullToZoomView/.idea
25 | *.iml
26 |
--------------------------------------------------------------------------------
/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,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/PullToZoomView/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | .DS_Store
5 | /build
6 |
--------------------------------------------------------------------------------
/PullToZoomView/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/PullToZoomView/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "20.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.ecloud.pulltozoomview.demo"
9 | minSdkVersion 14
10 | targetSdkVersion 23
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 | compile 'com.android.support:appcompat-v7:23.0.1'
25 | compile 'com.android.support:recyclerview-v7:23.0.1'
26 | compile project(':library')
27 | // compile 'com.github.frank-zhu:pullzoomview:1.0.0'
28 | }
29 |
--------------------------------------------------------------------------------
/PullToZoomView/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\Android\android-studio\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/androidTest/java/com/ecloud/pulltozoomview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
27 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview.demo;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.os.Bundle;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 |
10 | import com.ecloud.pulltozoomview.demo.recyclerview.PullToZoomRecyclerActivity;
11 |
12 |
13 | public class MainActivity extends ActionBarActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 |
20 | findViewById(R.id.btn_list).setOnClickListener(new View.OnClickListener() {
21 | @Override
22 | public void onClick(View v) {
23 | startActivity(new Intent(MainActivity.this, PullToZoomListActivity.class));
24 | }
25 | });
26 |
27 | findViewById(R.id.btn_scroll).setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View v) {
30 | startActivity(new Intent(MainActivity.this, PullToZoomScrollActivity.class));
31 | }
32 | });
33 |
34 | findViewById(R.id.btn_recycler_view).setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | startActivity(new Intent(MainActivity.this, PullToZoomRecyclerActivity.class));
38 | }
39 | });
40 | }
41 |
42 |
43 | @Override
44 | public boolean onCreateOptionsMenu(Menu menu) {
45 | getMenuInflater().inflate(R.menu.main, menu);
46 | return true;
47 | }
48 |
49 | @Override
50 | public boolean onOptionsItemSelected(MenuItem item) {
51 | int id = item.getItemId();
52 | if (id == R.id.action_settings) {
53 | return true;
54 | }
55 | return super.onOptionsItemSelected(item);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomListActivity.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.util.DisplayMetrics;
6 | import android.util.Log;
7 | import android.view.Menu;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.widget.AbsListView;
11 | import android.widget.AdapterView;
12 | import android.widget.ArrayAdapter;
13 |
14 | import com.ecloud.pulltozoomview.PullToZoomListViewEx;
15 |
16 | /**
17 | * Author: ZhuWenWu
18 | * Version V1.0
19 | * Date: 2014/9/4 17:11.
20 | * Description:
21 | * Modification History:
22 | * Date Author Version Description
23 | * -----------------------------------------------------------------------------------
24 | * 2014/9/4 ZhuWenWu 1.0 1.0
25 | * Why & What is modified:
26 | */
27 | public class PullToZoomListActivity extends ActionBarActivity {
28 |
29 | private PullToZoomListViewEx listView;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_pull_to_zoom_list_view);
35 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
36 |
37 | listView = (PullToZoomListViewEx) findViewById(R.id.listview);
38 |
39 | String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
40 | "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
41 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
42 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
43 |
44 | listView.setAdapter(new ArrayAdapter(PullToZoomListActivity.this, android.R.layout.simple_list_item_1, adapterData));
45 | listView.getPullRootView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
46 | @Override
47 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
48 | Log.e("zhuwenwu", "position = " + position);
49 | }
50 | });
51 |
52 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
53 | @Override
54 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
55 | Log.e("zhuwenwu", "position = " + position);
56 | }
57 | });
58 |
59 | DisplayMetrics localDisplayMetrics = new DisplayMetrics();
60 | getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
61 | int mScreenHeight = localDisplayMetrics.heightPixels;
62 | int mScreenWidth = localDisplayMetrics.widthPixels;
63 | AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
64 | listView.setHeaderLayoutParams(localObject);
65 | }
66 |
67 | @Override
68 | public boolean onCreateOptionsMenu(Menu menu) {
69 | getMenuInflater().inflate(R.menu.list_view, menu);
70 | return true;
71 | }
72 |
73 | @Override
74 | public boolean onOptionsItemSelected(MenuItem item) {
75 | int id = item.getItemId();
76 | if (id == android.R.id.home) {
77 | finish();
78 | return true;
79 | } else if (id == R.id.action_normal) {
80 | listView.setParallax(false);
81 | return true;
82 | } else if (id == R.id.action_parallax) {
83 | listView.setParallax(true);
84 | return true;
85 | } else if (id == R.id.action_show_head) {
86 | listView.setHideHeader(false);
87 | return true;
88 | } else if (id == R.id.action_hide_head) {
89 | listView.setHideHeader(true);
90 | return true;
91 | } else if (id == R.id.action_disable_zoom) {
92 | listView.setZoomEnabled(false);
93 | return true;
94 | } else if (id == R.id.action_enable_zoom) {
95 | listView.setZoomEnabled(true);
96 | return true;
97 | }
98 | return super.onOptionsItemSelected(item);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomRecyclerViewEx.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview.demo;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.os.SystemClock;
6 | import android.support.v7.widget.GridLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.AttributeSet;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.animation.Interpolator;
13 | import android.widget.AbsListView;
14 | import android.widget.AdapterView;
15 | import android.widget.FrameLayout;
16 |
17 | import com.ecloud.pulltozoomview.PullToZoomBase;
18 | import com.ecloud.pulltozoomview.demo.recyclerview.RecyclerViewHeaderAdapter;
19 |
20 | /**
21 | * Author: ZhuWenWu
22 | * Version V1.0
23 | * Date: 2014/11/7 18:01.
24 | * Description:
25 | * Modification History:
26 | * Date Author Version Description
27 | * -----------------------------------------------------------------------------------
28 | * 2014/11/7 ZhuWenWu 1.0 1.0
29 | * Why & What is modified:
30 | */
31 | public class PullToZoomRecyclerViewEx extends PullToZoomBase implements AbsListView.OnScrollListener {
32 | private static final String TAG = PullToZoomRecyclerViewEx.class.getSimpleName();
33 | private FrameLayout mHeaderContainer;
34 | private int mHeaderHeight;
35 | private ScalingRunnable mScalingRunnable;
36 |
37 | private static final Interpolator sInterpolator = new Interpolator() {
38 | public float getInterpolation(float paramAnonymousFloat) {
39 | float f = paramAnonymousFloat - 1.0F;
40 | return 1.0F + f * (f * (f * (f * f)));
41 | }
42 | };
43 |
44 | public PullToZoomRecyclerViewEx(Context context) {
45 | this(context, null);
46 | }
47 |
48 | public PullToZoomRecyclerViewEx(Context context, AttributeSet attrs) {
49 | super(context, attrs);
50 | mRootView.setOnScrollListener(new RecyclerView.OnScrollListener() {
51 |
52 |
53 | @Override
54 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
55 | super.onScrolled(recyclerView, dx, dy);
56 |
57 | if (mZoomView != null && !isHideHeader() && isPullToZoomEnabled()) {
58 | float f = mHeaderHeight - mHeaderContainer.getBottom();
59 | Log.d(TAG, "onScroll --> f = " + f);
60 | if (isParallax()) {
61 | if ((f > 0.0F) && (f < mHeaderHeight)) {
62 | int i = (int) (0.65D * f);
63 | mHeaderContainer.scrollTo(0, -i);
64 | } else if (mHeaderContainer.getScrollY() != 0) {
65 | mHeaderContainer.scrollTo(0, 0);
66 | }
67 | }
68 | }
69 |
70 | }
71 |
72 | @Override
73 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
74 | super.onScrollStateChanged(recyclerView, newState);
75 |
76 |
77 | }
78 | });
79 | mScalingRunnable = new ScalingRunnable();
80 | }
81 |
82 | /**
83 | * 是否显示headerView
84 | *
85 | * @param isHideHeader true: show false: hide
86 | */
87 | @Override
88 | public void setHideHeader(boolean isHideHeader) {
89 | if (isHideHeader != isHideHeader()) {
90 | super.setHideHeader(isHideHeader);
91 | if (isHideHeader) {
92 | removeHeaderView();
93 | } else {
94 | updateHeaderView();
95 | }
96 | }
97 | }
98 |
99 | @Override
100 | public void setHeaderView(View headerView) {
101 | if (headerView != null) {
102 | this.mHeaderView = headerView;
103 | updateHeaderView();
104 | }
105 | }
106 |
107 | @Override
108 | public void setZoomView(View zoomView) {
109 | if (zoomView != null) {
110 | this.mZoomView = zoomView;
111 | updateHeaderView();
112 | }
113 | }
114 |
115 | /**
116 | * 移除HeaderView
117 | * 如果要兼容API 9,需要修改此处逻辑,API 11以下不支持动态添加header
118 | */
119 | private void removeHeaderView() {
120 | if (mHeaderContainer != null) {
121 | if (mRootView != null && mRootView.getAdapter() != null) {
122 |
123 | RecyclerViewHeaderAdapter mAdapter = (RecyclerViewHeaderAdapter) mRootView.getAdapter();
124 |
125 | if (mAdapter != null) {
126 |
127 | if (mAdapter.getHeader(0) != null)
128 | mAdapter.removeHeaderView(mAdapter.getHeader(0));
129 | }
130 |
131 | }
132 | }
133 | }
134 |
135 | /**
136 | * 更新HeaderView 先移除-->再添加zoomView、HeaderView -->然后添加到listView的head
137 | * 如果要兼容API 9,需要修改此处逻辑,API 11以下不支持动态添加header
138 | */
139 | private void updateHeaderView() {
140 | if (mHeaderContainer != null) {
141 |
142 | if (mRootView != null && mRootView.getAdapter() != null) {
143 |
144 | RecyclerViewHeaderAdapter mAdapter = (RecyclerViewHeaderAdapter) mRootView.getAdapter();
145 |
146 | if (mAdapter != null) {
147 |
148 | if (mAdapter.getHeader(0) != null)
149 | mAdapter.removeHeaderView(mAdapter.getHeader(0));
150 |
151 | mHeaderContainer.removeAllViews();
152 |
153 | if (mZoomView != null) {
154 | mHeaderContainer.addView(mZoomView);
155 | }
156 |
157 | if (mHeaderView != null) {
158 | mHeaderContainer.addView(mHeaderView);
159 | }
160 |
161 | mHeaderHeight = mHeaderContainer.getHeight();
162 |
163 | RecyclerViewHeaderAdapter.ExtraItem mExtraItem = new RecyclerViewHeaderAdapter.ExtraItem(RecyclerViewHeaderAdapter.INT_TYPE_HEADER, new RecyclerView.ViewHolder(mHeaderContainer) {
164 | @Override
165 | public String toString() {
166 | return super.toString();
167 | }
168 | });
169 |
170 | mAdapter.addHeaderView(mExtraItem);
171 | }
172 | }
173 | }
174 | }
175 |
176 | public void setAdapterAndLayoutManager(RecyclerView.Adapter adapter, GridLayoutManager mLayoutManager) {
177 | mRootView.setLayoutManager(mLayoutManager);
178 | mRootView.setAdapter(adapter);
179 | updateHeaderView();
180 | }
181 |
182 | public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
183 | // mRootView.setOnItemClickListener(listener);
184 | }
185 |
186 | /**
187 | * 创建listView 如果要兼容API9,需要修改此处
188 | *
189 | * @param context 上下文
190 | * @param attrs AttributeSet
191 | * @return ListView
192 | */
193 | @Override
194 | protected RecyclerView createRootView(Context context, AttributeSet attrs) {
195 | RecyclerView rv = new RecyclerView(context, attrs);
196 | // Set it to this so it can be used in ListActivity/ListFragment
197 |
198 | // rv.setId(android.R.id.list);
199 | return rv;
200 | }
201 |
202 | /**
203 | * 重置动画,自动滑动到顶部
204 | */
205 | @Override
206 | protected void smoothScrollToTop() {
207 | Log.d(TAG, "smoothScrollToTop --> ");
208 | mScalingRunnable.startAnimation(200L);
209 | }
210 |
211 | /**
212 | * zoomView动画逻辑
213 | *
214 | * @param newScrollValue 手指Y轴移动距离值
215 | */
216 | @Override
217 | protected void pullHeaderToZoom(int newScrollValue) {
218 | Log.d(TAG, "pullHeaderToZoom --> newScrollValue = " + newScrollValue);
219 | Log.d(TAG, "pullHeaderToZoom --> mHeaderHeight = " + mHeaderHeight);
220 | if (mScalingRunnable != null && !mScalingRunnable.isFinished()) {
221 | mScalingRunnable.abortAnimation();
222 | }
223 |
224 | ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
225 | localLayoutParams.height = Math.abs(newScrollValue) + mHeaderHeight;
226 | mHeaderContainer.setLayoutParams(localLayoutParams);
227 | }
228 |
229 | @Override
230 | protected boolean isReadyForPullStart() {
231 | return isFirstItemVisible();
232 | }
233 |
234 | private boolean isFirstItemVisible() {
235 | if (mRootView != null) {
236 | final RecyclerView.Adapter adapter = mRootView.getAdapter();
237 | final GridLayoutManager mLayoutmanager = (GridLayoutManager) mRootView.getLayoutManager();
238 |
239 |
240 | if (null == adapter || adapter.getItemCount() == 0) {
241 | return true;
242 | } else {
243 | /**
244 | * This check should really just be:
245 | * mRootView.getFirstVisiblePosition() == 0, but PtRListView
246 | * internally use a HeaderView which messes the positions up. For
247 | * now we'll just add one to account for it and rely on the inner
248 | * condition which checks getTop().
249 | */
250 |
251 | int[] into = {0,0};
252 | if (mLayoutmanager != null)
253 | into[0] = mLayoutmanager.findFirstVisibleItemPosition();
254 | if (into.length > 0 && into.length > 0 && into[0] <= 1) {
255 | final View firstVisibleChild = mRootView.getChildAt(0);
256 | if (firstVisibleChild != null) {
257 | return firstVisibleChild.getTop() >= mRootView.getTop();
258 | }
259 | }
260 | }
261 | }
262 |
263 | return false;
264 | }
265 |
266 | @Override
267 | public void handleStyledAttributes(TypedArray a) {
268 | mHeaderContainer = new FrameLayout(getContext());
269 | if (mZoomView != null) {
270 | mHeaderContainer.addView(mZoomView);
271 | }
272 | if (mHeaderView != null) {
273 | mHeaderContainer.addView(mHeaderView);
274 | }
275 | RecyclerViewHeaderAdapter mAdapter = (RecyclerViewHeaderAdapter) mRootView.getAdapter();
276 | if (mAdapter != null) {
277 | RecyclerViewHeaderAdapter.ExtraItem mExtraItem = new RecyclerViewHeaderAdapter.ExtraItem(RecyclerViewHeaderAdapter.INT_TYPE_HEADER, new RecyclerView.ViewHolder(mHeaderContainer) {
278 | @Override
279 | public String toString() {
280 | return super.toString();
281 | }
282 | });
283 |
284 | mAdapter.addHeaderView(mExtraItem);
285 | }
286 | }
287 |
288 | /**
289 | * 设置HeaderView高度
290 | *
291 | * @param width 宽
292 | * @param height 高
293 | */
294 | public void setHeaderViewSize(int width, int height) {
295 | if (mHeaderContainer != null) {
296 | Object localObject = mHeaderContainer.getLayoutParams();
297 | if (localObject == null) {
298 | localObject = new AbsListView.LayoutParams(width, height);
299 | }
300 | ((ViewGroup.LayoutParams) localObject).width = width;
301 | ((ViewGroup.LayoutParams) localObject).height = height;
302 | mHeaderContainer.setLayoutParams((ViewGroup.LayoutParams) localObject);
303 | mHeaderHeight = height;
304 | }
305 | }
306 |
307 | public void setHeaderLayoutParams(AbsListView.LayoutParams layoutParams) {
308 | if (mHeaderContainer != null) {
309 | mHeaderContainer.setLayoutParams(layoutParams);
310 | mHeaderHeight = layoutParams.height;
311 | }
312 | }
313 |
314 | protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2,
315 | int paramInt3, int paramInt4) {
316 | super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
317 | Log.d(TAG, "onLayout --> ");
318 | if (mHeaderHeight == 0 && mHeaderContainer != null) {
319 | mHeaderHeight = mHeaderContainer.getHeight();
320 | }
321 | }
322 |
323 | @Override
324 | public void onScrollStateChanged(AbsListView view, int scrollState) {
325 | Log.d(TAG, "onScrollStateChanged --> ");
326 | }
327 |
328 | @Override
329 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
330 | if (mZoomView != null && !isHideHeader() && isPullToZoomEnabled()) {
331 | float f = mHeaderHeight - mHeaderContainer.getBottom();
332 | Log.d(TAG, "onScroll --> f = " + f);
333 | if (isParallax()) {
334 | if ((f > 0.0F) && (f < mHeaderHeight)) {
335 | int i = (int) (0.65D * f);
336 | mHeaderContainer.scrollTo(0, -i);
337 | } else if (mHeaderContainer.getScrollY() != 0) {
338 | mHeaderContainer.scrollTo(0, 0);
339 | }
340 | }
341 | }
342 | }
343 |
344 |
345 | class ScalingRunnable implements Runnable {
346 | protected long mDuration;
347 | protected boolean mIsFinished = true;
348 | protected float mScale;
349 | protected long mStartTime;
350 |
351 | ScalingRunnable() {
352 | }
353 |
354 | public void abortAnimation() {
355 | mIsFinished = true;
356 | }
357 |
358 | public boolean isFinished() {
359 | return mIsFinished;
360 | }
361 |
362 | public void run() {
363 | if (mZoomView != null) {
364 | float f2;
365 | ViewGroup.LayoutParams localLayoutParams;
366 | if ((!mIsFinished) && (mScale > 1.0D)) {
367 | float f1 = ((float) SystemClock.currentThreadTimeMillis() - (float) mStartTime) / (float) mDuration;
368 | f2 = mScale - (mScale - 1.0F) * PullToZoomRecyclerViewEx.sInterpolator.getInterpolation(f1);
369 | localLayoutParams = mHeaderContainer.getLayoutParams();
370 | Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
371 | if (f2 > 1.0F) {
372 | localLayoutParams.height = ((int) (f2 * mHeaderHeight));
373 | mHeaderContainer.setLayoutParams(localLayoutParams);
374 | post(this);
375 | return;
376 | }
377 | mIsFinished = true;
378 | }
379 | }
380 | }
381 |
382 | public void startAnimation(long paramLong) {
383 | if (mZoomView != null) {
384 | mStartTime = SystemClock.currentThreadTimeMillis();
385 | mDuration = paramLong;
386 | mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
387 | mIsFinished = false;
388 | post(this);
389 | }
390 | }
391 | }
392 | }
393 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomScrollActivity.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.util.DisplayMetrics;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 | import android.view.View;
11 | import android.widget.LinearLayout;
12 |
13 | import com.ecloud.pulltozoomview.PullToZoomScrollViewEx;
14 |
15 | /**
16 | * Author: ZhuWenWu
17 | * Version V1.0
18 | * Date: 2014/9/4 17:30.
19 | * Description:
20 | * Modification History:
21 | * Date Author Version Description
22 | * -----------------------------------------------------------------------------------
23 | * 2014/9/4 ZhuWenWu 1.0 1.0
24 | * Why & What is modified:
25 | */
26 | public class PullToZoomScrollActivity extends ActionBarActivity {
27 |
28 | private PullToZoomScrollViewEx scrollView;
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_pull_to_zoom_scroll_view);
34 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
35 | loadViewForCode();
36 | scrollView = (PullToZoomScrollViewEx) findViewById(R.id.scroll_view);
37 | scrollView.getPullRootView().findViewById(R.id.tv_test1).setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | Log.e("zhuwenwu", "onClick -->");
41 | }
42 | });
43 |
44 | scrollView.getPullRootView().findViewById(R.id.tv_test2).setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View v) {
47 | Log.e("zhuwenwu", "onClick -->");
48 | }
49 | });
50 |
51 | scrollView.getPullRootView().findViewById(R.id.tv_test3).setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | Log.e("zhuwenwu", "onClick -->");
55 | }
56 | });
57 | DisplayMetrics localDisplayMetrics = new DisplayMetrics();
58 | getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
59 | int mScreenHeight = localDisplayMetrics.heightPixels;
60 | int mScreenWidth = localDisplayMetrics.widthPixels;
61 | LinearLayout.LayoutParams localObject = new LinearLayout.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
62 | scrollView.setHeaderLayoutParams(localObject);
63 | }
64 |
65 | @Override
66 | public boolean onCreateOptionsMenu(Menu menu) {
67 | getMenuInflater().inflate(R.menu.scroll_view, menu);
68 | return true;
69 | }
70 |
71 | @Override
72 | public boolean onOptionsItemSelected(MenuItem item) {
73 | int id = item.getItemId();
74 | if (id == android.R.id.home) {
75 | finish();
76 | return true;
77 | }
78 | // else if (id == R.id.action_settings) {
79 | // loadViewForCode();
80 | // return true;
81 | // }
82 | else if (id == R.id.action_normal) {
83 | scrollView.setParallax(false);
84 | return true;
85 | } else if (id == R.id.action_parallax) {
86 | scrollView.setParallax(true);
87 | return true;
88 | } else if (id == R.id.action_show_head) {
89 | // scrollView.showHeaderView();
90 | scrollView.setHideHeader(false);
91 | return true;
92 | } else if (id == R.id.action_hide_head) {
93 | // scrollView.hideHeaderVie˛w();
94 | scrollView.setHideHeader(true);
95 | return true;
96 | } else if (id == R.id.action_disable_zoom) {
97 | // scrollView.setEnableZoom(false);
98 | scrollView.setZoomEnabled(false);
99 | return true;
100 | } else if (id == R.id.action_enable_zoom) {
101 | // scrollView.setEnableZoom(true);
102 | scrollView.setZoomEnabled(true);
103 | return true;
104 | }
105 | return super.onOptionsItemSelected(item);
106 | }
107 |
108 | private void loadViewForCode() {
109 | PullToZoomScrollViewEx scrollView = (PullToZoomScrollViewEx) findViewById(R.id.scroll_view);
110 | View headView = LayoutInflater.from(this).inflate(R.layout.profile_head_view, null, false);
111 | View zoomView = LayoutInflater.from(this).inflate(R.layout.profile_zoom_view, null, false);
112 | View contentView = LayoutInflater.from(this).inflate(R.layout.profile_content_view, null, false);
113 | scrollView.setHeaderView(headView);
114 | scrollView.setZoomView(zoomView);
115 | scrollView.setScrollContentView(contentView);
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/PullToZoomRecyclerActivity.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview.demo.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.support.v7.widget.GridLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.DisplayMetrics;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.AbsListView;
14 | import android.widget.TextView;
15 |
16 | import com.ecloud.pulltozoomview.demo.PullToZoomRecyclerViewEx;
17 | import com.ecloud.pulltozoomview.demo.R;
18 |
19 | /**
20 | * Created by manishdeora on 13/05/15.
21 | */
22 | public class PullToZoomRecyclerActivity extends ActionBarActivity {
23 | private PullToZoomRecyclerViewEx listView;
24 |
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 |
30 |
31 | setContentView(R.layout.activity_pull_to_zoom_recycler_view);
32 |
33 | listView = (PullToZoomRecyclerViewEx) findViewById(R.id.recyclerview);
34 |
35 |
36 | final RecyclerViewHeaderAdapter mAdapter = new RecyclerAdapterCustom(this);
37 |
38 | final GridLayoutManager manager = new GridLayoutManager(this, 2);
39 | manager.setOrientation(GridLayoutManager.VERTICAL);
40 | manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
41 | @Override
42 | public int getSpanSize(int position) {
43 | return mAdapter.getItemViewType(position) == RecyclerViewHeaderAdapter.INT_TYPE_HEADER ? 2 : 1;
44 | }
45 | });
46 | listView.setAdapterAndLayoutManager(mAdapter, manager);
47 |
48 |
49 | DisplayMetrics localDisplayMetrics = new DisplayMetrics();
50 | getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
51 | int mScreenHeight = localDisplayMetrics.heightPixels;
52 | int mScreenWidth = localDisplayMetrics.widthPixels;
53 | AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
54 | listView.setHeaderLayoutParams(localObject);
55 | }
56 |
57 | @Override
58 | public boolean onCreateOptionsMenu(Menu menu) {
59 | getMenuInflater().inflate(R.menu.list_view, menu);
60 | return true;
61 | }
62 |
63 | @Override
64 | public boolean onOptionsItemSelected(MenuItem item) {
65 | int id = item.getItemId();
66 | if (id == android.R.id.home) {
67 | finish();
68 | return true;
69 | } else if (id == R.id.action_normal) {
70 | listView.setParallax(false);
71 | return true;
72 | } else if (id == R.id.action_parallax) {
73 | listView.setParallax(true);
74 | return true;
75 | } else if (id == R.id.action_show_head) {
76 | listView.setHideHeader(false);
77 | return true;
78 | } else if (id == R.id.action_hide_head) {
79 | listView.setHideHeader(true);
80 | return true;
81 | } else if (id == R.id.action_disable_zoom) {
82 | listView.setZoomEnabled(false);
83 | return true;
84 | } else if (id == R.id.action_enable_zoom) {
85 | listView.setZoomEnabled(true);
86 | return true;
87 | }
88 | return super.onOptionsItemSelected(item);
89 | }
90 |
91 |
92 | public class RecyclerAdapterCustom extends RecyclerViewHeaderAdapter {
93 | final String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
94 | "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
95 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
96 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
97 | "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
98 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
99 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
100 | "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
101 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
102 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
103 | "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
104 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
105 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
106 | "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
107 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
108 | "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
109 |
110 | public RecyclerAdapterCustom(Context context) {
111 | super(context);
112 | }
113 |
114 | @Override
115 | public int getCount() {
116 | return adapterData.length;
117 | }
118 |
119 | @Override
120 | public ViewHolderRecyclerPullToZoom onCreateContentView(ViewGroup parent, int viewType) {
121 | return new ViewHolderRecyclerPullToZoom(new TextView(getContext()));
122 | }
123 |
124 | @Override
125 | public void onBindView(ViewHolderRecyclerPullToZoom view, int position) {
126 |
127 | view.mtextview.setText(adapterData[position]);
128 |
129 | // final StaggeredGridLayoutManager.LayoutParams lp =
130 | // (StaggeredGridLayoutManager.LayoutParams) view.mtextview.getLayoutParams();
131 | ////
132 | // lp.span = span;
133 | // lp.height = size;
134 | // itemView.setLayoutParams(lp);
135 |
136 |
137 | }
138 | }
139 |
140 | public static class ViewHolderRecyclerPullToZoom extends RecyclerView.ViewHolder {
141 |
142 | TextView mtextview;
143 |
144 | public ViewHolderRecyclerPullToZoom(View itemView) {
145 | super(itemView);
146 |
147 | mtextview = (TextView) itemView;
148 | }
149 | }
150 | }
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/RecyclerViewHeaderAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Krishan Patel.
3 | * Copyright (c) 2014. Rocko Labs Ltd. All Rights Reserved.
4 | */
5 |
6 | package com.ecloud.pulltozoomview.demo.recyclerview;
7 |
8 | import android.content.Context;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.support.v7.widget.StaggeredGridLayoutManager;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | public abstract class RecyclerViewHeaderAdapter extends RecyclerView.Adapter {
18 | public static final int INT_TYPE_HEADER = 0;
19 | public static final int INT_TYPE_FOOTER = 1;
20 |
21 | public static class ExtraItem {
22 | public final int type;
23 | public final V view;
24 |
25 | public ExtraItem(int type, V view) {
26 | this.type = type;
27 | this.view = view;
28 | }
29 |
30 | }
31 |
32 | private View emptyView;
33 |
34 | private final Context context;
35 | private final List headers;
36 | private final List footers;
37 |
38 | public RecyclerViewHeaderAdapter(Context context) {
39 | this.context = context;
40 | this.headers = new ArrayList();
41 | this.footers = new ArrayList();
42 | }
43 |
44 | public Context getContext() {
45 | return context;
46 | }
47 |
48 | public void setEmptyView(View emptyView) {
49 | this.emptyView = emptyView;
50 | emptyView.setVisibility(getCount() == 0 ? View.VISIBLE : View.GONE);
51 | }
52 |
53 | public abstract int getCount();
54 |
55 | @Override
56 | public final int getItemCount() {
57 | int count = headers.size();
58 | count += getCount();
59 | count += footers.size();
60 |
61 | if (emptyView != null)
62 | emptyView.setVisibility(getCount() == 0 ? View.VISIBLE : View.GONE);
63 |
64 | return count;
65 | }
66 |
67 | public ExtraItem addHeaderView(int type, V headerView) {
68 | ExtraItem item = new ExtraItem(type, headerView);
69 | addHeaderView(item);
70 | return item;
71 | }
72 |
73 | public void addHeaderView(ExtraItem headerView) {
74 | headers.add(headerView);
75 | notifyItemInserted(headers.size());
76 | }
77 |
78 | public void removeHeaderView(int type) {
79 | List indexesToRemove = new ArrayList();
80 | for (int i = 0; i < headers.size(); i++) {
81 | ExtraItem item = headers.get(i);
82 | if (item.type == type)
83 | indexesToRemove.add(item);
84 | }
85 |
86 | for (ExtraItem item : indexesToRemove) {
87 | int index = headers.indexOf(item);
88 | headers.remove(item);
89 | notifyItemRemoved(index);
90 | }
91 | }
92 |
93 | public void removeHeaderView(ExtraItem headerView) {
94 | int indexToRemove = headers.indexOf(headerView);
95 | if (indexToRemove >= 0) {
96 | headers.remove(indexToRemove);
97 | notifyItemRemoved(indexToRemove);
98 | }
99 | }
100 |
101 | public ExtraItem addFooterView(int type, V footerView) {
102 | ExtraItem item = new ExtraItem(type, footerView);
103 | addFooterView(item);
104 | return item;
105 | }
106 |
107 | public void addFooterView(ExtraItem footerView) {
108 | footers.add(footerView);
109 | notifyItemInserted(getItemCount());
110 | }
111 |
112 | public void removeFooterView(int type) {
113 | List indexesToRemove = new ArrayList();
114 | for (int i = 0; i < footers.size(); i++) {
115 | ExtraItem item = footers.get(i);
116 | if (item.type == type)
117 | indexesToRemove.add(item);
118 | }
119 |
120 | for (ExtraItem item : indexesToRemove) {
121 | int index = footers.indexOf(item);
122 | footers.remove(item);
123 | notifyItemRemoved(headers.size() + getCount() + index);
124 | }
125 | }
126 |
127 | public void removeFooterView(ExtraItem footerView) {
128 | int indexToRemove = footers.indexOf(footerView);
129 | if (indexToRemove >= 0) {
130 | footers.remove(indexToRemove);
131 | notifyItemRemoved(headers.size() + getCount() + indexToRemove);
132 | }
133 | }
134 |
135 | public int getViewType(int position) {
136 | return super.getItemViewType(position);
137 | }
138 |
139 |
140 | public ExtraItem getHeader(int mIntArgHeaderPos) {
141 |
142 | if (headers != null && headers.size() > mIntArgHeaderPos) {
143 | return headers.get(mIntArgHeaderPos);
144 | }
145 | return null;
146 | }
147 |
148 | @Override
149 | public final int getItemViewType(int position) {
150 | if (position < headers.size())
151 | return INT_TYPE_HEADER;
152 | else
153 | return INT_TYPE_FOOTER;
154 | // return getViewType(position - headers.size());
155 | }
156 |
157 | @Override
158 | public final V onCreateViewHolder(ViewGroup parent, int viewType) {
159 | for (ExtraItem item : headers)
160 | if (viewType == item.type)
161 | return item.view;
162 |
163 | for (ExtraItem item : footers)
164 | if (viewType == item.type)
165 | return item.view;
166 |
167 | return onCreateContentView(parent, viewType);
168 | }
169 |
170 | public abstract V onCreateContentView(ViewGroup parent, int viewType);
171 |
172 | @Override
173 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
174 | if (position >= headers.size() && (position - headers.size()) < getCount()) {
175 | //noinspection unchecked
176 | onBindView((V) holder, position - headers.size());
177 | } else {
178 |
179 | try {
180 | final StaggeredGridLayoutManager.LayoutParams lp =
181 | (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
182 | //
183 | lp.setFullSpan(true);
184 | ;
185 |
186 | holder.itemView.setLayoutParams(lp);
187 | } catch (Exception e) {
188 | e.printStackTrace();
189 | }
190 | }
191 | }
192 |
193 | public abstract void onBindView(V view, int position);
194 |
195 | }
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/SpannableStaggeredGridLayoutManager.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview.demo.recyclerview;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 |
5 | /**
6 | * Created by manishdeora on 14/05/15.
7 | */
8 | public class SpannableStaggeredGridLayoutManager extends RecyclerView.LayoutManager{
9 |
10 |
11 | @Override
12 | public RecyclerView.LayoutParams generateDefaultLayoutParams() {
13 | return null;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_img_line_v.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_img_line_v.png
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_img_profile_bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_img_profile_bg.jpg
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_img_user_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_img_user_default.png
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-xhdpi/splash01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-xhdpi/splash01.jpg
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
23 |
24 |
34 |
35 |
36 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_list_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
15 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
15 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_scroll_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/list_head_zoom_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/profile_content_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
25 |
26 |
34 |
35 |
42 |
43 |
47 |
48 |
55 |
56 |
63 |
64 |
71 |
72 |
79 |
80 |
84 |
85 |
92 |
93 |
100 |
101 |
108 |
109 |
116 |
117 |
121 |
122 |
129 |
130 |
137 |
138 |
145 |
146 |
153 |
154 |
158 |
159 |
166 |
167 |
174 |
175 |
182 |
183 |
190 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/profile_head_view.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
16 |
17 |
27 |
28 |
37 |
38 |
49 |
50 |
61 |
62 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/layout/profile_zoom_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/menu/list_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/menu/scroll_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PullToZoomView
5 | Hello world!
6 | Code
7 | ZoomListView
8 | ZoomScrollView
9 | ZoomRecyclerView
10 | Normal
11 | Parallax
12 | Show Head
13 | Hide Head
14 | Disable Zoom
15 | Enable Zoom
16 |
17 |
18 |
--------------------------------------------------------------------------------
/PullToZoomView/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/PullToZoomView/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:1.2.3'
9 |
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 |
--------------------------------------------------------------------------------
/PullToZoomView/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | VERSION_NAME=1.0.0
21 | VERSION_CODE=100
22 | GROUP=com.github.frank-zhu
23 |
24 | ANDROID_BUILD_MIN_SDK_VERSION=14
25 | ANDROID_BUILD_TARGET_SDK_VERSION=23
26 | ANDROID_BUILD_SDK_VERSION=23
27 | ANDROID_BUILD_TOOLS_VERSION=23.0.0
28 |
29 | POM_DESCRIPTION=An Android custom ListView and ScrollView with pull to zoom-in.
30 | POM_URL=https://github.com/Frank-Zhu/PullZoomView/tree/master/PullToZoomView
31 | POM_SCM_URL=https://github.com/Frank-Zhu/PullZoomView/tree/master/PullToZoomView
32 | POM_SCM_CONNECTION=scm:git@github.com:Frank-Zhu/PullZoomView.git
33 | POM_SCM_DEV_CONNECTION=scm:git@github.com:Frank-Zhu/PullZoomView.git
34 | POM_LICENCE_NAME=apache
35 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0
36 | POM_LICENCE_DIST=repo
37 | POM_DEVELOPER_ID=frank-zhu
38 | POM_DEVELOPER_NAME=Frank Zhu
--------------------------------------------------------------------------------
/PullToZoomView/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/PullToZoomView/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Feb 06 15:14:21 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/PullToZoomView/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 |
--------------------------------------------------------------------------------
/PullToZoomView/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 |
--------------------------------------------------------------------------------
/PullToZoomView/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/PullToZoomView/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'maven'
3 |
4 | android {
5 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
6 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
7 |
8 | defaultConfig {
9 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
10 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
11 | versionName project.VERSION_NAME
12 | versionCode Integer.parseInt(project.VERSION_CODE)
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 | compile 'com.android.support:appcompat-v7:23.0.1'
25 | }
26 |
27 | apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
28 |
--------------------------------------------------------------------------------
/PullToZoomView/library/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | POM_NAME=PullToZoomView Library
21 | POM_ARTIFACT_ID=pullzoomview
22 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/PullToZoomView/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 E:/Android/android-studio/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/androidTest/java/com/ecloud/pulltozoomview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/IPullToZoom.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview;
2 |
3 | /**
4 | * Author: ZhuWenWu
5 | * Version V1.0
6 | * Date: 2014/11/7 14:21.
7 | * Description:
8 | * Modification History:
9 | * Date Author Version Description
10 | * -----------------------------------------------------------------------------------
11 | * 2014/11/7 ZhuWenWu 1.0 1.0
12 | * Why & What is modified:
13 | */
14 |
15 | import android.content.res.TypedArray;
16 | import android.view.View;
17 |
18 | public interface IPullToZoom {
19 | /**
20 | * Get the Wrapped Zoom View. Anything returned here has already been
21 | * added to the content view.
22 | *
23 | * @return The View which is currently wrapped
24 | */
25 | public View getZoomView();
26 |
27 | public View getHeaderView();
28 |
29 | /**
30 | * Get the Wrapped root View.
31 | *
32 | * @return The View which is currently wrapped
33 | */
34 | public T getPullRootView();
35 |
36 | /**
37 | * Whether Pull-to-Refresh is enabled
38 | *
39 | * @return enabled
40 | */
41 | public boolean isPullToZoomEnabled();
42 |
43 | /**
44 | * Returns whether the Widget is currently in the Zooming state
45 | *
46 | * @return true if the Widget is currently zooming
47 | */
48 | public boolean isZooming();
49 |
50 | /**
51 | * Returns whether the Widget is currently in the Zooming anim type
52 | *
53 | * @return true if the anim is parallax
54 | */
55 | public boolean isParallax();
56 |
57 | public boolean isHideHeader();
58 |
59 | public void handleStyledAttributes(TypedArray a);
60 | }
61 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomBase.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.support.annotation.NonNull;
7 | import android.util.AttributeSet;
8 | import android.util.DisplayMetrics;
9 | import android.view.Gravity;
10 | import android.view.LayoutInflater;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.ViewConfiguration;
14 | import android.view.ViewGroup;
15 | import android.widget.LinearLayout;
16 |
17 | /**
18 | * Author: ZhuWenWu
19 | * Version V1.0
20 | * Date: 2014/11/7 14:18.
21 | * Description:
22 | * Modification History:
23 | * Date Author Version Description
24 | * -----------------------------------------------------------------------------------
25 | * 2014/11/7 ZhuWenWu 1.0 1.0
26 | * Why & What is modified:
27 | */
28 | public abstract class PullToZoomBase extends LinearLayout implements IPullToZoom {
29 | private static final float FRICTION = 2.0f;
30 | protected T mRootView;
31 | protected View mHeaderView;//头部View
32 | protected View mZoomView;//缩放拉伸View
33 |
34 | protected int mScreenHeight;
35 | protected int mScreenWidth;
36 |
37 | private boolean isZoomEnabled = true;
38 | private boolean isParallax = true;
39 | private boolean isZooming = false;
40 | private boolean isHideHeader = false;
41 |
42 | private int mTouchSlop;
43 | private boolean mIsBeingDragged = false;
44 | private float mLastMotionY;
45 | private float mLastMotionX;
46 | private float mInitialMotionY;
47 | private float mInitialMotionX;
48 | private OnPullZoomListener onPullZoomListener;
49 |
50 | public PullToZoomBase(Context context) {
51 | this(context, null);
52 | }
53 |
54 | public PullToZoomBase(Context context, AttributeSet attrs) {
55 | super(context, attrs);
56 |
57 | init(context, attrs);
58 | }
59 |
60 | private void init(Context context, AttributeSet attrs) {
61 | setGravity(Gravity.CENTER);
62 |
63 | ViewConfiguration config = ViewConfiguration.get(context);
64 | mTouchSlop = config.getScaledTouchSlop();
65 |
66 | DisplayMetrics localDisplayMetrics = new DisplayMetrics();
67 | ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
68 | mScreenHeight = localDisplayMetrics.heightPixels;
69 | mScreenWidth = localDisplayMetrics.widthPixels;
70 |
71 | // Refreshable View
72 | // By passing the attrs, we can add ListView/GridView params via XML
73 | mRootView = createRootView(context, attrs);
74 |
75 | if (attrs != null) {
76 | LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
77 | //初始化状态View
78 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PullToZoomView);
79 |
80 | int zoomViewResId = a.getResourceId(R.styleable.PullToZoomView_zoomView, 0);
81 | if (zoomViewResId > 0) {
82 | mZoomView = mLayoutInflater.inflate(zoomViewResId, null, false);
83 | }
84 |
85 | int headerViewResId = a.getResourceId(R.styleable.PullToZoomView_headerView, 0);
86 | if (headerViewResId > 0) {
87 | mHeaderView = mLayoutInflater.inflate(headerViewResId, null, false);
88 | }
89 |
90 | isParallax = a.getBoolean(R.styleable.PullToZoomView_isHeaderParallax, true);
91 |
92 | // Let the derivative classes have a go at handling attributes, then
93 | // recycle them...
94 | handleStyledAttributes(a);
95 | a.recycle();
96 | }
97 | addView(mRootView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
98 | }
99 |
100 | public void setOnPullZoomListener(OnPullZoomListener onPullZoomListener) {
101 | this.onPullZoomListener = onPullZoomListener;
102 | }
103 |
104 | @Override
105 | public T getPullRootView() {
106 | return mRootView;
107 | }
108 |
109 | @Override
110 | public View getZoomView() {
111 | return mZoomView;
112 | }
113 |
114 | @Override
115 | public View getHeaderView() {
116 | return mHeaderView;
117 | }
118 |
119 | @Override
120 | public boolean isPullToZoomEnabled() {
121 | return isZoomEnabled;
122 | }
123 |
124 | @Override
125 | public boolean isZooming() {
126 | return isZooming;
127 | }
128 |
129 | @Override
130 | public boolean isParallax() {
131 | return isParallax;
132 | }
133 |
134 | @Override
135 | public boolean isHideHeader() {
136 | return isHideHeader;
137 | }
138 |
139 | public void setZoomEnabled(boolean isZoomEnabled) {
140 | this.isZoomEnabled = isZoomEnabled;
141 | }
142 |
143 | public void setParallax(boolean isParallax) {
144 | this.isParallax = isParallax;
145 | }
146 |
147 | public void setHideHeader(boolean isHideHeader) {//header显示才能Zoom
148 | this.isHideHeader = isHideHeader;
149 | }
150 |
151 | @Override
152 | public boolean onInterceptTouchEvent(MotionEvent event) {
153 | if (!isPullToZoomEnabled() || isHideHeader()) {
154 | return false;
155 | }
156 |
157 | final int action = event.getAction();
158 |
159 | if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
160 | mIsBeingDragged = false;
161 | return false;
162 | }
163 |
164 | if (action != MotionEvent.ACTION_DOWN && mIsBeingDragged) {
165 | return true;
166 | }
167 | switch (action) {
168 | case MotionEvent.ACTION_MOVE: {
169 | if (isReadyForPullStart()) {
170 | final float y = event.getY(), x = event.getX();
171 | final float diff, oppositeDiff, absDiff;
172 |
173 | // We need to use the correct values, based on scroll
174 | // direction
175 | diff = y - mLastMotionY;
176 | oppositeDiff = x - mLastMotionX;
177 | absDiff = Math.abs(diff);
178 |
179 | if (absDiff > mTouchSlop && absDiff > Math.abs(oppositeDiff)) {
180 | if (diff >= 1f && isReadyForPullStart()) {
181 | mLastMotionY = y;
182 | mLastMotionX = x;
183 | mIsBeingDragged = true;
184 | }
185 | }
186 | }
187 | break;
188 | }
189 | case MotionEvent.ACTION_DOWN: {
190 | if (isReadyForPullStart()) {
191 | mLastMotionY = mInitialMotionY = event.getY();
192 | mLastMotionX = mInitialMotionX = event.getX();
193 | mIsBeingDragged = false;
194 | }
195 | break;
196 | }
197 | }
198 |
199 | return mIsBeingDragged;
200 | }
201 |
202 | @Override
203 | public boolean onTouchEvent(@NonNull MotionEvent event) {
204 | if (!isPullToZoomEnabled() || isHideHeader()) {
205 | return false;
206 | }
207 |
208 | if (event.getAction() == MotionEvent.ACTION_DOWN && event.getEdgeFlags() != 0) {
209 | return false;
210 | }
211 |
212 | switch (event.getAction()) {
213 | case MotionEvent.ACTION_MOVE: {
214 | if (mIsBeingDragged) {
215 | mLastMotionY = event.getY();
216 | mLastMotionX = event.getX();
217 | pullEvent();
218 | isZooming = true;
219 | return true;
220 | }
221 | break;
222 | }
223 |
224 | case MotionEvent.ACTION_DOWN: {
225 | if (isReadyForPullStart()) {
226 | mLastMotionY = mInitialMotionY = event.getY();
227 | mLastMotionX = mInitialMotionX = event.getX();
228 | return true;
229 | }
230 | break;
231 | }
232 |
233 | case MotionEvent.ACTION_CANCEL:
234 | case MotionEvent.ACTION_UP: {
235 | if (mIsBeingDragged) {
236 | mIsBeingDragged = false;
237 | // If we're already refreshing, just scroll back to the top
238 | if (isZooming()) {
239 | smoothScrollToTop();
240 | if (onPullZoomListener != null) {
241 | onPullZoomListener.onPullZoomEnd();
242 | }
243 | isZooming = false;
244 | return true;
245 | }
246 | return true;
247 | }
248 | break;
249 | }
250 | }
251 | return false;
252 | }
253 |
254 | private void pullEvent() {
255 | final int newScrollValue;
256 | final float initialMotionValue, lastMotionValue;
257 |
258 | initialMotionValue = mInitialMotionY;
259 | lastMotionValue = mLastMotionY;
260 |
261 | newScrollValue = Math.round(Math.min(initialMotionValue - lastMotionValue, 0) / FRICTION);
262 |
263 | pullHeaderToZoom(newScrollValue);
264 | if (onPullZoomListener != null) {
265 | onPullZoomListener.onPullZooming(newScrollValue);
266 | }
267 | }
268 |
269 | protected abstract void pullHeaderToZoom(int newScrollValue);
270 |
271 | public abstract void setHeaderView(View headerView);
272 |
273 | public abstract void setZoomView(View zoomView);
274 |
275 | protected abstract T createRootView(Context context, AttributeSet attrs);
276 |
277 | protected abstract void smoothScrollToTop();
278 |
279 | protected abstract boolean isReadyForPullStart();
280 |
281 | public interface OnPullZoomListener {
282 | public void onPullZooming(int newScrollValue);
283 |
284 | public void onPullZoomEnd();
285 | }
286 | }
287 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListViewEx.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.os.SystemClock;
6 | import android.util.AttributeSet;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.animation.Interpolator;
11 | import android.widget.AbsListView;
12 | import android.widget.Adapter;
13 | import android.widget.AdapterView;
14 | import android.widget.FrameLayout;
15 | import android.widget.ListAdapter;
16 | import android.widget.ListView;
17 |
18 | /**
19 | * Author: ZhuWenWu
20 | * Version V1.0
21 | * Date: 2014/11/7 18:01.
22 | * Description:
23 | * Modification History:
24 | * Date Author Version Description
25 | * -----------------------------------------------------------------------------------
26 | * 2014/11/7 ZhuWenWu 1.0 1.0
27 | * Why & What is modified:
28 | */
29 | public class PullToZoomListViewEx extends PullToZoomBase implements AbsListView.OnScrollListener {
30 | private static final String TAG = PullToZoomListViewEx.class.getSimpleName();
31 | private FrameLayout mHeaderContainer;
32 | private int mHeaderHeight;
33 | private ScalingRunnable mScalingRunnable;
34 |
35 | private static final Interpolator sInterpolator = new Interpolator() {
36 | public float getInterpolation(float paramAnonymousFloat) {
37 | float f = paramAnonymousFloat - 1.0F;
38 | return 1.0F + f * (f * (f * (f * f)));
39 | }
40 | };
41 |
42 | public PullToZoomListViewEx(Context context) {
43 | this(context, null);
44 | }
45 |
46 | public PullToZoomListViewEx(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | mRootView.setOnScrollListener(this);
49 | mScalingRunnable = new ScalingRunnable();
50 | }
51 |
52 | /**
53 | * 是否显示headerView
54 | *
55 | * @param isHideHeader true: show false: hide
56 | */
57 | @Override
58 | public void setHideHeader(boolean isHideHeader) {
59 | if (isHideHeader != isHideHeader()) {
60 | super.setHideHeader(isHideHeader);
61 | if (isHideHeader) {
62 | removeHeaderView();
63 | } else {
64 | updateHeaderView();
65 | }
66 | }
67 | }
68 |
69 | @Override
70 | public void setHeaderView(View headerView) {
71 | if (headerView != null) {
72 | this.mHeaderView = headerView;
73 | updateHeaderView();
74 | }
75 | }
76 |
77 | @Override
78 | public void setZoomView(View zoomView) {
79 | if (zoomView != null) {
80 | this.mZoomView = zoomView;
81 | updateHeaderView();
82 | }
83 | }
84 |
85 | private void removeHeaderView() {
86 | if (mHeaderContainer != null) {
87 | mRootView.removeHeaderView(mHeaderContainer);
88 | }
89 | }
90 |
91 | private void updateHeaderView() {
92 | if (mHeaderContainer != null) {
93 | mRootView.removeHeaderView(mHeaderContainer);
94 |
95 | mHeaderContainer.removeAllViews();
96 |
97 | if (mZoomView != null) {
98 | mHeaderContainer.addView(mZoomView);
99 | }
100 |
101 | if (mHeaderView != null) {
102 | mHeaderContainer.addView(mHeaderView);
103 | }
104 |
105 | mHeaderHeight = mHeaderContainer.getHeight();
106 | mRootView.addHeaderView(mHeaderContainer);
107 | }
108 | }
109 |
110 | public void setAdapter(ListAdapter adapter) {
111 | mRootView.setAdapter(adapter);
112 | }
113 |
114 | public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
115 | mRootView.setOnItemClickListener(listener);
116 | }
117 |
118 | @Override
119 | protected ListView createRootView(Context context, AttributeSet attrs) {
120 | ListView lv = new ListView(context, attrs);
121 | // Set it to this so it can be used in ListActivity/ListFragment
122 | lv.setId(android.R.id.list);
123 | return lv;
124 | }
125 |
126 | /**
127 | * 重置动画,自动滑动到顶部
128 | */
129 | @Override
130 | protected void smoothScrollToTop() {
131 | Log.d(TAG, "smoothScrollToTop --> ");
132 | mScalingRunnable.startAnimation(200L);
133 | }
134 |
135 | @Override
136 | protected void pullHeaderToZoom(int newScrollValue) {
137 | Log.d(TAG, "pullHeaderToZoom --> newScrollValue = " + newScrollValue);
138 | Log.d(TAG, "pullHeaderToZoom --> mHeaderHeight = " + mHeaderHeight);
139 | if (mScalingRunnable != null && !mScalingRunnable.isFinished()) {
140 | mScalingRunnable.abortAnimation();
141 | }
142 |
143 | ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
144 | localLayoutParams.height = Math.abs(newScrollValue) + mHeaderHeight;
145 | mHeaderContainer.setLayoutParams(localLayoutParams);
146 | }
147 |
148 | @Override
149 | protected boolean isReadyForPullStart() {
150 | return isFirstItemVisible();
151 | }
152 |
153 | private boolean isFirstItemVisible() {
154 | final Adapter adapter = mRootView.getAdapter();
155 |
156 | if (null == adapter || adapter.isEmpty()) {
157 | return true;
158 | } else {
159 | /**
160 | * This check should really just be:
161 | * mRootView.getFirstVisiblePosition() == 0, but PtRListView
162 | * internally use a HeaderView which messes the positions up. For
163 | * now we'll just add one to account for it and rely on the inner
164 | * condition which checks getTop().
165 | */
166 | if (mRootView.getFirstVisiblePosition() <= 1) {
167 | final View firstVisibleChild = mRootView.getChildAt(0);
168 | if (firstVisibleChild != null) {
169 | return firstVisibleChild.getTop() >= mRootView.getTop();
170 | }
171 | }
172 | }
173 |
174 | return false;
175 | }
176 |
177 | @Override
178 | public void handleStyledAttributes(TypedArray a) {
179 | mHeaderContainer = new FrameLayout(getContext());
180 | if (mZoomView != null) {
181 | mHeaderContainer.addView(mZoomView);
182 | }
183 | if (mHeaderView != null) {
184 | mHeaderContainer.addView(mHeaderView);
185 | }
186 |
187 | mRootView.addHeaderView(mHeaderContainer);
188 | }
189 |
190 | /**
191 | * 设置HeaderView高度
192 | *
193 | * @param width
194 | * @param height
195 | */
196 | public void setHeaderViewSize(int width, int height) {
197 | if (mHeaderContainer != null) {
198 | Object localObject = mHeaderContainer.getLayoutParams();
199 | if (localObject == null) {
200 | localObject = new AbsListView.LayoutParams(width, height);
201 | }
202 | ((ViewGroup.LayoutParams) localObject).width = width;
203 | ((ViewGroup.LayoutParams) localObject).height = height;
204 | mHeaderContainer.setLayoutParams((ViewGroup.LayoutParams) localObject);
205 | mHeaderHeight = height;
206 | }
207 | }
208 |
209 | public void setHeaderLayoutParams(AbsListView.LayoutParams layoutParams) {
210 | if (mHeaderContainer != null) {
211 | mHeaderContainer.setLayoutParams(layoutParams);
212 | mHeaderHeight = layoutParams.height;
213 | }
214 | }
215 |
216 | protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2,
217 | int paramInt3, int paramInt4) {
218 | super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
219 | Log.d(TAG, "onLayout --> ");
220 | if (mHeaderHeight == 0 && mHeaderContainer != null) {
221 | mHeaderHeight = mHeaderContainer.getHeight();
222 | }
223 | }
224 |
225 | @Override
226 | public void onScrollStateChanged(AbsListView view, int scrollState) {
227 | Log.d(TAG, "onScrollStateChanged --> ");
228 | }
229 |
230 | @Override
231 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
232 | if (mZoomView != null && !isHideHeader() && isPullToZoomEnabled()) {
233 | float f = mHeaderHeight - mHeaderContainer.getBottom();
234 | Log.d(TAG, "onScroll --> f = " + f);
235 | if (isParallax()) {
236 | if ((f > 0.0F) && (f < mHeaderHeight)) {
237 | int i = (int) (0.65D * f);
238 | mHeaderContainer.scrollTo(0, -i);
239 | } else if (mHeaderContainer.getScrollY() != 0) {
240 | mHeaderContainer.scrollTo(0, 0);
241 | }
242 | }
243 | }
244 | }
245 |
246 |
247 | class ScalingRunnable implements Runnable {
248 | protected long mDuration;
249 | protected boolean mIsFinished = true;
250 | protected float mScale;
251 | protected long mStartTime;
252 |
253 | ScalingRunnable() {
254 | }
255 |
256 | public void abortAnimation() {
257 | mIsFinished = true;
258 | }
259 |
260 | public boolean isFinished() {
261 | return mIsFinished;
262 | }
263 |
264 | public void run() {
265 | if (mZoomView != null) {
266 | float f2;
267 | ViewGroup.LayoutParams localLayoutParams;
268 | if ((!mIsFinished) && (mScale > 1.0D)) {
269 | float f1 = ((float) SystemClock.currentThreadTimeMillis() - (float) mStartTime) / (float) mDuration;
270 | f2 = mScale - (mScale - 1.0F) * PullToZoomListViewEx.sInterpolator.getInterpolation(f1);
271 | localLayoutParams = mHeaderContainer.getLayoutParams();
272 | Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
273 | if (f2 > 1.0F) {
274 | localLayoutParams.height = ((int) (f2 * mHeaderHeight));
275 | mHeaderContainer.setLayoutParams(localLayoutParams);
276 | post(this);
277 | return;
278 | }
279 | mIsFinished = true;
280 | }
281 | }
282 | }
283 |
284 | public void startAnimation(long paramLong) {
285 | if (mZoomView != null) {
286 | mStartTime = SystemClock.currentThreadTimeMillis();
287 | mDuration = paramLong;
288 | mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
289 | mIsFinished = false;
290 | post(this);
291 | }
292 | }
293 | }
294 | }
295 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollViewEx.java:
--------------------------------------------------------------------------------
1 | package com.ecloud.pulltozoomview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.os.SystemClock;
6 | import android.util.AttributeSet;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.view.animation.Interpolator;
12 | import android.widget.FrameLayout;
13 | import android.widget.LinearLayout;
14 | import android.widget.ScrollView;
15 |
16 | /**
17 | * Author: ZhuWenWu
18 | * Version V1.0
19 | * Date: 2014/11/10 14:25.
20 | * Description:
21 | * Modification History:
22 | * Date Author Version Description
23 | * -----------------------------------------------------------------------------------
24 | * 2014/11/10 ZhuWenWu 1.0 1.0
25 | * Why & What is modified:
26 | */
27 | public class PullToZoomScrollViewEx extends PullToZoomBase {
28 | private static final String TAG = PullToZoomScrollViewEx.class.getSimpleName();
29 | private boolean isCustomHeaderHeight = false;
30 | private FrameLayout mHeaderContainer;
31 | private LinearLayout mRootContainer;
32 | private View mContentView;
33 | private int mHeaderHeight;
34 | private ScalingRunnable mScalingRunnable;
35 |
36 | private static final Interpolator sInterpolator = new Interpolator() {
37 | public float getInterpolation(float paramAnonymousFloat) {
38 | float f = paramAnonymousFloat - 1.0F;
39 | return 1.0F + f * (f * (f * (f * f)));
40 | }
41 | };
42 |
43 | public PullToZoomScrollViewEx(Context context) {
44 | this(context, null);
45 | }
46 |
47 | public PullToZoomScrollViewEx(Context context, AttributeSet attrs) {
48 | super(context, attrs);
49 | mScalingRunnable = new ScalingRunnable();
50 | ((InternalScrollView) mRootView).setOnScrollViewChangedListener(new OnScrollViewChangedListener() {
51 | @Override
52 | public void onInternalScrollChanged(int left, int top, int oldLeft, int oldTop) {
53 | if (isPullToZoomEnabled() && isParallax()) {
54 | Log.d(TAG, "onScrollChanged --> getScrollY() = " + mRootView.getScrollY());
55 | float f = mHeaderHeight - mHeaderContainer.getBottom() + mRootView.getScrollY();
56 | Log.d(TAG, "onScrollChanged --> f = " + f);
57 | if ((f > 0.0F) && (f < mHeaderHeight)) {
58 | int i = (int) (0.65D * f);
59 | mHeaderContainer.scrollTo(0, -i);
60 | } else if (mHeaderContainer.getScrollY() != 0) {
61 | mHeaderContainer.scrollTo(0, 0);
62 | }
63 | }
64 | }
65 | });
66 | }
67 |
68 | @Override
69 | protected void pullHeaderToZoom(int newScrollValue) {
70 | Log.d(TAG, "pullHeaderToZoom --> newScrollValue = " + newScrollValue);
71 | Log.d(TAG, "pullHeaderToZoom --> mHeaderHeight = " + mHeaderHeight);
72 | if (mScalingRunnable != null && !mScalingRunnable.isFinished()) {
73 | mScalingRunnable.abortAnimation();
74 | }
75 |
76 | ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
77 | localLayoutParams.height = Math.abs(newScrollValue) + mHeaderHeight;
78 | mHeaderContainer.setLayoutParams(localLayoutParams);
79 |
80 | if (isCustomHeaderHeight) {
81 | ViewGroup.LayoutParams zoomLayoutParams = mZoomView.getLayoutParams();
82 | zoomLayoutParams.height = Math.abs(newScrollValue) + mHeaderHeight;
83 | mZoomView.setLayoutParams(zoomLayoutParams);
84 | }
85 | }
86 |
87 | /**
88 | * 是否显示headerView
89 | *
90 | * @param isHideHeader true: show false: hide
91 | */
92 | @Override
93 | public void setHideHeader(boolean isHideHeader) {
94 | if (isHideHeader != isHideHeader() && mHeaderContainer != null) {
95 | super.setHideHeader(isHideHeader);
96 | if (isHideHeader) {
97 | mHeaderContainer.setVisibility(GONE);
98 | } else {
99 | mHeaderContainer.setVisibility(VISIBLE);
100 | }
101 | }
102 | }
103 |
104 | @Override
105 | public void setHeaderView(View headerView) {
106 | if (headerView != null) {
107 | mHeaderView = headerView;
108 | updateHeaderView();
109 | }
110 | }
111 |
112 | @Override
113 | public void setZoomView(View zoomView) {
114 | if (zoomView != null) {
115 | mZoomView = zoomView;
116 | updateHeaderView();
117 | }
118 | }
119 |
120 | private void updateHeaderView() {
121 | if (mHeaderContainer != null) {
122 | mHeaderContainer.removeAllViews();
123 |
124 | if (mZoomView != null) {
125 | mHeaderContainer.addView(mZoomView);
126 | }
127 |
128 | if (mHeaderView != null) {
129 | mHeaderContainer.addView(mHeaderView);
130 | }
131 | }
132 | }
133 |
134 | public void setScrollContentView(View contentView) {
135 | if (contentView != null) {
136 | if (mContentView != null) {
137 | mRootContainer.removeView(mContentView);
138 | }
139 | mContentView = contentView;
140 | mRootContainer.addView(mContentView);
141 | }
142 | }
143 |
144 | @Override
145 | protected ScrollView createRootView(Context context, AttributeSet attrs) {
146 | ScrollView scrollView = new InternalScrollView(context, attrs);
147 | scrollView.setId(R.id.scrollview);
148 | return scrollView;
149 | }
150 |
151 | @Override
152 | protected void smoothScrollToTop() {
153 | Log.d(TAG, "smoothScrollToTop --> ");
154 | mScalingRunnable.startAnimation(200L);
155 | }
156 |
157 | @Override
158 | protected boolean isReadyForPullStart() {
159 | return mRootView.getScrollY() == 0;
160 | }
161 |
162 | @Override
163 | public void handleStyledAttributes(TypedArray a) {
164 | mRootContainer = new LinearLayout(getContext());
165 | mRootContainer.setOrientation(LinearLayout.VERTICAL);
166 | mHeaderContainer = new FrameLayout(getContext());
167 |
168 | if (mZoomView != null) {
169 | mHeaderContainer.addView(mZoomView);
170 | }
171 | if (mHeaderView != null) {
172 | mHeaderContainer.addView(mHeaderView);
173 | }
174 | int contentViewResId = a.getResourceId(R.styleable.PullToZoomView_contentView, 0);
175 | if (contentViewResId > 0) {
176 | LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
177 | mContentView = mLayoutInflater.inflate(contentViewResId, null, false);
178 | }
179 |
180 | mRootContainer.addView(mHeaderContainer);
181 | if (mContentView != null) {
182 | mRootContainer.addView(mContentView);
183 | }
184 |
185 | mRootContainer.setClipChildren(false);
186 | mHeaderContainer.setClipChildren(false);
187 |
188 | mRootView.addView(mRootContainer);
189 | }
190 |
191 | /**
192 | * 设置HeaderView高度
193 | *
194 | * @param width
195 | * @param height
196 | */
197 | public void setHeaderViewSize(int width, int height) {
198 | if (mHeaderContainer != null) {
199 | Object localObject = mHeaderContainer.getLayoutParams();
200 | if (localObject == null) {
201 | localObject = new ViewGroup.LayoutParams(width, height);
202 | }
203 | ((ViewGroup.LayoutParams) localObject).width = width;
204 | ((ViewGroup.LayoutParams) localObject).height = height;
205 | mHeaderContainer.setLayoutParams((ViewGroup.LayoutParams) localObject);
206 | mHeaderHeight = height;
207 | isCustomHeaderHeight = true;
208 | }
209 | }
210 |
211 | /**
212 | * 设置HeaderView LayoutParams
213 | *
214 | * @param layoutParams LayoutParams
215 | */
216 | public void setHeaderLayoutParams(LinearLayout.LayoutParams layoutParams) {
217 | if (mHeaderContainer != null) {
218 | mHeaderContainer.setLayoutParams(layoutParams);
219 | mHeaderHeight = layoutParams.height;
220 | isCustomHeaderHeight = true;
221 | }
222 | }
223 |
224 | protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2,
225 | int paramInt3, int paramInt4) {
226 | super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
227 | Log.d(TAG, "onLayout --> ");
228 | if (mHeaderHeight == 0 && mZoomView != null) {
229 | mHeaderHeight = mHeaderContainer.getHeight();
230 | }
231 | }
232 |
233 | class ScalingRunnable implements Runnable {
234 | protected long mDuration;
235 | protected boolean mIsFinished = true;
236 | protected float mScale;
237 | protected long mStartTime;
238 |
239 | ScalingRunnable() {
240 | }
241 |
242 | public void abortAnimation() {
243 | mIsFinished = true;
244 | }
245 |
246 | public boolean isFinished() {
247 | return mIsFinished;
248 | }
249 |
250 | public void run() {
251 | if (mZoomView != null) {
252 | float f2;
253 | ViewGroup.LayoutParams localLayoutParams;
254 | if ((!mIsFinished) && (mScale > 1.0D)) {
255 | float f1 = ((float) SystemClock.currentThreadTimeMillis() - (float) mStartTime) / (float) mDuration;
256 | f2 = mScale - (mScale - 1.0F) * PullToZoomScrollViewEx.sInterpolator.getInterpolation(f1);
257 | localLayoutParams = mHeaderContainer.getLayoutParams();
258 | Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
259 | if (f2 > 1.0F) {
260 | localLayoutParams.height = ((int) (f2 * mHeaderHeight));
261 | mHeaderContainer.setLayoutParams(localLayoutParams);
262 | if (isCustomHeaderHeight) {
263 | ViewGroup.LayoutParams zoomLayoutParams;
264 | zoomLayoutParams = mZoomView.getLayoutParams();
265 | zoomLayoutParams.height = ((int) (f2 * mHeaderHeight));
266 | mZoomView.setLayoutParams(zoomLayoutParams);
267 | }
268 | post(this);
269 | return;
270 | }
271 | mIsFinished = true;
272 | }
273 | }
274 | }
275 |
276 | public void startAnimation(long paramLong) {
277 | if (mZoomView != null) {
278 | mStartTime = SystemClock.currentThreadTimeMillis();
279 | mDuration = paramLong;
280 | mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
281 | mIsFinished = false;
282 | post(this);
283 | }
284 | }
285 | }
286 |
287 | protected class InternalScrollView extends ScrollView {
288 | private OnScrollViewChangedListener onScrollViewChangedListener;
289 |
290 | public InternalScrollView(Context context) {
291 | this(context, null);
292 | }
293 |
294 | public InternalScrollView(Context context, AttributeSet attrs) {
295 | super(context, attrs);
296 | }
297 |
298 | public void setOnScrollViewChangedListener(OnScrollViewChangedListener onScrollViewChangedListener) {
299 | this.onScrollViewChangedListener = onScrollViewChangedListener;
300 | }
301 |
302 | @Override
303 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
304 | super.onScrollChanged(l, t, oldl, oldt);
305 | if (onScrollViewChangedListener != null) {
306 | onScrollViewChangedListener.onInternalScrollChanged(l, t, oldl, oldt);
307 | }
308 | }
309 | }
310 |
311 | protected interface OnScrollViewChangedListener {
312 | public void onInternalScrollChanged(int left, int top, int oldLeft, int oldTop);
313 | }
314 | }
315 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/library/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/library/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/library/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/PullToZoomView/library/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/PullToZoomView/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/PullToZoomView/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | PullZoomView
2 | ============
3 |
4 | An Android custom ListView and ScrollView with pull to zoom-in.
5 |
6 | 
7 |
8 | Features
9 | ============
10 | * Set ZoomView enable
11 | * Add HeaderView Custom
12 | * ZoomView Parallax or Normal
13 | * HeaderView Show or Hide
14 |
15 | Usage
16 | ============
17 |
18 | In your `build.gradle`:
19 |
20 | ```gradle
21 | dependencies {
22 | compile 'com.github.frank-zhu:pullzoomview:1.0.0'
23 | }
24 | ```
25 | or Maven:
26 |
27 | ```xml
28 |
29 | com.github.frank-zhu
30 | pullzoomview
31 | 1.0.0
32 | aar
33 |
34 | ```
35 |
36 | Using this library?
37 | ============
38 | If you're using this library in one of your projects just [send me a G+ message](https://plus.google.com/u/0/108962319538026346008/posts/p/pub) and I'll add your project to the list.
39 |
40 | Contribution
41 | ============
42 | ### Pull requests are welcome!
43 |
44 | If you have a bug to report a feature to request or have other questions, [file an issue](https://github.com/Frank-Zhu/PullZoomView/issues). I'll try to answer as soon as I can.
45 |
46 | Thanks
47 | ============
48 | Developers @matrixxun
49 | [PullToZoomInListView](https://github.com/matrixxun/PullToZoomInListView)
50 |
51 | About me
52 | ============
53 | [Click Me](http://frank-zhu.github.io/about/)
54 |
55 | License
56 | ============
57 |
58 | Copyright 2014 Frank Zhu
59 |
60 | Licensed under the Apache License, Version 2.0 (the "License");
61 | you may not use this file except in compliance with the License.
62 | You may obtain a copy of the License at
63 |
64 | http://www.apache.org/licenses/LICENSE-2.0
65 |
66 | Unless required by applicable law or agreed to in writing, software
67 | distributed under the License is distributed on an "AS IS" BASIS,
68 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69 | See the License for the specific language governing permissions and
70 | limitations under the License.
71 |
--------------------------------------------------------------------------------
/art/pull-to-zoom.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Frank-Zhu/PullZoomView/fed1339e86937d20ffba95f12b371aa459c7e3d9/art/pull-to-zoom.gif
--------------------------------------------------------------------------------