fixed issues with music

This commit is contained in:
gdlbo
2023-04-28 21:58:14 +03:00
parent 67ba4319f8
commit a295e11a9d
2 changed files with 14 additions and 3 deletions
@@ -1,8 +1,6 @@
package ru.vtosters.lite.feature.groupslist;
import android.util.Log;
import com.vk.catalog2.core.api.dto.buttons.CatalogButtonOpenSection;
import com.vk.core.serialize.Serializer;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -18,6 +16,18 @@ public class GroupsCatalogInjector {
return jsonObject;
}
public static void injectIntoCatalog(JSONObject jsonObject) {
var section = jsonObject.optJSONObject("section");
if (section == null) return; // early return if section is null
var blocks = section.optJSONArray("blocks");
if (blocks == null) return; // early return if blocks are null
var json = blocks.optJSONObject(1);
if (json == null) return; // early return if json is null
var data_type = json.optString("data_type");
if (!data_type.contains("groups")) return; // early return if data_type does not contain "groups"
fixGroups(section);
}
public static void fixGroups(JSONObject section) {
var blocks = section.optJSONArray("blocks");
if (blocks == null) return;
@@ -221,7 +221,8 @@ public class CatalogJsonInjector {
public static JSONObject injectIntoCatalogs(JSONObject json) {
musicLinkFix(json);
fixGroups(json.optJSONObject("section"));
injectIntoCatalog(json);
return json;
}