summaryrefslogtreecommitdiff
path: root/src/com/android/launcher3/celllayout/CellPosMapper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/celllayout/CellPosMapper.java')
-rw-r--r--src/com/android/launcher3/celllayout/CellPosMapper.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/com/android/launcher3/celllayout/CellPosMapper.java b/src/com/android/launcher3/celllayout/CellPosMapper.java
index 1891696d54..b133a1d59f 100644
--- a/src/com/android/launcher3/celllayout/CellPosMapper.java
+++ b/src/com/android/launcher3/celllayout/CellPosMapper.java
@@ -17,6 +17,7 @@ package com.android.launcher3.celllayout;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
+import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.data.ItemInfo;
import java.util.Objects;
@@ -26,9 +27,14 @@ import java.util.Objects;
*/
public class CellPosMapper {
- public static final CellPosMapper DEFAULT = new CellPosMapper();
+ public static final CellPosMapper DEFAULT = new CellPosMapper(false, -1);
+ private final boolean mHasVerticalHotseat;
+ private final int mNumOfHotseat;
- private CellPosMapper() { }
+ public CellPosMapper(boolean hasVerticalHotseat, int numOfHotseat) {
+ mHasVerticalHotseat = hasVerticalHotseat;
+ mNumOfHotseat = numOfHotseat;
+ }
/**
* Maps the position in model to the position in view
@@ -42,17 +48,22 @@ public class CellPosMapper {
*/
public CellPos mapPresenterToModel(int presenterX, int presenterY, int presenterScreen,
int container) {
+ if (container == Favorites.CONTAINER_HOTSEAT) {
+ presenterScreen = mHasVerticalHotseat
+ ? mNumOfHotseat - presenterY - 1 : presenterX;
+ }
return new CellPos(presenterX, presenterY, presenterScreen);
}
/**
* Cell mapper which maps two panels into a single layout
*/
- public static class TwoPanelCellPosMapper extends CellPosMapper {
+ public static class TwoPanelCellPosMapper extends CellPosMapper {
private final int mColumnCount;
public TwoPanelCellPosMapper(int columnCount) {
+ super(false, -1);
mColumnCount = columnCount;
}
@@ -103,5 +114,13 @@ public class CellPosMapper {
public int hashCode() {
return Objects.hash(cellX, cellY, screenId);
}
+
+ @Override
+ public String toString() {
+ return "CellPos{"
+ + "cellX=" + cellX
+ + ", cellY=" + cellY
+ + ", screenId=" + screenId + '}';
+ }
}
}