Skip to content

Commit

Permalink
Initial addition of an animation when Paul returns
Browse files Browse the repository at this point in the history
  • Loading branch information
amlcurran committed Mar 27, 2013
1 parent 4619fb7 commit 130634f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 65 deletions.
Binary file added android/res/drawable-xhdpi/deal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-xhdpi/paul.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 29 additions & 59 deletions android/res/layout/main.xml
@@ -1,68 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="4"
android:rowCount="4" >

<TextView
android:text="1,1" />

<TextView
android:text="1,2" />

<TextView
android:text="1,3" />

<TextView
android:text="1,4" />

<TextView
android:text="2,1" />

<TextView
android:text="2,2" />

<TextView
android:text="2,3" />

<TextView
android:text="2,4" />

<TextView
android:text="3,1" />

<TextView
android:text="3,2" />

<TextView
android:text="3,3 longer" />

<TextView
android:text="3,4" />

<TextView
android:text="4,1" />

<TextView
android:text="4,2" />

<TextView
android:text="4,3" />

<TextView
android:text="4,4" />

</GridLayout>
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp">

</android.support.v4.view.ViewPager>

</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/paulsMug"
android:src="@drawable/paul"
android:layout_centerHorizontal="true"
android:layout_marginTop="85dp"
android:focusableInTouchMode="false"
android:visibility="invisible" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/paulsSpecs"
android:src="@drawable/deal"
android:layout_alignParentTop="true"
android:layout_marginTop="106dp"
android:layout_marginLeft="10dp"
android:layout_alignLeft="@+id/paulsMug"
android:visibility="invisible" />

</RelativeLayout>
3 changes: 3 additions & 0 deletions android/res/menu/menu_main.xml
Expand Up @@ -6,4 +6,7 @@
android:title="@string/show_seconds"
android:checkable="true" />

<item android:id="@+id/menu_controlledExplosion"
android:title="Controlled Explosion" />

</menu>
25 changes: 19 additions & 6 deletions android/src/ca/keithzg/paulmiller/is/offline/MainActivity.java
Expand Up @@ -10,8 +10,10 @@
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;
import com.nineoldandroids.animation.ObjectAnimator;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -140,12 +142,6 @@ public void onTick(long millisUntilFinished) {
MainActivity.seconds = seconds
);

//tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 58);
//SimpleDateFormat dateformatYYYYMMDD = new SimpleDateFormat("yyyy MM dd \nhh mm ss");
//String testString = dateformatYYYYMMDD.format(date);
//tv.setText(paulTimeLeft + "\n" + testString);
//tv.setText(paulTimeLeft);
//Log.w("paulTimer: ", paulTimeLeft);
}
}

Expand All @@ -162,8 +158,25 @@ public void overflow(View v) {
PopupMenu pm = new PopupMenu(this, v);
pm.inflate(R.menu.menu_main);
PreferenceMenuItemHelper.associate(this, pm.getMenu(), R.id.menu_secondsToggle, "showSeconds");
pm.getMenu().findItem(R.id.menu_controlledExplosion).setVisible(BuildConfig.DEBUG);
pm.getMenu().findItem(R.id.menu_controlledExplosion).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
dealWithIt();
return false;
}
});
pm.show();

}

public void dealWithIt() {
findViewById(R.id.paulsMug).setVisibility(View.VISIBLE);
findViewById(R.id.paulsSpecs).setVisibility(View.VISIBLE);
ObjectAnimator.ofFloat(findViewById(R.id.paulsMug), "alpha", 0f, 1f).start();
ObjectAnimator marginAnimator = ObjectAnimator.ofFloat(findViewById(R.id.paulsSpecs), "translationY",
-120f * getResources().getDisplayMetrics().density, 0f);
marginAnimator.setDuration(3000).start();
}

}

0 comments on commit 130634f

Please sign in to comment.