diff --git a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GameStateCallback.java b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GameStateCallback.java
index da44496..be465c8 100644
--- a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GameStateCallback.java
+++ b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GameStateCallback.java
@@ -12,4 +12,6 @@ public interface GameStateCallback {
void cellDrawingInProgress();
void cellDrawingFinished();
+
+ void gameStarted();
}
diff --git a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GridPresenter.java b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GridPresenter.java
index c4f135e..d6bc8ac 100644
--- a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GridPresenter.java
+++ b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/GridPresenter.java
@@ -36,6 +36,7 @@ public void passLiveCellsToModelAndStartGame(){
worldGrid.setInitialLiveCells(userSelectedCells);
startConstantUpdate();
worldGridLayout.setEnabled(false);
+ worldGridLayout.gameStarted();
} else {
worldGridLayout.noCellsWereSelected();
}
diff --git a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridFragment.java b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridFragment.java
index 66fb8ef..ea0e704 100644
--- a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridFragment.java
+++ b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridFragment.java
@@ -142,6 +142,11 @@ public void cellDrawingFinished() {
mListener.cellDrawingFinished();
}
+ @Override
+ public void gameStarted() {
+ mListener.gameStarted();
+ }
+
public interface OnFragmentInteractionListener {
void gameOver();
@@ -151,5 +156,7 @@ public interface OnFragmentInteractionListener {
void cellDrawingInProgress();
void cellDrawingFinished();
+
+ void gameStarted();
}
}
diff --git a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridLayout.java b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridLayout.java
index ec20d4d..dbbc60a 100644
--- a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridLayout.java
+++ b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/LifeGridLayout.java
@@ -177,6 +177,10 @@ public void noCellsWereSelected(){
public void cellsDiedGameOver(){
gameStateCallback.gameOver();
}
+
+ public void gameStarted() {
+ gameStateCallback.gameStarted();
+ }
//can disable this as no scrolling needed
@Override
public boolean shouldDelayChildPressedState() {
diff --git a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/MainActivity.java b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/MainActivity.java
index 0225ac2..945180b 100644
--- a/app/src/main/java/io/github/lewismcgeary/androidgameoflife/MainActivity.java
+++ b/app/src/main/java/io/github/lewismcgeary/androidgameoflife/MainActivity.java
@@ -2,13 +2,13 @@
import android.content.Intent;
import android.content.pm.ActivityInfo;
-import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
+import android.support.graphics.drawable.AnimatedVectorDrawableCompat;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
@@ -26,8 +26,8 @@ public class MainActivity extends AppCompatActivity implements IntroFragment.OnF
FloatingActionButton startResetFab;
String startButtonText;
String resetButtonText;
- Drawable playIcon;
- Drawable resetIcon;
+ AnimatedVectorDrawableCompat playIcon;
+ AnimatedVectorDrawableCompat resetIcon;
Snackbar snack;
LifeGridFragment lifeGridFragment;
@@ -57,7 +57,6 @@ protected void onResume() {
@Override
public void onBackPressed() {
super.onBackPressed();
- showButtonInStartMode();
startResetFab.hide();
appBarLayout.setExpanded(true, true);
setFixedScreenOrientation(false);
@@ -81,13 +80,12 @@ private void initialiseButton(){
startResetFab = (FloatingActionButton)findViewById(R.id.start_reset_fab);
startButtonText = getString(R.string.start_button_text);
resetButtonText = getString(R.string.reset_button_text);
- playIcon = ContextCompat.getDrawable(this, R.drawable.ic_play_arrow_24dp);
- resetIcon = ContextCompat.getDrawable(this, R.drawable.ic_replay_24dp);
+ playIcon = AnimatedVectorDrawableCompat.create(this, R.drawable.fab_reset_to_play_animated_vector);
+ resetIcon = AnimatedVectorDrawableCompat.create(this, R.drawable.fab_play_to_reset_animated_vector);
startResetFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (startResetFab.getTag().equals(startButtonText)) {
- showButtonInResetMode();
lifeGridFragment.worldGridPresenter.passLiveCellsToModelAndStartGame();
} else {
showButtonInStartMode();
@@ -101,11 +99,13 @@ public void onClick(View v) {
private void showButtonInStartMode(){
startResetFab.setTag(startButtonText);
startResetFab.setImageDrawable(playIcon);
+ playIcon.start();
}
private void showButtonInResetMode(){
startResetFab.setTag(resetButtonText);
startResetFab.setImageDrawable(resetIcon);
+ resetIcon.start();
}
private void startTransition(){
@@ -207,12 +207,17 @@ public void noCellsWereSelected() {
ViewGroup group = (ViewGroup) snack.getView();
group.setBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
snack.show();
- showButtonInStartMode();
+ }
+
+ @Override
+ public void gameStarted() {
+ showButtonInResetMode();
}
@Override
public void letsPlay() {
setFixedScreenOrientation(true);
+ showButtonInStartMode();
startTransition();
}
diff --git a/app/src/main/res/animator/fab_arrowhead_to_play.xml b/app/src/main/res/animator/fab_arrowhead_to_play.xml
new file mode 100644
index 0000000..5c32b4c
--- /dev/null
+++ b/app/src/main/res/animator/fab_arrowhead_to_play.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/animator/fab_arrowhead_to_play_startoffset.xml b/app/src/main/res/animator/fab_arrowhead_to_play_startoffset.xml
new file mode 100644
index 0000000..c3286c4
--- /dev/null
+++ b/app/src/main/res/animator/fab_arrowhead_to_play_startoffset.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/animator/fab_play_to_arrowhead.xml b/app/src/main/res/animator/fab_play_to_arrowhead.xml
new file mode 100644
index 0000000..2ab12f1
--- /dev/null
+++ b/app/src/main/res/animator/fab_play_to_arrowhead.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/animator/fab_rotate_reset_arrow.xml b/app/src/main/res/animator/fab_rotate_reset_arrow.xml
new file mode 100644
index 0000000..a13d3b0
--- /dev/null
+++ b/app/src/main/res/animator/fab_rotate_reset_arrow.xml
@@ -0,0 +1,11 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/animator/fab_tail_grow.xml b/app/src/main/res/animator/fab_tail_grow.xml
new file mode 100644
index 0000000..0b97b4a
--- /dev/null
+++ b/app/src/main/res/animator/fab_tail_grow.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/animator/fab_tail_shrink.xml b/app/src/main/res/animator/fab_tail_shrink.xml
new file mode 100644
index 0000000..7b95694
--- /dev/null
+++ b/app/src/main/res/animator/fab_tail_shrink.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/fab_ic_play_arrow_24dp.xml b/app/src/main/res/drawable/fab_ic_play_arrow_24dp.xml
new file mode 100644
index 0000000..e41f13f
--- /dev/null
+++ b/app/src/main/res/drawable/fab_ic_play_arrow_24dp.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/fab_ic_replay_24dp.xml b/app/src/main/res/drawable/fab_ic_replay_24dp.xml
new file mode 100644
index 0000000..2621416
--- /dev/null
+++ b/app/src/main/res/drawable/fab_ic_replay_24dp.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/fab_play_to_reset_animated_vector.xml b/app/src/main/res/drawable/fab_play_to_reset_animated_vector.xml
new file mode 100644
index 0000000..3e623b9
--- /dev/null
+++ b/app/src/main/res/drawable/fab_play_to_reset_animated_vector.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/fab_reset_to_play_animated_vector.xml b/app/src/main/res/drawable/fab_reset_to_play_animated_vector.xml
new file mode 100644
index 0000000..a3c9a4d
--- /dev/null
+++ b/app/src/main/res/drawable/fab_reset_to_play_animated_vector.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/vector_drawable_config.xml b/app/src/main/res/values/vector_drawable_config.xml
index 5facab7..6cfffe5 100644
--- a/app/src/main/res/values/vector_drawable_config.xml
+++ b/app/src/main/res/values/vector_drawable_config.xml
@@ -6,4 +6,6 @@
M0,0 L24,0 24,24 0,24 z
scale group
+
+ 400
\ No newline at end of file