Exemplo n.º 1
0
  /**
   * Invoked when the Activity is created.
   *
   * @param savedInstanceState a Bundle containing state saved from a previous execution, or null if
   *     this is a new execution
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // tell system to use the layout defined in our XML file
    setContentView(R.layout.rsf_layout);

    // get handles to the RsfAppView from XML, and its LunarThread
    mRsfAppView = (RsfAppView) findViewById(R.id.Rsf);
    mRsfAppThread = mRsfAppView.getThread();

    // give the RsfAppView a handle to the TextView used for messages
    mRsfAppView.setTextView((TextView) findViewById(R.id.text));

    if (savedInstanceState == null) {
      // we were just launched: set up a new game
      mRsfAppThread.setState(RsfAppThread.STATE_READY);
      Log.w(this.getClass().getName(), "SIS is null");

    } else {
      // we are being restored: resume a previous game
      mRsfAppThread.restoreState(savedInstanceState);
      Log.w(this.getClass().getName(), "SIS is nonnull");
    }
  }
Exemplo n.º 2
0
 /**
  * Notification that something is about to happen, to give the Activity a chance to save state.
  *
  * @param outState a Bundle into which this Activity should save its state
  */
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   // just have the View's thread save its state into our Bundle
   super.onSaveInstanceState(outState);
   mRsfAppThread.saveState(outState);
   Log.w(this.getClass().getName(), "SIS called");
 }
Exemplo n.º 3
0
  /**
   * Invoked when the user selects an item from the Menu.
   *
   * @param item the Menu entry which was selected
   * @return true if the Menu item was legit (and we consumed it), false otherwise
   */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case MENU_START:
        mRsfAppThread.doStart();
        return true;
      case MENU_STOP:
        mRsfAppThread.setState(RsfAppThread.STATE_GAME_STOPPED, getText(R.string.message_stopped));
        return true;
      case MENU_PAUSE:
        mRsfAppThread.pause();
        return true;
      case MENU_RESUME:
        mRsfAppThread.unpause();
        return true;
      case MENU_EASY:
        mRsfAppThread.setDifficulty(RsfAppThread.DIFFICULTY_EASY);
        return true;
      case MENU_MEDIUM:
        mRsfAppThread.setDifficulty(RsfAppThread.DIFFICULTY_MEDIUM);
        return true;
      case MENU_HARD:
        mRsfAppThread.setDifficulty(RsfAppThread.DIFFICULTY_HARD);
        return true;
    }

    return false;
  }