コード例 #1
0
  private void computRemainingTime(ParadeVideoInfo mParadeVideoInfo) {
    int remainingHour;
    int remainingMinute;
    int remainingSecond;
    int year;
    int month;
    int day;
    int hour;
    int minute;
    int second;
    String startTime = mParadeVideoInfo.getStartTime();
    // 2016-08-27 15:14:00
    year = Integer.parseInt(startTime.substring(0, 4));
    month = Integer.parseInt(startTime.substring(5, 7));
    day = Integer.parseInt(startTime.substring(8, 10));
    hour = Integer.parseInt(startTime.substring(11, 13));
    minute = Integer.parseInt(startTime.substring(14, 16));
    second = Integer.parseInt(startTime.substring(17, 19));

    Time time = new Time();
    time.setToNow();
    Log.d(
        TAG,
        "remainintimeyear"
            + time.year
            + "/"
            + time.month
            + "/"
            + time.monthDay
            + "/"
            + time.hour
            + "/"
            + time.minute
            + "/"
            + time.second);
    Log.d(TAG, "remaininyear" + year + "/" + month + "/" + day + "/" + hour + "/" + minute + "/");

    if (year > time.year || month > time.month + 1 || day > time.monthDay) {
      remainingHour = 24 - time.hour + hour;
      remainingMinute = (60 - time.minute + minute) % 60;
    } else {
      remainingHour = hour - time.hour;
      if (remainingHour > 0) remainingMinute = (60 - time.minute + minute) % 60;
      else remainingMinute = minute - time.minute;
    }
    remainingSecond = 60 - time.second + second;

    remainingMinute += remainingSecond / 60;
    remainingSecond %= 60;
    mParadeVideoInfo.setRemainingTime(remainingHour, remainingMinute, remainingSecond);
  }
コード例 #2
0
 private void showRemainingTimeDialog() {
   dialog = new Dialog(getParent().getParent(), R.style.dialog);
   dialog.setContentView(R.layout.remaining_time_dialog);
   ((TextView) dialog.findViewById(R.id.user_name)).setText(mChoseParadeVideoInfo.getUserName());
   ((TextView) dialog.findViewById(R.id.remaining_timer))
       .setText(mChoseParadeVideoInfo.getRemainingTimeDigitString());
   QavsdkApplication mQavsdkApplication = (QavsdkApplication) getApplication();
   ((TextView) dialog.findViewById(R.id.praise_count))
       .setText("" + mQavsdkApplication.getMyselfUserInfo().getPraiseCount());
   ImageButton btnCloseDialog =
       (ImageButton) dialog.findViewById(R.id.close_remaining_time_dialog);
   btnCloseDialog.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View view) {
           dialog.dismiss();
         }
       });
   dialog.setCanceledOnTouchOutside(false);
   dialog.show();
 }