Skip to content

Commit 10788ed

Browse files
author
Tsur Yohananov
committed
implememnted fonts & fixed bugs
1 parent c0e439c commit 10788ed

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

androidcountdown/src/main/java/com/tsuryo/androidcountdown/Counter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,18 @@ private void startCounting(String dateString) {
206206
}
207207
new CountDownTimer(date.getTime() - now.getTime(), 1000) {
208208
public void onTick(long millisUntilFinished) {
209+
long mMinutes = MILLISECONDS.toMinutes(millisUntilFinished);
210+
long mHours = MILLISECONDS.toHours(millisUntilFinished);
211+
209212
long days = MILLISECONDS.toDays(millisUntilFinished);
210213
long hours = days >= 1 && mMaxTimeUnit < TimeUnits.HOUR.getValue() ?
211214
MILLISECONDS.toHours(millisUntilFinished) - TimeUnit.DAYS.toHours(days) :
212215
MILLISECONDS.toHours(millisUntilFinished);
213-
long minutes = hours >= 1 && mMaxTimeUnit < TimeUnits.MINUTE.getValue() ?
216+
long minutes = mHours >= 1 && mMaxTimeUnit < TimeUnits.MINUTE.getValue() ?
214217
MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS
215218
.toMinutes(MILLISECONDS.toHours(millisUntilFinished)) :
216219
MILLISECONDS.toMinutes(millisUntilFinished);
217-
long seconds = minutes >= 1 && mMaxTimeUnit < TimeUnits.SECOND.getValue() ?
220+
long seconds = mMinutes >= 1 && mMaxTimeUnit < TimeUnits.SECOND.getValue() ?
218221
MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(
219222
MILLISECONDS.toMinutes(millisUntilFinished)) :
220223
MILLISECONDS.toSeconds(millisUntilFinished);
@@ -228,10 +231,12 @@ public void onFinish() {
228231
}
229232

230233
private void setText(long days, long hours, long minutes, long seconds) {
231-
if (days == 0) {
234+
if (days == 0 && mMaxTimeUnit >
235+
TimeUnits.DAY.getValue()) {
232236
mTvDay.setVisibility(GONE);
233237
}
234-
if (hours == 0) {
238+
if (hours == 0 && mMaxTimeUnit >
239+
TimeUnits.HOUR.getValue()) {
235240
mTvHour.setVisibility(GONE);
236241
}
237242
if (mIsShowingTextDesc) {

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
app:layout_constraintLeft_toLeftOf="parent"
1616
app:layout_constraintRight_toRightOf="parent"
1717
app:layout_constraintTop_toTopOf="parent"
18-
app:max_time_unit="DAY"
18+
app:max_time_unit="HOUR"
1919
app:text_color="@color/colorPrimary"
2020
app:text_size="36dp" />
2121

@@ -28,7 +28,7 @@
2828
app:layout_constraintLeft_toLeftOf="parent"
2929
app:layout_constraintRight_toRightOf="parent"
3030
app:layout_constraintTop_toBottomOf="@id/counter"
31-
app:max_time_unit="HOUR"
31+
app:max_time_unit="DAY"
3232
app:text_color="@color/colorAccent"
3333
app:text_size="36dp"
3434
app:textual_description="true" />

0 commit comments

Comments
 (0)