Commit f58da8ec authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Use drag region to calculate dragview center

parent f6bd7feb
Pipeline #135078 passed with stage
in 10 minutes and 35 seconds
......@@ -1391,7 +1391,6 @@ class TestActivity : BaseDraggingActivity(), AutoCompleteAdapter.OnSuggestionCli
})
animator = workspaceAnim
} else {
val finalProgressOpposite = finalProgress - 1
val workspaceAnim = ValueAnimator.ofFloat(currentProgress, finalProgress)
workspaceAnim.addUpdateListener {
workspace.onOverlayScrollChanged(it.animatedValue as Float)
......
......@@ -94,18 +94,17 @@ public interface DropTarget {
public final float[] getVisualCenter(float[] recycle) {
final float res[] = (recycle == null) ? new float[2] : recycle;
Rect dragRegion = dragView.getDragRegion();
// These represent the visual top and left of drag view if a dragRect was provided.
// If a dragRect was not provided, then they correspond to the actual view left and
// top, as the dragRect is in that case taken to be the entire dragView.
// R.dimen.dragViewOffsetY.
Log.d("DropTarget", "X: "+x+", Y: "+y+", xoffset: "+xOffset+", yoffset: "+yOffset);
int left = x - xOffset;
int top = y - yOffset;
int left = x - xOffset - dragRegion.left;
int top = y - yOffset - dragRegion.top;
// In order to find the visual center, we shift by half the dragRect
res[0] = left + dragView.getWidth() / 2;
res[1] = top + dragView.getHeight() / 2;
res[0] = left + dragRegion.width() / 2;
res[1] = top + dragRegion.height() / 2;
return res;
}
......
......@@ -154,13 +154,10 @@ public class DragPreviewProvider {
public float getScaleAndPosition(Bitmap preview, int[] outPos) {
float scale = TestActivity.Companion.getLauncher(mView.getContext())
.getDragLayer().getLocationInDragLayer(mView, outPos);
Log.i("DragPreview", "getScaleAndPosition: "+outPos[0]+" "+outPos[1]+" "+preview.getWidth()+" "+mView.getWidth());
outPos[0] = Math.round(outPos[0] -
(preview.getWidth() - scale * mView.getWidth() * mView.getScaleX()) / 2);
outPos[1] = Math.round(outPos[1] - (1 - scale) * preview.getHeight() / 2
- previewPadding / 2);
Log.i("DragPreview", "getScaleAndPosition: "+outPos[0]+" "+outPos[1] + " "+scale);
return scale;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment