Avoid toggling multi-select mode if long press on card art

Avoid toggling checkbox if user taps on card art
This commit is contained in:
drdev
2016-04-08 15:59:26 +00:00
parent e20ddea9c9
commit d23e016850
3 changed files with 31 additions and 23 deletions

View File

@@ -79,6 +79,9 @@ public class CardManager extends ItemManager<PaperCard> {
@Override
public boolean longPress(Integer index, Entry<PaperCard, Integer> value, float x, float y) {
if (CardRenderer.cardListItemTap(model.getOrderedList(), index, CardManager.this, x, y, 1, compactModeHandler.isCompactMode())) {
return true; //avoid calling onCardLongPress if user long presses on card art
}
onCardLongPress(index, value, x, y);
return true;
}

View File

@@ -100,6 +100,9 @@ public class SpellShopManager extends ItemManager<InventoryItem> {
@Override
public boolean longPress(Integer index, Entry<InventoryItem, Integer> value, float x, float y) {
if (value.getKey() instanceof PaperCard && CardRenderer.cardListItemTap(model.getOrderedList(), index, SpellShopManager.this, x, y, 1, compactModeHandler.isCompactMode())) {
return true; //avoid calling toggleMultiSelectMode if user long presses on card art
}
toggleMultiSelectMode(index);
return true;
}

View File

@@ -200,7 +200,9 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
@Override
public boolean tap(Integer index, Entry<T, Integer> value, float x, float y, int count) {
if (maxSelections > 1) {
if (maxSelections > 1) { //if multi-select
//don't toggle checkbox if renderer handles tap
if (!renderer.tap(index, value, x, y, count)) {
if (selectedIndices.contains(index)) {
//allow removing selection if it won't fall below min
//or if max selected (since you need to be able to deselect an item before selecting a new item)
@@ -215,14 +217,12 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
onSelectionChange();
}
}
else {
}
else { //if single-select
setSelectedIndex(index);
}
if (renderer.tap(index, value, x, y, count)) {
prevTapIndex = index;
return true; //don't activate if renderer handles tap
}
if (maxSelections <= 1) {
//don't activate if renderer handles tap
if (!renderer.tap(index, value, x, y, count)) {
if (count == 1) {
itemManager.showMenu(false);
}
@@ -230,6 +230,8 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
itemManager.activateSelectedItems();
}
}
}
prevTapIndex = index;
return true;
}