mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Fix ripple when days are reversed
This commit is contained in:
@@ -31,6 +31,8 @@ import org.isoron.uhabits.models.*;
|
|||||||
import org.isoron.uhabits.preferences.*;
|
import org.isoron.uhabits.preferences.*;
|
||||||
import org.isoron.uhabits.utils.*;
|
import org.isoron.uhabits.utils.*;
|
||||||
|
|
||||||
|
import static android.view.View.MeasureSpec.*;
|
||||||
|
|
||||||
public class CheckmarkPanelView extends LinearLayout
|
public class CheckmarkPanelView extends LinearLayout
|
||||||
{
|
{
|
||||||
private static final int CHECKMARK_LEFT_TO_RIGHT = 0;
|
private static final int CHECKMARK_LEFT_TO_RIGHT = 0;
|
||||||
@@ -62,8 +64,13 @@ public class CheckmarkPanelView extends LinearLayout
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckmarkButtonView getButton(int position)
|
public CheckmarkButtonView indexToButton(int i)
|
||||||
{
|
{
|
||||||
|
int position = i;
|
||||||
|
|
||||||
|
if (getCheckmarkOrder() == CHECKMARK_RIGHT_TO_LEFT)
|
||||||
|
position = nButtons - i - 1;
|
||||||
|
|
||||||
return (CheckmarkButtonView) getChildAt(position);
|
return (CheckmarkButtonView) getChildAt(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,10 +114,8 @@ public class CheckmarkPanelView extends LinearLayout
|
|||||||
|
|
||||||
float width = buttonWidth * nButtons;
|
float width = buttonWidth * nButtons;
|
||||||
|
|
||||||
widthSpec =
|
widthSpec = makeMeasureSpec((int) width, EXACTLY);
|
||||||
MeasureSpec.makeMeasureSpec((int) width, MeasureSpec.EXACTLY);
|
heightSpec = makeMeasureSpec((int) buttonHeight, EXACTLY);
|
||||||
heightSpec = MeasureSpec.makeMeasureSpec((int) buttonHeight,
|
|
||||||
MeasureSpec.EXACTLY);
|
|
||||||
|
|
||||||
super.onMeasure(widthSpec, heightSpec);
|
super.onMeasure(widthSpec, heightSpec);
|
||||||
}
|
}
|
||||||
@@ -130,16 +135,6 @@ public class CheckmarkPanelView extends LinearLayout
|
|||||||
CHECKMARK_LEFT_TO_RIGHT;
|
CHECKMARK_LEFT_TO_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckmarkButtonView indexToButton(int i)
|
|
||||||
{
|
|
||||||
int position = i;
|
|
||||||
|
|
||||||
if (getCheckmarkOrder() == CHECKMARK_RIGHT_TO_LEFT)
|
|
||||||
position = nButtons - i - 1;
|
|
||||||
|
|
||||||
return (CheckmarkButtonView) getChildAt(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
if (isInEditMode()) return;
|
if (isInEditMode()) return;
|
||||||
@@ -154,7 +149,7 @@ public class CheckmarkPanelView extends LinearLayout
|
|||||||
CheckmarkButtonView buttonView)
|
CheckmarkButtonView buttonView)
|
||||||
{
|
{
|
||||||
if (controller == null) return;
|
if (controller == null) return;
|
||||||
if(!(getContext() instanceof ListHabitsActivity)) return;
|
if (!(getContext() instanceof ListHabitsActivity)) return;
|
||||||
|
|
||||||
ListHabitsActivity activity = (ListHabitsActivity) getContext();
|
ListHabitsActivity activity = (ListHabitsActivity) getContext();
|
||||||
CheckmarkButtonControllerFactory buttonControllerFactory = activity
|
CheckmarkButtonControllerFactory buttonControllerFactory = activity
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class HabitCardView extends FrameLayout
|
|||||||
long today = DateUtils.getStartOfToday();
|
long today = DateUtils.getStartOfToday();
|
||||||
long day = DateUtils.millisecondsInOneDay;
|
long day = DateUtils.millisecondsInOneDay;
|
||||||
int offset = (int) ((today - timestamp) / day);
|
int offset = (int) ((today - timestamp) / day);
|
||||||
CheckmarkButtonView button = checkmarkPanel.getButton(offset);
|
CheckmarkButtonView button = checkmarkPanel.indexToButton(offset);
|
||||||
|
|
||||||
float y = button.getHeight() / 2.0f;
|
float y = button.getHeight() / 2.0f;
|
||||||
float x = checkmarkPanel.getX() + button.getX() + button.getWidth() / 2;
|
float x = checkmarkPanel.getX() + button.getX() + button.getWidth() / 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user