mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Small performance changes
This commit is contained in:
@@ -138,7 +138,7 @@ public class CheckmarkButtonView extends View
|
|||||||
paint.setTextSize(res.getDimension(R.dimen.regularTextSize));
|
paint.setTextSize(res.getDimension(R.dimen.regularTextSize));
|
||||||
|
|
||||||
rect = new RectF();
|
rect = new RectF();
|
||||||
color = ColorUtils.getAndroidTestColor(0);
|
color = Color.BLACK;
|
||||||
lowContrastColor = styledRes.getColor(R.attr.lowContrastTextColor);
|
lowContrastColor = styledRes.getColor(R.attr.lowContrastTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public abstract class ScoreList implements Iterable<Score>
|
|||||||
|
|
||||||
protected ModelObservable observable;
|
protected ModelObservable observable;
|
||||||
|
|
||||||
|
protected Double todayValue = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ScoreList for the given habit.
|
* Creates a new ScoreList for the given habit.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -69,7 +71,8 @@ public abstract class ScoreList implements Iterable<Score>
|
|||||||
*/
|
*/
|
||||||
public double getTodayValue()
|
public double getTodayValue()
|
||||||
{
|
{
|
||||||
return getValue(DateUtils.getStartOfToday());
|
if(todayValue == null) todayValue = getValue(DateUtils.getStartOfToday());
|
||||||
|
return todayValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ public class MemoryScoreList extends ScoreList
|
|||||||
if (s.getTimestamp() >= timestamp) discard.add(s);
|
if (s.getTimestamp() >= timestamp) discard.add(s);
|
||||||
|
|
||||||
list.removeAll(discard);
|
list.removeAll(discard);
|
||||||
|
|
||||||
|
todayValue = null;
|
||||||
getObservable().notifyListeners();
|
getObservable().notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ public class SQLiteScoreList extends ScoreList
|
|||||||
.and("timestamp >= ?", timestamp)
|
.and("timestamp >= ?", timestamp)
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
todayValue = null;
|
||||||
getObservable().notifyListeners();
|
getObservable().notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,16 +52,16 @@ public class HabitRecord extends Model implements SQLiteRecord
|
|||||||
public String description;
|
public String description;
|
||||||
|
|
||||||
@Column(name = "freq_num")
|
@Column(name = "freq_num")
|
||||||
public Integer freqNum;
|
public int freqNum;
|
||||||
|
|
||||||
@Column(name = "freq_den")
|
@Column(name = "freq_den")
|
||||||
public Integer freqDen;
|
public int freqDen;
|
||||||
|
|
||||||
@Column(name = "color")
|
@Column(name = "color")
|
||||||
public Integer color;
|
public int color;
|
||||||
|
|
||||||
@Column(name = "position")
|
@Column(name = "position")
|
||||||
public Integer position;
|
public int position;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Column(name = "reminder_hour")
|
@Column(name = "reminder_hour")
|
||||||
@@ -71,24 +71,23 @@ public class HabitRecord extends Model implements SQLiteRecord
|
|||||||
@Column(name = "reminder_min")
|
@Column(name = "reminder_min")
|
||||||
public Integer reminderMin;
|
public Integer reminderMin;
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Column(name = "reminder_days")
|
@Column(name = "reminder_days")
|
||||||
public Integer reminderDays;
|
public int reminderDays;
|
||||||
|
|
||||||
@Column(name = "highlight")
|
@Column(name = "highlight")
|
||||||
public Integer highlight;
|
public int highlight;
|
||||||
|
|
||||||
@Column(name = "archived")
|
@Column(name = "archived")
|
||||||
public Integer archived;
|
public int archived;
|
||||||
|
|
||||||
@Column(name = "type")
|
@Column(name = "type")
|
||||||
public Integer type;
|
public int type;
|
||||||
|
|
||||||
@Column(name = "target_value")
|
@Column(name = "target_value")
|
||||||
public Double targetValue;
|
public double targetValue;
|
||||||
|
|
||||||
@Column(name = "target_type")
|
@Column(name = "target_type")
|
||||||
public Integer targetType;
|
public int targetType;
|
||||||
|
|
||||||
@Column(name = "unit")
|
@Column(name = "unit")
|
||||||
public String unit;
|
public String unit;
|
||||||
|
|||||||
@@ -95,8 +95,11 @@ public class NotificationTray
|
|||||||
(ToggleRepetitionCommand) command;
|
(ToggleRepetitionCommand) command;
|
||||||
|
|
||||||
Habit habit = toggleCmd.getHabit();
|
Habit habit = toggleCmd.getHabit();
|
||||||
if (habit.getCheckmarks().getTodayValue() != Checkmark.UNCHECKED)
|
taskRunner.execute(() ->
|
||||||
cancel(habit);
|
{
|
||||||
|
if (habit.getCheckmarks().getTodayValue() !=
|
||||||
|
Checkmark.UNCHECKED) cancel(habit);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command instanceof DeleteHabitsCommand)
|
if (command instanceof DeleteHabitsCommand)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.support.annotation.*;
|
|||||||
|
|
||||||
import org.isoron.uhabits.*;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.commands.*;
|
import org.isoron.uhabits.commands.*;
|
||||||
|
import org.isoron.uhabits.tasks.*;
|
||||||
|
|
||||||
import javax.inject.*;
|
import javax.inject.*;
|
||||||
|
|
||||||
@@ -40,15 +41,19 @@ public class WidgetUpdater implements CommandRunner.Listener
|
|||||||
@NonNull
|
@NonNull
|
||||||
private final CommandRunner commandRunner;
|
private final CommandRunner commandRunner;
|
||||||
|
|
||||||
|
private TaskRunner taskRunner;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WidgetUpdater(@NonNull @AppContext Context context,
|
public WidgetUpdater(@NonNull @AppContext Context context,
|
||||||
@NonNull CommandRunner commandRunner)
|
@NonNull CommandRunner commandRunner,
|
||||||
|
@NonNull TaskRunner taskRunner)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.commandRunner = commandRunner;
|
this.commandRunner = commandRunner;
|
||||||
|
this.taskRunner = taskRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,11 +84,14 @@ public class WidgetUpdater implements CommandRunner.Listener
|
|||||||
|
|
||||||
public void updateWidgets()
|
public void updateWidgets()
|
||||||
{
|
{
|
||||||
updateWidgets(CheckmarkWidgetProvider.class);
|
taskRunner.execute(() ->
|
||||||
updateWidgets(HistoryWidgetProvider.class);
|
{
|
||||||
updateWidgets(ScoreWidgetProvider.class);
|
updateWidgets(CheckmarkWidgetProvider.class);
|
||||||
updateWidgets(StreakWidgetProvider.class);
|
updateWidgets(HistoryWidgetProvider.class);
|
||||||
updateWidgets(FrequencyWidgetProvider.class);
|
updateWidgets(ScoreWidgetProvider.class);
|
||||||
|
updateWidgets(StreakWidgetProvider.class);
|
||||||
|
updateWidgets(FrequencyWidgetProvider.class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateWidgets(Class providerClass)
|
public void updateWidgets(Class providerClass)
|
||||||
|
|||||||
Reference in New Issue
Block a user