Skip to content

Commit 5e328a8

Browse files
committed
删除磁力连接线部分代码
1 parent eeefd74 commit 5e328a8

1 file changed

Lines changed: 0 additions & 114 deletions

File tree

app/src/main/java/com/lee/drawlayoutsample/MainActivity.java

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,6 @@ public boolean onTouch(View v, final MotionEvent event) {
654654
return false;
655655
}
656656

657-
float targetX = 0;
658-
float targetY = 0;
659-
float targetRight = 0;
660-
float targetBottom = 0;
661-
662657
switch (action) {
663658
case MotionEvent.ACTION_DOWN:
664659
fdownX = event.getX();
@@ -680,118 +675,9 @@ public boolean onTouch(View v, final MotionEvent event) {
680675
imageW = mCurrentImageView.getWidth();
681676
imageH = mCurrentImageView.getHeight();
682677

683-
targetX = mCurrentImageView.getX() - MARGER_LEFT;
684-
targetY = mCurrentImageView.getY() - MARGER_TOP;
685-
targetRight = targetX + imageW;
686-
targetBottom = targetY + imageH;
687-
// Log.d(TAG, "ACTION_MOVE " + (int) targetX + "," + (int) targetY + "," + (int) targetRight + "," + (int) targetBottom);
688678
mCurrentImageView.setBackgroundResource(android.R.color.transparent);
689679
setImageResource(mCurrentImageView, true);
690680

691-
for (int i = 0; i < mTops.size(); i++) {
692-
float consultTop = mTops.get(i);
693-
View line = mLines.get(i);
694-
ViewInfo lineInfo = (ViewInfo) line.getTag();
695-
if ((lineInfo.degree == 90 || lineInfo.degree == 270) && Math.abs(consultTop - targetBottom) <= LIMIT) { //在竖线上面
696-
int lineMiddleX = (2 * mRights.get(i) - line.getHeight()) / 2;//获取到线条的y/2
697-
if (disX >= 0) { //从左往右
698-
if (Math.abs(mLefts.get(i) - targetRight) <= OFFSET) {
699-
mCurrentImageView.setX(lineMiddleX - imageW / 2 + MARGER_LEFT);
700-
mCurrentImageView.setY(consultTop - imageH + MARGER_TOP + PADDING);
701-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
702-
Log.d(TAG, "竖线上边匹配成功 从左往右 targetBottom : " + targetBottom + ", consultTop: " + consultTop);
703-
}
704-
} else {
705-
if (Math.abs(targetX - mRights.get(i)) <= OFFSET) {
706-
mCurrentImageView.setX(lineMiddleX - imageW / 2 + MARGER_LEFT);
707-
mCurrentImageView.setY(consultTop - imageH + MARGER_TOP + PADDING);
708-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
709-
Log.d(TAG, "竖线上边匹配成功 从右往左 targetBottom : " + targetBottom + ", consultTop: " + consultTop);
710-
}
711-
}
712-
}
713-
}
714-
715-
for (int i = 0; i < mBottoms.size(); i++) {
716-
float consultBottom = mBottoms.get(i);
717-
View line = mLines.get(i);
718-
ViewInfo lineInfo = (ViewInfo) line.getTag();
719-
if ((lineInfo.degree == 90 || lineInfo.degree == 270) && Math.abs(targetY - consultBottom) <= LIMIT) {
720-
int lineMiddleX = (2 * mRights.get(i) - line.getHeight()) / 2;//获取到线条的y/2
721-
722-
if (disX >= 0) { //从左往右
723-
if (Math.abs(mLefts.get(i) - targetRight) <= OFFSET) {
724-
mCurrentImageView.setX(lineMiddleX - imageW / 2 + MARGER_LEFT);
725-
mCurrentImageView.setY(consultBottom + MARGER_TOP - PADDING);
726-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
727-
Log.i(TAG, "竖线下边匹配成功 从左往右 targetY : " + targetY + ", consultBottom : " + consultBottom);
728-
}
729-
} else {
730-
if (Math.abs(targetX - mRights.get(i)) <= OFFSET) {
731-
mCurrentImageView.setX(lineMiddleX - imageW / 2 + MARGER_LEFT);
732-
mCurrentImageView.setY(consultBottom + MARGER_TOP - PADDING);
733-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
734-
Log.i(TAG, "竖线下边匹配成功 从右往左 targetY : " + targetY + ", consultBottom : " + consultBottom);
735-
}
736-
737-
}
738-
739-
}
740-
}
741-
742-
for (int i = 0; i < mLefts.size(); i++) {
743-
float consultLeft = mLefts.get(i);
744-
View line = mLines.get(i);
745-
ViewInfo lineInfo = (ViewInfo) line.getTag();
746-
if ((lineInfo.degree == 0 || lineInfo.degree == 180) && Math.abs(consultLeft - targetRight) <= LIMIT) {
747-
int lineMiddleY = (2 * mBottoms.get(i) - line.getHeight()) / 2;//获取到线条的y/2
748-
int newY = lineMiddleY - imageH / 2;
749-
Log.d(TAG, "lineMiddleY : " + lineMiddleY + ", newY: " + newY);
750-
751-
if (disY >= 0) { //从上到下
752-
if (Math.abs(mTops.get(i) - targetBottom) <= OFFSET) {
753-
mCurrentImageView.setX(consultLeft - imageW + MARGER_LEFT + PADDING);
754-
mCurrentImageView.setY(newY + MARGER_TOP);
755-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
756-
Log.d(TAG, "横线左边匹配成功 从上往下 targetRight : " + targetRight + " , consultLeft: " + consultLeft);
757-
}
758-
} else {
759-
if (Math.abs(targetY - mBottoms.get(i)) <= OFFSET) {
760-
mCurrentImageView.setX(consultLeft - imageW + MARGER_LEFT + PADDING);
761-
mCurrentImageView.setY(newY + MARGER_TOP);
762-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
763-
Log.d(TAG, "横线左边匹配成功 从下往上 targetRight : " + targetRight + " , consultLeft: " + consultLeft);
764-
}
765-
}
766-
}
767-
}
768-
769-
for (int i = 0; i < mRights.size(); i++) {
770-
float consultRight = mRights.get(i);
771-
View line = mLines.get(i);
772-
ViewInfo lineInfo = (ViewInfo) line.getTag();
773-
if ((lineInfo.degree == 0 || lineInfo.degree == 180) && targetX - consultRight > 0 && targetX - consultRight <= LIMIT) {
774-
int lineMiddleY = (2 * mBottoms.get(i) - line.getHeight()) / 2;//获取到线条的y/2
775-
int newY = lineMiddleY - imageH / 2;
776-
Log.d(TAG, "lineMiddleY : " + lineMiddleY + ", newY: " + newY);
777-
if (disY >= 0) { //从上往下
778-
if (Math.abs(mTops.get(i) - targetBottom) <= OFFSET) {
779-
mCurrentImageView.setX(consultRight + MARGER_LEFT - PADDING);
780-
mCurrentImageView.setY(newY + MARGER_TOP);
781-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
782-
Log.d(TAG, "横线右边匹配成功 从上往下 targetX : " + targetX + " , consultRight: " + consultRight);
783-
}
784-
} else {
785-
if (Math.abs(targetY - mBottoms.get(i)) <= OFFSET) {
786-
mCurrentImageView.setX(consultRight + MARGER_LEFT - PADDING);
787-
mCurrentImageView.setY(newY + MARGER_TOP);
788-
mCurrentImageView.setBackgroundResource(R.drawable.border_shape_green);
789-
Log.d(TAG, "横线右边匹配成功 从下往上 targetX : " + targetX + " , consultRight: " + consultRight);
790-
}
791-
}
792-
}
793-
}
794-
// }
795681

796682
return true;
797683
case MotionEvent.ACTION_UP:

0 commit comments

Comments
 (0)