修复长按环境标签不能保存部分页面快捷跳转的问题
This commit is contained in:
@ -330,38 +330,41 @@ public class EntranceUtils {
|
||||
/**
|
||||
* 将 Bundle 转为 Json
|
||||
*/
|
||||
private static JSONObject getJsonFromBundle(Bundle bundle, JSONObject json, @Nullable JSONObject bundleWrapper) {
|
||||
private static JSONObject getJsonFromBundle(Bundle bundle, JSONObject json, @Nullable JSONObject bundleWrapper) throws JSONException {
|
||||
Set<String> keys = bundle.keySet();
|
||||
|
||||
for (String key : keys) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
try {
|
||||
Object object = bundle.get(key);
|
||||
if (object instanceof Bundle) {
|
||||
json = getJsonFromBundle((Bundle) object, json, new JSONObject());
|
||||
} else if (object instanceof Parcelable) {
|
||||
String parcelableName = key + ":parcelable";
|
||||
String parcelableType = object.getClass().getName();
|
||||
String objectJsonString = GsonUtils.toJson(object);
|
||||
JSONObject jObject = null;
|
||||
jObject = new JSONObject(objectJsonString);
|
||||
Object object = bundle.get(key);
|
||||
if (object instanceof Bundle) {
|
||||
json = getJsonFromBundle((Bundle) object, json, new JSONObject());
|
||||
} else if (object instanceof Parcelable) {
|
||||
String parcelableName = key + ":parcelable";
|
||||
String parcelableType = object.getClass().getName();
|
||||
String objectJsonString = GsonUtils.toJson(object);
|
||||
JSONObject jObject = null;
|
||||
jObject = new JSONObject(objectJsonString);
|
||||
|
||||
if (bundleWrapper != null) {
|
||||
bundleWrapper.put(parcelableName, parcelableType);
|
||||
bundleWrapper.put(key, jObject);
|
||||
json.put(":bundle", bundleWrapper);
|
||||
} else {
|
||||
json.put(parcelableName, parcelableType);
|
||||
json.put(key, jObject);
|
||||
}
|
||||
if (bundleWrapper != null) {
|
||||
bundleWrapper.put(parcelableName, parcelableType);
|
||||
bundleWrapper.put(key, jObject);
|
||||
} else {
|
||||
json.put(parcelableName, parcelableType);
|
||||
json.put(key, jObject);
|
||||
}
|
||||
} else {
|
||||
if (bundleWrapper != null) {
|
||||
bundleWrapper.put(key, JSONObject.wrap(bundle.get(key)));
|
||||
} else {
|
||||
json.put(key, JSONObject.wrap(bundle.get(key)));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bundleWrapper != null) {
|
||||
json.put(":bundle", bundleWrapper);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user