Fix crash
This commit is contained in:
parent
0dc89c1148
commit
38a6d3c9c1
|
|
@ -48,8 +48,7 @@ public class Init {
|
||||||
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_LONG).show());
|
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_LONG).show());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Activity getActivity() {
|
public static Activity getActivity() throws Exception {
|
||||||
try {
|
|
||||||
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
||||||
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
||||||
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
|
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
|
||||||
|
|
@ -67,9 +66,6 @@ public class Init {
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -163,13 +163,19 @@ public class Misc {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addView(View view, ViewGroup.LayoutParams params) {
|
public static void addView(View view, ViewGroup.LayoutParams params) {
|
||||||
|
try {
|
||||||
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
group.addView(view, params);
|
group.addView(view, params);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeView(View view) {
|
public static void removeView(View view) {
|
||||||
|
try {
|
||||||
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
group.removeView(view);
|
group.removeView(view);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadWebView(String url, WebViewClient client) {
|
public static void loadWebView(String url, WebViewClient client) {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
906b337d4b4baef13292d004e5fd8f9b
|
487834a2d0d9aa7614beeba237cce0c2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue