/**
  * starts the mode that was selected
  *
  * @param mode mode to start
  */
 private void startGame(GameModeEnum mode) {
   Intent i;
   if (mode.equals(GameModeEnum.weekly)) {
     // updateWeeklyPuzzle();
     SudroidDatabaseHelper helper = new SudroidDatabaseHelper(this);
     SQLiteDatabase db = helper.getReadableDatabase();
     Cursor cursor =
         db.query(
             "Weekly",
             new String[] {"_id", "place"},
             "place != null or place != 0",
             null,
             null,
             null,
             null);
     if (cursor.moveToNext()) {
       int id = cursor.getInt(0);
       db.query("Puzzle", new String[] {"_id", "time"}, "_id = " + id, null, null, null, null);
       if (cursor.moveToNext()) {
         i = new Intent(this, SudroidHighScoreActivity.class);
         i.putExtra(SudroidHighScoreActivity.finishTime, cursor.getString(1));
         i.putExtra("week", true);
         startActivity(i);
       }
     }
   }
   i = new Intent(this, SudroidGameActivity.class);
   i.putExtra(SudroidGameActivity.mode, mode.ordinal());
   startActivity(i);
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // add main display
    setContentView(R.layout.main);

    // if easy id was selected, start game in easy mode
    findViewById(R.id.easy)
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                startGame(GameModeEnum.easy);
              }
            });

    // if medium id was selected, start game in medium mode
    findViewById(R.id.medium)
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                startGame(GameModeEnum.medium);
              }
            });

    // if hard id was selected, start game in hard mode
    findViewById(R.id.hard)
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                startGame(GameModeEnum.hard);
              }
            });

    // if weekly puzzle id was selected, start game in weekly puzzle mode.
    // feature for later update, comment out since its not needed now.
    /*findViewById(R.id.weekPuzzle).setOnClickListener(
            new OnClickListener() {
        public void onClick(View v) {
            startGame(GameModeEnum.weekly);
        }
    });*/

    // if resume id was selected, resume last game
    findViewById(R.id.resume)
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                startGame(GameModeEnum.resume);
              }
            });

    SudroidDatabaseHelper helper = new SudroidDatabaseHelper(this);
    SQLiteDatabase db = helper.getReadableDatabase();
    Cursor cursor = db.query("Current", new String[] {"_id"}, null, null, null, null, null);
    if (cursor.moveToNext()) {
      findViewById(R.id.resume).setEnabled(true);
    } else {
      findViewById(R.id.resume).setEnabled(false);
    }
    db.close();
  }