Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Solved an error with dates sorting
  • Loading branch information
Javinator9889 committed Jul 2, 2020
1 parent ea713e1 commit 9999898
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Expand Up @@ -123,6 +123,7 @@ class DiseasesFragment : BaseFragmentView(), LayoutVisibilityChange,
countChart.notifyDataSetChanged()
countChart.fitScreen()
countChart.moveViewToX(0F)
countChart.setVisibleXRangeMaximum(7F)
countChart.invalidate()
val todayAmount =
handwashingViewModel.getAsync(CalendarUtils.today.time)
Expand Down Expand Up @@ -195,6 +196,9 @@ class DiseasesFragment : BaseFragmentView(), LayoutVisibilityChange,
)
)
handwashingViewModel.increment(CalendarUtils.today.time)
Timber.d("${CalendarUtils.lastWeek.time}")
Timber.d("${CalendarUtils.lastMonth.time}")
handwashingViewModel.create(Handwashing(CalendarUtils.lastWeek.time, 12))
leaves.visibility = View.VISIBLE
if (!leaves.isAnimating)
leaves.playAnimation()
Expand All @@ -211,6 +215,7 @@ class DiseasesFragment : BaseFragmentView(), LayoutVisibilityChange,
)
)
handwashingViewModel.decrement(CalendarUtils.today.time)
handwashingViewModel.create(Handwashing(CalendarUtils.lastMonth.time, 123))
}
}
}
Expand Down
Expand Up @@ -32,25 +32,27 @@ object CalendarUtils {
}

val lastWeek: Calendar
get() = with(today) {
today.add(Calendar.DAY_OF_YEAR, -7)
today
get() {
val aWeekAgo = today
aWeekAgo.add(Calendar.DAY_OF_MONTH, -7)
return aWeekAgo
}

val lastMonth: Calendar
get() = with(today) {
today.add(Calendar.MONTH, -1)
today
get() {
val aMonthAgo = today
aMonthAgo.add(Calendar.MONTH, -1)
return aMonthAgo
}

fun timeBetweenIn(
unit: TimeUnit,
to: Long,
from: Long = Calendar.getInstance().timeInMillis
from: Long = today.timeInMillis
): Long = unit.convert(timeBetween(to, from), TimeUnit.MILLISECONDS)

fun timeBetween(
to: Long,
from: Long = Calendar.getInstance().timeInMillis
from: Long = today.timeInMillis
): Long = from - to
}

0 comments on commit 9999898

Please sign in to comment.