├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── mran
│ │ └── cardviewpage
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── mran
│ │ │ └── cardviewpage
│ │ │ ├── BookFlippageFadePageTransormer.java
│ │ │ ├── CardFlipoverPageTransormer.java
│ │ │ ├── CardStackPaegTransformer.java
│ │ │ ├── CascadeZoomPageTransformer.java
│ │ │ ├── CubesPageTransformer.java
│ │ │ ├── DepthCardTransformer.java
│ │ │ ├── FilpPageRotationPageTransformer.java
│ │ │ ├── Main2Activity.kt
│ │ │ ├── MainActivity.java
│ │ │ ├── TurntablePageTransformer.java
│ │ │ └── ZoominPagerTransFormer.java
│ └── res
│ │ ├── drawable
│ │ ├── a.png
│ │ ├── b.png
│ │ ├── c.png
│ │ ├── d.png
│ │ ├── e.png
│ │ ├── f.png
│ │ └── g.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── activity_main2.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── mran
│ └── cardviewpage
│ └── ExampleUnitTest.java
├── build.gradle
├── cardpage
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── mran
│ │ └── cardpage
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── mran
│ │ │ └── cardpage
│ │ │ ├── CardItem.java
│ │ │ └── CardPage.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── mran
│ └── cardpage
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 书籍翻页渐隐
2 |
3 | 
4 | ```java
5 | public class BookFlippageFadePageTransormer implements ViewPager.PageTransformer {
6 | @Override
7 | public void transformPage(View page, float position) {
8 | if (position <= -1) {
9 | /*页面已经在屏幕左侧且不可视*/
10 | page.setAlpha(position);
11 | } else if (position <= 0) {
12 | /*页面从左侧进入或者向左侧滑出的状态*/
13 | page.setAlpha(1 + position);
14 | page.setPivotY(page.getHeight() / 2);
15 | page.setPivotX(0);
16 | page.setCameraDistance(60000);/*调整摄像机的位置,避免出现糊脸的感觉*/
17 | page.setRotationY((position * 180));
18 | page.setTranslationX(position * -page.getWidth());
19 | } else if (position <= 1) {
20 | /*页面从右侧进入或者向右侧滑出的状态*/
21 | page.setTranslationX(position * -page.getWidth());
22 | } else if (position > 1) {
23 | /*页面已经在屏幕右侧且不可视*/
24 | page.setTranslationX(position * -page.getWidth());
25 |
26 | }
27 | }
28 | }
29 |
30 | ```
31 | ## 翻页旋转
32 |
33 | 
34 | ```java
35 | public class FilpPageRotationPageTransformer implements ViewPager.PageTransformer {
36 | @Override
37 | public void transformPage(View page, float position) {
38 | if (position < -1) { /* [-Infinity,-1)*/
39 | /*页面已经在屏幕左侧且不可视*/
40 | } else if (position <= 0) { /* [-1,0]*/
41 | /*页面从左侧进入或者向左侧滑出的状态*/
42 | page.setCameraDistance(60000);
43 | page.setAlpha(1 + position);
44 | page.setTranslationX(page.getWidth() * -position);
45 | page.setPivotX(0);
46 | page.setRotationY(position * 90);
47 | } else if (position <= 1) {/* (0,1]*/
48 | /*页面从右侧进入或者向右侧滑出的状态*/
49 | page.setCameraDistance(60000);
50 | page.setTranslationX(page.getWidth() * -position);
51 | page.setPivotX(0);
52 | page.setRotationY(position * 90);
53 | page.setAlpha(1 - position);
54 | } else if (position > 1) {
55 | /*页面已经在屏幕右侧且不可视*/
56 | }
57 | }
58 | }
59 | ```
60 | ## 卡片绕中心旋转
61 |
62 | 
63 | ```java
64 | public class CardFlipoverPageTransormer implements PageTransformer {
65 |
66 | @Override
67 | public void transformPage(View page, float position) {
68 | if (position <= -1) {
69 | /*页面已经在屏幕左侧且不可视*/
70 | /*设置离开的page不可点击,不可见*/
71 | page.setClickable(false);
72 | page.setAlpha(0);
73 | } else if (position <= 0) {
74 | page.setClickable(false);
75 | /*页面从左侧进入或者向左侧滑出的状态*/
76 | /*把旋转中心改为中间*/
77 | page.setAlpha(1);
78 | if (position <= -0.5)
79 | /*旋转到中间时该页page隐藏掉*/
80 | page.setAlpha(0);
81 | page.setPivotX(page.getWidth() / 2);
82 | page.setPivotY(page.getHeight() / 2);
83 |
84 |
85 | page.setTranslationX(position * -page.getWidth());
86 | page.setCameraDistance(10000);
87 | page.setRotationY(position * 180);
88 | } else if (position <= 1) {
89 | /*页面从右侧进入或者向右侧滑出的状态*/
90 | /*初始状态要是隐藏状态*/
91 | page.setAlpha(0);
92 | if (position <= 0.5)
93 | /*旋转到中间时该页page显示出来*/
94 | page.setAlpha(1);
95 | page.setPivotX(page.getWidth() / 2);
96 | page.setPivotY(page.getHeight() / 2);
97 | page.setTranslationX(position * -page.getWidth());
98 | page.setCameraDistance(10000);
99 | page.setRotationY(-180 - (1 - position) * 180);
100 | } else if (position >= 1) {
101 | /*页面已经在屏幕右侧且不可视*/
102 | }
103 | }
104 | }
105 | ```
106 | ## 立方体旋转
107 |
108 | 
109 | ```java
110 | public class CubesPageTransformer implements ViewPager.PageTransformer {
111 | @Override
112 | public void transformPage(View page, float position) {
113 | if (position <=-1) { /* [-Infinity,-1)*/
114 | /*页面已经在屏幕左侧且不可视*/
115 | } else if (position <= 0) { /* [-1,0]*/
116 | /*页面从左侧进入或者向左侧滑出的状态*/
117 | page.setCameraDistance(100000);
118 | page.setPivotX(page.getMeasuredWidth());
119 | page.setPivotY(page.getMeasuredHeight()*0.5f);
120 | page.setRotationY(90*position);
121 | } else if (position <= 1) {/* (0,1]*/
122 | /*页面从右侧进入或者向右侧滑出的状态*/
123 | page.setCameraDistance(100000);
124 | page.setPivotX(0);
125 | page.setPivotY( page.getWidth()*(0.5f));
126 | page.setRotationY(90*position);
127 | }else if (position >1){
128 | /*页面已经在屏幕右侧且不可视*/
129 |
130 | }
131 | }
132 | }
133 | ```
134 | ## 转盘旋转
135 |
136 | 
137 | ```java
138 | public class TurntablePageTransformer implements ViewPager.PageTransformer {
139 | @Override
140 | public void transformPage(View page, float position) {
141 | if (position < -1) { /* [-Infinity,-1)*/
142 | /*页面已经在屏幕左侧且不可视*/
143 | } else if (position <= 0) { /* [-1,0]*/
144 | /*页面从左侧进入或者向左侧滑出的状态*/
145 | page.setPivotX(page.getWidth() / 2);
146 | page.setPivotY(page.getHeight());
147 | page.setRotation(90*position);
148 | } else if (position <= 1) {/* (0,1]*/
149 | /*页面从右侧进入或者向右侧滑出的状态*/
150 | page.setPivotX(page.getWidth() / 2);
151 | page.setPivotY(page.getHeight());
152 | page.setRotation(90*position);
153 | } else if (position > 1) {
154 | /*页面已经在屏幕右侧且不可视*/
155 |
156 | }
157 | }
158 | }
159 | ```
160 | ## 层叠缩放
161 |
162 | 
163 | ```java
164 | public class CascadeZoomPageTransformer implements ViewPager.PageTransformer {
165 | @Override
166 | public void transformPage(View page, float position) {
167 | if (position < -1) { /* [-Infinity,-1)*/
168 | /*页面已经在屏幕左侧且不可视*/
169 | } else if (position <= 0) { /* [-1,0]*/
170 | /*页面从左侧进入或者向左侧滑出的状态*/
171 | page.setAlpha(1 + position);
172 | } else if (position <= 1) {/* (0,1]*/
173 | /*页面从右侧进入或者向右侧滑出的状态*/
174 | page.setTranslationX(page.getWidth() * -position);
175 | page.setScaleX(1-position*0.5f);
176 | page.setScaleY(1-position*0.5f);
177 | page.setAlpha(1 - position);
178 | }else if (position >1){
179 | /*页面已经在屏幕右侧且不可视*/
180 |
181 | }
182 | }
183 | }
184 | ```
185 | ## 折叠向上
186 |
187 | 
188 | ```java
189 | /**
190 | * Created by M on 2017/9/21.
191 | * 这个要配和在ViewPager里设置android:clipChildren="false"
192 | * android:margin="xxdp"
193 | * 在ViewPager的外层里设置android:clipChildren="false"
194 | */
195 |
196 | public class DepthCardTransformer implements ViewPager.PageTransformer {
197 | @Override
198 | public void transformPage(View page, float position) {
199 | if (position < -1) { /* [-Infinity,-1)*/
200 | /*页面已经在屏幕左侧第一个*/
201 | page.setCameraDistance(10000);
202 | page.setPivotX(page.getWidth()/2);
203 | page.setPivotY(page.getWidth());
204 | page.setRotationY(20);
205 | } else if (position <= 0) { /* [-1,0]*/
206 | /*页面从左侧进入或者向左侧滑出的状态*/
207 | page.setCameraDistance(10000);
208 | page.setPivotX(page.getWidth()/2);
209 | page.setPivotY(page.getWidth());
210 | page.setRotationY(-20+(1-position)*20);
211 | } else if (position <= 1) {/* (0,1]*/
212 | /*页面从右侧进入或者向右侧滑出的状态*/
213 | page.setCameraDistance(10000);
214 | page.setPivotX(page.getWidth()/2);
215 | page.setPivotY(page.getWidth());
216 | page.setRotationY(-20+(1-position)*20);
217 | } else if (position<=2) {
218 | /*页面已经在屏幕右侧第一个*/
219 | page.setCameraDistance(10000);
220 | page.setPivotX(page.getWidth()/2);
221 | page.setPivotY(page.getWidth());
222 | page.setRotationY(-20);
223 | }
224 |
225 | }
226 | }
227 | ```
228 | ## 滑动缩放
229 |
230 | 
231 | ```java
232 | /**
233 | * Created by M on 2017/9/21.
234 | * 这个要配和在ViewPager里设置android:clipChildren="false"
235 | * android:margin="xxdp"
236 | * 在ViewPager的外层里设置android:clipChildren="false"
237 | */
238 | public class ZoominPagerTransFormer implements ViewPager.PageTransformer {
239 | @Override
240 | public void transformPage(View page, float position) {
241 |
242 |
243 | if (position < -1) { /* [-Infinity,-1)*/
244 | /*页面已经在屏幕左侧且不可视*/
245 | page.setScaleX((float) (1 + position * 0.1));
246 | page.setScaleY((float) (1 + position * 0.1));
247 | } else if (position <= 0) { /* [-1,0]*/
248 | /*页面从左侧进入或者向左侧滑出的状态*/
249 |
250 | page.setScaleX((float) (1 + position * 0.1));
251 | page.setScaleY((float) (1 + position * 0.1));
252 | } else if (position <= 1) {/* (0,1]*/
253 | /*页面从右侧进入或者向右侧滑出的状态*/
254 | page.setScaleX((float) (1- position * 0.1));
255 | page.setScaleY((float) (1 - position * 0.1));
256 | } else if (position > 1) {
257 | /*页面已经在屏幕右侧且不可视*/
258 | page.setScaleX((float) (1- position * 0.1));
259 | page.setScaleY((float) (1 - position * 0.1));
260 | }
261 | }
262 | }
263 | ```
264 | ## 卡片堆叠
265 |
266 | 
267 | ```java
268 | public class CardStackPaegTransformer implements ViewPager.PageTransformer {
269 | public void transformPage(View page, float position) {
270 | if (position <= -1) {
271 | /*页面已经在屏幕左侧且不可视*/
272 | } else if (position <= 0) {
273 | /*页面从左侧进入或者向左侧滑出的状态*/
274 | } else if (position < 1) {
275 | /*页面从右侧进入或者向右侧滑出的状态*/
276 | page.setAlpha((float) (1 - position * 0.1));
277 | page.setPivotX(page.getWidth() / 2f);
278 | page.setPivotY(page.getHeight() / 2f);
279 | page.setScaleX((float) Math.pow(0.9f, position)); /*0.9f为缩放系数*/
280 | page.setScaleY((float) Math.pow(0.9f, position));
281 | page.setTranslationX(position * -page.getWidth());
282 | page.setTranslationY(-position * 70);/*70每层card的Y轴间隔*/
283 |
284 | } else if (position >= 1) {
285 | /*页面已经在屏幕右侧且不可视*/
286 | page.setAlpha((float) (1 - position * 0.1));
287 | page.setPivotX(page.getWidth() / 2f);
288 | page.setPivotY(page.getHeight() / 2f);
289 | page.setScaleX((float) Math.pow(0.9f, position));
290 | page.setScaleY((float) Math.pow(0.9f, position));
291 | page.setTranslationX(position * -page.getWidth());
292 | page.setTranslationY(-position * 70);
293 | }
294 |
295 | }
296 | }
297 | ```
298 | ## 卡片堆叠 进阶版
299 |
300 | 
301 | 这个进阶版可以看到是在滑动结束后有一个弹跳的类似于果冻动画,这个实际上我是对Viewpage设置了滑动监听,在滑动状态改变时对当前的page设置一个缩放动画,这样就好了
302 | 下面是果冻动画的代码,这里安利一个网站[http://inloop.github.io/interpolator/](http://inloop.github.io/interpolator/),这个网站可以直观看到不同插值器的曲线变化情况,我的这个插值器也是在这里经过调整之后得到的.
303 | ```java
304 | /*配合以下代码可以实现滑动结束后的果冻效果*/
305 | int mCurrentPosition=0;
306 | float mFactor = 0.5f;
307 | mAnimation = new ScaleAnimation(0.9f, 1.0f, 0.9f, 1.0f, 150, 450);
308 | mAnimation.setDuration(500);
309 | mAnimation.setFillAfter(true);
310 | mAnimation.setInterpolator(new Interpolator() {
311 | @Override
312 | public float getInterpolation(float input) {
313 | return (float) (Math.pow(2, -10 * input) * Math.sin((input - mFactor / 4) * (2 * Math.PI) / mFactor) + 0.9);
314 | }
315 | });
316 |
317 |
318 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
319 | @Override
320 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
321 | Log.d("MainActivity", "onPageScrolled: position" + position + " positionOffset" + positionOffset + " positionOffsetPixels" + positionOffsetPixels);
322 | }
323 |
324 | @Override
325 | public void onPageSelected(int position) {
326 | Log.d("MainActivity", "onPageSelected: position" + position);
327 | mImageViewList.get(mCurrentPosition ).clearAnimation();
328 | mCurrentPosition = position;
329 | mImageViewList.get(mCurrentPosition).startAnimation(mAnimation);
330 |
331 | }
332 |
333 | @Override
334 | public void onPageScrollStateChanged(int state) {
335 | Log.d("MainActivity", "onPageScrollStateChanged: state" + state);
336 |
337 | }
338 | });
339 |
340 | ```
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 28
7 | buildToolsVersion "28.0.3"
8 |
9 | aaptOptions.cruncherEnabled = false
10 | aaptOptions.useNewCruncher = false
11 | defaultConfig {
12 | applicationId "com.mran.cardviewpage"
13 | minSdkVersion 19
14 | targetSdkVersion 28
15 | versionCode 1
16 | versionName "1.0"
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | implementation 'com.android.support:appcompat-v7:28.0.0'
33 | implementation 'com.android.support:support-dynamic-animation:28.0.0'
34 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
35 | implementation "org.jetbrains.anko:anko:0.10.8"
36 |
37 | testImplementation 'junit:junit:4.12'
38 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
39 | }
40 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\M\AppData\Local\Android\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/mran/cardviewpage/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.mran.cardviewpage", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/BookFlippageFadePageTransormer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/21.
8 | */
9 |
10 | public class BookFlippageFadePageTransormer implements ViewPager.PageTransformer {
11 | @Override
12 | public void transformPage(View page, float position) {
13 | if (position <= -1) {
14 | /*页面已经在屏幕左侧且不可视*/
15 | page.setAlpha(position);
16 | } else if (position <= 0) {
17 | /*页面从左侧进入或者向左侧滑出的状态*/
18 | page.setAlpha(1 + position);
19 | page.setPivotY(page.getHeight() / 2);
20 | page.setPivotX(0);
21 | page.setCameraDistance(60000);/*调整摄像机的位置,避免出现糊脸的感觉*/
22 | page.setRotationY((position * 180));
23 | page.setTranslationX(position * -page.getWidth());
24 | } else if (position <= 1) {
25 | /*页面从右侧进入或者向右侧滑出的状态*/
26 | page.setTranslationX(position * -page.getWidth());
27 |
28 | } else if (position > 1) {
29 |
30 | /*页面已经在屏幕右侧且不可视*/
31 | page.setTranslationX(position * -page.getWidth());
32 |
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/CardFlipoverPageTransormer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager.PageTransformer;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/21.
8 | * 卡片绕卡片中心旋转
9 | */
10 |
11 | public class CardFlipoverPageTransormer implements PageTransformer {
12 |
13 | @Override
14 | public void transformPage(View page, float position) {
15 | if (position <= -1) {
16 | /*页面已经在屏幕左侧且不可视*/
17 | /*设置离开的page不可点击,不可见*/
18 | page.setClickable(false);
19 | page.setAlpha(0);
20 | } else if (position <= 0) {
21 | page.setClickable(false);
22 | /*页面从左侧进入或者向左侧滑出的状态*/
23 | /*把旋转中心改为中间*/
24 | page.setAlpha(1);
25 | if (position <= -0.5)
26 | /*旋转到中间时该页page隐藏掉*/
27 | page.setAlpha(0);
28 | page.setPivotX(page.getWidth() / 2);
29 | page.setPivotY(page.getHeight() / 2);
30 |
31 |
32 | page.setTranslationX(position * -page.getWidth());
33 | page.setCameraDistance(10000);
34 | page.setRotationY(position * 180);
35 | } else if (position <= 1) {
36 | /*页面从右侧进入或者向右侧滑出的状态*/
37 | /*初始状态要是隐藏状态*/
38 | page.setAlpha(0);
39 | if (position <= 0.5)
40 | /*旋转到中间时该页page显示出来*/
41 | page.setAlpha(1);
42 | page.setPivotX(page.getWidth() / 2);
43 | page.setPivotY(page.getHeight() / 2);
44 | page.setTranslationX(position * -page.getWidth());
45 | page.setCameraDistance(10000);
46 | page.setRotationY(-180 - (1 - position) * 180);
47 | } else if (position >= 1) {
48 | /*页面已经在屏幕右侧且不可视*/
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/CardStackPaegTransformer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/21.
8 | */
9 |
10 | public class CardStackPaegTransformer implements ViewPager.PageTransformer {
11 | public void transformPage(View page, float position) {
12 | if (position <= -1) {
13 | /*页面已经在屏幕左侧且不可视*/
14 | } else if (position <= 0) {
15 | /*页面从左侧进入或者向左侧滑出的状态*/
16 | } else if (position < 1) {
17 | /*页面从右侧进入或者向右侧滑出的状态*/
18 | page.setAlpha((float) (1 - position * 0.1));
19 | page.setPivotX(page.getWidth() / 2f);
20 | page.setPivotY(page.getHeight() / 2f);
21 | page.setScaleX((float) Math.pow(0.9f, position)); /*0.9f为缩放系数*/
22 | page.setScaleY((float) Math.pow(0.9f, position));
23 | page.setTranslationX(position * -page.getWidth());
24 | page.setTranslationY(-position * 70);/*70每层card的Y轴间隔*/
25 |
26 | } else if (position >= 1) {
27 | /*页面已经在屏幕右侧且不可视*/
28 | page.setAlpha((float) (1 - position * 0.1));
29 | page.setPivotX(page.getWidth() / 2f);
30 | page.setPivotY(page.getHeight() / 2f);
31 | page.setScaleX((float) Math.pow(0.9f, position));
32 | page.setScaleY((float) Math.pow(0.9f, position));
33 | page.setTranslationX(position * -page.getWidth());
34 | page.setTranslationY(-position * 70);
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/CascadeZoomPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/24.
8 | */
9 |
10 | public class CascadeZoomPageTransformer implements ViewPager.PageTransformer {
11 | @Override
12 | public void transformPage(View page, float position) {
13 | if (position < -1) { /* [-Infinity,-1)*/
14 | /*页面已经在屏幕左侧且不可视*/
15 | } else if (position <= 0) { /* [-1,0]*/
16 | /*页面从左侧进入或者向左侧滑出的状态*/
17 | page.setAlpha(1 + position);
18 | } else if (position <= 1) {/* (0,1]*/
19 | /*页面从右侧进入或者向右侧滑出的状态*/
20 | page.setTranslationX(page.getWidth() * -position);
21 | page.setScaleX(1-position*0.5f);
22 | page.setScaleY(1-position*0.5f);
23 | page.setAlpha(1 - position);
24 | }else if (position >1){
25 | /*页面已经在屏幕右侧且不可视*/
26 |
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/CubesPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/21.
8 | */
9 |
10 | public class CubesPageTransformer implements ViewPager.PageTransformer {
11 | @Override
12 | public void transformPage(View page, float position) {
13 | if (position <=-1) { /* [-Infinity,-1)*/
14 | /*页面已经在屏幕左侧且不可视*/
15 | } else if (position <= 0) { /* [-1,0]*/
16 | /*页面从左侧进入或者向左侧滑出的状态*/
17 | page.setCameraDistance(100000);
18 | page.setPivotX(page.getMeasuredWidth());
19 | page.setPivotY(page.getMeasuredHeight()*0.5f);
20 | page.setRotationY(90*position);
21 | } else if (position <= 1) {/* (0,1]*/
22 | /*页面从右侧进入或者向右侧滑出的状态*/
23 | page.setCameraDistance(100000);
24 | page.setPivotX(0);
25 | page.setPivotY( page.getWidth()*(0.5f));
26 | page.setRotationY(90*position);
27 | }else if (position >1){
28 | /*页面已经在屏幕右侧且不可视*/
29 |
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/DepthCardTransformer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/21.
8 | * 这个要配和在ViewPager里设置android:clipChildren="false"
9 | * android:margin="xxdp"
10 | * 在ViewPager的外层里设置android:clipChildren="false"
11 | */
12 |
13 | public class DepthCardTransformer implements ViewPager.PageTransformer {
14 | @Override
15 | public void transformPage(View page, float position) {
16 | if (position < -1) { /* [-Infinity,-1)*/
17 | /*页面已经在屏幕左侧第一个*/
18 | page.setCameraDistance(10000);
19 | page.setPivotX(page.getWidth()/2);
20 | page.setPivotY(page.getWidth());
21 | page.setRotationY(20);
22 | } else if (position <= 0) { /* [-1,0]*/
23 | /*页面从左侧进入或者向左侧滑出的状态*/
24 | page.setCameraDistance(10000);
25 | page.setPivotX(page.getWidth()/2);
26 | page.setPivotY(page.getWidth());
27 | page.setRotationY(-20+(1-position)*20);
28 | } else if (position <= 1) {/* (0,1]*/
29 | /*页面从右侧进入或者向右侧滑出的状态*/
30 | page.setCameraDistance(10000);
31 | page.setPivotX(page.getWidth()/2);
32 | page.setPivotY(page.getWidth());
33 | page.setRotationY(-20+(1-position)*20);
34 | } else if (position<=2) {
35 | /*页面已经在屏幕右侧第一个*/
36 | page.setCameraDistance(10000);
37 | page.setPivotX(page.getWidth()/2);
38 | page.setPivotY(page.getWidth());
39 | page.setRotationY(-20);
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/FilpPageRotationPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/24.
8 | */
9 |
10 | public class FilpPageRotationPageTransformer implements ViewPager.PageTransformer {
11 | @Override
12 | public void transformPage(View page, float position) {
13 | if (position < -1) { /* [-Infinity,-1)*/
14 | /*页面已经在屏幕左侧且不可视*/
15 | } else if (position <= 0) { /* [-1,0]*/
16 | /*页面从左侧进入或者向左侧滑出的状态*/
17 | page.setCameraDistance(60000);
18 | page.setAlpha(1 + position);
19 | page.setTranslationX(page.getWidth() * -position);
20 | page.setPivotX(0);
21 | page.setRotationY(position * 90);
22 | } else if (position <= 1) {/* (0,1]*/
23 | /*页面从右侧进入或者向右侧滑出的状态*/
24 | page.setCameraDistance(60000);
25 | page.setTranslationX(page.getWidth() * -position);
26 | page.setPivotX(0);
27 | page.setRotationY(position * 90);
28 | page.setAlpha(1 - position);
29 | } else if (position > 1) {
30 | /*页面已经在屏幕右侧且不可视*/
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/Main2Activity.kt:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage
2 |
3 | import android.support.v7.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.view.View
6 | import android.widget.AdapterView
7 | import android.widget.TextView
8 | import kotlinx.android.synthetic.main.activity_main2.*
9 | import org.jetbrains.anko.startActivity
10 |
11 | class Main2Activity : AppCompatActivity(), AdapterView.OnItemClickListener {
12 | override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
13 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
14 | }
15 |
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | setContentView(R.layout.activity_main2)
19 | BookFlippageFadePageTransormer.setOnClickListener {
20 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.BookFlippageFadePageTransormer"))
21 | }
22 | CardFlipoverPageTransormer.setOnClickListener {
23 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.CardFlipoverPageTransormer"))
24 | }
25 | CardStackPaegTransformer.setOnClickListener {
26 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.CardStackPaegTransformer"))
27 | }
28 | CascadeZoomPageTransformer.setOnClickListener {
29 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.CascadeZoomPageTransformer"))
30 | }
31 | CubesPageTransformer.setOnClickListener {
32 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.CubesPageTransformer"))
33 | }
34 | DepthCardTransformer.setOnClickListener {
35 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.DepthCardTransformer"))
36 | }
37 | FilpPageRotationPageTransformer.setOnClickListener {
38 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.FilpPageRotationPageTransformer"))
39 | }
40 | TurntablePageTransformer.setOnClickListener {
41 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.TurntablePageTransformer"))
42 | }
43 | ZoominPagerTransFormer.setOnClickListener {
44 | startActivity(Pair("PageTransormer", "com.mran.cardviewpage.ZoominPagerTransFormer"))
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.support.v4.view.ViewPager;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.animation.Animation;
11 | import android.view.animation.Interpolator;
12 | import android.view.animation.ScaleAnimation;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | import static com.mran.cardviewpage.R.drawable.e;
20 | import static com.mran.cardviewpage.R.drawable.f;
21 |
22 | public class MainActivity extends AppCompatActivity {
23 |
24 | TextView mTextView;
25 | ViewPager mViewPager;
26 | int mCurrentPosition = 0;
27 | ViewPager.PageTransformer mPageTransformer;
28 | Animation mAnimation;
29 | List mImageViewList = new ArrayList<>();
30 | int[] mDrawable = {R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d, e, f, R.drawable.g, R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d, e, f, R.drawable.g};
31 | int[] mColor = {R.color.a, R.color.b, R.color.c, R.color.d, R.color.e, R.color.f, R.color.g, R.color.a, R.color.b, R.color.c, R.color.d, R.color.e, R.color.f, R.color.g};
32 | float mFactor = 0.5f;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_main);
38 |
39 | mTextView = (TextView) findViewById(R.id.textview);
40 | mViewPager = (ViewPager) findViewById(R.id.viewpager);
41 | mViewPager.setPageMargin(1);
42 | mViewPager.setOffscreenPageLimit(5);
43 | mAnimation = new ScaleAnimation(0.9f, 1.0f, 0.9f, 1.0f, 150, 450);
44 | mAnimation.setDuration(500);
45 | mAnimation.setFillAfter(true);
46 | mAnimation.setInterpolator(new Interpolator() {
47 | @Override
48 | public float getInterpolation(float input) {
49 | return (float) (Math.pow(2, -10 * input) * Math.sin((input - mFactor / 4) * (2 * Math.PI) / mFactor) + 0.9);
50 | }
51 | });
52 | for (int i = 0; i < mDrawable.length; i++) {
53 | ImageView imageView = new ImageView(getApplicationContext());
54 | imageView.setImageResource(mColor[i]);
55 | imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
56 | imageView.setScaleType(ImageView.ScaleType.FIT_XY);
57 | mImageViewList.add(imageView);
58 | }
59 | mViewPager.setAdapter(new PagerAdapter() {
60 | @Override
61 | public int getCount() {
62 | return mDrawable.length;
63 | }
64 |
65 | @Override
66 | public Object instantiateItem(ViewGroup container, int position) {
67 | ImageView imageView = mImageViewList.get(position);
68 | container.addView(imageView);
69 | return imageView;
70 | }
71 |
72 |
73 | @Override
74 | public void destroyItem(ViewGroup container, int position, Object object) {
75 | container.removeView((View) object);
76 | }
77 |
78 | @Override
79 | public boolean isViewFromObject(View view, Object object) {
80 | return view == object;
81 | }
82 | });
83 |
84 |
85 | // /*卡片绕中心旋转*/
86 | // mPageTransformer = new CardFlipoverPageTransormer();
87 | // /*书籍翻页渐隐*/
88 | // mPageTransformer = new BookFlippageFadePageTransormer();
89 | // /*立方体旋转*/
90 | // mPageTransformer = new CubesPageTransformer();
91 | // /* 转盘旋转*/
92 | // mPageTransformer = new TurntablePageTransformer();
93 | // /* 翻页旋转*/
94 | // mPageTransformer = new FilpPageRotationPageTransformer();
95 | // /*单层叠缩放*/
96 | // mPageTransformer = new CascadeZoomPageTransformer();
97 | // /*折叠向上*/
98 | // mPageTransformer = new DepthCardTransformer();
99 | // /*滑动缩放*/
100 | // mPageTransformer = new ZoominPagerTransFormer();
101 | //
102 | // /*卡片堆叠*/
103 | // mPageTransformer = new CardStackPaegTransformer();
104 | String clazzName = getIntent().getStringExtra("PageTransormer");
105 | try {
106 | Class c = Class.forName(clazzName);
107 | mPageTransformer = (ViewPager.PageTransformer) c.newInstance();
108 | } catch (ClassNotFoundException e1) {
109 | e1.printStackTrace();
110 | } catch (IllegalAccessException e1) {
111 | e1.printStackTrace();
112 | } catch (InstantiationException e1) {
113 | e1.printStackTrace();
114 | }
115 |
116 | mViewPager.setPageTransformer(true, mPageTransformer);
117 |
118 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
119 | @Override
120 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
121 | Log.d("MainActivity", "onPageScrolled: position" + position + " positionOffset" + positionOffset + " positionOffsetPixels" + positionOffsetPixels);
122 | }
123 |
124 | @Override
125 | public void onPageSelected(int position) {
126 | Log.d("MainActivity", "onPageSelected: position" + position);
127 | mImageViewList.get(mCurrentPosition).clearAnimation();/*//把上一个page的动画取消掉*/
128 | mCurrentPosition = position;/*更新当前的page位置*/
129 | mImageViewList.get(mCurrentPosition).startAnimation(mAnimation);/*开始动画*/
130 |
131 | }
132 |
133 | @Override
134 | public void onPageScrollStateChanged(int state) {
135 | Log.d("MainActivity", "onPageScrollStateChanged: state" + state);
136 |
137 | }
138 | });
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/TurntablePageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/24.
8 | */
9 |
10 | public class TurntablePageTransformer implements ViewPager.PageTransformer {
11 | @Override
12 | public void transformPage(View page, float position) {
13 | if (position < -1) { /* [-Infinity,-1)*/
14 | /*页面已经在屏幕左侧且不可视*/
15 | } else if (position <= 0) { /* [-1,0]*/
16 | /*页面从左侧进入或者向左侧滑出的状态*/
17 | page.setPivotX(page.getWidth() / 2);
18 | page.setPivotY(page.getHeight());
19 | page.setRotation(90*position);
20 | } else if (position <= 1) {/* (0,1]*/
21 | /*页面从右侧进入或者向右侧滑出的状态*/
22 | page.setPivotX(page.getWidth() / 2);
23 | page.setPivotY(page.getHeight());
24 | page.setRotation(90*position);
25 | } else if (position > 1) {
26 | /*页面已经在屏幕右侧且不可视*/
27 |
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mran/cardviewpage/ZoominPagerTransFormer.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by M on 2017/9/24.
8 | */
9 |
10 | public class ZoominPagerTransFormer implements ViewPager.PageTransformer {
11 | @Override
12 | public void transformPage(View page, float position) {
13 |
14 |
15 | if (position < -1) { /* [-Infinity,-1)*/
16 | /*页面已经在屏幕左侧且不可视*/
17 | page.setScaleX((float) (1 + position * 0.1));
18 | page.setScaleY((float) (1 + position * 0.1));
19 | } else if (position <= 0) { /* [-1,0]*/
20 | /*页面从左侧进入或者向左侧滑出的状态*/
21 |
22 | page.setScaleX((float) (1 + position * 0.1));
23 | page.setScaleY((float) (1 + position * 0.1));
24 | } else if (position <= 1) {/* (0,1]*/
25 | /*页面从右侧进入或者向右侧滑出的状态*/
26 | page.setScaleX((float) (1- position * 0.1));
27 | page.setScaleY((float) (1 - position * 0.1));
28 | } else if (position > 1) {
29 | /*页面已经在屏幕右侧且不可视*/
30 | page.setScaleX((float) (1- position * 0.1));
31 | page.setScaleY((float) (1 - position * 0.1));
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/drawable/a.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/drawable/b.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/drawable/c.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/drawable/d.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/e.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/drawable/e.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/f.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/drawable/f.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/g.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/drawable/g.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
23 |
28 |
29 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
57 |
58 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #ffb2c87c
6 | #fad000
7 | #7dfa00
8 | #00fabc
9 | #0068fa
10 | #0004fa
11 | #ab00fa
12 | #fa0053
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CardViewPage
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/mran/cardviewpage/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardviewpage;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.21'
5 |
6 | repositories {
7 | jcenter()
8 | google()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.3.2'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | google()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/cardpage/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/cardpage/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 19
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:25.2.0'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/cardpage/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 C:\Users\M\AppData\Local\Android\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/cardpage/src/androidTest/java/com/mran/cardpage/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardpage;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.mran.cardpage.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/cardpage/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/cardpage/src/main/java/com/mran/cardpage/CardItem.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardpage;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Created by M on 2017/9/17.
7 | */
8 |
9 | class CardItem {
10 | private View mView;
11 | public int mIndexInCards;//记录card在card堆中的位置,上层到下层依次是0-4;
12 | public int cardWidth;
13 | public int cardHeight;
14 | public int cardTop;
15 | public int cardLeft;
16 | public int cardRight;
17 | public int cardBottom;
18 | public int oldCardWidth;
19 | public int oldCardHeight;
20 | public int oldCardTop;
21 | public int oldCardLeft;
22 | public int oldCardRight;
23 | public int oldCardBottom;
24 | public int alpha;
25 |
26 | CardItem(View page, int index) {
27 | this.mView = page;
28 | this.mView.setTag(index);
29 | }
30 |
31 | public View getView() {
32 | return mView;
33 | }
34 |
35 | public void setView(View view) {
36 | mView = view;
37 | }
38 |
39 | public int getCardWidth() {
40 | return cardWidth;
41 | }
42 |
43 | public void setCardWidth(int cardWidth) {
44 | this.cardWidth = cardWidth;
45 | }
46 |
47 | public int getCardHeight() {
48 | return cardHeight;
49 | }
50 |
51 | public void setCardHeight(int cardHeight) {
52 | this.cardHeight = cardHeight;
53 | }
54 |
55 | public int getCardTop() {
56 | return cardTop;
57 | }
58 |
59 | public void setCardTop(int cardTop) {
60 | this.cardTop = cardTop;
61 | }
62 |
63 | public int getCardLeft() {
64 | return cardLeft;
65 | }
66 |
67 | public void setCardLeft(int cardLeft) {
68 | this.cardLeft = cardLeft;
69 | }
70 |
71 | public int getCardRight() {
72 | return cardRight;
73 | }
74 |
75 | public void setCardRight(int cardRight) {
76 | this.cardRight = cardRight;
77 | }
78 |
79 | public int getCardBottom() {
80 | return cardBottom;
81 | }
82 |
83 | public void setCardBottom(int cardBottom) {
84 | this.cardBottom = cardBottom;
85 | }
86 |
87 | public int getAlpha() {
88 | return alpha;
89 | }
90 |
91 | public void setAlpha(int alpha) {
92 | this.alpha = alpha;
93 | }
94 |
95 | public void update() {
96 | oldCardWidth = cardWidth;
97 | oldCardHeight = cardHeight;
98 | oldCardTop = cardTop;
99 | oldCardLeft = cardLeft;
100 | oldCardRight = cardRight;
101 | oldCardBottom = cardBottom;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/cardpage/src/main/java/com/mran/cardpage/CardPage.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardpage;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.os.Build;
7 | import android.support.annotation.RequiresApi;
8 | import android.support.v4.widget.ViewDragHelper;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | import static android.support.v4.widget.ViewDragHelper.STATE_DRAGGING;
19 | import static android.support.v4.widget.ViewDragHelper.STATE_IDLE;
20 |
21 | /**
22 | * Created by M on 2017/9/15.
23 | */
24 |
25 | public class CardPage extends ViewGroup {
26 | private final static int CARDMAXSIZE = 5;
27 | private final static int CARD_SPACING = 30;
28 | private int width;//整个宽度
29 | private int height;//整个高度
30 | private int middleWidthPostion;//中间位置
31 | private int percentage10;//百分之10的宽度
32 | private float suofangxish = 0.9f;
33 | private int jianju = 100;
34 | private Paint mPaint;
35 | private Context mContext;
36 | private AttributeSet mAttributeSet;
37 | private int[] cardWidth = {0, 0, 0, 0, 0};//card的宽度
38 | private int[] cardHeight = {0, 0, 0, 0, 0};//card的高度
39 | private int[] cardLeftPostion = {0, 0, 0, 0, 0};//card左边坐标
40 | private int[] cardTopPostion = {0, 0, 0, 0, 0};//card上部坐标
41 | private int[] cardColor = {0xc8ffeff4, 0xd8ffeff4, 0xe8ffeff4, 0xf8ffeff4};
42 | private int pageSize = 0;
43 | private int pageInTop = 0;
44 | private int pageInBottom = 0;
45 | private int pageLast = 0;
46 | private float mMoveDetal = 0;//全局移动变量
47 | boolean changedSuccess = false;//用来判断是否移动成功
48 | boolean forcelayout = false;
49 | private int topPosition = jianju * 4;
50 | private int leftPsotion;
51 | float firstTouchPosition = 0;
52 | float alpha;
53 | private int dragState = -1;
54 | private ViewDragHelper mViewDragHelper;
55 | private List mViewList = new ArrayList<>();
56 |
57 | public CardPage(Context context, AttributeSet attrs) {
58 | super(context, attrs);
59 | init(context, attrs);
60 | }
61 |
62 | public CardPage(Context context, AttributeSet attrs, int defStyleAttr) {
63 | super(context, attrs, defStyleAttr);
64 | init(context, attrs);
65 | }
66 |
67 | private void init(Context context, AttributeSet attributeSet) {
68 | this.mContext = context;
69 | this.mAttributeSet = attributeSet;
70 | mPaint = new Paint();
71 | setWillNotDraw(false);
72 | mViewDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelper.Callback() {
73 | @Override
74 | public boolean tryCaptureView(View child, int pointerId) {
75 | return child == getChildAt(getChildCount() - 1);/*只有处于最顶层的view才可以被拖动,否则在顶层拖动未结束时拖动其他view,顶层view会被释放*/
76 | }
77 |
78 |
79 | @Override
80 | public void onEdgeDragStarted(int edgeFlags, int pointerId) {
81 |
82 | super.onEdgeDragStarted(edgeFlags, pointerId);
83 | }
84 |
85 | @Override
86 | public int clampViewPositionHorizontal(View child, int left, int dx) {
87 |
88 | return left;
89 | }
90 |
91 | @Override
92 | public int clampViewPositionVertical(View child, int top, int dy) {
93 | return jianju * 4;
94 | }
95 |
96 | @Override
97 | public void onViewDragStateChanged(int state) {
98 | dragState = state;
99 | switch (state) {
100 | case STATE_DRAGGING:
101 | break;
102 | case STATE_IDLE:
103 | forcelayout = false;
104 | xx = 0;
105 | cx = 0;
106 | if (changedSuccess) {
107 | // removeView(getChildAt(getChildCount() - 1));
108 | removeViewInLayout(getChildAt(getChildCount() - 1));
109 | if (pageInBottom < pageSize)
110 | addView(mViewList.get(pageInBottom++).getView(), 0);
111 | }
112 | break;
113 | }
114 |
115 | super.onViewDragStateChanged(state);
116 | }
117 |
118 | int xx = 0;
119 | float cx = 0;
120 |
121 | @Override
122 | public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
123 |
124 | alpha = (float) ((float) Math.abs(left - leftPsotion) / (0.95 * width));//更新即将出来的Card的透明度
125 | mMoveDetal = (float) ((float) Math.abs(left - leftPsotion) / (0.95 * width));
126 | Log.d("CardPage", "onViewPositionChanged: left" + left + "mMoveDeta" + mMoveDetal + "leftPsotion" + leftPsotion + "width" + width);
127 | forcelayout = true;
128 | xx += dx;
129 | cx += (int) (dx * jianju / (0.90 * width));
130 | int size=getChildCount();
131 | int addx=0;
132 | if (size
2 | CardPage
3 |
4 |
--------------------------------------------------------------------------------
/cardpage/src/test/java/com/mran/cardpage/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.mran.cardpage;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mran/ViewPageTransformer/bea5c7241e4907e504d2aa5233221128741a21e0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Sep 10 23:02:05 CST 2017
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-5.0-milestone-1-all.zip
--------------------------------------------------------------------------------
/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------