public void checkAnswer(String str) {
   Button nextButton = (Button) findViewById(R.id.viewer_next_button);
   Button showMeButton = (Button) findViewById(R.id.viewer_answer_button);
   if (isCorrectAnswer(str)) {
     showMeButton.setBackgroundResource(R.drawable.green_button);
     nextButton.setBackgroundResource(R.drawable.green_button);
     nextButton.setText("Continue");
     TextView tv = (TextView) findViewById(R.id.viewer_photoName);
     tv.setText(AssetManagement.getPhotoName(assetPaths[assetIndex]));
     isCorrect = true;
     if (firstCorrect) {
       Toast.makeText(ViewerActivity.this, "Correct!", Toast.LENGTH_SHORT).show();
       firstCorrect = false;
     }
     Log.d(TAG, "Correct");
   } else {
     showMeButton.setBackgroundResource(R.drawable.red_button);
     nextButton.setBackgroundResource(R.drawable.red_button);
     nextButton.setText("Skip");
     TextView tv = (TextView) findViewById(R.id.viewer_photoName);
     tv.setText("");
     isCorrect = false;
     if (firstWrong) {
       Toast.makeText(ViewerActivity.this, "Touch photo for another try!", Toast.LENGTH_SHORT)
           .show();
       firstWrong = false;
     }
   }
   LinearLayout ll = (LinearLayout) findViewById(R.id.viewer_controlsFrame);
   ll.setVisibility(View.VISIBLE);
   Log.d(TAG, "Wrong");
 }
  private void nextPhoto() {
    isCorrect = false;
    giveUp = false;
    if (assetIndex < assetPaths.length) {
      TextView counter = (TextView) findViewById(R.id.viewer_picture_counter);
      counter.setText((assetIndex + 1) + "/" + assetPaths.length);

      LinearLayout ll = (LinearLayout) findViewById(R.id.viewer_controlsFrame);
      ll.setVisibility(View.INVISIBLE);
      ImageView photoView = (ImageView) findViewById(R.id.viewer_imageView);

      InputStream iStream = null;
      try {
        Log.d(TAG, "Index: " + assetIndex);
        Log.d(TAG, "Next Asset: " + assetPaths[assetIndex]);
        iStream = ViewerActivity.this.getAssets().open(assetPaths[assetIndex]);

        bitmapImage = AssetManagement.drawNextPhoto(iStream, 500, 500);

        photoView.setImageBitmap(bitmapImage);
        photoView.setOnTouchListener(
            new OnTouchListener() {
              @Override
              public boolean onTouch(View arg0, MotionEvent arg1) {
                if (!isCorrect && !giveUp) {
                  photoNameInputAlert();
                }
                return false;
              }
            });
      } catch (IOException e) {
        Log.d(TAG, "Exception Was Thrown.");
        Log.d(TAG, e.toString());
      }
    } else {
      Intent intent = new Intent(ViewerActivity.this, ScoreActivity.class);
      intent.putExtra(MainActivity.NAME_THAT_CORRECT, correctCount);
      intent.putExtra(MainActivity.NAME_THAT_WRONG, wrongCount);
      intent.putExtra(MainActivity.NAME_THAT_WRONG_PHOTOS, wrongAnswers);
      startActivity(intent);
      finish();
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewer);

    SharedPreferences settings = getSharedPreferences(MainActivity.NAME_THAT_PREFS, MODE_PRIVATE);
    _firstUse = settings.getBoolean(VIEWER_FIRST_USE, true);
    wrongAnswers = new ArrayList<String>(); // Initialize the wrongAnswer array

    // Get All photos and put them into AssetPaths
    try {
      assetPaths = AssetManagement.getShuffledAssetPhotos(this);
      for (String name : assetPaths) {
        System.out.println(name);
      }
    } catch (IOException e) {
      Log.d(TAG, e.toString());
    }

    nextPhoto(); // Get the first photo

    if (_firstUse) {
      touchInfoAlert();
    }

    final Button nextButton = (Button) findViewById(R.id.viewer_next_button);
    nextButton.setOnClickListener(
        new Button.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            // updates the counters
            if (isCorrect) {
              correctCount++;
            } else {
              Log.d(TAG, "AssetIndex: " + assetIndex);
              wrongAnswers.add(assetPaths[assetIndex]);
              wrongCount++;
            }
            assetIndex++;
            // Gets the next photo
            nextPhoto();
            // Sets the counters on the top of the screen
            TextView memorized = (TextView) findViewById(R.id.viewer_memorized);
            memorized.setText("" + correctCount);
            TextView wrong = (TextView) findViewById(R.id.viewer_wrong);
            wrong.setText("" + wrongCount);
            Log.d(TAG, "Next Memorized. PhotoIndex=" + assetIndex);

            if (_firstUse) {
              statInfoAlert();
            }
          }
        });

    final Button showMeButton = (Button) findViewById(R.id.viewer_answer_button);
    showMeButton.setOnClickListener(
        new Button.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            giveUp = true;
            TextView tv = (TextView) findViewById(R.id.viewer_photoName);
            tv.setText(AssetManagement.getPhotoName(assetPaths[assetIndex]));
          }
        });
  }