├── .DS_Store ├── ._.DS_Store ├── .gitignore ├── .gradle └── 2.2.1 │ └── taskArtifacts │ ├── cache.properties │ ├── cache.properties.lock │ ├── fileHashes.bin │ ├── fileSnapshots.bin │ ├── outputFileStates.bin │ └── taskArtifacts.bin ├── LICENSE ├── README.markdown ├── build.gradle ├── build └── intermediates │ ├── dex-cache │ └── cache.xml │ └── model_data.bin ├── example2 ├── .gitignore ├── build.gradle ├── example2.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mingle │ │ └── example │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── mingle │ │ └── example │ │ ├── MainActivity.java │ │ ├── WebViewActivity.java │ │ ├── WebViewFragment.java │ │ └── model │ │ ├── OtherModelActivity.java │ │ ├── OtherViewModel.java │ │ ├── ScrollViewModel.java │ │ └── ScrollViewModelActivity.java │ └── res │ ├── layout │ ├── activity_main.xml │ ├── activity_other.xml │ ├── activity_pull_to_next_layout_demo.xml │ ├── activity_view_pager.xml │ ├── activity_web_view.xml │ ├── fragment_blank.xml │ ├── fragment_other.xml │ ├── fragment_scrollview.xml │ └── fragment_web_view.xml │ ├── menu │ ├── menu_main.xml │ ├── menu_other.xml │ ├── menu_pull_to_next_layout_demo.xml │ ├── menu_view_pager.xml │ └── menu_web_view.xml │ ├── mipmap-hdpi │ ├── ic_icon1.jpg │ ├── ic_icon2.jpg │ ├── ic_icon3.jpg │ ├── ic_icon4.jpg │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── datas.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── maven-push.gradle ├── pulltonextlayout ├── .DS_Store ├── ._.DS_Store ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── pulltonextlayout.iml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── mingle │ │ └── pulltonextlayout │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── mingle │ │ └── pulltonextlayout │ │ ├── BaseAdapter.java │ │ ├── OnItemSelectListener.java │ │ ├── PromptEntity.java │ │ ├── PullToNextEntity.java │ │ ├── PullToNextLayout.java │ │ ├── PullToNextView.java │ │ ├── adapter │ │ ├── PullToNextFragmentAdapter.java │ │ └── PullToNextModelAdapter.java │ │ ├── anim │ │ ├── PullToNextAnimationI.java │ │ └── SimpleAnimation.java │ │ ├── base │ │ └── SimpleAnimatorListener.java │ │ ├── model │ │ └── PullToNextModel.java │ │ └── observable │ │ ├── PullToNextDataObserver.java │ │ └── PullToNextDataSetObservable.java │ └── res │ ├── layout │ └── pull_to_next_prompt_view.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── attr.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/.DS_Store -------------------------------------------------------------------------------- /._.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/._.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | 21 | # Proguard folder generated by Eclipse 22 | proguard/ 23 | 24 | # Intellij project files 25 | *.iml 26 | *.ipr 27 | *.iws 28 | .idea/ 29 | 30 | # Log Files 31 | *.log 32 | /bin 33 | -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/cache.properties: -------------------------------------------------------------------------------- 1 | #Fri Apr 03 09:41:12 CST 2015 2 | -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/cache.properties.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/.gradle/2.2.1/taskArtifacts/cache.properties.lock -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/.gradle/2.2.1/taskArtifacts/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/fileSnapshots.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/outputFileStates.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/.gradle/2.2.1/taskArtifacts/outputFileStates.bin -------------------------------------------------------------------------------- /.gradle/2.2.1/taskArtifacts/taskArtifacts.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | 2 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android--PullToNextLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1893) 3 | --- 4 | 5 | 6 | ![webView.gif](http://upload-images.jianshu.io/upload_images/166866-c9840dfc44752550.gif) 7 | 8 | ![ScrollView.gif](http://upload-images.jianshu.io/upload_images/166866-2609a7f9c0d8f740.gif) 9 | 10 | ![other.gif](http://upload-images.jianshu.io/upload_images/166866-3a9ed8d196dad787.gif) 11 | 12 | 13 | 14 | [github](https://github.com/zzz40500/Android-PullToNextLayout) 15 | ##更新至1.3.1## 16 | #usage:# 17 | 18 | android studio 引用: 19 | ~~~ 20 | compile 'com.mingle.zzz40500:pulltonextlayout:1.3.1' 21 | ~~~ 22 | 23 | 24 | activity 的布局 25 | ~~~ 26 | 32 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | ~~~ 44 | 45 | 简单说明 : 布局中只有一个控件`PullToNextLayout`, 控件中不包含其他组件 46 | 47 | java 代码中引用使用: 48 | ~~~ 49 | pullToNextLayout= (PullToNextLayout) findViewById(R.id.pullToNextLayout); 50 | 51 | 52 | list=new ArrayList<>(); 53 | 54 | for (int i = 0; i < 4; i++) { 55 | 56 | list.add(new ScrollViewModel(currentIndex++)); 57 | } 58 | 59 | adapter= new PullToNextModelAdapter(this,list); 60 | pullToNextLayout.setAdapter(adapter); 61 | 62 | pullToNextLayout.setOnItemSelectListener(new OnItemSelectListener() { 63 | @Override 64 | public void onSelectItem(int position, View view) { 65 | setTitle(position+1+".0 谷歌仍是毕业生心目中的最佳雇主"); 66 | } 67 | }); 68 | ~~~ 69 | 70 | 71 | 72 | 73 | 74 | 75 | ScrollViewModel 76 | 主要方法如下: 77 | ~~~ 78 | @Override 79 | public void onCreate(Context context) { 80 | super.onCreate(context); 81 | Log.e(TAG,"onCreate"+" "+index); 82 | } 83 | 84 | /** 85 | * 返回视图 86 | * @return 87 | */ 88 | @Override 89 | public int getLayoutViewId() { 90 | return R.layout.fragment_scrollview; 91 | } 92 | /** 93 | * 绑定数据源 94 | * @param v 95 | */ 96 | @Override 97 | public void onBindView(int position, View v, PullToNextView pullToNextView) { 98 | 99 | PromptEntity p=new PromptEntity(); 100 | 101 | TextView titleTV= (TextView) v.findViewById(R.id.titleTV); 102 | TextView contentTv= (TextView) v.findViewById(R.id.textView); 103 | scrollView = (ScrollView) v.findViewById(R.id.scrollView); 104 | titleTV.setText(index+1+".0"+title); 105 | contentTv.setText(content); 106 | Log.e(TAG, "onBindView"+" "+index); 107 | } 108 | 109 | 110 | 111 | 112 | /** 113 | * 在onBindView 调用后调用. 114 | * @param view 115 | */ 116 | @Override 117 | public void onResumeView(int position, View view, PullToNextView pullToNextView) { 118 | super.onResumeView(position, view, pullToNextView); 119 | 120 | if(scrollView!=null){ 121 | scrollView.pageScroll(ScrollView.FOCUS_UP); 122 | } 123 | Log.e(TAG, "onResumeView"+" "+index); 124 | } 125 | 126 | 127 | /** 128 | * 解绑数据 129 | * @param view 130 | */ 131 | 132 | @Override 133 | public void onUnBindView(int position, View view, PullToNextView pullToNextView) { 134 | super.onUnBindView(position,view,pullToNextView); 135 | Log.e(TAG, "onUnBindView"+" "+index); 136 | } 137 | @Override 138 | public void onPauseView(int position, View view, PullToNextView pullToNextView) { 139 | super.onPauseView(position,view,pullToNextView); 140 | Log.e(TAG, "onPauseView"+" "+index); 141 | } 142 | @Override 143 | public void setUserVisibleHint(boolean userVisibleHint) { 144 | super.setUserVisibleHint(userVisibleHint); 145 | 146 | if(userVisibleHint){ 147 | } 148 | Log.e(TAG, "userVisibleHint" + userVisibleHint+" " + index); 149 | } 150 | ~~~ 151 | 152 | 1.3.1 更新 153 | >1. 修改了onBindView方法暴露出PullToNextView 和 position 字段 154 | * 支持动态修改提示提示内容. 155 | 156 | 1.3.0 更新 157 | >1. 重构了部分代码.Deprecated 了PullToNextFragmentAdapter,加入了PullToNextModelAdapter,新的适配器支持了相同视图的复用. 158 | * 向下支持 sdk9 ; 159 | * 加入了PullToNextModel 类,视图配置类 160 | 161 | 162 | 1.2.1 内容: 163 | >1. 控件支持ScrollView ,WebView 组件控件内滚动; 164 | * 支持gradle 方式加入; 165 | * 支持预加载,逻辑类似ViewPager,即预先加载当前页的前一个和下一个; 166 | 167 | 168 | 169 | Q.怎么自定义下拉和上拉的文字提示: 170 | ~~~ 171 | A. 172 | 静态(资源文件): 173 | res->values->strings.xml 174 | 添加6个,app会优先读取你项目中的资源文件. 175 | 没有更多信息~ 176 | 放手查看下一个~ 177 | 上拉查看下一个~ 178 | 已经是第一个了~ 179 | 放手查看前一个~ 180 | 下拉查看前一个~ 181 | 修改成你自己喜欢的文字 182 | 动态(java 代码) 183 | pullToNextView.setPromptEntity(); 184 | ~~~ 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | #end# 196 | -------------------------------------------------------------------------------- /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.0.0' 9 | 10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' 11 | classpath 'com.github.dcendents:android-maven-plugin:1.2' 12 | 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /build/intermediates/dex-cache/cache.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 16 | 17 | 18 | 23 | 24 | 25 | 30 | 31 | 32 | 37 | 38 | 39 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /build/intermediates/model_data.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/build/intermediates/model_data.bin -------------------------------------------------------------------------------- /example2/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example2/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | applicationId "com.mingle.example" 9 | minSdkVersion 9 10 | targetSdkVersion 21 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:22.0.0' 25 | compile project(':pulltonextlayout') 26 | } 27 | -------------------------------------------------------------------------------- /example2/example2.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /example2/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 /Users/zzz40500/Documents/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 | -------------------------------------------------------------------------------- /example2/src/androidTest/java/com/mingle/example/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example; 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 | } -------------------------------------------------------------------------------- /example2/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example2/src/main/java/com/mingle/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example; 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.mingle.example.model.OtherModelActivity; 11 | import com.mingle.example.model.ScrollViewModelActivity; 12 | 13 | 14 | public class MainActivity extends ActionBarActivity { 15 | 16 | 17 | 18 | 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | 25 | } 26 | 27 | 28 | public void onClick(View view){ 29 | 30 | startActivity(new Intent(this,ScrollViewModelActivity.class)); 31 | 32 | } 33 | public void onClick2(View view){ 34 | 35 | startActivity(new Intent(this,WebViewActivity.class)); 36 | 37 | } 38 | public void onClick3(View view){ 39 | 40 | startActivity(new Intent(this,OtherModelActivity.class)); 41 | 42 | } 43 | 44 | @Override 45 | public boolean onCreateOptionsMenu(Menu menu) { 46 | // Inflate the menu; this adds items to the action bar if it is present. 47 | // getMenuInflater().inflate(R.menu.menu_main, menu); 48 | return true; 49 | } 50 | 51 | @Override 52 | public boolean onOptionsItemSelected(MenuItem item) { 53 | // Handle action bar item clicks here. The action bar will 54 | // automatically handle clicks on the Home/Up button, so long 55 | // as you specify a parent activity in AndroidManifest.xml. 56 | int id = item.getItemId(); 57 | 58 | //noinspection SimplifiableIfStatement 59 | if (id == R.id.action_settings) { 60 | return true; 61 | } 62 | 63 | return super.onOptionsItemSelected(item); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /example2/src/main/java/com/mingle/example/WebViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v7.app.ActionBarActivity; 5 | import android.os.Bundle; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | 9 | import com.mingle.pulltonextlayout.OnItemSelectListener; 10 | import com.mingle.pulltonextlayout.adapter.PullToNextFragmentAdapter; 11 | import com.mingle.pulltonextlayout.PullToNextLayout; 12 | 13 | import java.util.ArrayList; 14 | 15 | 16 | public class WebViewActivity extends ActionBarActivity { 17 | 18 | public PullToNextLayout pullToNextLayout; 19 | 20 | private ArrayList list; 21 | 22 | private String[] titles={"PullToNextLayout","使用 DrawerLayout 实现 Material Design风格的侧滑", 23 | "分享3个 自定义控件","BouncyEditText 不一样的 EditText" 24 | ,"会变色的 ViewPager","android Heads-Up风格通知" 25 | ,"快速集成图片游览器 android","JSon实体类快速生成插件 GsonFormat使用" 26 | ,"ListView适配器的超省写法"}; 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_pull_to_next_layout_demo); 32 | 33 | 34 | pullToNextLayout= (PullToNextLayout) findViewById(R.id.pullToNextLayout); 35 | 36 | 37 | list=new ArrayList<>(); 38 | 39 | list.add( WebViewFragment.newInstant(0)); 40 | list.add( WebViewFragment.newInstant(1)); 41 | list.add( WebViewFragment.newInstant(2)); 42 | list.add( WebViewFragment.newInstant(3)); 43 | list.add( WebViewFragment.newInstant(4)); 44 | list.add( WebViewFragment.newInstant(5)); 45 | list.add( WebViewFragment.newInstant(6)); 46 | list.add( WebViewFragment.newInstant(7)); 47 | list.add( WebViewFragment.newInstant(8)); 48 | 49 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 50 | 51 | getSupportActionBar().setHomeButtonEnabled(true); 52 | 53 | pullToNextLayout.setAdapter(new PullToNextFragmentAdapter(getSupportFragmentManager(), list)); 54 | 55 | pullToNextLayout.setOnItemSelectListener(new OnItemSelectListener() { 56 | @Override 57 | public void onSelectItem(int position, View view) { 58 | 59 | WebViewActivity.this.setTitle(titles[position]); 60 | 61 | 62 | } 63 | }); 64 | WebViewActivity.this.setTitle(titles[0]); 65 | } 66 | 67 | @Override 68 | public boolean onOptionsItemSelected(MenuItem item) { 69 | // Handle action bar item clicks here. The action bar will 70 | // automatically handle clicks on the Home/Up button, so long 71 | // as you specify a parent activity in AndroidManifest.xml. 72 | int id = item.getItemId(); 73 | 74 | 75 | if (id == android.R.id.home) { 76 | 77 | 78 | this.finish(); 79 | return true; 80 | } 81 | 82 | return super.onOptionsItemSelected(item); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /example2/src/main/java/com/mingle/example/WebViewFragment.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.webkit.WebChromeClient; 10 | import android.webkit.WebView; 11 | 12 | 13 | /** 14 | * A simple {@link android.support.v4.app.Fragment} subclass. 15 | */ 16 | public class WebViewFragment extends Fragment { 17 | 18 | 19 | 20 | 21 | private WebView webView; 22 | 23 | 24 | 25 | 26 | 27 | private int index; 28 | public WebViewFragment( ) { 29 | 30 | } 31 | 32 | 33 | public static WebViewFragment newInstant(int index){ 34 | WebViewFragment webViewFragment=new WebViewFragment(); 35 | 36 | Bundle bundle=new Bundle(); 37 | bundle.putInt("index", index); 38 | 39 | 40 | webViewFragment.setArguments(bundle); 41 | return webViewFragment; 42 | 43 | } 44 | 45 | 46 | @Override 47 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 48 | Bundle savedInstanceState) { 49 | // Inflate the layout for this fragment 50 | 51 | index= getArguments().getInt("index"); 52 | 53 | View v= inflater.inflate(R.layout.fragment_web_view, container, false); 54 | 55 | webView= (WebView) v.findViewById(R.id.webView); 56 | 57 | String[] urls=getResources().getStringArray(R.array.urls); 58 | 59 | webView.loadUrl(urls[index]); 60 | webView.setWebChromeClient(new WebChromeClient()); 61 | 62 | return v; 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /example2/src/main/java/com/mingle/example/model/OtherModelActivity.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example.model; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentPagerAdapter; 5 | import android.support.v7.app.ActionBarActivity; 6 | import android.os.Bundle; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | 11 | import com.mingle.example.R; 12 | import com.mingle.pulltonextlayout.OnItemSelectListener; 13 | import com.mingle.pulltonextlayout.adapter.PullToNextFragmentAdapter; 14 | import com.mingle.pulltonextlayout.PullToNextLayout; 15 | import com.mingle.pulltonextlayout.adapter.PullToNextModelAdapter; 16 | import com.mingle.pulltonextlayout.model.PullToNextModel; 17 | 18 | import java.util.ArrayList; 19 | 20 | 21 | public class OtherModelActivity extends ActionBarActivity { 22 | 23 | public PullToNextLayout pullToNextLayout; 24 | 25 | 26 | private ArrayList list; 27 | private String[] names={"于文文","张钧甯","陈乔恩","贾青"}; 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_pull_to_next_layout_demo); 33 | 34 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 35 | 36 | getSupportActionBar().setHomeButtonEnabled(true); 37 | 38 | pullToNextLayout= (PullToNextLayout) findViewById(R.id.pullToNextLayout); 39 | 40 | 41 | list=new ArrayList<>(); 42 | 43 | list.add(new OtherViewModel(0)); 44 | list.add(new OtherViewModel(1)); 45 | list.add(new OtherViewModel(2)); 46 | list.add(new OtherViewModel(3)); 47 | 48 | 49 | pullToNextLayout.setAdapter(new PullToNextModelAdapter(this, list)); 50 | 51 | pullToNextLayout.setOnItemSelectListener(new OnItemSelectListener() { 52 | @Override 53 | public void onSelectItem(int position, View view) { 54 | setTitle(names[position]); 55 | } 56 | }); 57 | 58 | setTitle(names[0]); 59 | } 60 | 61 | 62 | 63 | @Override 64 | public boolean onCreateOptionsMenu(Menu menu) { 65 | return true; 66 | } 67 | 68 | @Override 69 | public boolean onOptionsItemSelected(MenuItem item) { 70 | int id = item.getItemId(); 71 | 72 | 73 | if (id == android.R.id.home) { 74 | 75 | 76 | this.finish(); 77 | return true; 78 | } 79 | 80 | return super.onOptionsItemSelected(item); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /example2/src/main/java/com/mingle/example/model/OtherViewModel.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example.model; 2 | 3 | import android.util.Log; 4 | import android.view.View; 5 | import android.widget.ImageView; 6 | import android.widget.TextView; 7 | 8 | import com.mingle.example.R; 9 | import com.mingle.pulltonextlayout.PullToNextView; 10 | import com.mingle.pulltonextlayout.model.PullToNextModel; 11 | 12 | /** 13 | * Created by zzz40500 on 15/5/30. 14 | */ 15 | public class OtherViewModel extends PullToNextModel { 16 | 17 | private String[] names={"于文文","张钧甯","陈乔恩","贾青"}; 18 | 19 | 20 | private String[] birthday={"1989年11月7日","1982年9月4日","1979年04月04日", 21 | "1986年11月2日" 22 | }; 23 | 24 | private int[] imgRes={R.mipmap.ic_icon1,R.mipmap.ic_icon2,R.mipmap.ic_icon3, 25 | R.mipmap.ic_icon4 26 | }; 27 | 28 | 29 | private int index=0; 30 | 31 | 32 | public OtherViewModel(int index) { 33 | this.index = index; 34 | } 35 | 36 | @Override 37 | public int getLayoutViewId() { 38 | return R.layout.fragment_other; 39 | } 40 | 41 | @Override 42 | public void onBindView(int position, View v, PullToNextView pullToNextView) { 43 | TextView nameTV= (TextView) v.findViewById(R.id.nameTV); 44 | TextView birthdayTV= (TextView) v.findViewById(R.id.birthdayTV); 45 | ImageView imageView= (ImageView) v.findViewById(R.id.image); 46 | nameTV.setText(names[index]); 47 | 48 | birthdayTV.setText("出生日期: " + birthday[index]); 49 | imageView.setImageResource(imgRes[index]); 50 | 51 | v.setClickable(true); 52 | } 53 | 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /example2/src/main/java/com/mingle/example/model/ScrollViewModel.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example.model; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.widget.ScrollView; 7 | import android.widget.TextView; 8 | 9 | import com.mingle.example.R; 10 | import com.mingle.pulltonextlayout.PromptEntity; 11 | import com.mingle.pulltonextlayout.PullToNextView; 12 | import com.mingle.pulltonextlayout.model.PullToNextModel; 13 | 14 | /** 15 | * Created by zzz40500 on 15/5/30. 16 | */ 17 | public class ScrollViewModel extends PullToNextModel { 18 | 19 | 20 | 21 | private String TAG="ScrollViewModel"; 22 | 23 | String title=" 谷歌仍是毕业生心目中的最佳雇主"; 24 | private ScrollView scrollView; 25 | 26 | String content=" 网易科技讯 3月27日消息,调研公司Universum Global发布最新调查报告称,谷歌仍是计算机科学专业大学生心目中的最佳雇主。\n" + 27 | "\n" + 28 | "这份调查覆盖了275所大学超过3200名计算机科学专业大学生。调查发现,谷歌在大学生心目中是最佳雇主,紧随其后的是微软、苹果、亚马逊和Facebook。此次调查并未纳入Uber和Airbnb等初创公司,原因在于这些公司不会大规模招聘毕业生。\n" + 29 | "\n" + 30 | "自2008年Universum开始追踪大学生心目中的最佳雇主以来,谷歌一直是计算机科学专业大学生心目中的最佳雇主。调查称,该专业的大学生中,大部分人认为谷歌拥有创新、灵活的工作环境。值得一提的是,谷歌的受欢迎程度还在上升,今年超过50%的受访学生支持谷歌,略高于去年。\n" + 31 | "\n" + 32 | "尽管软件公司成为榜单的“主角”,去年,包括达美航空和美国航空集团在内的航空公司的受欢迎程度同样大幅上升。此外,亚马逊和星巴克等零售企业的表现也不错。\n" + 33 | "\n" + 34 | "整个市场对于毕业生的需求正在发生变化。随着经济的复苏,更多公司选择到校园直接招聘毕业生,越来越多的计算机专业毕业生一毕业就找到了工作。调查显示,每位计算机科学专业的毕业生可以挑选34.4家雇主,高于2012年的26.4家,列在所有专业的首位。\n" + 35 | "\n" + 36 | "调查显示,所有的学生在找工作时压力减轻,相信能有更多工作选择。例如,招聘初期就给学生发offer的银行、咨询和审计公司有可能会收到求职者“或许会接受offer”的回复,因为这些学生还在等待来自消费品、零售和科技公司的offer。\n" + 37 | "\n" + 38 | "因此,雇主发现,使用向求职者施压,威胁2天内不回复就取消offer的招聘策略已经没以前那么有效果了。(思远)"; 39 | 40 | 41 | 42 | private int index; 43 | public ScrollViewModel(int index){ 44 | this.index=index; 45 | } 46 | 47 | @Override 48 | public void onCreate(Context context) { 49 | super.onCreate(context); 50 | Log.e(TAG,"onCreate"+" "+index); 51 | } 52 | 53 | /** 54 | * 返回视图 55 | * @return 56 | */ 57 | @Override 58 | public int getLayoutViewId() { 59 | return R.layout.fragment_scrollview; 60 | } 61 | /** 62 | * 绑定数据源 63 | * @param v 64 | */ 65 | @Override 66 | public void onBindView(int position, View v, PullToNextView pullToNextView) { 67 | 68 | PromptEntity p=new PromptEntity(); 69 | 70 | TextView titleTV= (TextView) v.findViewById(R.id.titleTV); 71 | TextView contentTv= (TextView) v.findViewById(R.id.textView); 72 | scrollView = (ScrollView) v.findViewById(R.id.scrollView); 73 | titleTV.setText(index+1+".0"+title); 74 | contentTv.setText(content); 75 | Log.e(TAG, "onBindView"+" "+index); 76 | } 77 | 78 | 79 | 80 | 81 | /** 82 | * 在onBindView 调用后调用. 83 | * @param view 84 | */ 85 | @Override 86 | public void onResumeView(int position, View view, PullToNextView pullToNextView) { 87 | super.onResumeView(position, view, pullToNextView); 88 | 89 | if(scrollView!=null){ 90 | scrollView.pageScroll(ScrollView.FOCUS_UP); 91 | } 92 | Log.e(TAG, "onResumeView"+" "+index); 93 | } 94 | 95 | 96 | /** 97 | * 解绑数据 98 | * @param view 99 | */ 100 | 101 | @Override 102 | public void onUnBindView(int position, View view, PullToNextView pullToNextView) { 103 | super.onUnBindView(position,view,pullToNextView); 104 | Log.e(TAG, "onUnBindView"+" "+index); 105 | } 106 | @Override 107 | public void onPauseView(int position, View view, PullToNextView pullToNextView) { 108 | super.onPauseView(position,view,pullToNextView); 109 | Log.e(TAG, "onPauseView"+" "+index); 110 | } 111 | @Override 112 | public void setUserVisibleHint(boolean userVisibleHint) { 113 | super.setUserVisibleHint(userVisibleHint); 114 | 115 | if(userVisibleHint){ 116 | 117 | 118 | 119 | 120 | 121 | } 122 | Log.e(TAG, "userVisibleHint" + userVisibleHint+" " + index); 123 | } 124 | 125 | 126 | } 127 | -------------------------------------------------------------------------------- /example2/src/main/java/com/mingle/example/model/ScrollViewModelActivity.java: -------------------------------------------------------------------------------- 1 | package com.mingle.example.model; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.ActionBarActivity; 5 | import android.util.Log; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.view.View; 9 | 10 | import com.mingle.example.R; 11 | import com.mingle.pulltonextlayout.OnItemSelectListener; 12 | import com.mingle.pulltonextlayout.PullToNextLayout; 13 | import com.mingle.pulltonextlayout.adapter.PullToNextModelAdapter; 14 | import com.mingle.pulltonextlayout.model.PullToNextModel; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | 20 | public class ScrollViewModelActivity extends ActionBarActivity { 21 | 22 | public PullToNextLayout pullToNextLayout; 23 | 24 | private List list; 25 | 26 | private int currentIndex=0; 27 | private PullToNextModelAdapter adapter; 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_pull_to_next_layout_demo); 33 | 34 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 35 | 36 | getSupportActionBar().setHomeButtonEnabled(true); 37 | 38 | pullToNextLayout= (PullToNextLayout) findViewById(R.id.pullToNextLayout); 39 | 40 | 41 | list=new ArrayList<>(); 42 | 43 | for (int i = 0; i < 4; i++) { 44 | 45 | list.add(new ScrollViewModel(currentIndex++)); 46 | } 47 | 48 | adapter= new PullToNextModelAdapter(this,list); 49 | pullToNextLayout.setAdapter(adapter); 50 | 51 | pullToNextLayout.setOnItemSelectListener(new OnItemSelectListener() { 52 | @Override 53 | public void onSelectItem(int position, View view) { 54 | setTitle(position+1+".0 谷歌仍是毕业生心目中的最佳雇主"); 55 | 56 | } 57 | }); 58 | setTitle(1+".0 谷歌仍是毕业生心目中的最佳雇主"); 59 | } 60 | 61 | 62 | 63 | @Override 64 | public boolean onCreateOptionsMenu(Menu menu) { 65 | // Inflate the menu; this adds items to the action bar if it is present. 66 | getMenuInflater().inflate(R.menu.menu_pull_to_next_layout_demo, menu); 67 | return true; 68 | } 69 | 70 | @Override 71 | public boolean onOptionsItemSelected(MenuItem item) { 72 | // Handle action bar item clicks here. The action bar will 73 | // automatically handle clicks on the Home/Up button, so long 74 | // as you specify a parent activity in AndroidManifest.xml. 75 | int id = item.getItemId(); 76 | 77 | //noinspection SimplifiableIfStatement 78 | if(id== R.id.action_addALL){ 79 | 80 | 81 | for (int i = 0; i < 5; i++) { 82 | 83 | list.add(new ScrollViewModel(currentIndex++)); 84 | } 85 | 86 | adapter.notifyDataSetChanged(); 87 | 88 | }else if(id== R.id.action_setSelection){ 89 | 90 | pullToNextLayout.setCurrentItem(1); 91 | 92 | }else if(id== R.id.action_delete){ 93 | pullToNextLayout.deleteCurrentItem(); 94 | } 95 | 96 | if (id == android.R.id.home) { 97 | 98 | 99 | this.finish(); 100 | return true; 101 | } 102 | 103 | return super.onOptionsItemSelected(item); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /example2/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 |