|
|
@ -21,7 +21,6 @@ package org.isoron.uhabits.activities.habits.list.views;
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.*;
|
|
|
|
import android.annotation.*;
|
|
|
|
import android.content.*;
|
|
|
|
import android.content.*;
|
|
|
|
import android.graphics.*;
|
|
|
|
|
|
|
|
import android.graphics.drawable.*;
|
|
|
|
import android.graphics.drawable.*;
|
|
|
|
import android.os.*;
|
|
|
|
import android.os.*;
|
|
|
|
import android.support.annotation.*;
|
|
|
|
import android.support.annotation.*;
|
|
|
@ -78,7 +77,7 @@ public class HabitCardView extends FrameLayout
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onModelChange()
|
|
|
|
public void onModelChange()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
postInvalidate();
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setCheckmarkValues(int checkmarks[])
|
|
|
|
public void setCheckmarkValues(int checkmarks[])
|
|
|
@ -100,11 +99,21 @@ public class HabitCardView extends FrameLayout
|
|
|
|
|
|
|
|
|
|
|
|
this.habit = habit;
|
|
|
|
this.habit = habit;
|
|
|
|
checkmarkPanel.setHabit(habit);
|
|
|
|
checkmarkPanel.setHabit(habit);
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
|
|
|
|
attachToHabit();
|
|
|
|
attachToHabit();
|
|
|
|
postInvalidate();
|
|
|
|
postInvalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refresh()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int color = getActiveColor(habit);
|
|
|
|
|
|
|
|
label.setText(habit.getName());
|
|
|
|
|
|
|
|
label.setTextColor(color);
|
|
|
|
|
|
|
|
scoreRing.setColor(color);
|
|
|
|
|
|
|
|
checkmarkPanel.setColor(color);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setScore(int score)
|
|
|
|
public void setScore(int score)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float percentage = (float) score / Score.MAX_VALUE;
|
|
|
|
float percentage = (float) score / Score.MAX_VALUE;
|
|
|
@ -144,21 +153,6 @@ public class HabitCardView extends FrameLayout
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onDraw(Canvas canvas)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (habit != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int color = getActiveColor(habit);
|
|
|
|
|
|
|
|
label.setText(habit.getName());
|
|
|
|
|
|
|
|
label.setTextColor(color);
|
|
|
|
|
|
|
|
scoreRing.setColor(color);
|
|
|
|
|
|
|
|
checkmarkPanel.setColor(color);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
super.onDraw(canvas);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void attachToHabit()
|
|
|
|
private void attachToHabit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (habit != null) habit.getObservable().addListener(this);
|
|
|
|
if (habit != null) habit.getObservable().addListener(this);
|
|
|
@ -183,8 +177,6 @@ public class HabitCardView extends FrameLayout
|
|
|
|
inflate(context, R.layout.list_habits_card, this);
|
|
|
|
inflate(context, R.layout.list_habits_card, this);
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
|
|
|
|
|
|
|
|
setWillNotDraw(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
innerFrame.setOnTouchListener((v, event) -> {
|
|
|
|
innerFrame.setOnTouchListener((v, event) -> {
|
|
|
|
if (SDK_INT >= LOLLIPOP)
|
|
|
|
if (SDK_INT >= LOLLIPOP)
|
|
|
|
v.getBackground().setHotspot(event.getX(), event.getY());
|
|
|
|
v.getBackground().setHotspot(event.getX(), event.getY());
|
|
|
|