Skip to content

Commit

Permalink
Cleaning up and standardizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeinstein10 committed Feb 2, 2013
1 parent 6cd4954 commit 5438e99
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 93 deletions.
3 changes: 2 additions & 1 deletion lib/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<com.jfeinstein.jazzyviewpager.JazzyViewPager xmlns:android="http://schemas.android.com/apk/res/android"
<com.jfeinstein.jazzyviewpager.JazzyViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/jazzy_pager"
android:layout_width="match_parent"
Expand Down
15 changes: 8 additions & 7 deletions lib/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
<enum name="tablet" value="1" />
<enum name="cubein" value="2" />
<enum name="cubeout" value="3" />
<enum name="flip" value="4" />
<enum name="stack" value="5" />
<enum name="zoomin" value="6" />
<enum name="zoomout" value="7" />
<enum name="rotateup" value="8" />
<enum name="rotatedown" value="9" />
<enum name="accordion" value="10" />
<enum name="flipvertical" value="4" />
<enum name="fliphorizontal" value="5" />
<enum name="stack" value="6" />
<enum name="zoomin" value="7" />
<enum name="zoomout" value="8" />
<enum name="rotateup" value="9" />
<enum name="rotatedown" value="10" />
<enum name="accordion" value="11" />
</attr>
<attr name="fadeEnabled" format="boolean" />
<attr name="outlineEnabled" format="boolean" />
Expand Down
5 changes: 3 additions & 2 deletions lib/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

<string name="app_name">JazzyViewPager</string>

<string-array name="animatevp_effects">
<string-array name="jazzy_effects">
<item>Standard</item>
<item>Tablet</item>
<item>CubeIn</item>
<item>CubeOut</item>
<item>Flip</item>
<item>FlipVertical</item>
<item>FlipHorizontal</item>
<item>Stack</item>
<item>ZoomIn</item>
<item>ZoomOut</item>
Expand Down
62 changes: 31 additions & 31 deletions lib/src/com/jfeinstein/jazzyviewpager/JazzyViewPager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jfeinstein.jazzyviewpager;

import java.util.HashMap;
import java.util.LinkedHashMap;

import android.annotation.TargetApi;
import android.content.Context;
Expand Down Expand Up @@ -28,7 +29,7 @@ public class JazzyViewPager extends ViewPager {
public static int sOutlineColor = Color.WHITE;
private TransitionEffect mEffect = TransitionEffect.Standard;

private HashMap<Integer, Object> mObjs = new HashMap<Integer, Object>();
private HashMap<Integer, Object> mObjs = new LinkedHashMap<Integer, Object>();

private static final float SCALE_MAX = 0.5f;
private static final float ZOOM_MAX = 0.5f;
Expand All @@ -40,7 +41,7 @@ public enum TransitionEffect {
CubeIn,
CubeOut,
FlipVertical,
FlipHorizonal,
FlipHorizontal,
Stack,
ZoomIn,
ZoomOut,
Expand All @@ -50,7 +51,6 @@ public enum TransitionEffect {
}

private static final boolean API_11;

static {
API_11 = Build.VERSION.SDK_INT >= 11;
}
Expand All @@ -66,7 +66,7 @@ public JazzyViewPager(Context context, AttributeSet attrs) {
// now style everything!
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.JazzyViewPager);
int effect = ta.getInt(R.styleable.JazzyViewPager_style, 0);
String[] transitions = getResources().getStringArray(R.array.animatevp_effects);
String[] transitions = getResources().getStringArray(R.array.jazzy_effects);
setTransitionEffect(TransitionEffect.valueOf(transitions[effect]));
setFadeEnabled(ta.getBoolean(R.styleable.JazzyViewPager_fadeEnabled, false));
setOutlineEnabled(ta.getBoolean(R.styleable.JazzyViewPager_outlineEnabled, false));
Expand Down Expand Up @@ -160,41 +160,41 @@ private enum State {
GOING_LEFT,
GOING_RIGHT
}

// public void reset() {
// resetPrivate();
// int curr = getCurrentItem();
// onPageScrolled(curr, 0.0f, 0);
// }
// resetPrivate();
// int curr = getCurrentItem();
// onPageScrolled(curr, 0.0f, 0);
//}
//
// private void resetPrivate() {
// for (int i = 0; i < getChildCount(); i++) {
// View v = getChildAt(i);
// // ViewHelper.setRotation(v, -ViewHelper.getRotation(v));
// // ViewHelper.setRotationX(v, -ViewHelper.getRotationX(v));
// // ViewHelper.setRotationY(v, -ViewHelper.getRotationY(v));
// //
// // ViewHelper.setTranslationX(v, -ViewHelper.getTranslationX(v));
// // ViewHelper.setTranslationY(v, -ViewHelper.getTranslationY(v));
//private void resetPrivate() {
// for (int i = 0; i < getChildCount(); i++) {
// View v = getChildAt(i);
// // ViewHelper.setRotation(v, -ViewHelper.getRotation(v));
// // ViewHelper.setRotationX(v, -ViewHelper.getRotationX(v));
// // ViewHelper.setRotationY(v, -ViewHelper.getRotationY(v));
// //
// // ViewHelper.setTranslationX(v, -ViewHelper.getTranslationX(v));
// // ViewHelper.setTranslationY(v, -ViewHelper.getTranslationY(v));
//
// ViewHelper.setRotation(v, 0);
// ViewHelper.setRotationX(v, 0);
// ViewHelper.setRotationY(v, 0);
// ViewHelper.setRotation(v, 0);
// ViewHelper.setRotationX(v, 0);
// ViewHelper.setRotationY(v, 0);
//
// ViewHelper.setTranslationX(v, 0);
// ViewHelper.setTranslationY(v, 0);
// ViewHelper.setTranslationX(v, 0);
// ViewHelper.setTranslationY(v, 0);
//
// ViewHelper.setAlpha(v, 1.0f);
// ViewHelper.setAlpha(v, 1.0f);
//
// ViewHelper.setScaleX(v, 1.0f);
// ViewHelper.setScaleY(v, 1.0f);
// ViewHelper.setScaleX(v, 1.0f);
// ViewHelper.setScaleY(v, 1.0f);
//
// ViewHelper.setPivotX(v, 0);
// ViewHelper.setPivotY(v, 0);
// ViewHelper.setPivotX(v, 0);
// ViewHelper.setPivotY(v, 0);
//
// logState(v, "Child " + i);
// }
// logState(v, "Child " + i);
// }
//}

private void logState(View v, String title) {
Log.v(TAG, title + ": ROT (" + ViewHelper.getRotation(v) + ", " +
Expand Down Expand Up @@ -514,7 +514,7 @@ else if (mState == State.GOING_LEFT && goingRight)
case FlipVertical:
animateFlipVertical(mLeft, mRight, positionOffset, positionOffsetPixels);
break;
case FlipHorizonal:
case FlipHorizontal:
animateFlipHorizontal(mLeft, mRight, effectOffset, positionOffsetPixels);
case Stack:
animateStack(mLeft, mRight, effectOffset, positionOffsetPixels);
Expand Down
57 changes: 5 additions & 52 deletions lib/src/com/jfeinstein/jazzyviewpager/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,63 +28,16 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
// getMenuInflater().inflate(R.menu.activity_main, menu);
String[] effects = this.getResources().getStringArray(R.array.jazzy_effects);
for (String effect : effects)
menu.add(effect);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
TransitionEffect effect = TransitionEffect.Standard;
switch(item.getItemId()) {
case R.id.menu_standard: {
effect = TransitionEffect.Standard;
break;
}
case R.id.menu_tablet: {
effect = TransitionEffect.Tablet;
break;
}
case R.id.menu_cube_in: {
effect = TransitionEffect.CubeIn;
break;
}
case R.id.menu_cube_out: {
effect = TransitionEffect.CubeOut;
break;
}
case R.id.menu_flip_vertical: {
effect = TransitionEffect.FlipVertical;
break;
}
case R.id.menu_flip_horizontal: {
effect = TransitionEffect.FlipHorizonal;
break;
}
case R.id.menu_stack: {
effect = TransitionEffect.Stack;
break;
}
case R.id.menu_zoom_in: {
effect = TransitionEffect.ZoomIn;
break;
}
case R.id.menu_zoom_out: {
effect = TransitionEffect.ZoomOut;
break;
}
case R.id.menu_rotate_up: {
effect = TransitionEffect.RotateUp;
break;
}
case R.id.menu_rotate_down: {
effect = TransitionEffect.RotateDown;
break;
}
case R.id.menu_accordian: {
effect = TransitionEffect.Accordion;
break;
}
}
TransitionEffect effect = TransitionEffect.valueOf(item.getTitle().toString());
setupJazziness(effect);
return true;
}
Expand Down

0 comments on commit 5438e99

Please sign in to comment.