@Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.four_buzzer_record);
   Datasave data = Datasave.sharedDatasave();
   TextView Player1 = (TextView) this.findViewById(R.id.fourplayer1);
   TextView Player2 = (TextView) this.findViewById(R.id.fourplayer2);
   TextView Player3 = (TextView) this.findViewById(R.id.fourplayer3);
   TextView Player4 = (TextView) this.findViewById(R.id.fourplayer4);
   this.setString(String.format("%.0f", this.player1(data.Fourplayers1)), Player1);
   this.setString(String.format("%.0f", this.player2(data.Fourplayers2)), Player2);
   this.setString(String.format("%.0f", this.player3(data.Fourplayers3)), Player3);
   this.setString(String.format("%.0f", this.player4(data.Fourplayers4)), Player4);
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.clear) {
      Datasave.sharedDatasave().reset(this);
      Intent intent = new Intent(this, FourBuzzerRecordActivity.class);
      this.startActivity(intent);
      this.finish();
    }
    if (id == R.id.email) {
      String Statistics = "";
      Statistics +=
          "\tfour_players1_win: "
              + ((TextView) this.findViewById(R.id.fourplayer1)).getText()
              + "\n";
      Statistics +=
          "\tfour_players2_win: "
              + ((TextView) this.findViewById(R.id.fourplayer2)).getText()
              + "\n";
      Statistics +=
          "\tfour_players3_win: "
              + ((TextView) this.findViewById(R.id.fourplayer3)).getText()
              + "\n";
      Statistics +=
          "\tfour_players4_win: "
              + ((TextView) this.findViewById(R.id.fourplayer4)).getText()
              + "\n";

      Statistics += "Jiaxuan Yue\n";

      // Following function based on http://stackoverflow.com/a/2197841/393009
      Intent text = new Intent(Intent.ACTION_SENDTO);
      text.setType("message/rfc822");
      text.putExtra(Intent.EXTRA_SUBJECT, "4 buzzers");
      text.putExtra(Intent.EXTRA_TEXT, Statistics);
      text.setData(Uri.parse("mailto:[email protected]"));
      try {
        this.startActivity(Intent.createChooser(text, "Send mail..."));
      } catch (ActivityNotFoundException e) {
        Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
      }
    }

    return super.onOptionsItemSelected(item);
  }
Esempio n. 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Datasave.sharedDatasave().loadFromFile(this);

    Button btn1 = (Button) findViewById(R.id.reactionTimerButton);
    btn1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            Intent intent = new Intent(MainActivity.this, ReactionTimerActivity.class);
            startActivity(intent);
          }
        });

    Button btn2 = (Button) findViewById(R.id.gameshowBuzzerButton);
    btn2.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, NumberOfBuzzerActivity.class);
            startActivity(intent);
          }
        });

    Button btn3 = (Button) findViewById(R.id.recordButton);
    btn3.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, RecordActivity.class);
            startActivity(intent);
          }
        });
  }