![JAR search and dependency download from the Maven repository](/logo.png)
com.qa.automation.android.view.ViewLocationComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-automation-library Show documentation
Show all versions of android-automation-library Show documentation
Support android ui automaton such as identify Toast and PopupWindow for appium
package com.qa.automation.android.view;
import android.view.View;
import java.util.Comparator;
/**
* The type View location comparator.
*/
public class ViewLocationComparator implements Comparator {
private final int a[] = new int[2];
private final int b[] = new int[2];
private final int axis1, axis2;
/**
* Instantiates a new View location comparator.
*/
public ViewLocationComparator() {
this(true);
}
/**
* Instantiates a new View location comparator.
*
* @param yAxisFirst Whether the y-axis should be compared before the x-axis.
*/
public ViewLocationComparator(boolean yAxisFirst) {
this.axis1 = yAxisFirst ? 1 : 0;
this.axis2 = yAxisFirst ? 0 : 1;
}
public int compare(View lhs, View rhs) {
lhs.getLocationOnScreen(a);
rhs.getLocationOnScreen(b);
if (a[axis1] != b[axis1]) {
return a[axis1] < b[axis1] ? -1 : 1;
}
if (a[axis2] < b[axis2]) {
return -1;
}
return a[axis2] == b[axis2] ? 0 : 1;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy