add flutter
@@ -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);
|
||||
}
|
||||
}
|
||||