package com.bignerdranch.android.geoquiz;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class CheatActivity extends AppCompatActivity {

    private static final String EXTRA_ANSWER_IS_TRUE = "com.bignerdranch.android.geoquiz.answer_is_true";
    private static final String EXTRA_ANSWER_SHOWN = "com.bignerdranch.android.geoquiz.answer_shown";

    private static final String KEY_CHEATED = "cheated";

    private TextView mAnswerTextView;
    private Button mShowAnswer;

    private boolean mAnswerIsTrue;
    private boolean mCheated = false;

    public static Intent newIntent(Context packageContext, boolean answerIsTrue) {
        Intent intent = new Intent(packageContext, CheatActivity.class);
        intent.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue);
        return intent;
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putBoolean(KEY_CHEATED, mCheated);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cheat);

        mAnswerIsTrue = getIntent().getBooleanExtra(EXTRA_ANSWER_IS_TRUE, false);

        mAnswerTextView = (TextView)findViewById(R.id.answer_text_view);

        mShowAnswer = (Button)findViewById(R.id.show_answer_button);
        mShowAnswer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cheat();
            }
        });

        if (savedInstanceState != null) {
            if (savedInstanceState.getBoolean(KEY_CHEATED, false)) {
                cheat();
            }
        }
    }

    public static boolean wasAnswerShown(Intent intent) {
        return intent.getBooleanExtra(EXTRA_ANSWER_SHOWN, false);
    }

    private void cheat() {
        mCheated = true;
        mAnswerTextView.setText(mAnswerIsTrue ? R.string.true_button : R.string.false_button);
        setAnswerShownResult(true);
    }

    private void setAnswerShownResult(boolean isAnswerShown) {
        Intent intent = new Intent();
        intent.putExtra(EXTRA_ANSWER_SHOWN, isAnswerShown);
        setResult(RESULT_OK, intent);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_cheat, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

@@ -36,16 +36,101 @@
 oquiz;%0A%0A
+import android.animation.Animator;%0Aimport android.animation.AnimatorListenerAdapter;%0A
 import a
@@ -341,16 +341,56 @@
 w.View;%0A
+import android.view.ViewAnimationUtils;%0A
 import a
@@ -1854,24 +1854,735 @@
 k(View v) %7B%0A
+%0A                int cx = mShowAnswer.getWidth() / 2;%0A                int cy = mShowAnswer.getHeight() / 2;%0A                float radius = mShowAnswer.getWidth();%0A%0A                Animator animator = ViewAnimationUtils.createCircularReveal(mShowAnswer, cx, cy, radius, 0);%0A                animator.addListener(new AnimatorListenerAdapter() %7B%0A                    @Override%0A                    public void onAnimationEnd(Animator animation) %7B%0A                        super.onAnimationEnd(animation);%0A                        mAnswerTextView.setVisibility(View.VISIBLE);%0A                        mShowAnswer.setVisibility(View.INVISIBLE);%0A                    %7D%0A                %7D);%0A                animator.start();%0A%0A
             

Add fancy animation to ShowAnswer button