mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
General code refactoring
> Removing utility method for isAttachedToWindow > Moving logic to calculate cell size from workspace to DeviceProfile > Replacing some constants with xml resource variables > Saving the item info using content values for better compatibility with other methods Change-Id: Idd612633d97a6241cb31148df9466031374bd5a0
This commit is contained in:
@@ -48,7 +48,6 @@ import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Choreographer;
|
||||
import android.view.Display;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -140,9 +139,6 @@ public class Workspace extends PagedView
|
||||
private int mDragOverX = -1;
|
||||
private int mDragOverY = -1;
|
||||
|
||||
private static Rect mLandscapeCellLayoutMetrics = null;
|
||||
private static Rect mPortraitCellLayoutMetrics = null;
|
||||
|
||||
CustomContentCallbacks mCustomContentCallbacks;
|
||||
boolean mCustomContentShowing;
|
||||
private float mLastCustomContentScrollProgress = -1f;
|
||||
@@ -2851,45 +2847,6 @@ public class Workspace extends PagedView
|
||||
}
|
||||
}
|
||||
|
||||
/** Return a rect that has the cellWidth/cellHeight (left, top), and
|
||||
* widthGap/heightGap (right, bottom) */
|
||||
static Rect getCellLayoutMetrics(Launcher launcher, int orientation) {
|
||||
LauncherAppState app = LauncherAppState.getInstance();
|
||||
InvariantDeviceProfile inv = app.getInvariantDeviceProfile();
|
||||
|
||||
Display display = launcher.getWindowManager().getDefaultDisplay();
|
||||
Point smallestSize = new Point();
|
||||
Point largestSize = new Point();
|
||||
display.getCurrentSizeRange(smallestSize, largestSize);
|
||||
int countX = (int) inv.numColumns;
|
||||
int countY = (int) inv.numRows;
|
||||
boolean isLayoutRtl = Utilities.isRtl(launcher.getResources());
|
||||
if (orientation == CellLayout.LANDSCAPE) {
|
||||
if (mLandscapeCellLayoutMetrics == null) {
|
||||
Rect padding = inv.landscapeProfile.getWorkspacePadding(isLayoutRtl);
|
||||
int width = largestSize.x - padding.left - padding.right;
|
||||
int height = smallestSize.y - padding.top - padding.bottom;
|
||||
mLandscapeCellLayoutMetrics = new Rect();
|
||||
mLandscapeCellLayoutMetrics.set(
|
||||
DeviceProfile.calculateCellWidth(width, countX),
|
||||
DeviceProfile.calculateCellHeight(height, countY), 0, 0);
|
||||
}
|
||||
return mLandscapeCellLayoutMetrics;
|
||||
} else if (orientation == CellLayout.PORTRAIT) {
|
||||
if (mPortraitCellLayoutMetrics == null) {
|
||||
Rect padding = inv.portraitProfile.getWorkspacePadding(isLayoutRtl);
|
||||
int width = smallestSize.x - padding.left - padding.right;
|
||||
int height = largestSize.y - padding.top - padding.bottom;
|
||||
mPortraitCellLayoutMetrics = new Rect();
|
||||
mPortraitCellLayoutMetrics.set(
|
||||
DeviceProfile.calculateCellWidth(width, countX),
|
||||
DeviceProfile.calculateCellHeight(height, countY), 0, 0);
|
||||
}
|
||||
return mPortraitCellLayoutMetrics;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragExit(DragObject d) {
|
||||
if (ENFORCE_DRAG_EVENT_ORDER) {
|
||||
|
||||
Reference in New Issue
Block a user