mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Show bar chart with monthly totals
This commit is contained in:
@@ -140,11 +140,7 @@ public class ShowHabitRootView extends BaseRootView
|
||||
historyCard.setHabit(habit);
|
||||
streakCard.setHabit(habit);
|
||||
frequencyCard.setHabit(habit);
|
||||
|
||||
if(habit.isNumerical())
|
||||
barCard.setHabit(habit);
|
||||
else
|
||||
barCard.setVisibility(GONE);
|
||||
barCard.setHabit(habit);
|
||||
}
|
||||
|
||||
public interface Controller extends HistoryCard.Controller
|
||||
|
||||
@@ -62,7 +62,7 @@ public class BarCard extends HabitCard
|
||||
@Override
|
||||
protected void refreshData()
|
||||
{
|
||||
if(taskRunner == null) return;
|
||||
if (taskRunner == null) return;
|
||||
taskRunner.execute(new RefreshTask(getHabit()));
|
||||
}
|
||||
|
||||
@@ -93,14 +93,17 @@ public class BarCard extends HabitCard
|
||||
{
|
||||
private final Habit habit;
|
||||
|
||||
public RefreshTask(Habit habit) {this.habit = habit;}
|
||||
public RefreshTask(Habit habit)
|
||||
{
|
||||
this.habit = habit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInBackground()
|
||||
{
|
||||
Timestamp today = DateUtils.getToday();
|
||||
List<Checkmark> checkmarks =
|
||||
habit.getCheckmarks().getByInterval(Timestamp.ZERO, today);
|
||||
List<Checkmark> checkmarks = habit.getCheckmarks().groupBy(
|
||||
DateUtils.TruncateField.MONTH);
|
||||
chart.setCheckmarks(checkmarks);
|
||||
}
|
||||
|
||||
@@ -110,7 +113,10 @@ public class BarCard extends HabitCard
|
||||
int color = PaletteUtils.getColor(getContext(), habit.getColor());
|
||||
title.setTextColor(color);
|
||||
chart.setColor(color);
|
||||
chart.setTarget(habit.getTargetValue());
|
||||
if(habit.isNumerical())
|
||||
chart.setTarget(habit.getTargetValue());
|
||||
else
|
||||
chart.setTarget(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user