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));
|
||||
|
||||
rect = new RectF();
|
||||
color = ColorUtils.getAndroidTestColor(0);
|
||||
color = Color.BLACK;
|
||||
lowContrastColor = styledRes.getColor(R.attr.lowContrastTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ public abstract class ScoreList implements Iterable<Score>
|
||||
|
||||
protected ModelObservable observable;
|
||||
|
||||
protected Double todayValue = null;
|
||||
|
||||
/**
|
||||
* Creates a new ScoreList for the given habit.
|
||||
* <p>
|
||||
@@ -69,7 +71,8 @@ public abstract class ScoreList implements Iterable<Score>
|
||||
*/
|
||||
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);
|
||||
|
||||
list.removeAll(discard);
|
||||
|
||||
todayValue = null;
|
||||
getObservable().notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ public class SQLiteScoreList extends ScoreList
|
||||
.and("timestamp >= ?", timestamp)
|
||||
.execute();
|
||||
|
||||
todayValue = null;
|
||||
getObservable().notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,16 +52,16 @@ public class HabitRecord extends Model implements SQLiteRecord
|
||||
public String description;
|
||||
|
||||
@Column(name = "freq_num")
|
||||
public Integer freqNum;
|
||||
public int freqNum;
|
||||
|
||||
@Column(name = "freq_den")
|
||||
public Integer freqDen;
|
||||
public int freqDen;
|
||||
|
||||
@Column(name = "color")
|
||||
public Integer color;
|
||||
public int color;
|
||||
|
||||
@Column(name = "position")
|
||||
public Integer position;
|
||||
public int position;
|
||||
|
||||
@Nullable
|
||||
@Column(name = "reminder_hour")
|
||||
@@ -71,24 +71,23 @@ public class HabitRecord extends Model implements SQLiteRecord
|
||||
@Column(name = "reminder_min")
|
||||
public Integer reminderMin;
|
||||
|
||||
@NonNull
|
||||
@Column(name = "reminder_days")
|
||||
public Integer reminderDays;
|
||||
public int reminderDays;
|
||||
|
||||
@Column(name = "highlight")
|
||||
public Integer highlight;
|
||||
public int highlight;
|
||||
|
||||
@Column(name = "archived")
|
||||
public Integer archived;
|
||||
public int archived;
|
||||
|
||||
@Column(name = "type")
|
||||
public Integer type;
|
||||
public int type;
|
||||
|
||||
@Column(name = "target_value")
|
||||
public Double targetValue;
|
||||
public double targetValue;
|
||||
|
||||
@Column(name = "target_type")
|
||||
public Integer targetType;
|
||||
public int targetType;
|
||||
|
||||
@Column(name = "unit")
|
||||
public String unit;
|
||||
|
||||
@@ -95,8 +95,11 @@ public class NotificationTray
|
||||
(ToggleRepetitionCommand) command;
|
||||
|
||||
Habit habit = toggleCmd.getHabit();
|
||||
if (habit.getCheckmarks().getTodayValue() != Checkmark.UNCHECKED)
|
||||
cancel(habit);
|
||||
taskRunner.execute(() ->
|
||||
{
|
||||
if (habit.getCheckmarks().getTodayValue() !=
|
||||
Checkmark.UNCHECKED) cancel(habit);
|
||||
});
|
||||
}
|
||||
|
||||
if (command instanceof DeleteHabitsCommand)
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.support.annotation.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.commands.*;
|
||||
import org.isoron.uhabits.tasks.*;
|
||||
|
||||
import javax.inject.*;
|
||||
|
||||
@@ -40,15 +41,19 @@ public class WidgetUpdater implements CommandRunner.Listener
|
||||
@NonNull
|
||||
private final CommandRunner commandRunner;
|
||||
|
||||
private TaskRunner taskRunner;
|
||||
|
||||
@NonNull
|
||||
private final Context context;
|
||||
|
||||
@Inject
|
||||
public WidgetUpdater(@NonNull @AppContext Context context,
|
||||
@NonNull CommandRunner commandRunner)
|
||||
@NonNull CommandRunner commandRunner,
|
||||
@NonNull TaskRunner taskRunner)
|
||||
{
|
||||
this.context = context;
|
||||
this.commandRunner = commandRunner;
|
||||
this.taskRunner = taskRunner;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,11 +84,14 @@ public class WidgetUpdater implements CommandRunner.Listener
|
||||
|
||||
public void updateWidgets()
|
||||
{
|
||||
updateWidgets(CheckmarkWidgetProvider.class);
|
||||
updateWidgets(HistoryWidgetProvider.class);
|
||||
updateWidgets(ScoreWidgetProvider.class);
|
||||
updateWidgets(StreakWidgetProvider.class);
|
||||
updateWidgets(FrequencyWidgetProvider.class);
|
||||
taskRunner.execute(() ->
|
||||
{
|
||||
updateWidgets(CheckmarkWidgetProvider.class);
|
||||
updateWidgets(HistoryWidgetProvider.class);
|
||||
updateWidgets(ScoreWidgetProvider.class);
|
||||
updateWidgets(StreakWidgetProvider.class);
|
||||
updateWidgets(FrequencyWidgetProvider.class);
|
||||
});
|
||||
}
|
||||
|
||||
public void updateWidgets(Class providerClass)
|
||||
|
||||
Reference in New Issue
Block a user