├── .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 |