add flutter
@@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
# FragmentAnimations
|
||||
|
||||
[](http://developer.android.com/index.html)
|
||||
<img src="https://img.shields.io/badge/license-Apache 2.0-green.svg?style=flat">
|
||||
[](https://android-arsenal.com/api?level=4)
|
||||
[](https://android-arsenal.com/details/1/3526)
|
||||
|
||||
Animation examples for `support.v4.Fragment` transition.
|
||||
|
||||
These animations do not depends on any external libraries.
|
||||
|
||||
[<img src="https://dply.me/h7azvd/button/large" alt="Try it on your device via DeployGate">](https://dply.me/h7azvd)
|
||||
|
||||
## Usage Example
|
||||
|
||||
In your `Fragment`, just code like this.
|
||||
|
||||
```java
|
||||
@Override
|
||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
||||
return CubeAnimation.create(CubeAnimation.UP, enter, DURATION);
|
||||
}
|
||||
```
|
||||
|
||||
See more example in [ExampleFragment.java](https://github.com/kakajika/FragmentAnimations/blob/master/app/src/main/java/com/labo/kaji/fragmentanimations/example/ExampleFragment.java)
|
||||
|
||||
## Contents
|
||||
|
||||
### Cube Animation
|
||||
|
||||
[CubeAnimation.java](https://github.com/kakajika/FragmentAnimations/blob/master/fragmentanimations/src/main/java/com/labo/kaji/fragmentanimations/CubeAnimation.java)
|
||||
|
||||

|
||||
|
||||
### Flip Animation
|
||||
|
||||
[FlipAnimation.java](https://github.com/kakajika/FragmentAnimations/blob/master/fragmentanimations/src/main/java/com/labo/kaji/fragmentanimations/FlipAnimation.java)
|
||||
|
||||

|
||||
|
||||
### Push/Pull Animation
|
||||
|
||||
[PushPullAnimation.java](https://github.com/kakajika/FragmentAnimations/blob/master/fragmentanimations/src/main/java/com/labo/kaji/fragmentanimations/PushPullAnimation.java)
|
||||
|
||||

|
||||
|
||||
### Sides Animation
|
||||
|
||||
[SidesAnimation.java](https://github.com/kakajika/FragmentAnimations/blob/master/fragmentanimations/src/main/java/com/labo/kaji/fragmentanimations/SidesAnimation.java)
|
||||
|
||||
### Move Animation
|
||||
|
||||
[MoveAnimation.java](https://github.com/kakajika/FragmentAnimations/blob/master/fragmentanimations/src/main/java/com/labo/kaji/fragmentanimations/MoveAnimation.java)
|
||||
|
||||

|
||||
|
||||
## Combination
|
||||
|
||||
You can use above Animations with another one.
|
||||
|
||||
```java
|
||||
@Override
|
||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
||||
if (enter) {
|
||||
return MoveAnimation.create(MoveAnimation.UP, enter, DURATION);
|
||||
} else {
|
||||
return CubeAnimation.create(CubeAnimation.UP, enter, DURATION);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cube/Move Animation
|
||||
|
||||

|
||||
|
||||
### Move/Cube Animation
|
||||
|
||||

|
||||
|
||||
### Push/Move Animation
|
||||
|
||||

|
||||
|
||||
### Move/Pull Animation
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
This library is available in jcenter.
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
compile 'com.labo.kaji:fragmentanimations:0.1.1'
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2015 kakajika
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,32 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'deploygate'
|
||||
|
||||
android {
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion "24.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.labo.kaji.fragmentanimations"
|
||||
minSdkVersion 7
|
||||
targetSdkVersion 24
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile project(':fragmentanimations')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:24.1.1'
|
||||
compile 'com.android.support:design:24.1.1'
|
||||
compile 'com.android.support:support-v4:24.1.1'
|
||||
compile 'com.jakewharton:butterknife:7.0.1'
|
||||
compile 'com.deploygate:sdk:3.1'
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/kakajika/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="com.labo.kaji.fragmentanimations.example"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.labo.kaji.fragmentanimations.example;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.deploygate.sdk.DeployGate;
|
||||
|
||||
/**
|
||||
* @author kakajika
|
||||
* @since 2016/04/20
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
DeployGate.install(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
package com.labo.kaji.fragmentanimations.example;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.labo.kaji.fragmentanimations.CubeAnimation;
|
||||
import com.labo.kaji.fragmentanimations.FlipAnimation;
|
||||
import com.labo.kaji.fragmentanimations.MoveAnimation;
|
||||
import com.labo.kaji.fragmentanimations.PushPullAnimation;
|
||||
import com.labo.kaji.fragmentanimations.SidesAnimation;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* @author kakajika
|
||||
* @since 2015/11/27
|
||||
*/
|
||||
public class ExampleFragment extends Fragment {
|
||||
|
||||
@IntDef({NONE, MOVE, CUBE, FLIP, PUSHPULL, SIDES, CUBEMOVE, MOVECUBE, PUSHMOVE, MOVEPULL, FLIPMOVE, MOVEFLIP, FLIPCUBE, CUBEFLIP})
|
||||
public @interface AnimationStyle {}
|
||||
public static final int NONE = 0;
|
||||
public static final int MOVE = 1;
|
||||
public static final int CUBE = 2;
|
||||
public static final int FLIP = 3;
|
||||
public static final int PUSHPULL = 4;
|
||||
public static final int SIDES = 5;
|
||||
public static final int CUBEMOVE = 6;
|
||||
public static final int MOVECUBE = 7;
|
||||
public static final int PUSHMOVE = 8;
|
||||
public static final int MOVEPULL = 9;
|
||||
public static final int FLIPMOVE = 10;
|
||||
public static final int MOVEFLIP = 11;
|
||||
public static final int FLIPCUBE = 12;
|
||||
public static final int CUBEFLIP = 13;
|
||||
|
||||
@IntDef({NODIR, UP, DOWN, LEFT, RIGHT})
|
||||
public @interface AnimationDirection {}
|
||||
public static final int NODIR = 0;
|
||||
public static final int UP = 1;
|
||||
public static final int DOWN = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
|
||||
private static final long DURATION = 500;
|
||||
|
||||
@AnimationStyle
|
||||
private static int sAnimationStyle = CUBE;
|
||||
|
||||
@Bind(R.id.textAnimationStyle)
|
||||
TextView mTextAnimationStyle;
|
||||
|
||||
public static ExampleFragment newInstance(@AnimationDirection int direction) {
|
||||
ExampleFragment f = new ExampleFragment();
|
||||
f.setArguments(new Bundle());
|
||||
f.getArguments().putInt("direction", direction);
|
||||
return f;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.content_anim, container, false);
|
||||
int color = Color.rgb((int) Math.floor(Math.random() * 128) + 64,
|
||||
(int) Math.floor(Math.random() * 128) + 64,
|
||||
(int) Math.floor(Math.random() * 128) + 64);
|
||||
view.setBackgroundColor(color);
|
||||
ButterKnife.bind(this, view);
|
||||
setAnimationStyleText();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
|
||||
switch (sAnimationStyle) {
|
||||
case MOVE:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return MoveAnimation.create(MoveAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return MoveAnimation.create(MoveAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return MoveAnimation.create(MoveAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return MoveAnimation.create(MoveAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case CUBE:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return CubeAnimation.create(CubeAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return CubeAnimation.create(CubeAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return CubeAnimation.create(CubeAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return CubeAnimation.create(CubeAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case FLIP:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return FlipAnimation.create(FlipAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return FlipAnimation.create(FlipAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return FlipAnimation.create(FlipAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return FlipAnimation.create(FlipAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case PUSHPULL:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return PushPullAnimation.create(PushPullAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return PushPullAnimation.create(PushPullAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return PushPullAnimation.create(PushPullAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return PushPullAnimation.create(PushPullAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case SIDES:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return SidesAnimation.create(SidesAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return SidesAnimation.create(SidesAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return SidesAnimation.create(SidesAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return SidesAnimation.create(SidesAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case CUBEMOVE:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.UP, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
CubeAnimation.create(CubeAnimation.UP, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case DOWN:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.DOWN, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
CubeAnimation.create(CubeAnimation.DOWN, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case LEFT:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.LEFT, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
CubeAnimation.create(CubeAnimation.LEFT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case RIGHT:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.RIGHT, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
CubeAnimation.create(CubeAnimation.RIGHT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
}
|
||||
break;
|
||||
case MOVECUBE:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.UP, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
MoveAnimation.create(MoveAnimation.UP, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case DOWN:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.DOWN, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
MoveAnimation.create(MoveAnimation.DOWN, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case LEFT:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.LEFT, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
MoveAnimation.create(MoveAnimation.LEFT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case RIGHT:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.RIGHT, enter, DURATION).fading(0.3f, 1.0f) :
|
||||
MoveAnimation.create(MoveAnimation.RIGHT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
}
|
||||
break;
|
||||
case PUSHMOVE:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.UP, enter, DURATION) :
|
||||
PushPullAnimation.create(PushPullAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.DOWN, enter, DURATION) :
|
||||
PushPullAnimation.create(PushPullAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.LEFT, enter, DURATION) :
|
||||
PushPullAnimation.create(PushPullAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.RIGHT, enter, DURATION) :
|
||||
PushPullAnimation.create(PushPullAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case MOVEPULL:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? PushPullAnimation.create(PushPullAnimation.UP, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.UP, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case DOWN:
|
||||
return enter ? PushPullAnimation.create(PushPullAnimation.DOWN, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.DOWN, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case LEFT:
|
||||
return enter ? PushPullAnimation.create(PushPullAnimation.LEFT, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.LEFT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case RIGHT:
|
||||
return enter ? PushPullAnimation.create(PushPullAnimation.RIGHT, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.RIGHT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
}
|
||||
break;
|
||||
case FLIPMOVE:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.UP, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.DOWN, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.LEFT, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return enter ? MoveAnimation.create(MoveAnimation.RIGHT, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case MOVEFLIP:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.UP, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.UP, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case DOWN:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.DOWN, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.DOWN, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case LEFT:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.LEFT, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.LEFT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case RIGHT:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.RIGHT, enter, DURATION) :
|
||||
MoveAnimation.create(MoveAnimation.RIGHT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
}
|
||||
break;
|
||||
case FLIPCUBE:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.UP, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.UP, enter, DURATION);
|
||||
case DOWN:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.DOWN, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.DOWN, enter, DURATION);
|
||||
case LEFT:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.LEFT, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.LEFT, enter, DURATION);
|
||||
case RIGHT:
|
||||
return enter ? CubeAnimation.create(CubeAnimation.RIGHT, enter, DURATION) :
|
||||
FlipAnimation.create(FlipAnimation.RIGHT, enter, DURATION);
|
||||
}
|
||||
break;
|
||||
case CUBEFLIP:
|
||||
switch (getArguments().getInt("direction")) {
|
||||
case UP:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.UP, enter, DURATION) :
|
||||
CubeAnimation.create(CubeAnimation.UP, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case DOWN:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.DOWN, enter, DURATION) :
|
||||
CubeAnimation.create(CubeAnimation.DOWN, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case LEFT:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.LEFT, enter, DURATION) :
|
||||
CubeAnimation.create(CubeAnimation.LEFT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
case RIGHT:
|
||||
return enter ? FlipAnimation.create(FlipAnimation.RIGHT, enter, DURATION) :
|
||||
CubeAnimation.create(CubeAnimation.RIGHT, enter, DURATION).fading(1.0f, 0.3f);
|
||||
}
|
||||
break;
|
||||
case NONE:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@OnClick(R.id.buttonUp)
|
||||
void onButtonUp() {
|
||||
getArguments().putInt("direction", UP);
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.layout_main, ExampleFragment.newInstance(UP));
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@OnClick(R.id.buttonDown)
|
||||
void onButtonDown() {
|
||||
getArguments().putInt("direction", DOWN);
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.layout_main, ExampleFragment.newInstance(DOWN));
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@OnClick(R.id.buttonLeft)
|
||||
void onButtonLeft() {
|
||||
getArguments().putInt("direction", LEFT);
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.layout_main, ExampleFragment.newInstance(LEFT));
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@OnClick(R.id.buttonRight)
|
||||
void onButtonRight() {
|
||||
getArguments().putInt("direction", RIGHT);
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.layout_main, ExampleFragment.newInstance(RIGHT));
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@OnClick(R.id.textAnimationStyle)
|
||||
public void switchAnimationStyle(View view) {
|
||||
@AnimationStyle int[] styles;
|
||||
styles = new int[]{MOVE, CUBE, FLIP, PUSHPULL, SIDES, CUBEMOVE, MOVECUBE, PUSHMOVE, MOVEPULL, FLIPMOVE, MOVEFLIP, FLIPCUBE, CUBEFLIP};
|
||||
for (int i = 0; i<styles.length-1; ++i) {
|
||||
if (styles[i] == sAnimationStyle) {
|
||||
setAnimationStyle(styles[i+1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setAnimationStyle(MOVE);
|
||||
}
|
||||
|
||||
public void setAnimationStyle(@AnimationStyle int style) {
|
||||
if (sAnimationStyle != style) {
|
||||
sAnimationStyle = style;
|
||||
setAnimationStyleText();
|
||||
Snackbar.make(getView(), "Animation Style is Changed", Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void setAnimationStyleText() {
|
||||
switch (sAnimationStyle) {
|
||||
case NONE:
|
||||
mTextAnimationStyle.setText("None");
|
||||
break;
|
||||
case MOVE:
|
||||
mTextAnimationStyle.setText("Move");
|
||||
break;
|
||||
case CUBE:
|
||||
mTextAnimationStyle.setText("Cube");
|
||||
break;
|
||||
case FLIP:
|
||||
mTextAnimationStyle.setText("Flip");
|
||||
break;
|
||||
case PUSHPULL:
|
||||
mTextAnimationStyle.setText("Push/Pull");
|
||||
break;
|
||||
case SIDES:
|
||||
mTextAnimationStyle.setText("Sides");
|
||||
break;
|
||||
case CUBEMOVE:
|
||||
mTextAnimationStyle.setText("Cube/Move");
|
||||
break;
|
||||
case MOVECUBE:
|
||||
mTextAnimationStyle.setText("Move/Cube");
|
||||
break;
|
||||
case PUSHMOVE:
|
||||
mTextAnimationStyle.setText("Push/Move");
|
||||
break;
|
||||
case MOVEPULL:
|
||||
mTextAnimationStyle.setText("Move/Pull");
|
||||
break;
|
||||
case FLIPMOVE:
|
||||
mTextAnimationStyle.setText("Flip/Move");
|
||||
break;
|
||||
case MOVEFLIP:
|
||||
mTextAnimationStyle.setText("Move/Flip");
|
||||
break;
|
||||
case FLIPCUBE:
|
||||
mTextAnimationStyle.setText("Flip/Cube");
|
||||
break;
|
||||
case CUBEFLIP:
|
||||
mTextAnimationStyle.setText("Cube/Flip");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.labo.kaji.fragmentanimations.example;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.layout_main, ExampleFragment.newInstance(ExampleFragment.NODIR));
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
ExampleFragment f = (ExampleFragment)getSupportFragmentManager().findFragmentById(R.id.layout_main);
|
||||
switch (id) {
|
||||
case R.id.style_move:
|
||||
f.setAnimationStyle(ExampleFragment.MOVE);
|
||||
return true;
|
||||
case R.id.style_cube:
|
||||
f.setAnimationStyle(ExampleFragment.CUBE);
|
||||
return true;
|
||||
case R.id.style_flip:
|
||||
f.setAnimationStyle(ExampleFragment.FLIP);
|
||||
return true;
|
||||
case R.id.style_pushpull:
|
||||
f.setAnimationStyle(ExampleFragment.PUSHPULL);
|
||||
return true;
|
||||
case R.id.style_sides:
|
||||
f.setAnimationStyle(ExampleFragment.SIDES);
|
||||
return true;
|
||||
case R.id.style_cubemove:
|
||||
f.setAnimationStyle(ExampleFragment.CUBEMOVE);
|
||||
return true;
|
||||
case R.id.style_movecube:
|
||||
f.setAnimationStyle(ExampleFragment.MOVECUBE);
|
||||
return true;
|
||||
case R.id.style_pushmove:
|
||||
f.setAnimationStyle(ExampleFragment.PUSHMOVE);
|
||||
return true;
|
||||
case R.id.style_movepull:
|
||||
f.setAnimationStyle(ExampleFragment.MOVEPULL);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 301 B |
|
After Width: | Height: | Size: 366 B |
|
After Width: | Height: | Size: 361 B |
|
After Width: | Height: | Size: 326 B |
|
After Width: | Height: | Size: 346 B |
|
After Width: | Height: | Size: 328 B |
|
After Width: | Height: | Size: 504 B |
|
After Width: | Height: | Size: 480 B |
|
After Width: | Height: | Size: 435 B |
|
After Width: | Height: | Size: 484 B |
|
After Width: | Height: | Size: 520 B |
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 800 B |
|
After Width: | Height: | Size: 716 B |
|
After Width: | Height: | Size: 746 B |
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textAnimationStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="8dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textAppearance="@android:style/TextAppearance.Large"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/buttonLeft"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center"
|
||||
android:src="@drawable/ic_left"
|
||||
android:padding="8dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/buttonRight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right|center"
|
||||
android:src="@drawable/ic_right"
|
||||
android:padding="8dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/buttonUp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|center"
|
||||
android:src="@drawable/ic_up"
|
||||
android:padding="8dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/buttonDown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:src="@drawable/ic_down"
|
||||
android:padding="8dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:background="#444"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".MainActivity"
|
||||
tools:showIn="@layout/activity_main">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layout_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="32dp"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,41 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".example.MainActivity">
|
||||
<item
|
||||
android:id="@+id/style_move"
|
||||
android:title="Move"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_cube"
|
||||
android:title="Cube"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_flip"
|
||||
android:title="Flip"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_pushpull"
|
||||
android:title="Push/Pull"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_sides"
|
||||
android:title="Sides"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_cubemove"
|
||||
android:title="Cube/Move"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_movecube"
|
||||
android:title="Move/Cube"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_pushmove"
|
||||
android:title="Push/Move"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/style_movepull"
|
||||
android:title="Move/Pull"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,9 @@
|
||||
<resources>>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">FragmentAnimations</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,20 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* To work on unit tests, switch the Test Artifact in the Build Variants view.
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.2'
|
||||
classpath 'com.novoda:bintray-release:0.3.4'
|
||||
classpath 'com.deploygate:gradle:1.0.4'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,25 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
namespace 'com.labo.kaji.fragmentanimations'
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode 1
|
||||
versionName "0.1.1"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.annotation:annotation:1.7.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/kakajika/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* 3D Cube Animation
|
||||
* @author kakajika
|
||||
* @since 2015/11/28
|
||||
*/
|
||||
public class CubeAnimation extends ViewPropertyAnimation {
|
||||
|
||||
@IntDef({UP, DOWN, LEFT, RIGHT})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface Direction {}
|
||||
public static final int UP = 1;
|
||||
public static final int DOWN = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
|
||||
protected final @Direction int mDirection;
|
||||
protected final boolean mEnter;
|
||||
|
||||
/**
|
||||
* Create new Animation.
|
||||
* @param direction Direction of animation
|
||||
* @param enter true for Enter / false for Exit
|
||||
* @param duration Duration of Animation
|
||||
* @return
|
||||
*/
|
||||
public static @NonNull CubeAnimation create(@Direction int direction, boolean enter, long duration) {
|
||||
switch (direction) {
|
||||
case UP:
|
||||
case DOWN:
|
||||
return new VerticalCubeAnimation(direction, enter, duration);
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
default:
|
||||
return new HorizontalCubeAnimation(direction, enter, duration);
|
||||
}
|
||||
}
|
||||
|
||||
private CubeAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
mDirection = direction;
|
||||
mEnter = enter;
|
||||
setDuration(duration);
|
||||
}
|
||||
|
||||
private static class VerticalCubeAnimation extends CubeAnimation {
|
||||
|
||||
private VerticalCubeAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = width * 0.5f;
|
||||
mPivotY = (mEnter == (mDirection == UP)) ? 0.0f : height;
|
||||
mCameraZ = -height * 0.015f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == DOWN) value *= -1.0f;
|
||||
mRotationX = value * 90.0f;
|
||||
mTranslationY = -value * mHeight;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class HorizontalCubeAnimation extends CubeAnimation {
|
||||
|
||||
private HorizontalCubeAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = (mEnter == (mDirection == LEFT)) ? 0.0f : width;
|
||||
mPivotY = height * 0.5f;
|
||||
mCameraZ = -width * 0.015f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == RIGHT) value *= -1.0f;
|
||||
mRotationY = -value * 90.0f;
|
||||
mTranslationX = -value * mWidth;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* 3D Flip Animation
|
||||
* @author kakajika
|
||||
* @since 2015/11/28
|
||||
*/
|
||||
public class FlipAnimation extends ViewPropertyAnimation {
|
||||
|
||||
@IntDef({UP, DOWN, LEFT, RIGHT})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface Direction {}
|
||||
public static final int UP = 1;
|
||||
public static final int DOWN = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
|
||||
protected final @Direction int mDirection;
|
||||
protected final boolean mEnter;
|
||||
|
||||
/**
|
||||
* Create new Animation.
|
||||
* @param direction Direction of animation
|
||||
* @param enter true for Enter / false for Exit
|
||||
* @param duration Duration of Animation
|
||||
* @return
|
||||
*/
|
||||
public static @NonNull FlipAnimation create(@Direction int direction, boolean enter, long duration) {
|
||||
switch (direction) {
|
||||
case UP:
|
||||
case DOWN:
|
||||
return new VerticalFlipAnimation(direction, enter, duration);
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
default:
|
||||
return new HorizontalFlipAnimation(direction, enter, duration);
|
||||
}
|
||||
}
|
||||
|
||||
private FlipAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
mDirection = direction;
|
||||
mEnter = enter;
|
||||
setDuration(duration);
|
||||
}
|
||||
|
||||
private static class VerticalFlipAnimation extends FlipAnimation {
|
||||
|
||||
public VerticalFlipAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = width * 0.5f;
|
||||
mPivotY = (mEnter == (mDirection == UP)) ? 0.0f : height;
|
||||
mCameraZ = -height * 0.015f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == DOWN) value *= -1.0f;
|
||||
mRotationX = value * 180.0f;
|
||||
mTranslationY = -value * mHeight;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
|
||||
// Hide entering/exiting view before/after half point.
|
||||
if (mEnter) {
|
||||
mAlpha = interpolatedTime <= 0.5f ? 0.0f : 1.0f;
|
||||
} else {
|
||||
mAlpha = interpolatedTime <= 0.5f ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class HorizontalFlipAnimation extends FlipAnimation {
|
||||
|
||||
public HorizontalFlipAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = (mEnter == (mDirection == LEFT)) ? 0.0f : width;
|
||||
mPivotY = height * 0.5f;
|
||||
mCameraZ = -width * 0.015f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == RIGHT) value *= -1.0f;
|
||||
mRotationY = -value * 180.0f;
|
||||
mTranslationX = -value * mWidth;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
|
||||
// Hide entering/exiting view before/after half point.
|
||||
if (mEnter) {
|
||||
mAlpha = interpolatedTime <= 0.5f ? 0.0f : 1.0f;
|
||||
} else {
|
||||
mAlpha = interpolatedTime <= 0.5f ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Move Animation
|
||||
* @author kakajika
|
||||
* @since 2015/11/28
|
||||
*/
|
||||
public class MoveAnimation extends ViewPropertyAnimation {
|
||||
|
||||
@IntDef({UP, DOWN, LEFT, RIGHT})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface Direction {}
|
||||
public static final int UP = 1;
|
||||
public static final int DOWN = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
|
||||
protected final @Direction int mDirection;
|
||||
protected final boolean mEnter;
|
||||
|
||||
/**
|
||||
* Create new Animation.
|
||||
* @param direction Direction of animation
|
||||
* @param enter true for Enter / false for Exit
|
||||
* @param duration Duration of Animation
|
||||
* @return
|
||||
*/
|
||||
public static @NonNull MoveAnimation create(@Direction int direction, boolean enter, long duration) {
|
||||
switch (direction) {
|
||||
case UP:
|
||||
case DOWN:
|
||||
return new VerticalMoveAnimation(direction, enter, duration);
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
default:
|
||||
return new HorizontalMoveAnimation(direction, enter, duration);
|
||||
}
|
||||
}
|
||||
|
||||
private MoveAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
mDirection = direction;
|
||||
mEnter = enter;
|
||||
setDuration(duration);
|
||||
}
|
||||
|
||||
private static class VerticalMoveAnimation extends MoveAnimation {
|
||||
|
||||
private VerticalMoveAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == DOWN) value *= -1.0f;
|
||||
mTranslationY = -value * mHeight;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class HorizontalMoveAnimation extends MoveAnimation {
|
||||
|
||||
private HorizontalMoveAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == RIGHT) value *= -1.0f;
|
||||
mTranslationX = -value * mWidth;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* 3D Push/Pull Animation
|
||||
* @author kakajika
|
||||
* @since 2015/11/28
|
||||
*/
|
||||
public class PushPullAnimation extends ViewPropertyAnimation {
|
||||
|
||||
@IntDef({UP, DOWN, LEFT, RIGHT})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface Direction {}
|
||||
public static final int UP = 1;
|
||||
public static final int DOWN = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
|
||||
protected final @Direction int mDirection;
|
||||
protected final boolean mEnter;
|
||||
|
||||
/**
|
||||
* Create new Animation.
|
||||
* @param direction Direction of animation
|
||||
* @param enter true for Enter / false for Exit
|
||||
* @param duration Duration of Animation
|
||||
* @return
|
||||
*/
|
||||
public static @NonNull PushPullAnimation create(@Direction int direction, boolean enter, long duration) {
|
||||
switch (direction) {
|
||||
case UP:
|
||||
case DOWN:
|
||||
return new VerticalPushPullAnimation(direction, enter, duration);
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
default:
|
||||
return new HorizontalPushPullAnimation(direction, enter, duration);
|
||||
}
|
||||
}
|
||||
|
||||
private PushPullAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
mDirection = direction;
|
||||
mEnter = enter;
|
||||
setDuration(duration);
|
||||
}
|
||||
|
||||
private static class VerticalPushPullAnimation extends PushPullAnimation {
|
||||
|
||||
private VerticalPushPullAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = width * 0.5f;
|
||||
mPivotY = (mEnter == (mDirection == DOWN)) ? 0.0f : height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == UP) value *= -1.0f;
|
||||
mRotationX = value * 90.0f;
|
||||
mAlpha = mEnter ? interpolatedTime : (1.0f - interpolatedTime);
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class HorizontalPushPullAnimation extends PushPullAnimation {
|
||||
|
||||
private HorizontalPushPullAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = (mEnter == (mDirection == RIGHT)) ? 0.0f : width;
|
||||
mPivotY = height * 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == LEFT) value *= -1.0f;
|
||||
mRotationY = -value * 90.0f;
|
||||
mAlpha = mEnter ? interpolatedTime : (1.0f - interpolatedTime);
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* 3D Cube Animation
|
||||
* @author kakajika
|
||||
* @since 2015/11/28
|
||||
*/
|
||||
public class SidesAnimation extends ViewPropertyAnimation {
|
||||
|
||||
@IntDef({UP, DOWN, LEFT, RIGHT})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface Direction {}
|
||||
public static final int UP = 1;
|
||||
public static final int DOWN = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
|
||||
protected final @Direction int mDirection;
|
||||
protected final boolean mEnter;
|
||||
|
||||
/**
|
||||
* Create new Animation.
|
||||
* @param direction Direction of animation
|
||||
* @param enter true for Enter / false for Exit
|
||||
* @param duration Duration of Animation
|
||||
* @return
|
||||
*/
|
||||
public static @NonNull SidesAnimation create(@Direction int direction, boolean enter, long duration) {
|
||||
switch (direction) {
|
||||
case UP:
|
||||
case DOWN:
|
||||
return new VerticalCubeAnimation(direction, enter, duration);
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
default:
|
||||
return new HorizontalCubeAnimation(direction, enter, duration);
|
||||
}
|
||||
}
|
||||
|
||||
private SidesAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
mDirection = direction;
|
||||
mEnter = enter;
|
||||
setDuration(duration);
|
||||
setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
}
|
||||
|
||||
private static class VerticalCubeAnimation extends SidesAnimation {
|
||||
|
||||
private VerticalCubeAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = width * 0.5f;
|
||||
mPivotY = (mEnter == (mDirection == DOWN)) ? 0.0f : height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == UP) value *= -1.0f;
|
||||
mRotationX = value * 90.0f;
|
||||
mAlpha = mEnter ? interpolatedTime : (1.0f - interpolatedTime);
|
||||
mTranslationZ = (1.0f - mAlpha) * mWidth;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class HorizontalCubeAnimation extends SidesAnimation {
|
||||
|
||||
private HorizontalCubeAnimation(@Direction int direction, boolean enter, long duration) {
|
||||
super(direction, enter, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mPivotX = (mEnter == (mDirection == RIGHT)) ? 0.0f : width;
|
||||
mPivotY = height * 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
float value = mEnter ? (interpolatedTime - 1.0f) : interpolatedTime;
|
||||
if (mDirection == LEFT) value *= -1.0f;
|
||||
mRotationY = -value * 90.0f;
|
||||
mAlpha = mEnter ? interpolatedTime : (1.0f - interpolatedTime);
|
||||
mTranslationZ = (1.0f - mAlpha) * mHeight;
|
||||
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
applyTransformation(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import android.graphics.Camera;
|
||||
import android.graphics.Matrix;
|
||||
import android.os.Build;
|
||||
import androidx.annotation.FloatRange;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
/**
|
||||
* @author kakajika
|
||||
* @since 2015/11/27
|
||||
*/
|
||||
public class ViewPropertyAnimation extends Animation {
|
||||
|
||||
private final Camera mCamera = new Camera();
|
||||
protected int mWidth = 0;
|
||||
protected int mHeight = 0;
|
||||
protected float mAlpha = 1.0f;
|
||||
protected float mPivotX = 0.0f;
|
||||
protected float mPivotY = 0.0f;
|
||||
protected float mScaleX = 1.0f;
|
||||
protected float mScaleY = 1.0f;
|
||||
protected float mRotationX = 0.0f;
|
||||
protected float mRotationY = 0.0f;
|
||||
protected float mRotationZ = 0.0f;
|
||||
protected float mTranslationX = 0.0f;
|
||||
protected float mTranslationY = 0.0f;
|
||||
protected float mTranslationZ = 0.0f;
|
||||
protected float mCameraX = 0.0f;
|
||||
protected float mCameraY = 0.0f;
|
||||
protected float mCameraZ = -8.0f;
|
||||
|
||||
private float mFromAlpha = -1.0f;
|
||||
private float mToAlpha = -1.0f;
|
||||
|
||||
public ViewPropertyAnimation fading(@FloatRange(from=0.0f,to=1.0f) float fromAlpha, @FloatRange(from=0.0f,to=1.0f) float toAlpha) {
|
||||
mFromAlpha = fromAlpha;
|
||||
mToAlpha = toAlpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(int width, int height, int parentWidth, int parentHeight) {
|
||||
super.initialize(width, height, parentWidth, parentHeight);
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
super.applyTransformation(interpolatedTime, t);
|
||||
if (mFromAlpha >= 0 && mToAlpha >= 0) {
|
||||
mAlpha = mFromAlpha + (mToAlpha - mFromAlpha) * interpolatedTime;
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyTransformation(Transformation t) {
|
||||
final Matrix m = t.getMatrix();
|
||||
final float w = mWidth;
|
||||
final float h = mHeight;
|
||||
final float pX = mPivotX;
|
||||
final float pY = mPivotY;
|
||||
|
||||
final float rX = mRotationX;
|
||||
final float rY = mRotationY;
|
||||
final float rZ = mRotationZ;
|
||||
if ((rX != 0) || (rY != 0) || (rZ != 0)) {
|
||||
final Camera camera = mCamera;
|
||||
camera.save();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
|
||||
camera.setLocation(mCameraX, mCameraY, mCameraZ);
|
||||
}
|
||||
if (mTranslationZ != 0) {
|
||||
camera.translate(0, 0, mTranslationZ);
|
||||
}
|
||||
camera.rotateX(rX);
|
||||
camera.rotateY(rY);
|
||||
camera.rotateZ(-rZ);
|
||||
camera.getMatrix(m);
|
||||
camera.restore();
|
||||
m.preTranslate(-pX, -pY);
|
||||
m.postTranslate(pX, pY);
|
||||
}
|
||||
|
||||
final float sX = mScaleX;
|
||||
final float sY = mScaleY;
|
||||
if ((sX != 1.0f) || (sY != 1.0f)) {
|
||||
m.postScale(sX, sY);
|
||||
final float sPX = -(pX / w) * ((sX * w) - w);
|
||||
final float sPY = -(pY / h) * ((sY * h) - h);
|
||||
m.postTranslate(sPX, sPY);
|
||||
}
|
||||
|
||||
m.postTranslate(mTranslationX, mTranslationY);
|
||||
|
||||
t.setAlpha(mAlpha);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.labo.kaji.fragmentanimations;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* To work on unit tests, switch the Test Artifact in the Build Variants view.
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
@@ -0,0 +1,6 @@
|
||||
#Fri Apr 22 14:42:45 JST 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
@@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1 @@
|
||||
include ':app', ':fragmentanimations'
|
||||