├── .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 | [](http://android-arsenal.com/details/1/1893)
3 | ---
4 |
5 |
6 | 
7 |
8 | 
9 |
10 | 
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 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
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 |
18 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/activity_other.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/activity_pull_to_next_layout_demo.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/activity_view_pager.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/fragment_blank.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/fragment_other.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
16 |
24 |
32 |
33 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/fragment_scrollview.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
25 |
31 |
32 |
55 |
56 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/example2/src/main/res/layout/fragment_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/example2/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/example2/src/main/res/menu/menu_other.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/example2/src/main/res/menu/menu_pull_to_next_layout_demo.xml:
--------------------------------------------------------------------------------
1 |
19 |
--------------------------------------------------------------------------------
/example2/src/main/res/menu/menu_view_pager.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/example2/src/main/res/menu/menu_web_view.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-hdpi/ic_icon1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-hdpi/ic_icon1.jpg
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-hdpi/ic_icon2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-hdpi/ic_icon2.jpg
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-hdpi/ic_icon3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-hdpi/ic_icon3.jpg
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-hdpi/ic_icon4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-hdpi/ic_icon4.jpg
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example2/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/example2/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example2/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/example2/src/main/res/values/datas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | - http://www.jianshu.com/p/8d8ac27f41eb
9 | - http://www.jianshu.com/p/3fe2acac0ddb
10 | - http://www.jianshu.com/p/fa1b34f7c570
11 | - http://www.jianshu.com/p/cb5b012d1d85
12 | - http://www.jianshu.com/p/54ab0e833273
13 | - http://www.jianshu.com/p/4d76b2bc8784
14 | - http://www.jianshu.com/p/ac27d4f41608
15 | - http://www.jianshu.com/p/b83ea5e32ee1
16 | - http://www.jianshu.com/p/cef7b2808335
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example2/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/example2/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Example
3 |
4 | Hello world!
5 | Settings
6 | PullToNextLayoutDemoActivity
7 |
8 |
9 | Hello blank fragment
10 | WebViewActivity
11 | OtherActivity
12 | ViewPagerActivity
13 |
14 |
--------------------------------------------------------------------------------
/example2/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/maven-push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'maven'
18 | apply plugin: 'signing'
19 |
20 | def isReleaseBuild() {
21 | return VERSION_NAME.contains("SNAPSHOT") == false
22 | }
23 |
24 | def getReleaseRepositoryUrl() {
25 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
26 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
27 | }
28 |
29 | def getSnapshotRepositoryUrl() {
30 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
31 | : "https://oss.sonatype.org/content/repositories/snapshots/"
32 | }
33 |
34 | def getRepositoryUsername() {
35 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
36 | }
37 |
38 | def getRepositoryPassword() {
39 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
40 | }
41 |
42 | afterEvaluate { project ->
43 | uploadArchives {
44 | repositories {
45 | mavenDeployer {
46 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
47 |
48 | pom.groupId = GROUP
49 | pom.artifactId = POM_ARTIFACT_ID
50 | pom.version = VERSION_NAME
51 |
52 | repository(url: getReleaseRepositoryUrl()) {
53 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
54 | }
55 | snapshotRepository(url: getSnapshotRepositoryUrl()) {
56 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57 | }
58 |
59 | pom.project {
60 | name POM_NAME
61 | packaging POM_PACKAGING
62 | description POM_DESCRIPTION
63 | url POM_URL
64 |
65 | scm {
66 | url POM_SCM_URL
67 | connection POM_SCM_CONNECTION
68 | developerConnection POM_SCM_DEV_CONNECTION
69 | }
70 |
71 | licenses {
72 | license {
73 | name POM_LICENCE_NAME
74 | url POM_LICENCE_URL
75 | distribution POM_LICENCE_DIST
76 | }
77 | }
78 |
79 | developers {
80 | developer {
81 | id POM_DEVELOPER_ID
82 | name POM_DEVELOPER_NAME
83 | }
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
90 | signing {
91 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
92 | sign configurations.archives
93 | }
94 |
95 | task apklib(type: Zip) {
96 | appendix = extension = 'apklib'
97 |
98 | from 'AndroidManifest.xml'
99 | into('res') {
100 | from 'res'
101 | }
102 | into('src') {
103 | from 'src'
104 | }
105 | }
106 |
107 | task jar(type: Jar) {
108 | from android.sourceSets.main.java.srcDirs
109 | }
110 |
111 | task androidJavadocs(type: Javadoc) {
112 | source = android.sourceSets.main.java.srcDirs
113 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
114 | }
115 |
116 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
117 | classifier = 'javadoc'
118 | from androidJavadocs.destinationDir
119 | }
120 |
121 | task androidSourcesJar(type: Jar) {
122 | classifier = 'sources'
123 | from android.sourceSets.main.java.srcDirs
124 | }
125 |
126 | artifacts {
127 | archives androidSourcesJar
128 | archives apklib
129 | archives jar
130 | }
131 | }
--------------------------------------------------------------------------------
/pulltonextlayout/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/pulltonextlayout/.DS_Store
--------------------------------------------------------------------------------
/pulltonextlayout/._.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/pulltonextlayout/._.DS_Store
--------------------------------------------------------------------------------
/pulltonextlayout/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/pulltonextlayout/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.android.library'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 | apply plugin: 'com.jfrog.bintray'
5 | version = "1.3.0"
6 | // 根节点添加
7 |
8 | android {
9 | compileSdkVersion 21
10 | buildToolsVersion "21.1.2"
11 |
12 | defaultConfig {
13 | minSdkVersion 9
14 | targetSdkVersion 21
15 | versionCode 1
16 | versionName "1.3.0"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile 'com.nineoldandroids:library:2.4.0'
28 | compile 'com.android.support:support-v4:22.1.1'
29 |
30 | }
31 | def siteUrl = 'https://github.com/zzz40500/Android-PullToNextLayout'
32 | def gitUrl = 'https://github.com/zzz40500/Android-PullToNextLayout.git'
33 |
34 | group = "com.mingle.zzz40500"
35 |
36 | install {
37 | repositories.mavenInstaller {
38 | // This generates POM.xml with proper parameters
39 | pom {
40 | project {
41 | packaging 'aar'
42 | name 'pullToNextLayout '
43 | url siteUrl
44 | licenses {
45 | license {
46 | name 'The Apache Software License, Version 2.0'
47 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
48 | }
49 | }
50 | developers {
51 | developer {
52 | id 'zzz40500'
53 | name 'qingwei'
54 | email 'wyh405003836@126.com'
55 | }
56 | }
57 | scm {
58 | connection gitUrl
59 | developerConnection gitUrl
60 | url siteUrl
61 | }
62 | }
63 | }
64 | }
65 | }
66 |
67 |
68 |
69 | task sourcesJar(type: Jar) {
70 | from android.sourceSets.main.java.srcDirs
71 | classifier = 'sources'
72 | }
73 |
74 | task javadoc(type: Javadoc) {
75 | source = android.sourceSets.main.java.srcDirs
76 | classpath += project.files( android.getBootClasspath().join(File.pathSeparator))
77 | }
78 |
79 | task javadocJar(type: Jar, dependsOn: javadoc) {
80 | classifier = 'javadoc'
81 | from javadoc.destinationDir
82 | }
83 |
84 | artifacts {
85 | archives javadocJar
86 | archives sourcesJar
87 | }
88 |
89 | Properties properties = new Properties()
90 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
91 | bintray {
92 | user = properties.getProperty("bintray.user")
93 | key = properties.getProperty("bintray.apikey")
94 | configurations = ['archives']
95 | pkg {
96 | repo = "maven"
97 | name = "pullToNext"
98 | // #CONFIG# project name in jcenter
99 | websiteUrl = siteUrl
100 | vcsUrl = gitUrl
101 | licenses = ["Apache-2.0"]
102 | publish = true
103 | }
104 | }
105 |
106 |
--------------------------------------------------------------------------------
/pulltonextlayout/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 |
--------------------------------------------------------------------------------
/pulltonextlayout/pulltonextlayout.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
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 |
96 |
97 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/androidTest/java/com/mingle/pulltonextlayout/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout;
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 | }
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/BaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout;
2 |
3 | import android.view.View;
4 |
5 | import com.mingle.pulltonextlayout.observable.PullToNextDataObserver;
6 | import com.mingle.pulltonextlayout.observable.PullToNextDataSetObservable;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Created by zzz40500 on 15/5/30.
12 | */
13 | public abstract class BaseAdapter {
14 |
15 |
16 | protected List list;
17 | protected PullToNextDataSetObservable mDataSetObservable = new PullToNextDataSetObservable();
18 | public BaseAdapter(List list){
19 | this.list=list;
20 | }
21 |
22 |
23 | protected abstract void cleanAll();
24 | /**
25 | * 通知可见
26 | * @param position
27 | * @param visibility
28 | */
29 | public abstract void setOnItemVisibility(int position, boolean visibility);
30 | /**
31 | * 添加视图都pullToNextView.pullToNextView 中
32 | * @param pullToNextView
33 | */
34 | protected abstract void attachContentView(PullToNextEntity pullToNextView) ;
35 | /**
36 | *
37 | * @param pullToNextEntity
38 | */
39 | protected abstract void detachContentView(PullToNextEntity pullToNextEntity) ;
40 | protected abstract View getContentView(int position) ;
41 |
42 | public int getCount(){
43 | return list.size();
44 | }
45 |
46 | public T getItem(int arg0) {
47 | return list.get(arg0);
48 | }
49 |
50 | protected void deleteItem(int arg0) {
51 | list.remove(arg0);
52 | }
53 |
54 | public void addItem(T f){
55 | this.list.add(f);
56 | mDataSetObservable.notifyNewData();
57 | }
58 |
59 | public void addAllItem(List list){
60 | this.list.addAll(list);
61 | mDataSetObservable.notifyNewData();
62 | }
63 |
64 |
65 | protected void registerDataSetObserver(PullToNextDataObserver observer) {
66 | mDataSetObservable.registerObserver(observer);
67 | }
68 |
69 | protected void unregisterDataSetObserver(PullToNextDataObserver observer) {
70 | mDataSetObservable.unregisterObserver(observer);
71 | }
72 |
73 | private void notifyDataSetChanged() {
74 | mDataSetObservable.notifyChanged();
75 | }
76 |
77 | private void notifyDataSetInvalidated() {
78 | mDataSetObservable.notifyInvalidated();
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/OnItemSelectListener.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Created by zzz40500 on 15/3/21.
7 | */
8 | public interface OnItemSelectListener {
9 |
10 |
11 | public void onSelectItem(int position,View view);
12 | }
13 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/PromptEntity.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by zzz40500 on 15/5/31.
7 | */
8 | public class PromptEntity {
9 |
10 |
11 |
12 | private String noMoreDatePtn;
13 | private String releaseToNextPtn;
14 | private String pullUpToNextPtn;
15 | private String theFirstPtn;
16 | private String releaseToPreviousPtn;
17 | private String pullDownToPreviousPtn;
18 |
19 |
20 |
21 | public PromptEntity(Context context){
22 |
23 |
24 | setNoMoreDatePtn(context.getString(R.string.ptn_no_more_data));
25 | setPullDownToPreviousPtn(context.getString(R.string.ptn_pull_down_to_previous));
26 | setPullUpToNextPtn(context.getString(R.string.ptn_pull_up_to_next));
27 | setReleaseToNextPtn(context.getString(R.string.ptn_release_to_next));
28 | setReleaseToPreviousPtn(context.getString(R.string.ptn_release_to_previous));
29 | setTheFirstPtn(context.getString(R.string.ptn_the_first));
30 | }
31 |
32 |
33 | public PromptEntity(String noMoreDatePtn, String releaseToNextPtn, String pullUpToNextPtn, String theFirstPtn, String releaseToPreviousPtn, String pullDownToPreviousPtn) {
34 | this.noMoreDatePtn = noMoreDatePtn;
35 | this.releaseToNextPtn = releaseToNextPtn;
36 | this.pullUpToNextPtn = pullUpToNextPtn;
37 | this.theFirstPtn = theFirstPtn;
38 | this.releaseToPreviousPtn = releaseToPreviousPtn;
39 | this.pullDownToPreviousPtn = pullDownToPreviousPtn;
40 | }
41 |
42 | public PromptEntity() {
43 | }
44 |
45 | public String getNoMoreDatePtn() {
46 | return noMoreDatePtn;
47 | }
48 |
49 | public void setNoMoreDatePtn(String noMoreDatePtn) {
50 | this.noMoreDatePtn = noMoreDatePtn;
51 | }
52 |
53 | public String getReleaseToNextPtn() {
54 | return releaseToNextPtn;
55 | }
56 |
57 | public void setReleaseToNextPtn(String releaseToNextPtn) {
58 | this.releaseToNextPtn = releaseToNextPtn;
59 | }
60 |
61 | public String getPullUpToNextPtn() {
62 | return pullUpToNextPtn;
63 | }
64 |
65 | public void setPullUpToNextPtn(String pullUpToNextPtn) {
66 | this.pullUpToNextPtn = pullUpToNextPtn;
67 | }
68 |
69 | public String getTheFirstPtn() {
70 | return theFirstPtn;
71 | }
72 |
73 | public void setTheFirstPtn(String theFirstPtn) {
74 | this.theFirstPtn = theFirstPtn;
75 | }
76 |
77 | public String getReleaseToPreviousPtn() {
78 | return releaseToPreviousPtn;
79 | }
80 |
81 | public void setReleaseToPreviousPtn(String releaseToPreviousPtn) {
82 | this.releaseToPreviousPtn = releaseToPreviousPtn;
83 | }
84 |
85 | public String getPullDownToPreviousPtn() {
86 | return pullDownToPreviousPtn;
87 | }
88 |
89 | public void setPullDownToPreviousPtn(String pullDownToPreviousPtn) {
90 | this.pullDownToPreviousPtn = pullDownToPreviousPtn;
91 | }
92 |
93 |
94 |
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/PullToNextEntity.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout;
2 |
3 | /**
4 | * Created by zzz40500 on 15/3/28.
5 | */
6 | public class PullToNextEntity {
7 |
8 | private PullToNextView pullToNextView;
9 | private int contentId;
10 | private int position=-1;
11 |
12 |
13 | public PullToNextView getPullToNextView() {
14 | return pullToNextView;
15 | }
16 |
17 | public void setPullToNextView(PullToNextView pullToNextView) {
18 | this.pullToNextView = pullToNextView;
19 | }
20 |
21 | public int getContentId() {
22 | return contentId;
23 | }
24 |
25 | public void setContentId(int contentId) {
26 | this.contentId = contentId;
27 | }
28 |
29 | public int getPosition() {
30 | return position;
31 | }
32 |
33 | public void setPosition(int position) {
34 | this.position = position;
35 | }
36 |
37 | public boolean isAttach(){
38 |
39 |
40 | return pullToNextView != null && pullToNextView.getParent() != null;
41 |
42 | }
43 |
44 | public void reset(BaseAdapter adapter){
45 | getPullToNextView().reset(adapter,getPosition());
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/PullToNextLayout.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.os.Build;
7 | import android.util.AttributeSet;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.FrameLayout;
12 |
13 | import com.mingle.pulltonextlayout.anim.PullToNextAnimationI;
14 | import com.mingle.pulltonextlayout.anim.SimpleAnimation;
15 | import com.mingle.pulltonextlayout.base.SimpleAnimatorListener;
16 | import com.mingle.pulltonextlayout.observable.PullToNextDataObserver;
17 | import com.nineoldandroids.animation.Animator;
18 |
19 | /**
20 | * Created by zzz40500 on 15/3/21.
21 | */
22 | public class PullToNextLayout extends FrameLayout {
23 |
24 |
25 | private boolean isAnimating;
26 |
27 | private int mItemCount = 0;
28 |
29 | private BaseAdapter mAdapter;
30 |
31 | private OnItemSelectListener mOnItemSelectListener;
32 |
33 | private PUllToNextDataSetObservable mDataSetObserver;
34 |
35 | private PullToNextAnimationI simpleAnimation = new SimpleAnimation();
36 |
37 | private int bgColor;
38 |
39 |
40 | private PullToNextView.PullToNextI mPullToNextI = new PullToNextView.PullToNextI() {
41 | @Override
42 | public void previous() {
43 | PullToNextLayout.this.previous();
44 | }
45 |
46 | @Override
47 | public void next() {
48 | PullToNextLayout.this.next();
49 | }
50 | };
51 |
52 | public PullToNextLayout(Context context) {
53 | super(context);
54 | init(null);
55 | }
56 |
57 | public PullToNextLayout(Context context, AttributeSet attrs) {
58 | super(context, attrs);
59 | init(attrs);
60 | }
61 |
62 | public PullToNextLayout(Context context, AttributeSet attrs, int defStyleAttr) {
63 | super(context, attrs, defStyleAttr);
64 | init(attrs);
65 | }
66 |
67 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
68 | public PullToNextLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
69 | super(context, attrs, defStyleAttr, defStyleRes);
70 |
71 | init(attrs);
72 | }
73 |
74 | private void init(AttributeSet attrs) {
75 |
76 |
77 | if (attrs != null) {
78 | TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.PullToNextLayout);
79 | bgColor = typedArray.getColor(R.styleable.PullToNextLayout_underLayoutColor, getResources().getColor(R.color.bg));
80 | typedArray.recycle();
81 | } else {
82 | bgColor = getResources().getColor(R.color.bg);
83 | }
84 |
85 | initPullToNextLayout();
86 | }
87 |
88 | private void initPullToNextLayout() {
89 | currentPTE = newPullToNextView(R.id.contentFL1);
90 | previousPTE = newPullToNextView(R.id.contentFL2);
91 | nextPTE = newPullToNextView(R.id.contentFL3);
92 | setUnderLayerBackground(bgColor);
93 | }
94 |
95 |
96 | private PullToNextEntity currentPTE;
97 | private PullToNextEntity previousPTE;
98 | private PullToNextEntity nextPTE;
99 |
100 | public void setAdapter(BaseAdapter pullToNextFragmentAdapter) {
101 |
102 | this.setAdapter(pullToNextFragmentAdapter, 0);
103 | }
104 |
105 |
106 | public void setUnderLayerBackground(int bgColor) {
107 | this.setBackgroundColor(bgColor);
108 | setPullToNextViewBackground(currentPTE, bgColor);
109 | setPullToNextViewBackground(previousPTE, bgColor);
110 | setPullToNextViewBackground(nextPTE, bgColor);
111 | }
112 |
113 | private void setPullToNextViewBackground(PullToNextEntity pte, int bgColor) {
114 | if (null != pte.getPullToNextView()) {
115 | pte.getPullToNextView()
116 | .setBackgroundColor(bgColor);
117 | }
118 | }
119 |
120 | public void setAdapter(BaseAdapter adapter, int currentIndex) {
121 |
122 | if (mAdapter != null && mDataSetObserver != null && mAdapter != adapter ) {
123 |
124 | mAdapter.cleanAll();
125 | mAdapter.unregisterDataSetObserver(mDataSetObserver);
126 | }
127 |
128 | if (null == adapter) {
129 | return;
130 | }
131 | if (currentIndex < 0) {
132 | currentIndex = 0;
133 |
134 | } else if (currentIndex >= adapter.getCount()) {
135 | currentIndex = adapter.getCount() - 1;
136 | }
137 | removeAllViews();
138 |
139 | this.mAdapter = adapter;
140 |
141 | mItemCount = adapter.getCount();
142 |
143 | mDataSetObserver = new PUllToNextDataSetObservable();
144 | mAdapter.registerDataSetObserver(mDataSetObserver);
145 |
146 |
147 | if (mAdapter.getCount() > 0) {
148 | addPullToNextView(0, currentPTE,currentIndex);
149 | invalidateView(currentIndex);
150 | }
151 | }
152 |
153 |
154 | public void setCurrentItem(int i) {
155 |
156 | if (i < 0 || i >= mAdapter.getCount()) {
157 | return;
158 | }
159 | removeView(currentPTE.getPullToNextView());
160 | removeView(nextPTE.getPullToNextView());
161 | removeView(previousPTE.getPullToNextView());
162 | mAdapter.cleanAll();
163 | setAdapter(mAdapter, i);
164 |
165 | }
166 |
167 |
168 |
169 | private void invalidateView(int mCurItem) {
170 |
171 | mAdapter.setOnItemVisibility(mCurItem, true);
172 | if (mCurItem - 1 >= 0) {
173 | addPullToNextView(0, previousPTE, mCurItem - 1);
174 | mAdapter.setOnItemVisibility(mCurItem - 1, false);
175 | previousPTE.reset(mAdapter);
176 | }else{
177 | previousPTE.setPosition(-1);
178 | }
179 | if (mCurItem + 1 >= 0 && mCurItem + 1 < mAdapter.getCount()) {
180 |
181 | addPullToNextView(0, nextPTE,mCurItem + 1);
182 | mAdapter.setOnItemVisibility(mCurItem + 1, false);
183 | nextPTE.reset(mAdapter);
184 | }else{
185 | nextPTE.setPosition(-1);
186 | }
187 | currentPTE.reset(mAdapter);
188 | if (null != mOnItemSelectListener) {
189 | mOnItemSelectListener.onSelectItem(currentPTE.getPosition(), currentPTE.getPullToNextView());
190 | }
191 |
192 | }
193 |
194 |
195 | /**
196 | * 初始化 PullToNextEntity实体
197 | *
198 | * @param frameLayoutId
199 | * @return
200 | */
201 | public PullToNextEntity newPullToNextView(int frameLayoutId) {
202 |
203 |
204 | PullToNextEntity entity = new PullToNextEntity();
205 | PullToNextView pullToNextView = new PullToNextView(getContext());
206 | FrameLayout frameLayout = new FrameLayout(getContext());
207 | frameLayout.setId(frameLayoutId);
208 | pullToNextView.setContentView(frameLayout);
209 | pullToNextView.setPullToNextI(mPullToNextI);
210 | pullToNextView.setTag(frameLayoutId);
211 | entity.setContentId(frameLayoutId);
212 | entity.setPullToNextView(pullToNextView);
213 | return entity;
214 | }
215 |
216 | @Override
217 | public void setBackgroundColor(int color) {
218 | super.setBackgroundColor(color);
219 | }
220 |
221 | /**
222 | * 将pullToNextView 添加到 PullToNextLayout 控件中
223 | *
224 | * @param index
225 | * @param pullToNextView
226 | */
227 | public void addPullToNextView(int index, PullToNextEntity pullToNextView ,int position) {
228 |
229 |
230 | ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
231 | View view = pullToNextView.getPullToNextView();
232 | if (view.getParent() != null && (view.getParent() instanceof ViewGroup)) {
233 | ViewGroup viewGroup = (ViewGroup) view.getParent();
234 | viewGroup.removeView(view);
235 | }
236 | this.addView(pullToNextView.getPullToNextView(), index, layoutParams);
237 | if(position !=pullToNextView.getPosition()) {
238 | pullToNextView.setPosition(position);
239 | mAdapter.attachContentView(pullToNextView);
240 | }
241 | initPullToNextEnable(pullToNextView);
242 |
243 | }
244 |
245 | private void initPullToNextEnable(PullToNextEntity pullToNextView) {
246 |
247 |
248 | if (null == pullToNextView) {
249 | return;
250 | }
251 | if (pullToNextView.getPosition() == 0) {
252 | pullToNextView.getPullToNextView().setHashPrevious(false);
253 | } else {
254 | pullToNextView.getPullToNextView().setHashPrevious(true);
255 | }
256 | if (pullToNextView.getPosition() == mItemCount - 1) {
257 | pullToNextView.getPullToNextView().setHashNext(false);
258 | } else {
259 | pullToNextView.getPullToNextView().setHashNext(true);
260 | }
261 | }
262 |
263 |
264 | private void previous() {
265 |
266 | remove(nextPTE);
267 |
268 | Animator anim = simpleAnimation.getPullDownAnim(previousPTE.getPullToNextView(), currentPTE.getPullToNextView());
269 | anim.addListener(new Animator.AnimatorListener() {
270 | @Override
271 | public void onAnimationStart(Animator animation) {
272 | isAnimating = true;
273 | }
274 |
275 | @Override
276 | public void onAnimationEnd(Animator animation) {
277 |
278 | removeView(currentPTE.getPullToNextView());
279 | PullToNextEntity tempPTE = currentPTE;
280 | PullToNextEntity temp2PTE = nextPTE;
281 | currentPTE = previousPTE;
282 | previousPTE = temp2PTE;
283 | nextPTE = tempPTE;
284 | isAnimating = false;
285 | invalidateView(currentPTE.getPosition());
286 | }
287 |
288 | @Override
289 | public void onAnimationCancel(Animator animation) {
290 | }
291 |
292 | @Override
293 | public void onAnimationRepeat(Animator animation) {
294 | }
295 | });
296 |
297 | anim.start();
298 | }
299 |
300 |
301 | public PullToNextAnimationI getSimpleAnimation() {
302 | return simpleAnimation;
303 | }
304 |
305 | public void setSimpleAnimation(PullToNextAnimationI simpleAnimation) {
306 | this.simpleAnimation = simpleAnimation;
307 | }
308 |
309 | private void remove(PullToNextEntity pullToNextEntity) {
310 |
311 |
312 | if (pullToNextEntity.getPullToNextView() != null) {
313 | if (pullToNextEntity.isAttach()) {
314 | removeView(pullToNextEntity.getPullToNextView());
315 | mAdapter.detachContentView(pullToNextEntity);
316 | }
317 | }
318 |
319 | }
320 |
321 | private void next() {
322 |
323 | remove(previousPTE);
324 | Animator anim = simpleAnimation.getPullUpAnim(nextPTE.getPullToNextView(), currentPTE.getPullToNextView());
325 | anim.addListener(new SimpleAnimatorListener() {
326 | @Override
327 | public void onAnimationStart(Animator animation) {
328 | isAnimating = true;
329 | }
330 |
331 | @Override
332 | public void onAnimationEnd(Animator animation) {
333 |
334 | removeView(currentPTE.getPullToNextView());
335 | PullToNextEntity tempPTE = currentPTE;
336 | PullToNextEntity temp2PTE = previousPTE;
337 | currentPTE = nextPTE;
338 | previousPTE = tempPTE;
339 | nextPTE = temp2PTE;
340 | isAnimating = false;
341 | invalidateView(currentPTE.getPosition());
342 |
343 | }
344 | });
345 |
346 | anim.start();
347 | }
348 | public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
349 | this.mOnItemSelectListener = onItemSelectListener;
350 | }
351 |
352 |
353 | /**
354 | * 播放动画的时候 不能响应点击事件
355 | *
356 | * @param ev
357 | * @return
358 | */
359 | @Override
360 | public boolean onInterceptTouchEvent(MotionEvent ev) {
361 | return isAnimating || super.onInterceptTouchEvent(ev);
362 | }
363 |
364 | class PUllToNextDataSetObservable extends PullToNextDataObserver {
365 |
366 | public void onChanged() {
367 | int oldCount = mItemCount;
368 | mItemCount = mAdapter.getCount();
369 | int currentPosition = currentPTE.getPosition();
370 | if (currentPosition > mItemCount - 1) {
371 | setCurrentItem(mItemCount - 1);
372 | } else if (oldCount == 0) {
373 | setCurrentItem(0);
374 | } else {
375 | setCurrentItem(currentPosition);
376 | }
377 |
378 | }
379 |
380 | @Override
381 | public void onInvalidated() {
382 | super.onInvalidated();
383 | mAdapter.cleanAll();
384 | }
385 |
386 |
387 | @Override
388 | public void onNewData() {
389 | super.onNewData();
390 |
391 | int oldCount = mItemCount;
392 | mItemCount = mAdapter.getCount();
393 | if (oldCount == 0) {
394 | setCurrentItem(0);
395 | } else {
396 |
397 | initPullToNextEnable(currentPTE);
398 | invalidateView(currentPTE.getPosition());
399 | }
400 | }
401 | }
402 |
403 |
404 | /**
405 | * 删除当前的 Item
406 | */
407 | public void deleteCurrentItem() {
408 |
409 | if (mItemCount <= 0 || isAnimating) {
410 | return;
411 | }
412 | if (currentPTE.getPosition() == 0) {
413 | remove(previousPTE);
414 | Animator anim = simpleAnimation.getDeleteItemAnim(nextPTE.getPullToNextView(), currentPTE.getPullToNextView());
415 |
416 |
417 | anim.addListener(new SimpleAnimatorListener() {
418 | @Override
419 | public void onAnimationStart(Animator animation) {
420 | isAnimating = true;
421 | }
422 |
423 | @Override
424 | public void onAnimationEnd(Animator animation) {
425 | mAdapter.deleteItem(currentPTE.getPosition());
426 | mItemCount = mAdapter.getCount();
427 | isAnimating = false;
428 | PullToNextEntity temp = nextPTE;
429 |
430 | nextPTE = currentPTE;
431 | currentPTE = temp;
432 | setCurrentItem(0);
433 | }
434 |
435 |
436 | });
437 |
438 | anim.start();
439 |
440 |
441 | } else {
442 | remove(nextPTE);
443 | Animator anim = simpleAnimation.getDeleteItemAnim(previousPTE.getPullToNextView(), currentPTE.getPullToNextView());
444 | anim.addListener(new SimpleAnimatorListener() {
445 |
446 | @Override
447 | public void onAnimationEnd(Animator animation) {
448 |
449 | mAdapter.deleteItem(currentPTE.getPosition());
450 | isAnimating = false;
451 | mItemCount = mAdapter.getCount();
452 | PullToNextEntity temp = previousPTE;
453 | previousPTE = currentPTE;
454 | currentPTE = temp;
455 | setCurrentItem(currentPTE.getPosition());
456 | }
457 |
458 |
459 | });
460 | anim.start();
461 |
462 | }
463 | }
464 |
465 |
466 |
467 |
468 | public int getCurrentPosition(){
469 | return currentPTE.getPosition();
470 | }
471 | public PullToNextView getCurrentPullToNext(){
472 | return currentPTE.getPullToNextView();
473 | }
474 |
475 |
476 |
477 | }
478 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/PullToNextView.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.util.AttributeSet;
7 | import android.view.LayoutInflater;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.view.animation.DecelerateInterpolator;
12 | import android.webkit.WebView;
13 | import android.widget.LinearLayout;
14 | import android.widget.ScrollView;
15 | import android.widget.TextView;
16 |
17 | import com.nineoldandroids.animation.ValueAnimator;
18 | import com.nineoldandroids.view.ViewHelper;
19 |
20 |
21 | /**
22 | * Created by zzz40500 on 15/3/21.
23 | */
24 | public class PullToNextView extends LinearLayout {
25 |
26 | private static final int ANIMATION_DURATION = 500;
27 | /**
28 | * last y
29 | */
30 | private int mLastMotionY;
31 | /**
32 | * header view
33 | */
34 | private View mHeaderView;
35 | /**
36 | * scrollview
37 | */
38 | private ScrollView mScrollView;
39 |
40 | /**
41 | * webView
42 | */
43 | private WebView mWebView;
44 |
45 |
46 | private boolean isHashPrevious = true;
47 | private boolean isHashNext = true;
48 |
49 | private PullStateE mPullStateE = PullStateE.PULL_STATE_NONE;
50 |
51 |
52 | private View mFootView;
53 |
54 | private PromptEntity mPromptEntity;
55 |
56 |
57 |
58 |
59 | public PullToNextView(Context context) {
60 | super(context);
61 | init();
62 | }
63 |
64 | public PullToNextView(Context context, AttributeSet attrs) {
65 | super(context, attrs);
66 | init();
67 | }
68 |
69 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
70 | public PullToNextView(Context context, AttributeSet attrs, int defStyleAttr) {
71 | super(context, attrs, defStyleAttr);
72 | init();
73 | }
74 |
75 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
76 | public PullToNextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
77 | super(context, attrs, defStyleAttr, defStyleRes);
78 | init();
79 | }
80 |
81 | /**
82 | * init
83 | */
84 | private void init() {
85 |
86 | setOrientation(LinearLayout.VERTICAL);
87 | hiddenHeaderView();
88 |
89 | }
90 |
91 | private void measureView(View child) {
92 | ViewGroup.LayoutParams p = child.getLayoutParams();
93 | if (p == null) {
94 | p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
95 | ViewGroup.LayoutParams.WRAP_CONTENT);
96 | }
97 |
98 | int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0, p.width);
99 | int lpHeight = p.height;
100 | int childHeightSpec;
101 | if (lpHeight > 0) {
102 | childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight,
103 | MeasureSpec.EXACTLY);
104 | } else {
105 | childHeightSpec = MeasureSpec.makeMeasureSpec(0,
106 | MeasureSpec.UNSPECIFIED);
107 | }
108 | child.measure(childWidthSpec, childHeightSpec);
109 | }
110 |
111 |
112 | private int mHeadViewHeight;
113 |
114 | @Override
115 | protected void onFinishInflate() {
116 | super.onFinishInflate();
117 |
118 | hiddenFootView();
119 | initContentAdapterView(this);
120 | }
121 |
122 | private ViewGroup contentView;
123 |
124 | private TextView headPromptTV;
125 | private TextView footPromptTV;
126 |
127 | public void setContentView(ViewGroup view) {
128 | contentView = view;
129 | ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
130 | addView(view, params);
131 | hiddenFootView();
132 | initContentAdapterView(contentView);
133 |
134 | }
135 |
136 | private void hiddenFootView() {
137 | mFootView = LayoutInflater.from(getContext()).inflate(R.layout.pull_to_next_prompt_view, null);
138 | measureView(mFootView);
139 | mHeadViewHeight = mFootView.getMeasuredHeight();
140 |
141 | ViewGroup.LayoutParams footParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
142 | mHeadViewHeight
143 | );
144 |
145 | footPromptTV = (TextView) mFootView.findViewById(R.id.promptTV);
146 |
147 | addView(mFootView, footParams);
148 | }
149 |
150 | private void hiddenHeaderView() {
151 | mHeaderView = LayoutInflater.from(getContext()).inflate(R.layout.pull_to_next_prompt_view, null);
152 | measureView(mHeaderView);
153 | headPromptTV = (TextView) mHeaderView.findViewById(R.id.promptTV);
154 |
155 | mHeadViewHeight = mHeaderView.getMeasuredHeight();
156 | addView(mHeaderView);
157 | setHeaderTopMargin(-mHeadViewHeight);
158 | }
159 |
160 |
161 | /**
162 | * 设置header view 的topMargin的值
163 | *
164 | * @param topMargin ,为0时,说明header view 刚好完全显示出来; 为-mHeaderViewHeight时,说明完全隐藏了
165 | */
166 | private void setHeaderTopMargin(int topMargin) {
167 | LayoutParams params = (LayoutParams) mHeaderView.getLayoutParams();
168 | params.topMargin = topMargin;
169 | mHeaderView.setLayoutParams(params);
170 | invalidate();
171 | }
172 |
173 |
174 | public void initContentView(final BaseAdapter adapter, final int position) {
175 |
176 |
177 |
178 |
179 | if (contentView != null ) {
180 |
181 |
182 | contentView.postDelayed(new Runnable() {
183 | @Override
184 | public void run() {
185 |
186 |
187 | if (adapter.getContentView(position) != null) {
188 | a(adapter.getContentView(position) );
189 |
190 | }
191 | }
192 | }, 20);
193 | }
194 |
195 |
196 | }
197 |
198 | public void a(Object o) {
199 |
200 |
201 | if (o instanceof ViewGroup) {
202 |
203 | ViewGroup vp = (ViewGroup) o;
204 |
205 |
206 | if (o instanceof ScrollView) {
207 | mScrollView = (ScrollView) o;
208 | mScrollView.setOverScrollMode(OVER_SCROLL_NEVER);
209 | } else if (o instanceof WebView) {
210 | mWebView = (WebView) o;
211 | mWebView.setOverScrollMode(OVER_SCROLL_NEVER);
212 | }
213 |
214 |
215 | for (int i = 0; i < vp.getChildCount(); i++) {
216 |
217 |
218 | a(vp.getChildAt(i));
219 | }
220 | }
221 |
222 |
223 | }
224 |
225 |
226 | public void initContentAdapterView(ViewGroup contentView) {
227 |
228 |
229 | if (contentView == null) {
230 | contentView = this;
231 | }
232 | int count = contentView.getChildCount();
233 |
234 |
235 | View view = null;
236 | for (int i = 0; i < count; ++i) {
237 | view = contentView.getChildAt(i);
238 |
239 | if (view instanceof ScrollView) {
240 | // finish later
241 | mScrollView = (ScrollView) view;
242 | mScrollView.setOverScrollMode(OVER_SCROLL_NEVER);
243 | }
244 | }
245 | }
246 |
247 |
248 | boolean isBlock = false;
249 |
250 |
251 | int downy;
252 |
253 | @Override
254 | public boolean onInterceptTouchEvent(MotionEvent e) {
255 | int y = (int) e.getRawY();
256 | switch (e.getAction()) {
257 | case MotionEvent.ACTION_DOWN:
258 | // 首先拦截down事件,记录y坐标
259 | mLastMotionY = y;
260 | downy = y;
261 | break;
262 | case MotionEvent.ACTION_MOVE:
263 | // deltaY > 0 是向下运动,< 0是向上运动
264 | int deltaY = y - downy;
265 | return isRefreshViewScroll(deltaY);
266 |
267 | case MotionEvent.ACTION_UP:
268 | case MotionEvent.ACTION_CANCEL:
269 | isBlock = false;
270 | break;
271 | }
272 | return super.onInterceptTouchEvent(e);
273 | }
274 |
275 |
276 | /*
277 | * 如果在onInterceptTouchEvent()方法中没有拦截(即onInterceptTouchEvent()方法中 return
278 | * false)则由PullToRefreshView 的子View来处理;否则由下面的方法来处理(即由PullToRefreshView自己来处理)
279 | */
280 | @Override
281 | public boolean onTouchEvent(MotionEvent event) {
282 |
283 | int y = (int) event.getRawY();
284 | switch (event.getAction()) {
285 | case MotionEvent.ACTION_DOWN:
286 | break;
287 | case MotionEvent.ACTION_MOVE:
288 | int deltaY = y - mLastMotionY;
289 | changingHeaderViewTopMargin(deltaY);
290 | mLastMotionY = y;
291 | break;
292 | case MotionEvent.ACTION_UP:
293 | case MotionEvent.ACTION_CANCEL:
294 | int topMargin = getHeaderTopMargin();
295 |
296 |
297 | if (topMargin < -3 * mHeadViewHeight) {
298 |
299 |
300 | if (isHashNext) {
301 | pullToNextI.next();
302 | } else {
303 | moveTo(-mHeadViewHeight, ANIMATION_DURATION);
304 | }
305 |
306 | } else if (topMargin > mHeadViewHeight) {
307 |
308 |
309 | if (isHashPrevious) {
310 | pullToNextI.previous();
311 |
312 | } else {
313 | moveTo(-mHeadViewHeight, ANIMATION_DURATION);
314 | }
315 |
316 | } else {
317 | moveTo(-mHeadViewHeight, ANIMATION_DURATION);
318 | }
319 |
320 |
321 | break;
322 | }
323 | return super.onTouchEvent(event);
324 | }
325 |
326 |
327 | public void moveTo(final float i, int duration) {
328 | int topMargin = getHeaderTopMargin();
329 | ValueAnimator animator = ValueAnimator.ofFloat(topMargin, i);
330 | animator.setDuration(duration);
331 | animator.setInterpolator(new DecelerateInterpolator());
332 | mPullStateE = PullStateE.PULL_STATE_NONE;
333 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
334 |
335 |
336 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
337 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
338 |
339 | float temp = (Float) valueAnimator.getAnimatedValue();
340 |
341 | if (temp == i) {
342 | mPullStateE = PullStateE.PULL_STATE_NONE;
343 | }
344 | setHeaderTopMargin((int) temp);
345 | }
346 | });
347 | animator.start();
348 | }
349 |
350 |
351 | public void reset(BaseAdapter adapter, int position) {
352 | setHeaderTopMargin(-mHeadViewHeight);
353 | initContentView(adapter, position);
354 | mScrollView=null;
355 | mWebView=null;
356 | ViewHelper.setAlpha(this, 1);
357 | ViewHelper.setTranslationY(this, 0);
358 | ViewHelper.setTranslationY(this, 0);
359 | ViewHelper.setScaleX(this, 1);
360 | ViewHelper.setScaleY(this, 1);
361 | ViewHelper.setScrollX(this, 0);
362 | ViewHelper.setScrollY(this, 0);
363 | ViewHelper.setRotationX(this, 0);
364 | ViewHelper.setRotationY(this, 0);
365 |
366 |
367 | }
368 |
369 |
370 | private boolean isRefreshViewScroll(int deltaY) {
371 |
372 | if (PullStateE.PULL_STATE_REFRESH == mPullStateE) {
373 |
374 |
375 | return false;
376 | }
377 | LayoutParams params = (LayoutParams) mHeaderView.getLayoutParams();
378 | // 对于ScrollView
379 | if (mScrollView != null) {
380 | // 子scroll view滑动到最顶端
381 | View child = mScrollView.getChildAt(0);
382 |
383 | if (deltaY > 12 && mScrollView.getScrollY() == 0
384 | ) {
385 | // 向下
386 | mPullStateE = PullStateE.PULL_STATE_DOWN;
387 | return true;
388 | } else if (deltaY < -12 &&
389 |
390 | child.getMeasuredHeight() <= contentView.getHeight() + mScrollView.getScrollY()) {
391 | //向上
392 | mPullStateE = PullStateE.PULL_STATE_UP;
393 | return true;
394 | }
395 | } else if (mWebView != null) {
396 | if (deltaY > 12 && mWebView.getScrollY() == 0
397 | ) {
398 | //向下
399 | mPullStateE = PullStateE.PULL_STATE_DOWN;
400 |
401 | return true;
402 |
403 | } else if (deltaY < -12 &&
404 | (int) (mWebView.getContentHeight() * mWebView.getScale()) - mWebView.getHeight() - mWebView.getScrollY() == 0
405 |
406 | ) {
407 | //向上
408 |
409 | mPullStateE = PullStateE.PULL_STATE_UP;
410 | return true;
411 |
412 | }
413 |
414 | } else {
415 | return true;
416 | }
417 |
418 |
419 | return false;
420 | }
421 |
422 |
423 | /**
424 | * 修改Header view top margin的值
425 | *
426 | * @param deltaY
427 | */
428 | private int changingHeaderViewTopMargin(int deltaY) {
429 |
430 |
431 | LayoutParams params = (LayoutParams) mHeaderView.getLayoutParams();
432 | float newTopMargin = params.topMargin + deltaY * 0.5f;
433 |
434 | if (mPullStateE == PullStateE.PULL_STATE_UP) {
435 | newTopMargin = Math.min(newTopMargin, -mHeadViewHeight);
436 | } else if (PullStateE.PULL_STATE_DOWN == mPullStateE) {
437 | newTopMargin = Math.max(newTopMargin, -mHeadViewHeight);
438 | }
439 | params.topMargin = (int) newTopMargin;
440 | mHeaderView.setLayoutParams(params);
441 |
442 | if (newTopMargin < -mHeadViewHeight) {
443 | //下一个
444 |
445 | if (!isHashNext) {
446 | footPromptTV.setText(getPromptEntity().getNoMoreDatePtn());
447 | } else if (newTopMargin < -3 * mHeadViewHeight) {
448 |
449 | footPromptTV.setText(getPromptEntity().getReleaseToNextPtn());
450 | } else {
451 | footPromptTV.setText(getPromptEntity().getPullUpToNextPtn());
452 | }
453 |
454 |
455 | } else if (newTopMargin > -mHeadViewHeight) {
456 |
457 | //前一个
458 | if (!isHashPrevious) {
459 | headPromptTV.setText(getPromptEntity().getTheFirstPtn());
460 | } else if (newTopMargin > mHeadViewHeight) {
461 |
462 | headPromptTV.setText(getPromptEntity().getReleaseToPreviousPtn());
463 | } else {
464 | headPromptTV.setText(getPromptEntity().getPullDownToPreviousPtn());
465 |
466 | }
467 |
468 |
469 | } else {
470 | moveTo(-mHeadViewHeight, ANIMATION_DURATION);
471 | }
472 |
473 |
474 | invalidate();
475 | return params.topMargin;
476 | }
477 |
478 |
479 | /**
480 | * 获取当前header view 的topMargin
481 | */
482 | private int getHeaderTopMargin() {
483 | LayoutParams params = (LayoutParams) mHeaderView.getLayoutParams();
484 | return params.topMargin;
485 | }
486 |
487 | private PullToNextI pullToNextI;
488 |
489 | public void setPullToNextI(PullToNextI pullToNextI) {
490 | this.pullToNextI = pullToNextI;
491 | }
492 |
493 | protected interface PullToNextI {
494 | public void previous();
495 |
496 | public void next();
497 |
498 | }
499 |
500 |
501 | enum PullStateE {
502 |
503 | PULL_STATE_NONE,
504 | PULL_STATE_DOWN,
505 | PULL_STATE_UP,
506 | PULL_STATE_REFRESH
507 | }
508 |
509 | public void setHashPrevious(boolean isHashPrevious) {
510 | this.isHashPrevious = isHashPrevious;
511 | }
512 |
513 | public void setHashNext(boolean isHashNext) {
514 | this.isHashNext = isHashNext;
515 | }
516 |
517 |
518 | public PromptEntity getPromptEntity() {
519 |
520 | if(mPromptEntity==null){
521 | mPromptEntity=new PromptEntity(getContext());
522 | }
523 |
524 | return mPromptEntity;
525 | }
526 |
527 | public void setPromptEntity(PromptEntity promptEntity) {
528 | this.mPromptEntity = promptEntity;
529 | }
530 | }
531 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/adapter/PullToNextFragmentAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.adapter;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentTransaction;
6 | import android.view.View;
7 |
8 |
9 | import com.mingle.pulltonextlayout.BaseAdapter;
10 | import com.mingle.pulltonextlayout.PullToNextEntity;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * Created by zzz40500 on 15/3/21.
17 | */
18 |
19 | /**
20 | * 缺陷:对于2.3的系统使用 addItem() addAllItem() 方法会错乱.4.0以上没有这个问题.
21 | * 对于重复的视图没有做到复用.不支持 notifyDataSetChanged方法.
22 | * 推荐使用 {@link PullToNextModelAdapter}
23 | *
24 | */
25 | @Deprecated()
26 | public class PullToNextFragmentAdapter extends BaseAdapter {
27 |
28 |
29 | private FragmentManager fm;
30 |
31 | public PullToNextFragmentAdapter(Fragment fragment, List allList) {
32 | super(allList);
33 | if(null == allList){
34 | list=new ArrayList<>();
35 | }
36 | fm = fragment.getChildFragmentManager();
37 | }
38 |
39 | public PullToNextFragmentAdapter(FragmentManager manager, List allList) {
40 | super(allList);
41 | if(null == allList){
42 | this.list=new ArrayList<>();
43 | }
44 | fm = manager;
45 | }
46 |
47 | @Override
48 | protected void cleanAll() {
49 | List list = this.fm.getFragments();
50 | if (list == null || list.size() == 0) {
51 | return;
52 | }
53 | FragmentTransaction transaction = this.fm.beginTransaction();
54 | for (int j = 0; j < list.size(); j++) {
55 | Fragment fragment = list.get(j);
56 | if (fragment != null) {
57 | transaction.remove(list.get(j));
58 | }
59 | }
60 | transaction.commitAllowingStateLoss();
61 | if (null != this.fm) {
62 | this.fm.executePendingTransactions();
63 | }
64 | }
65 |
66 | public void setOnItemVisibility(int position, boolean visibility){
67 |
68 |
69 | if(getItem(position).getUserVisibleHint() != visibility) {
70 | getItem(position).setUserVisibleHint(visibility);
71 | getItem(position).setMenuVisibility(visibility);
72 | }
73 |
74 | }
75 |
76 |
77 | @Override
78 | public View getContentView(int position) {
79 |
80 | Fragment f = fm.findFragmentByTag("position" + position);
81 |
82 |
83 | if (f != null) {
84 | return f.getView();
85 | }else{
86 | return null;
87 | }
88 | }
89 |
90 | @Override
91 | protected void attachContentView(PullToNextEntity pullToNextView) {
92 |
93 | FragmentTransaction transaction = fm.beginTransaction();
94 | Fragment f
95 | = fm.findFragmentByTag("position" + pullToNextView.getPosition());
96 |
97 | if (f != null) {
98 | transaction.attach(f);
99 | } else {
100 | transaction.add(pullToNextView.getContentId(),
101 | this.getItem(pullToNextView.getPosition())
102 | , "position" + pullToNextView.getPosition());
103 | }
104 |
105 | transaction.commitAllowingStateLoss();
106 | this.fm.executePendingTransactions();
107 |
108 | }
109 |
110 | @Override
111 | protected void detachContentView(PullToNextEntity pullToNextEntity){
112 | Fragment f
113 | = this.fm.findFragmentByTag("position" + pullToNextEntity.getPosition());
114 |
115 | if (f != null) {
116 | this.fm.beginTransaction().detach(
117 | f).commit();
118 |
119 | }
120 | if (null != this.fm) {
121 |
122 | this.fm.executePendingTransactions();
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/adapter/PullToNextModelAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.LayoutRes;
5 | import android.util.SparseArray;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.mingle.pulltonextlayout.BaseAdapter;
11 | import com.mingle.pulltonextlayout.PullToNextEntity;
12 | import com.mingle.pulltonextlayout.model.PullToNextModel;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | *
19 | * Created by zzz40500 on 15/5/30.
20 | */
21 | public class PullToNextModelAdapter extends BaseAdapter {
22 | private SparseArray> holderMap = new SparseArray<>();
23 |
24 | private Context context;
25 |
26 | public PullToNextModelAdapter(Context context, List list) {
27 | super(list);
28 | this.context = context;
29 | }
30 |
31 | @Override
32 | protected void cleanAll() {
33 | holderMap.clear();
34 | }
35 |
36 | @Override
37 | public void setOnItemVisibility(int position, boolean userVisibleHint) {
38 |
39 | PullToNextModel model = list.get(position);
40 |
41 | if (model.isUserVisibleHint() != userVisibleHint) {
42 | model.setUserVisibleHint(userVisibleHint);
43 | }
44 | }
45 |
46 |
47 | @Override
48 | protected void attachContentView(PullToNextEntity pullToNextEntity) {
49 |
50 | PullToNextModel model = list.get(pullToNextEntity.getPosition());
51 | View view = getConvertView(model.getLayoutViewId());
52 |
53 | if (!model.isCreate()) {
54 | model.onCreate(context);
55 | model.setCreate(true);
56 | }
57 | model.setView(view);
58 | ViewGroup parentView = (ViewGroup) pullToNextEntity.getPullToNextView().findViewById(pullToNextEntity.getContentId());
59 | parentView.removeAllViews();
60 | parentView.addView(view);
61 | model.onBindView(pullToNextEntity.getPosition(), view, pullToNextEntity.getPullToNextView());
62 | model.onResumeView(pullToNextEntity.getPosition(),view,pullToNextEntity.getPullToNextView());
63 | }
64 |
65 |
66 | @Override
67 | protected void detachContentView(PullToNextEntity pullToNextEntity) {
68 | PullToNextModel model = list.get(pullToNextEntity.getPosition());
69 | ViewGroup parentView = (ViewGroup) pullToNextEntity.getPullToNextView().findViewById(pullToNextEntity.getContentId());
70 | model.onPauseView(pullToNextEntity.getPosition(), model.getView(), pullToNextEntity.getPullToNextView());
71 | model.onUnBindView(pullToNextEntity.getPosition(), model.getView(), pullToNextEntity.getPullToNextView());
72 | parentView.removeView(model.getView());
73 | model.setView(null);
74 | }
75 |
76 | @Override
77 | public View getContentView(int position) {
78 | PullToNextModel model = list.get(position);
79 | return model.getView();
80 | }
81 |
82 | /**
83 | * 实现 contentView 的复用
84 | * @param id
85 | * @return
86 | */
87 | private View getConvertView(@LayoutRes int id) {
88 |
89 | List views = holderMap.get(id);
90 | View v = null;
91 | if (views != null) {
92 |
93 | for (int i = 0; i < views.size(); i++) {
94 | View item = views.get(i);
95 | if (item.getParent() == null) {
96 | v = item;
97 | break;
98 | }
99 | }
100 |
101 | if (v == null) {
102 | v = LayoutInflater.from(context).inflate(id, null);
103 | views.add(v);
104 | }
105 |
106 | } else {
107 | views = new ArrayList<>();
108 | v = LayoutInflater.from(context).inflate(id, null);
109 | views.add(v);
110 | holderMap.put(id,views);
111 | }
112 | return v;
113 |
114 | }
115 |
116 | public void notifyDataSetChanged() {
117 | mDataSetObservable.notifyChanged();
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/anim/PullToNextAnimationI.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.anim;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.animation.Animator;
6 |
7 | /**
8 | * Created by zzz40500 on 15/5/3.
9 | */
10 | public interface PullToNextAnimationI {
11 |
12 |
13 | public Animator getPullDownAnim(View showView,View dismissView);
14 |
15 | public Animator getPullUpAnim(View showView,View dismissView);
16 | public Animator getDeleteItemAnim(View showView,View dismissView);
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/anim/SimpleAnimation.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.anim;
2 |
3 | import android.view.View;
4 | import android.view.animation.DecelerateInterpolator;
5 |
6 | import com.mingle.pulltonextlayout.PullToNextEntity;
7 | import com.nineoldandroids.animation.Animator;
8 | import com.nineoldandroids.animation.AnimatorSet;
9 | import com.nineoldandroids.animation.ObjectAnimator;
10 | import com.nineoldandroids.view.ViewHelper;
11 |
12 | /**
13 | * Created by zzz40500 on 15/5/3.
14 | */
15 | public class SimpleAnimation implements PullToNextAnimationI {
16 |
17 | private static final int ANIMATION_DURATION = 500;
18 |
19 |
20 | public Animator getPullDownAnimIn(View view) {
21 |
22 | ObjectAnimator in = ObjectAnimator.ofFloat(view, "translationY", -view.getMeasuredHeight(), 0);
23 |
24 | ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.6f, 1);
25 | ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.6f, 1);
26 |
27 | AnimatorSet set = new AnimatorSet();
28 | set.setInterpolator(new DecelerateInterpolator());
29 | in.setDuration(ANIMATION_DURATION);
30 | scaleY.setDuration(ANIMATION_DURATION);
31 | scaleX.setDuration(ANIMATION_DURATION);
32 | set.setDuration(ANIMATION_DURATION);
33 | set.playTogether(scaleY, scaleX, in);
34 |
35 |
36 | return set;
37 | }
38 |
39 | private Animator getPullDownAnimOut(View view) {
40 |
41 | ObjectAnimator out = ObjectAnimator.ofFloat(view, "translationY", 0, view.getMeasuredHeight());
42 |
43 | out.setDuration(ANIMATION_DURATION);
44 | return out;
45 | }
46 |
47 |
48 | private Animator getPullUpAnimIn(View view) {
49 |
50 | ObjectAnimator in = ObjectAnimator.ofFloat(view, "translationY", view.getMeasuredHeight(), 0);
51 | // ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "rotationX", 20, 0);
52 | ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.6f, 1);
53 | ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.6f, 1f);
54 | AnimatorSet set = new AnimatorSet();
55 | set.setInterpolator(new DecelerateInterpolator());
56 | in.setDuration(ANIMATION_DURATION);
57 | scaleY.setDuration(ANIMATION_DURATION);
58 | scaleX.setDuration(ANIMATION_DURATION);
59 | set.setDuration(ANIMATION_DURATION);
60 | set.playTogether(scaleY, scaleX, in);
61 |
62 |
63 | return set;
64 | }
65 |
66 |
67 | private Animator getPullUpAnimOut(View view) {
68 | ObjectAnimator out = ObjectAnimator.ofFloat(view, "translationY", 0, -view.getMeasuredHeight());
69 | out.setDuration(ANIMATION_DURATION);
70 | return out;
71 | }
72 |
73 |
74 |
75 | public Animator getPullDownAnim(View showView, View dismissView) {
76 | Animator out = getPullDownAnimOut(dismissView);
77 | Animator in = getPullDownAnimIn(showView);
78 | AnimatorSet set = new AnimatorSet();
79 | set.setInterpolator(new DecelerateInterpolator());
80 | set.setDuration(ANIMATION_DURATION);
81 | set.playTogether(out, in);
82 | return set;
83 | }
84 |
85 |
86 | public Animator getPullUpAnim(View showView, View dismissView) {
87 |
88 | Animator out = getPullUpAnimOut(dismissView);
89 |
90 | Animator in =getPullUpAnimIn(showView);
91 | AnimatorSet set = new AnimatorSet();
92 | set.setDuration(ANIMATION_DURATION);
93 | set.setInterpolator(new DecelerateInterpolator());
94 | set.playTogether(out, in);
95 |
96 | return set;
97 | }
98 |
99 | public Animator getDeleteItemDisMissAnimation(View view) {
100 |
101 | return getPullDownAnimOut(view);
102 | }
103 |
104 | public Animator getDeleteItemShowAnimation(View view) {
105 | ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.7f, 1);
106 | ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.7f, 1);
107 | AnimatorSet set = new AnimatorSet();
108 | set.setInterpolator(new DecelerateInterpolator());
109 | scaleY.setDuration(ANIMATION_DURATION);
110 | scaleX.setDuration(ANIMATION_DURATION);
111 | set.setDuration(ANIMATION_DURATION);
112 | set.playTogether(scaleY, scaleX);
113 | return set;
114 | }
115 |
116 | @Override
117 | public Animator getDeleteItemAnim(View showView, View dismissView) {
118 |
119 | Animator out = getDeleteItemDisMissAnimation(dismissView);
120 |
121 | Animator in =getDeleteItemShowAnimation(showView);
122 | AnimatorSet set = new AnimatorSet();
123 | set.setDuration(ANIMATION_DURATION);
124 | set.setInterpolator(new DecelerateInterpolator());
125 | set.playTogether(out, in);
126 | return set;
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/base/SimpleAnimatorListener.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.base;
2 |
3 |
4 | import com.nineoldandroids.animation.Animator;
5 |
6 |
7 | /**
8 | * Created by zzz40500 on 15/5/30.
9 | */
10 | public class SimpleAnimatorListener implements Animator.AnimatorListener{
11 |
12 | @Override
13 | public void onAnimationStart(Animator animation) {
14 |
15 | }
16 |
17 | @Override
18 | public void onAnimationEnd(Animator animation) {
19 |
20 | }
21 |
22 | @Override
23 | public void onAnimationCancel(Animator animation) {
24 |
25 | }
26 |
27 | @Override
28 | public void onAnimationRepeat(Animator animation) {
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/model/PullToNextModel.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.model;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.LayoutRes;
5 | import android.view.View;
6 | import android.widget.BaseAdapter;
7 |
8 | import com.mingle.pulltonextlayout.PullToNextView;
9 |
10 | /**
11 | *
12 | * Created by zzz40500 on 15/5/30.
13 | */
14 | public abstract class PullToNextModel {
15 |
16 |
17 | protected Context mContext;
18 | protected View view;
19 | private boolean userVisibleHint;
20 |
21 |
22 | private boolean create;
23 | /**
24 | * @param context
25 | */
26 | public void onCreate(Context context) {
27 | this.mContext = context;
28 |
29 | }
30 | /**
31 | * 返回布局的 ID
32 | * @return
33 | */
34 | public abstract
35 | @LayoutRes
36 | int getLayoutViewId();
37 |
38 |
39 | /**
40 | * 绑定数据
41 | *
42 | * @param view
43 | */
44 | public abstract void onBindView( int position,View view, PullToNextView pullToNextView) ;
45 |
46 | /**
47 | * 可见状态
48 | *
49 | * @param view
50 | */
51 | public void onResumeView(int position,View view, PullToNextView pullToNextView) {
52 |
53 | }
54 |
55 | /**
56 | * 不可见状态
57 | *
58 | * @param view
59 | */
60 | public void onPauseView(int position,View view, PullToNextView pullToNextView) {
61 |
62 | }
63 |
64 | /**
65 | * 解绑数据
66 | *
67 | * @param view
68 | */
69 |
70 | public void onUnBindView(int position,View view, PullToNextView pullToNextView) {
71 |
72 | }
73 |
74 | public View getView() {
75 | return view;
76 | }
77 |
78 | public void setView(View view) {
79 | this.view = view;
80 | }
81 |
82 | public boolean isUserVisibleHint() {
83 | return userVisibleHint;
84 | }
85 |
86 | public void setUserVisibleHint(boolean userVisibleHint) {
87 | this.userVisibleHint = userVisibleHint;
88 | }
89 |
90 | public boolean isCreate() {
91 | return create;
92 | }
93 |
94 | public void setCreate(boolean create) {
95 | this.create = create;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/observable/PullToNextDataObserver.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.observable;
2 |
3 | import android.database.DataSetObserver;
4 |
5 | /**
6 | * Created by zzz40500 on 15/5/22.
7 | */
8 | public class PullToNextDataObserver extends DataSetObserver {
9 |
10 |
11 |
12 | public void onNewData() {
13 | // Do nothing
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/java/com/mingle/pulltonextlayout/observable/PullToNextDataSetObservable.java:
--------------------------------------------------------------------------------
1 | package com.mingle.pulltonextlayout.observable;
2 |
3 | import android.database.Observable;
4 |
5 | /**
6 | * Created by zzz40500 on 15/5/22.
7 | */
8 | public class PullToNextDataSetObservable extends Observable {
9 |
10 |
11 |
12 |
13 | public void notifyChanged() {
14 | synchronized(mObservers) {
15 | // since onChanged() is implemented by the app, it could do anything, including
16 | // removing itself from {@link mObservers} - and that could cause problems if
17 | // an iterator is used on the ArrayList {@link mObservers}.
18 | // to avoid such problems, just march thru the list in the reverse order.
19 | for (int i = mObservers.size() - 1; i >= 0; i--) {
20 | mObservers.get(i).onChanged();
21 | }
22 | }
23 | }
24 |
25 |
26 | public void notifyInvalidated() {
27 | synchronized (mObservers) {
28 | for (int i = mObservers.size() - 1; i >= 0; i--) {
29 | mObservers.get(i).onInvalidated();
30 | }
31 | }
32 | }
33 |
34 | public void notifyNewData(){
35 | synchronized (mObservers) {
36 | for (int i = mObservers.size() - 1; i >= 0; i--) {
37 | mObservers.get(i).onNewData();
38 | }
39 | }
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/layout/pull_to_next_prompt_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/pulltonextlayout/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/pulltonextlayout/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/pulltonextlayout/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zzz40500/Android-PullToNextLayout/6803a0a725012ebb3c3f338722ea7543cbac092b/pulltonextlayout/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PullToNextLayout
3 |
4 |
5 |
6 | 没有更多信息
7 | 放手查看下一个
8 | 上拉查看下一个
9 | 已经是第一个了
10 | 放手查看前一个
11 | 下拉查看前一个
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pulltonextlayout/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | #606060
9 | #dddddd
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':pulltonextlayout', ':example2'
2 |
--------------------------------------------------------------------------------