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.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());
|
||||||
|
|||||||
@@ -78,13 +78,6 @@ public class HeaderView extends LinearLayout
|
|||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
|
||||||
{
|
|
||||||
createButtons();
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createButtons()
|
private void createButtons()
|
||||||
{
|
{
|
||||||
int layout = R.layout.list_habits_header_checkmark;
|
int layout = R.layout.list_habits_header_checkmark;
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class Preferences
|
|||||||
|
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
|
private Boolean shouldReverseCheckmarks = null;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Preferences(@AppContext Context context)
|
public Preferences(@AppContext Context context)
|
||||||
{
|
{
|
||||||
@@ -134,17 +136,21 @@ public class Preferences
|
|||||||
prefs.edit().putInt("pref_default_habit_palette_color", color).apply();
|
prefs.edit().putInt("pref_default_habit_palette_color", color).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShouldReverseCheckmarks(boolean shouldReverse)
|
public void setShouldReverseCheckmarks(boolean reverse)
|
||||||
{
|
{
|
||||||
|
shouldReverseCheckmarks = null;
|
||||||
prefs
|
prefs
|
||||||
.edit()
|
.edit()
|
||||||
.putBoolean("pref_checkmark_reverse_order", shouldReverse)
|
.putBoolean("pref_checkmark_reverse_order", reverse)
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldReverseCheckmarks()
|
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()
|
public void updateLastAppVersion()
|
||||||
|
|||||||
Reference in New Issue
Block a user