Skip to content

Commit

Permalink
Merge pull request #7 from lewismcgeary/improve-java-efficiency
Browse files Browse the repository at this point in the history
improve-java-efficiency
  • Loading branch information
lewismcgeary committed Jan 20, 2016
2 parents 4ac44c6 + 86a4f45 commit a63a458
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 58 deletions.
11 changes: 2 additions & 9 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,17 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/debug" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

public class MainActivity extends Activity {

AnimatedVectorDrawable mightyMorphinAnimatedVectorDrawable;
AnimatedVectorDrawable mightyMorphinAnimatedVectorDrawableReversed;
ImageView animatorImageView;

private AnimatedVectorDrawable mightyMorphinAnimatedVectorDrawable;
private AnimatedVectorDrawable mightyMorphinAnimatedVectorDrawableReversed;
private ImageView animatorImageView;
private boolean isShowingAndroid = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -21,39 +21,19 @@ protected void onCreate(Bundle savedInstanceState) {
animatorImageView = (ImageView) findViewById(R.id.path_morph_animated_vector);
mightyMorphinAnimatedVectorDrawable = (AnimatedVectorDrawable) getDrawable(R.drawable.consolidated_animated_vector);
mightyMorphinAnimatedVectorDrawableReversed = (AnimatedVectorDrawable) getDrawable(R.drawable.consolidated_animated_vector_reverse);
animatorImageView.setImageDrawable(getDrawable(R.drawable.android_logo_vector_morphable));

final ImageView toAppleButton = (ImageView) findViewById(R.id.to_apple_button);
final ImageView toAndroidButton = (ImageView) findViewById(R.id.to_android_button);
toAndroidButton.setEnabled(false);
toAppleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toAndroidButton.setEnabled(true);
toAppleButton.setEnabled(false);
animateToApple();
}
});
toAndroidButton.setOnClickListener(new View.OnClickListener() {
animatorImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toAppleButton.setEnabled(true);
toAndroidButton.setEnabled(false);
animateToAndroid();
morph();
}
});
}

public void animateToApple(){
mightyMorphinAnimatedVectorDrawable.stop();
animatorImageView.setImageDrawable(mightyMorphinAnimatedVectorDrawable);
mightyMorphinAnimatedVectorDrawable.start();
}

public void animateToAndroid(){
mightyMorphinAnimatedVectorDrawableReversed.stop();
animatorImageView.setImageDrawable(mightyMorphinAnimatedVectorDrawableReversed);
mightyMorphinAnimatedVectorDrawableReversed.start();
public void morph(){
AnimatedVectorDrawable currentDrawable = isShowingAndroid ? mightyMorphinAnimatedVectorDrawable : mightyMorphinAnimatedVectorDrawableReversed;
animatorImageView.setImageDrawable(currentDrawable);
currentDrawable.start();
isShowingAndroid = !isShowingAndroid;
}

}
19 changes: 1 addition & 18 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,10 @@

<ImageView
android:id="@+id/path_morph_animated_vector"
android:src="@drawable/android_logo_vector_morphable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:scaleType="fitCenter"
android:layout_centerHorizontal="true"/>
<ImageView
android:id="@+id/to_android_button"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/android_logo_vector_morphable"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
<ImageView
android:id="@+id/to_apple_button"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/apple_logo_vector_morphable"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:paddingBottom="16dp"/>



</RelativeLayout>

0 comments on commit a63a458

Please sign in to comment.