|
|
@@ -73,14 +73,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onDestroy() {
|
|
|
- fixHuaweiLeak();
|
|
|
- super.onDestroy();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
protected DialogProgress dialog;
|
|
|
public boolean isShowing() {
|
|
|
return dialog != null && dialog.getAlertDialog() != null && dialog.getAlertDialog().isShowing();
|
|
|
@@ -108,39 +100,4 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //解决华为手机内存泄漏问题
|
|
|
- private static Field[] leakFields = new Field[2];
|
|
|
- private static boolean[] hasLeakFields = {true, true};
|
|
|
- private static String[] leakFieldNames = {"mLastSrvView", "mNextServedView"};
|
|
|
-
|
|
|
- private void fixHuaweiLeak() {
|
|
|
- boolean goon = false;
|
|
|
- for (boolean has : hasLeakFields) {
|
|
|
- goon = goon || has;
|
|
|
- if (goon) break;
|
|
|
- }
|
|
|
- if (!goon) return;
|
|
|
-
|
|
|
- InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
|
|
- if (imm == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < leakFieldNames.length; i++) {
|
|
|
- try {
|
|
|
- if (leakFields[i] == null) {
|
|
|
- leakFields[i] = imm.getClass().getDeclaredField(leakFieldNames[i]);
|
|
|
- }
|
|
|
- if (leakFields[i] == null) {
|
|
|
- hasLeakFields[i] = false;
|
|
|
- }
|
|
|
- if (leakFields[i] != null) {
|
|
|
- leakFields[i].setAccessible(true);
|
|
|
- leakFields[i].set(imm, null);
|
|
|
- }
|
|
|
- } catch (Throwable t) {
|
|
|
- t.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|