`XC_LayoutInflated` should be comparable (#1851)

This commit is contained in:
LoveSy 2022-04-16 04:29:05 +08:00 committed by GitHub
parent b5aff15919
commit 81448c3958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -30,7 +30,7 @@ import de.robv.android.xposed.XposedBridge.CopyOnWriteSortedSet;
* Callback for hooking layouts. Such callbacks can be passed to {@link XResources#hookLayout} * Callback for hooking layouts. Such callbacks can be passed to {@link XResources#hookLayout}
* and its variants. * and its variants.
*/ */
public abstract class XC_LayoutInflated extends XCallback { public abstract class XC_LayoutInflated extends XCallback implements Comparable<XC_LayoutInflated> {
/** /**
* Creates a new callback with default priority. * Creates a new callback with default priority.
*/ */
@ -80,6 +80,22 @@ public abstract class XC_LayoutInflated extends XCallback {
public XResources res; public XResources res;
} }
/** @hide */
@Override
public int compareTo(XC_LayoutInflated other) {
if (this == other)
return 0;
// order descending by priority
if (other.priority != this.priority)
return other.priority - this.priority;
// then randomly
else if (System.identityHashCode(this) < System.identityHashCode(other))
return -1;
else
return 1;
}
/** /**
* @hide * @hide
*/ */