mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 15:48:26 -04:00
[Custom controls] Fix another crash
This commit is contained in:
parent
644af4eaaf
commit
29f14066bd
@ -42,11 +42,44 @@ public class ActionPopupWindow extends PinnedPopupWindow implements OnClickListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getInternalId(String type, String name) {
|
private int getInternalId(String type, String name) {
|
||||||
|
/*
|
||||||
int id = Resources.getSystem().getIdentifier(name, type, "com.android.internal");
|
int id = Resources.getSystem().getIdentifier(name, type, "com.android.internal");
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
mHandleView.getContext().getResources().getIdentifier(name, type, "android");
|
mHandleView.getContext().getResources().getIdentifier(name, type, "android");
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
|
*/
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (Class perType : Class.forName("com.android.internal.R").getDeclaredClasses()) {
|
||||||
|
if (perType.getSimpleName().equals(type)) {
|
||||||
|
try {
|
||||||
|
Field f = perType.getDeclaredField(name);
|
||||||
|
f.setAccessible(true);
|
||||||
|
return (int) f.get(null);
|
||||||
|
} catch (Throwable th) {
|
||||||
|
th.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If unable to find in com.android.internal.R, go find in android.R
|
||||||
|
for (Class perType : android.R.class.getDeclaredClasses()) {
|
||||||
|
if (perType.getSimpleName().equals(type)) {
|
||||||
|
try {
|
||||||
|
Field f = perType.getDeclaredField(name);
|
||||||
|
f.setAccessible(true);
|
||||||
|
return (int) f.get(null);
|
||||||
|
} catch (Throwable th) {
|
||||||
|
th.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user