mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Move ripple to correct place
This commit is contained in:
@@ -41,7 +41,7 @@ public class HabitCardController implements HabitCardView.Controller
|
|||||||
@Override
|
@Override
|
||||||
public void onToggle(Habit habit, long timestamp)
|
public void onToggle(Habit habit, long timestamp)
|
||||||
{
|
{
|
||||||
if (view != null) view.triggerRipple(0, 0);
|
if (view != null) view.triggerRipple(timestamp);
|
||||||
if (listener != null) listener.onToggle(habit, timestamp);
|
if (listener != null) listener.onToggle(habit, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,30 +19,25 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.ui.habits.list.views;
|
package org.isoron.uhabits.ui.habits.list.views;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.*;
|
||||||
import android.content.Context;
|
import android.content.*;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.*;
|
||||||
import android.os.Handler;
|
import android.os.*;
|
||||||
import android.util.AttributeSet;
|
import android.util.*;
|
||||||
import android.view.ViewGroup;
|
import android.view.*;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.*;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.models.Habit;
|
import org.isoron.uhabits.models.*;
|
||||||
import org.isoron.uhabits.models.Score;
|
|
||||||
import org.isoron.uhabits.ui.habits.list.*;
|
import org.isoron.uhabits.ui.habits.list.*;
|
||||||
import org.isoron.uhabits.ui.habits.show.views.RingView;
|
import org.isoron.uhabits.ui.habits.show.views.*;
|
||||||
import org.isoron.uhabits.utils.ColorUtils;
|
import org.isoron.uhabits.utils.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.*;
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
import static org.isoron.uhabits.utils.InterfaceUtils.getStyledColor;
|
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||||
import static org.isoron.uhabits.utils.InterfaceUtils.getStyledDrawable;
|
|
||||||
|
|
||||||
public class HabitCardView extends FrameLayout
|
public class HabitCardView extends FrameLayout
|
||||||
{
|
{
|
||||||
@@ -125,14 +120,16 @@ public class HabitCardView extends FrameLayout
|
|||||||
updateBackground(isSelected);
|
updateBackground(isSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void triggerRipple(final float x, final float y)
|
public void triggerRipple(long timestamp)
|
||||||
{
|
{
|
||||||
final Drawable background = innerFrame.getBackground();
|
long today = DateUtils.getStartOfToday();
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) background.setHotspot(x, y);
|
long day = DateUtils.millisecondsInOneDay;
|
||||||
background.setState(new int[]{
|
int offset = (int) ((today - timestamp) / day);
|
||||||
android.R.attr.state_pressed, android.R.attr.state_enabled
|
CheckmarkButtonView button = checkmarkPanel.getButton(offset);
|
||||||
});
|
|
||||||
new Handler().postDelayed(() -> background.setState(new int[]{}), 25);
|
float y = button.getHeight() / 2.0f;
|
||||||
|
float x = checkmarkPanel.getX() + button.getX() + button.getWidth() / 2;
|
||||||
|
triggerRipple(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getActiveColor(Habit habit)
|
private int getActiveColor(Habit habit)
|
||||||
@@ -193,6 +190,16 @@ public class HabitCardView extends FrameLayout
|
|||||||
checkmarkPanel.setCheckmarkValues(values);
|
checkmarkPanel.setCheckmarkValues(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void triggerRipple(final float x, final float y)
|
||||||
|
{
|
||||||
|
final Drawable background = innerFrame.getBackground();
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 21) background.setHotspot(x, y);
|
||||||
|
background.setState(new int[]{
|
||||||
|
android.R.attr.state_pressed, android.R.attr.state_enabled
|
||||||
|
});
|
||||||
|
new Handler().postDelayed(() -> background.setState(new int[]{}), 25);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateBackground(boolean isSelected)
|
private void updateBackground(boolean isSelected)
|
||||||
{
|
{
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21)
|
if (android.os.Build.VERSION.SDK_INT >= 21)
|
||||||
|
|||||||
Reference in New Issue
Block a user