-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 394bf8d
Showing
10 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.properties | ||
.idea | ||
.project | ||
*.iml | ||
out | ||
libs | ||
gen | ||
bin | ||
build.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<uses-sdk android:minSdkVersion="8"/> | ||
<application android:label="@string/app_name"> | ||
<activity android:name="MyActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# To enable ProGuard in your project, edit project.properties | ||
# to define the proguard.config property as described in that file. | ||
# | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in ${sdk.dir}/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the ProGuard | ||
# include property in project.properties. | ||
# | ||
# 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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="horizontal" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
> | ||
<!--<FrameLayout--> | ||
<!--android:id="@+id/fl1"--> | ||
<!--android:layout_width="fill_parent"--> | ||
<!--android:layout_height="fill_parent"--> | ||
<!--android:background="#f00"--> | ||
<!--android:layout_weight=".5"--> | ||
<!--/>--> | ||
<!--<FrameLayout--> | ||
<!--android:id="@+id/fl2"--> | ||
<!--android:layout_width="fill_parent"--> | ||
<!--android:layout_height="fill_parent"--> | ||
<!--android:layout_weight=".5"--> | ||
<!--android:background="#fff"--> | ||
<!--/>--> | ||
<!--<FrameLayout--> | ||
<!--android:id="@+id/fl3"--> | ||
<!--android:layout_width="fill_parent"--> | ||
<!--android:layout_height="fill_parent"--> | ||
<!--android:layout_weight="1"--> | ||
<!--android:visibility="gone"--> | ||
<!--android:background="#f0f"--> | ||
<!--/>--> | ||
</LinearLayout> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">3PanelFragments</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.example; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.view.Window; | ||
import android.view.animation.AccelerateInterpolator; | ||
import android.view.animation.BounceInterpolator; | ||
import android.view.animation.DecelerateInterpolator; | ||
|
||
public class MyActivity extends Activity { | ||
|
||
ThreeLayout layout; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
|
||
layout = new ThreeLayout(this, 3); | ||
layout.setAnimationDuration(1000); | ||
setContentView(layout); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
testAnimations(); | ||
} | ||
|
||
private void testAnimations() { | ||
Handler h = new Handler(); | ||
h.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
layout.startLeftAnimation(); | ||
} | ||
}, 1000); | ||
|
||
h.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
layout.setInterpolator(new BounceInterpolator()); | ||
layout.startRightAnimation(); | ||
} | ||
}, 3000); | ||
|
||
h.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
layout.setInterpolator(new AccelerateInterpolator()); | ||
layout.startLeftAnimation(); | ||
} | ||
}, 6000); | ||
|
||
h.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
layout.setInterpolator(new DecelerateInterpolator()); | ||
layout.startRightAnimation(); | ||
} | ||
}, 9000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.example; | ||
|
||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.animation.Animation; | ||
import android.view.animation.Transformation; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: weakwire (John Papadakis) | ||
* Date: 9/7/12 | ||
* Time: 1:38 AM | ||
*/ | ||
public class MyScaleAnimation extends Animation { | ||
private View mView; | ||
private float mToHeight; | ||
private float mFromHeight; | ||
|
||
private float mToWidth; | ||
private float mFromWidth; | ||
|
||
public MyScaleAnimation(View v, float fromWidth, float fromHeight, float toWidth, float toHeight) { | ||
mToHeight = toHeight; | ||
mToWidth = toWidth; | ||
mFromHeight = fromHeight; | ||
mFromWidth = fromWidth; | ||
mView = v; | ||
setDuration(400); | ||
} | ||
|
||
@Override | ||
protected void applyTransformation(float interpolatedTime, Transformation t) { | ||
float height = | ||
(mToHeight - mFromHeight) * interpolatedTime + mFromHeight; | ||
float width = (mToWidth - mFromWidth) * interpolatedTime + mFromWidth; | ||
ViewGroup.LayoutParams p = mView.getLayoutParams(); | ||
p.height = (int) height; | ||
p.width = (int) width; | ||
mView.requestLayout(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.example; | ||
|
||
import android.view.View; | ||
import android.view.animation.Animation; | ||
import android.view.animation.Transformation; | ||
import android.widget.RelativeLayout; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: weakwire (John Papadakis) | ||
* Date: 9/7/12 | ||
* Time: 1:38 AM | ||
*/ | ||
public class MyTranslateAnimation extends Animation { | ||
private View mView; | ||
private final float fromX; | ||
private final float toX; | ||
private final float fromY; | ||
private final float toY; | ||
|
||
|
||
public MyTranslateAnimation(View v, float fromX, float toX, float fromY, float toY) { | ||
|
||
mView = v; | ||
this.fromX = fromX; | ||
this.toX = toX; | ||
this.fromY = fromY; | ||
this.toY = toY; | ||
setDuration(400); | ||
} | ||
|
||
@Override | ||
protected void applyTransformation(float interpolatedTime, Transformation t) { | ||
float x = | ||
(toX - fromX) * interpolatedTime + fromX; | ||
float y = (toY - fromY) * interpolatedTime + fromY; | ||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mView.getLayoutParams(); | ||
params.setMargins(0, 0, (int) -x, (int) -y); | ||
mView.requestLayout(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
package com.example; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.view.animation.Animation; | ||
import android.view.animation.Interpolator; | ||
import android.view.animation.LinearInterpolator; | ||
import android.widget.FrameLayout; | ||
import android.widget.RelativeLayout; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: weakwire (John Papadakis) | ||
* Date: 9/7/12 | ||
* Time: 1:30 AM | ||
*/ | ||
public class ThreeLayout extends RelativeLayout { | ||
|
||
private FrameLayout view1; | ||
private FrameLayout view2; | ||
private FrameLayout view3; | ||
int width; | ||
int panel; | ||
long animationDuration = 800; | ||
private Interpolator interpolator = new LinearInterpolator(); | ||
|
||
public ThreeLayout(final Context context, final float leftWeight) { | ||
super(context); | ||
|
||
post(new Runnable() { | ||
@Override | ||
public void run() { | ||
width = getWidth(); | ||
panel = (int) (width / leftWeight); | ||
_initWithDimentions(context); | ||
} | ||
}); | ||
} | ||
|
||
public void setAnimationDuration(long animationDuration) { | ||
this.animationDuration = animationDuration; | ||
} | ||
|
||
public void setInterpolator(Interpolator i) { | ||
interpolator = i; | ||
} | ||
|
||
public void startLeftAnimation() { | ||
showAnimation(); | ||
} | ||
|
||
public void startRightAnimation() { | ||
hideAnimation(); | ||
} | ||
|
||
|
||
private FrameLayout fl1; | ||
private FrameLayout fl2; | ||
private FrameLayout fl3; | ||
|
||
public FrameLayout getLeftLayout() { | ||
return fl1; | ||
} | ||
|
||
public FrameLayout getMiddleLayout() { | ||
return fl2; | ||
} | ||
|
||
public FrameLayout getRightLayout() { | ||
return fl3; | ||
} | ||
|
||
private void _initWithDimentions(Context context) { | ||
|
||
fl1 = new FrameLayout(context); | ||
fl2 = new FrameLayout(context); | ||
fl3 = new FrameLayout(context); | ||
|
||
this.view1 = fl1; | ||
this.view2 = fl2; | ||
this.view3 = fl3; | ||
|
||
fl1.setBackgroundColor(Color.RED); | ||
fl2.setBackgroundColor(Color.GREEN); | ||
fl3.setBackgroundColor(Color.YELLOW); | ||
|
||
fl1.setId(1); | ||
fl2.setId(2); | ||
fl3.setId(3); | ||
|
||
LayoutParams params1 = new LayoutParams(panel, LayoutParams.FILL_PARENT); | ||
LayoutParams params2 = new LayoutParams(width - panel, LayoutParams.FILL_PARENT); | ||
LayoutParams params3 = new LayoutParams(width - panel, LayoutParams.FILL_PARENT); | ||
|
||
fl1.setLayoutParams(params1); | ||
params2.addRule(RelativeLayout.RIGHT_OF, 1); | ||
|
||
fl2.setLayoutParams(params2); | ||
params3.addRule(RelativeLayout.RIGHT_OF, 2); | ||
|
||
fl3.setLayoutParams(params3); | ||
|
||
addView(fl1); | ||
addView(fl2); | ||
addView(fl3); | ||
} | ||
|
||
private void showAnimation() { | ||
hideView1(); | ||
shrinkAndMoveView2(); | ||
} | ||
|
||
private void hideAnimation() { | ||
showView1(); | ||
growAndMoveView2(); | ||
} | ||
|
||
private void showView1() { | ||
Animation rightAnimation = new MyTranslateAnimation(view1, view1.getWidth(), 0, 0, 0); | ||
rightAnimation.setInterpolator(interpolator); | ||
rightAnimation.setDuration(animationDuration); | ||
view1.startAnimation(rightAnimation); | ||
} | ||
|
||
private void hideView1() { | ||
Animation leftAnimation = new MyTranslateAnimation(view1, 0, view1.getWidth(), 0, 0); | ||
leftAnimation.setInterpolator(interpolator); | ||
leftAnimation.setDuration(animationDuration); | ||
view1.startAnimation(leftAnimation); | ||
} | ||
|
||
private void growAndMoveView2() { | ||
Animation rightAnimation = new MyTranslateAnimation(view2, -view1.getWidth(), 0, 0, 0); | ||
rightAnimation.setInterpolator(interpolator); | ||
rightAnimation.setDuration(animationDuration); | ||
view2.startAnimation(rightAnimation); | ||
|
||
Animation shrinkAnimation = new MyScaleAnimation(view2, view2.getWidth(), view2.getHeight(), width - panel, view2.getHeight()); | ||
shrinkAnimation.setInterpolator(interpolator); | ||
shrinkAnimation.setDuration(animationDuration); | ||
view2.startAnimation(shrinkAnimation); | ||
} | ||
|
||
private void shrinkAndMoveView2() { | ||
Animation leftAnimation = new MyTranslateAnimation(view2, 0, -view1.getWidth(), 0, 0); | ||
leftAnimation.setInterpolator(interpolator); | ||
leftAnimation.setDuration(animationDuration); | ||
view2.startAnimation(leftAnimation); | ||
|
||
Animation shrinkAnimation = new MyScaleAnimation(view2, view2.getWidth(), view2.getHeight(), view1.getWidth(), view2.getHeight()); | ||
shrinkAnimation.setInterpolator(interpolator); | ||
shrinkAnimation.setDuration(animationDuration); | ||
view2.startAnimation(shrinkAnimation); | ||
} | ||
|
||
} |