|
|
@ -50,8 +50,10 @@ public class ScoreCard extends HabitCard
|
|
|
|
|
|
|
|
|
|
|
|
private int bucketSize;
|
|
|
|
private int bucketSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private TaskRunner taskRunner;
|
|
|
|
private TaskRunner taskRunner;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private Preferences prefs;
|
|
|
|
private Preferences prefs;
|
|
|
|
|
|
|
|
|
|
|
|
public ScoreCard(Context context)
|
|
|
|
public ScoreCard(Context context)
|
|
|
@ -93,21 +95,25 @@ public class ScoreCard extends HabitCard
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void refreshData()
|
|
|
|
protected void refreshData()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if(taskRunner == null) return;
|
|
|
|
taskRunner.execute(new RefreshTask());
|
|
|
|
taskRunner.execute(new RefreshTask());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int getDefaultSpinnerPosition()
|
|
|
|
private int getDefaultSpinnerPosition()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isInEditMode()) return 0;
|
|
|
|
if(prefs == null) return 0;
|
|
|
|
return prefs.getDefaultScoreSpinnerPosition();
|
|
|
|
return prefs.getDefaultScoreSpinnerPosition();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void init()
|
|
|
|
private void init()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HabitsApplication app =
|
|
|
|
Context appContext = getContext().getApplicationContext();
|
|
|
|
(HabitsApplication) getContext().getApplicationContext();
|
|
|
|
if (appContext instanceof HabitsApplication)
|
|
|
|
taskRunner = app.getComponent().getTaskRunner();
|
|
|
|
{
|
|
|
|
prefs = app.getComponent().getPreferences();
|
|
|
|
HabitsApplication app = (HabitsApplication) appContext;
|
|
|
|
|
|
|
|
taskRunner = app.getComponent().getTaskRunner();
|
|
|
|
|
|
|
|
prefs = app.getComponent().getPreferences();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inflate(getContext(), R.layout.show_habit_score, this);
|
|
|
|
inflate(getContext(), R.layout.show_habit_score, this);
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
ButterKnife.bind(this);
|
|
|
@ -127,8 +133,7 @@ public class ScoreCard extends HabitCard
|
|
|
|
|
|
|
|
|
|
|
|
private void setBucketSizeFromPosition(int position)
|
|
|
|
private void setBucketSizeFromPosition(int position)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isInEditMode()) return;
|
|
|
|
if(prefs == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
prefs.setDefaultScoreSpinnerPosition(position);
|
|
|
|
prefs.setDefaultScoreSpinnerPosition(position);
|
|
|
|
bucketSize = BUCKET_SIZES[position];
|
|
|
|
bucketSize = BUCKET_SIZES[position];
|
|
|
|
}
|
|
|
|
}
|
|
|
|