fix(autojs): screen request activity memory leak

fix(autojs): idStartsWith not working
This commit is contained in:
hyb1996
2018-04-25 15:53:04 +08:00
parent c488e9ccbb
commit 55f2e7b20a
15 changed files with 129 additions and 103 deletions

View File

@@ -19,28 +19,6 @@ public class IntentExtras implements Serializable {
private static AtomicInteger mMaxId = new AtomicInteger(-1);
private static SparseArray<Map<String, Object>> extraStore = new SparseArray<>();
public static IntentExtras newExtras() {
return new IntentExtras();
}
public static IntentExtras fromIntent(Intent intent) {
int id = intent.getIntExtra(EXTRA_ID, -1);
if (id < 0) {
return null;
}
return fromId(id);
}
public static IntentExtras fromId(int id) {
Map<String, Object> map = extraStore.get(id);
if (map == null) {
return null;
}
extraStore.remove(id);
return new IntentExtras(id, map);
}
private Map<String, Object> mMap;
private int mId;
@@ -56,6 +34,46 @@ public class IntentExtras implements Serializable {
mMap = map;
}
public static IntentExtras newExtras() {
return new IntentExtras();
}
public static IntentExtras fromIntentAndRelease(Intent intent) {
int id = intent.getIntExtra(EXTRA_ID, -1);
if (id < 0) {
return null;
}
return fromIdAndRelease(id);
}
public static IntentExtras fromIdAndRelease(int id) {
Map<String, Object> map = extraStore.get(id);
if (map == null) {
return null;
}
extraStore.remove(id);
return new IntentExtras(id, map);
}
public static IntentExtras fromId(int id) {
Map<String, Object> map = extraStore.get(id);
if (map == null) {
return null;
}
return new IntentExtras(id, map);
}
public static IntentExtras fromIntent(Intent intent) {
int id = intent.getIntExtra(EXTRA_ID, -1);
if (id < 0) {
return null;
}
return fromId(id);
}
public int getId() {
return mId;
}
@@ -80,5 +98,10 @@ public class IntentExtras implements Serializable {
return intent;
}
public void release() {
extraStore.remove(mId);
mId = -1;
}
}