superapp audio item fix
This commit is contained in:
@@ -19,8 +19,8 @@ public class SuperAppUtils {
|
||||
}
|
||||
|
||||
public static JSONObject superapp(JSONObject json) throws JSONException {
|
||||
var superApps = Preferences.getPreferences().getString("superapp_items",
|
||||
"menu,miniapps,vkpay_slim,greeting,promo,holiday,weather,sport,games,informer,food,event,music,vk_run").split(",");
|
||||
var superApps = Preferences.getPreferences().getString("superapp_items", "menu,miniapps,vkpay_slim,greeting,promo,holiday,weather,sport,games,informer,food,event,music,vk_run").split(",");
|
||||
|
||||
if (superApps.length == 0) return json;
|
||||
|
||||
var oldItems = json.optJSONArray("items");
|
||||
@@ -31,7 +31,24 @@ public class SuperAppUtils {
|
||||
var type = item.optString("type");
|
||||
for (String superApp : superApps) {
|
||||
if (type.equals(superApp))
|
||||
newItems.put(item);
|
||||
if (superApp.equals("menu")) { // superapp menu fix
|
||||
String menuitems = "groups,audios,stickers,podcasts,shopping,lives,videos,games,vk_calls,vk_pay,ads_easy_promote,classifieds,events";
|
||||
JSONObject menuItem = new JSONObject();
|
||||
JSONArray menuItems = new JSONArray();
|
||||
|
||||
generateMenuItems(menuitems, menuItems);
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("count", menuitems.split(",").length);
|
||||
object.put("items", menuItems);
|
||||
|
||||
menuItem.put("type", "menu");
|
||||
menuItem.put("object", object);
|
||||
|
||||
newItems.put(menuItem);
|
||||
} else {
|
||||
newItems.put(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < superApps.length; i++) {
|
||||
@@ -46,4 +63,16 @@ public class SuperAppUtils {
|
||||
|
||||
return json.putOpt("items", newItems);
|
||||
}
|
||||
|
||||
private static void generateMenuItems(String str, JSONArray jsonArray) throws JSONException {
|
||||
String[] strings = str.split(",");
|
||||
|
||||
for (String string : strings) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
jsonObject.put("name", string);
|
||||
|
||||
jsonArray.put(jsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user