mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Make scrolling very smooth again
This commit is contained in:
@@ -21,7 +21,6 @@ package org.isoron.uhabits.activities.habits.list.views;
|
||||
|
||||
import android.annotation.*;
|
||||
import android.content.*;
|
||||
import android.graphics.*;
|
||||
import android.graphics.drawable.*;
|
||||
import android.os.*;
|
||||
import android.support.annotation.*;
|
||||
@@ -78,7 +77,7 @@ public class HabitCardView extends FrameLayout
|
||||
@Override
|
||||
public void onModelChange()
|
||||
{
|
||||
postInvalidate();
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void setCheckmarkValues(int checkmarks[])
|
||||
@@ -100,11 +99,21 @@ public class HabitCardView extends FrameLayout
|
||||
|
||||
this.habit = habit;
|
||||
checkmarkPanel.setHabit(habit);
|
||||
refresh();
|
||||
|
||||
attachToHabit();
|
||||
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)
|
||||
{
|
||||
float percentage = (float) score / Score.MAX_VALUE;
|
||||
@@ -144,21 +153,6 @@ public class HabitCardView extends FrameLayout
|
||||
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()
|
||||
{
|
||||
if (habit != null) habit.getObservable().addListener(this);
|
||||
@@ -183,8 +177,6 @@ public class HabitCardView extends FrameLayout
|
||||
inflate(context, R.layout.list_habits_card, this);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
setWillNotDraw(false);
|
||||
|
||||
innerFrame.setOnTouchListener((v, event) -> {
|
||||
if (SDK_INT >= LOLLIPOP)
|
||||
v.getBackground().setHotspot(event.getX(), event.getY());
|
||||
|
||||
@@ -78,13 +78,6 @@ public class HeaderView extends LinearLayout
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
||||
{
|
||||
createButtons();
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
private void createButtons()
|
||||
{
|
||||
int layout = R.layout.list_habits_header_checkmark;
|
||||
|
||||
@@ -33,6 +33,8 @@ public class Preferences
|
||||
|
||||
private SharedPreferences prefs;
|
||||
|
||||
private Boolean shouldReverseCheckmarks = null;
|
||||
|
||||
@Inject
|
||||
public Preferences(@AppContext Context context)
|
||||
{
|
||||
@@ -134,17 +136,21 @@ public class Preferences
|
||||
prefs.edit().putInt("pref_default_habit_palette_color", color).apply();
|
||||
}
|
||||
|
||||
public void setShouldReverseCheckmarks(boolean shouldReverse)
|
||||
public void setShouldReverseCheckmarks(boolean reverse)
|
||||
{
|
||||
shouldReverseCheckmarks = null;
|
||||
prefs
|
||||
.edit()
|
||||
.putBoolean("pref_checkmark_reverse_order", shouldReverse)
|
||||
.putBoolean("pref_checkmark_reverse_order", reverse)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public boolean shouldReverseCheckmarks()
|
||||
{
|
||||
return prefs.getBoolean("pref_checkmark_reverse_order", false);
|
||||
if (shouldReverseCheckmarks == null) shouldReverseCheckmarks =
|
||||
prefs.getBoolean("pref_checkmark_reverse_order", false);
|
||||
|
||||
return shouldReverseCheckmarks;
|
||||
}
|
||||
|
||||
public void updateLastAppVersion()
|
||||
|
||||
Reference in New Issue
Block a user