package anabalica.github.io.meowletters;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;


/**
 * This is the activity that starts or continues the game. It is an educational
 * game for children to practice the knowledge of an alphabet.
 *
 * @author Ana Balica
 */
public class GameActivity extends Activity {

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


    @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_game, 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);
    }

    public void selectLetter(View view) {
        System.out.println("Button pressed");
    }
}

@@ -90,16 +90,50 @@
 Bundle;%0A
+import android.os.CountDownTimer;%0A
 import a
@@ -206,16 +206,51 @@
 w.View;%0A
+import android.widget.ProgressBar;%0A
 %0A%0A/**%0A *
@@ -463,16 +463,194 @@
 tivity %7B
+%0A    private ProgressBar timerBar;%0A    private GameCountDownTimer timer;%0A%0A    private int millisTotal = 3000;%0A    private int millisInterval = 5;%0A    private int millisReset = 0;
 %0A%0A    @O
@@ -806,22 +806,295 @@
 _game);%0A
+%0A
     
+    timerBar = (ProgressBar) findViewById(R.id.timerBar);%0A        timerBar.setMax(millisTotal);%0A        timerBar.setProgress(millisTotal);%0A%0A        // Start the countdown timer%0A        timer = new GameCountDownTimer(millisTotal, millisInterval);%0A        timer.start();%0A    
 %7D
-%0A
 %0A%0A    @O
@@ -1909,11 +1909,671 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Custom countdown timer that runs infinitely and updates it's state to%0A     * the progress bar.%0A     */%0A    public class GameCountDownTimer extends CountDownTimer %7B%0A%0A        public GameCountDownTimer(long millisInFuture, long countDownInterval) %7B%0A            super(millisInFuture, countDownInterval);%0A        %7D%0A%0A        @Override%0A        public void onFinish() %7B%0A            timerBar.setProgress(millisReset);%0A            timerBar.setProgress(millisTotal);%0A            timer.start();%0A        %7D%0A%0A        @Override%0A        public void onTick(long millisUntilFinished) %7B%0A            timerBar.setProgress((int) millisUntilFinished);%0A        %7D%0A    %7D
 %0A%7D%0A

create a countdown timer of 3s that loops over infinitely and updates the progressbar