From 9a02f2a7c39736c4bc827404f3f9fdcb53b97669 Mon Sep 17 00:00:00 2001 From: Vologhat <47892605+Vologhat@users.noreply.github.com> Date: Tue, 5 Jul 2022 20:51:02 +0300 Subject: [PATCH] fixed superapp injector --- .../ru/vtosters/lite/utils/JsonInjectors.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java b/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java index db56576ab..727c7c8d8 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java +++ b/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java @@ -8,6 +8,9 @@ import static ru.vtosters.lite.utils.Preferences.dev; import static ru.vtosters.lite.utils.Preferences.getBoolValue; import static ru.vtosters.lite.utils.Preferences.hasVerification; +import android.util.Log; + +import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -81,22 +84,19 @@ public class JsonInjectors{ return orig; } - public static JSONObject superapp(JSONObject orig) throws JSONException{ - var Items = orig.optJSONArray("items"); - - if(Items != null){ - for(int i = 0; i < Items.length(); i++) { - var items = Items.optJSONObject(i); - var type = items.optString("type"); - - if(getBoolValue("superapp_" + type, false)){ - Items.remove(i); - } - + public static JSONObject superapp(JSONObject json) throws JSONException{ + var oldItems = json.optJSONArray("items"); + var newItems = new JSONArray(); + if (oldItems != null) { + for (int i = 0; i < oldItems.length(); i++) { + var item = oldItems.optJSONObject(i); + var type = item.optString("type"); + if (!getBoolValue("superapp_" + type, false)) + newItems.put(item); } } - return orig; + return json.putOpt("items", newItems); } public static boolean haveDonateButton(){