コード例 #1
0
  /**
   * incrementScreenOff() Use to track the time when the screen was turned off when you are off the
   * charger When successful then: KEY_ON_TIME_RECORD = 0 KEY_OFF_TIME_RECORD = now
   * KEY_TOTAL_TIME_RECORD = addition to off - on time.
   */
  public void incrementScreenOff() {

    // Only increment if you are charging, if you are not do not increment.
    if (!this.isCharging()) {

      // Get the onTime for testing
      long onTime = this.getDataLong(KEY_ON_TIME_RECORD);

      // Only increment if onTime is not 0. We only get here if we have two off or two shutdown
      // intent together, which is very unlikely
      if (onTime != 0) {

        // Put the timestamp on KEY_OFF_TIME_RECORD
        this.putDataLong(KEY_OFF_TIME_RECORD, DateTimeHandler.todayTimestamp());

        // Then get the value of the off time
        long offTime = this.getDataLong(KEY_OFF_TIME_RECORD);

        // Get the total time.
        long totalTime = this.getDataLong(KEY_TOTAL_TIME_RECORD);

        // Get the difference of the offTime and onTime and add it to the total time
        this.putDataLong(KEY_TOTAL_TIME_RECORD, totalTime + (offTime - onTime));

        // Reset the onTime
        this.putDataLong(KEY_ON_TIME_RECORD, 0);
      }
    }
  }
コード例 #2
0
  /**
   * incrementScreenOn() Use to track the time when the screen was turned on when you are off the
   * charger When successful then: KEY_ON_TIME_RECORD = now KEY_OFF_TIME_RECORD = 0
   */
  public void incrementScreenOn() {

    // Only increment if you are charging, if you are not do not increment.
    if (!this.isCharging()) {
      long onTime = this.getDataLong(KEY_ON_TIME_RECORD);

      if (onTime == 0) {

        // Set the new onTime, and reset the offTime
        this.putDataLong(KEY_ON_TIME_RECORD, DateTimeHandler.todayTimestamp());
        this.putDataLong(KEY_OFF_TIME_RECORD, 0);
      }
    }
  }
コード例 #3
0
  private void assignMatchDetail() {
    Log.d(TAG, "Assigning Match Details");
    Cursor matchDetailsCursor = matchDetailsHandler.getMatchDetails(match_ID);
    matchDetailsCursor.moveToFirst();
    if (matchDetailsCursor.getString(1).equals("true")) {
      victoryLabel.setText("Radiant Victory");
      radiantKillsBack.setImageResource(R.drawable.win);
      direKillsBack.setImageResource(R.drawable.loss);
    } else {
      victoryLabel.setText("Dire Victory");
      radiantKillsBack.setImageResource(R.drawable.loss);
      direKillsBack.setImageResource(R.drawable.win);
    }
    dateTimeHandler = new DateTimeHandler(matchDetailsCursor.getString(2));
    matchDuration.setText(dateTimeHandler.getDuration());

    assignPlayerDetails();
  }