|
|
@ -30,6 +30,8 @@ import org.isoron.uhabits.models.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.controllers.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.controllers.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.model.*;
|
|
|
|
import org.isoron.uhabits.ui.habits.list.model.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
public class HabitCardListView extends RecyclerView
|
|
|
|
public class HabitCardListView extends RecyclerView
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@Nullable
|
|
|
|
@Nullable
|
|
|
@ -40,6 +42,8 @@ public class HabitCardListView extends RecyclerView
|
|
|
|
|
|
|
|
|
|
|
|
private final ItemTouchHelper touchHelper;
|
|
|
|
private final ItemTouchHelper touchHelper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int checkmarkCount;
|
|
|
|
|
|
|
|
|
|
|
|
public HabitCardListView(Context context, AttributeSet attrs)
|
|
|
|
public HabitCardListView(Context context, AttributeSet attrs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super(context, attrs);
|
|
|
|
super(context, attrs);
|
|
|
@ -73,10 +77,13 @@ public class HabitCardListView extends RecyclerView
|
|
|
|
boolean selected,
|
|
|
|
boolean selected,
|
|
|
|
int position)
|
|
|
|
int position)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int visibleCheckmarks[] =
|
|
|
|
|
|
|
|
Arrays.copyOfRange(checkmarks, 0, checkmarkCount);
|
|
|
|
|
|
|
|
|
|
|
|
HabitCardView cardView = (HabitCardView) holder.itemView;
|
|
|
|
HabitCardView cardView = (HabitCardView) holder.itemView;
|
|
|
|
cardView.setHabit(habit);
|
|
|
|
cardView.setHabit(habit);
|
|
|
|
cardView.setSelected(selected);
|
|
|
|
cardView.setSelected(selected);
|
|
|
|
cardView.setCheckmarkValues(checkmarks);
|
|
|
|
cardView.setCheckmarkValues(visibleCheckmarks);
|
|
|
|
cardView.setScore(score);
|
|
|
|
cardView.setScore(score);
|
|
|
|
if (controller != null) setupCardViewController(holder, position);
|
|
|
|
if (controller != null) setupCardViewController(holder, position);
|
|
|
|
return cardView;
|
|
|
|
return cardView;
|
|
|
@ -94,6 +101,11 @@ public class HabitCardListView extends RecyclerView
|
|
|
|
super.setAdapter(adapter);
|
|
|
|
super.setAdapter(adapter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setCheckmarkCount(int checkmarkCount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.checkmarkCount = checkmarkCount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setController(@Nullable Controller controller)
|
|
|
|
public void setController(@Nullable Controller controller)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.controller = controller;
|
|
|
|
this.controller = controller;
|
|
|
@ -134,8 +146,6 @@ public class HabitCardListView extends RecyclerView
|
|
|
|
public interface Controller
|
|
|
|
public interface Controller
|
|
|
|
extends CheckmarkButtonController.Listener, HabitCardController.Listener
|
|
|
|
extends CheckmarkButtonController.Listener, HabitCardController.Listener
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void drag(int from, int to);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void drop(int from, int to);
|
|
|
|
void drop(int from, int to);
|
|
|
|
|
|
|
|
|
|
|
|
void onItemClick(int pos);
|
|
|
|
void onItemClick(int pos);
|
|
|
|