以下功能是Google相机应用代码的一部分。我不明白粗体陈述的逻辑。请帮忙。需要帮助来解释Google的Android相机应用代码
int seconds = intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT,0); mMaxVideoDurationInMs = 1000 *秒;
mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);
//这个函数是更新记录时间
私人无效updateRecordingTime(){ 如果(mMediaRecorderRecording!){ 回报; } long now = SystemClock.uptimeMillis(); long delta = now - mRecordingStartTime;
// Starting a minute before reaching the max duration
// limit, we'll countdown the remaining time instead.
boolean countdownRemainingTime = (mMaxVideoDurationInMs != 0
&& delta >= mMaxVideoDurationInMs - 60000);
long next_update_delay = 1000 - (delta % 1000);
long seconds;
if (countdownRemainingTime) {
**delta = Math.max(0, mMaxVideoDurationInMs - delta);
seconds = (delta + 999)/1000;**
} else {
**seconds = delta/1000; // round to nearest**
}
long minutes = seconds/60;
long hours = minutes/60;
long remainderMinutes = minutes - (hours * 60);
long remainderSeconds = seconds - (minutes * 60);
String secondsString = Long.toString(remainderSeconds);
if (secondsString.length() < 2) {
secondsString = "0" + secondsString;
}
String minutesString = Long.toString(remainderMinutes);
if (minutesString.length() < 2) {
minutesString = "0" + minutesString;
}
String text = minutesString + ":" + secondsString;
if (hours > 0) {
String hoursString = Long.toString(hours);
if (hoursString.length() < 2) {
hoursString = "0" + hoursString;
}
text = hoursString + ":" + text;
}
mRecordingTimeView.setText(text);
if (mRecordingTimeCountsDown != countdownRemainingTime) {
// Avoid setting the color on every update, do it only
// when it needs changing.
mRecordingTimeCountsDown = countdownRemainingTime;
int color = getResources().getColor(countdownRemainingTime
? R.color.recording_time_remaining_text
: R.color.recording_time_elapsed_text);
mRecordingTimeView.setTextColor(color);
}
// Work around a limitation of the T-Mobile G1: The T-Mobile
// hardware blitter can't pixel-accurately scale and clip at the
// same time, and the SurfaceFlinger doesn't attempt to work around
// this limitation. In order to avoid visual corruption we must
// manually refresh the entire surface view when changing any
// overlapping view's contents.
mVideoPreview.invalidate();
mHandler.sendEmptyMessageDelayed(
UPDATE_RECORD_TIME, next_update_delay);
}
是这些都是我指to.Thank你行。 但是,我真的不明白'三角洲'。第2行和第3行有什么区别?在第2行,ms正在下降不是吗?第3行的需求是什么? – Namratha 2010-07-07 03:59:50
我更新了答案(因为答案部分的格式更容易)。这有帮助吗? – mbafford 2010-07-07 11:59:31
布尔countdownRemainingTime =(!mMaxVideoDurationInMs = 0 && 增量> = mMaxVideoDurationInMs - 60000); 你能解释一下这条线吗? – Namratha 2010-07-08 06:18:04