Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复小时数大于100时显示异常 #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
修复小时数大于100时显示异常
原因:updateShow时仅判断mDay的长度,没有判断mHour的值
解决方案:参考mDay方案来修改mHour的长度
验证建议:
  • Loading branch information
Cammmmer committed Dec 11, 2020
commit c490901c7f96506cee3283ec51803b150ea18b4c
16 changes: 16 additions & 0 deletions library/src/main/java/cn/iwgang/countdownview/BaseCountdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class BaseCountdown {
protected String mSuffix, mSuffixDay, mSuffixHour, mSuffixMinute, mSuffixSecond, mSuffixMillisecond;
protected float mSuffixDayTextWidth, mSuffixHourTextWidth, mSuffixMinuteTextWidth, mSuffixSecondTextWidth, mSuffixMillisecondTextWidth;
protected boolean isDayLargeNinetyNine;
protected boolean isHourLargeNinetyNine;
protected Paint mTimeTextPaint, mSuffixTextPaint, mMeasureHourWidthPaint;
protected float mLeftPaddingSize;
protected float mSuffixDayLeftMargin, mSuffixDayRightMargin;
Expand Down Expand Up @@ -730,6 +731,21 @@ public boolean handlerDayLargeNinetyNine() {
return isReLayout;
}

public boolean handlerHourLargeNinetyNine() {
boolean isReLayout = false;
if (isShowHour && isConvertDaysToHours) {
// handler large ninety nine
if (!isHourLargeNinetyNine && mHour > 99) {
isHourLargeNinetyNine = true;
isReLayout = true;
} else if (isHourLargeNinetyNine && mHour <= 99) {
isHourLargeNinetyNine = false;
isReLayout = true;
}
}
return isReLayout;
}

public void setTimes(int day, int hour, int minute, int second, int millisecond) {
mDay = day;
mHour = hour;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ public void updateShow(long ms) {
}
}

if (mCountdown.handlerAutoShowTime() || mCountdown.handlerDayLargeNinetyNine()) {
if (mCountdown.handlerAutoShowTime() || mCountdown.handlerDayLargeNinetyNine()
|| mCountdown.handlerHourLargeNinetyNine()) {
reLayout();
} else {
invalidate();
Expand Down