From 27b07719d9214b74ef69e4a3e61d5ee0f9764b0d Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Fri, 21 Jun 2024 20:59:46 +0300 Subject: [PATCH] fix music catalog --- .../music/injectors/CatalogJsonInjector.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/ru/vtosters/hooks/music/injectors/CatalogJsonInjector.java b/app/src/main/java/ru/vtosters/hooks/music/injectors/CatalogJsonInjector.java index efd5bea82..674e2f380 100644 --- a/app/src/main/java/ru/vtosters/hooks/music/injectors/CatalogJsonInjector.java +++ b/app/src/main/java/ru/vtosters/hooks/music/injectors/CatalogJsonInjector.java @@ -220,10 +220,14 @@ public class CatalogJsonInjector { } } - private static void removeUnsupportedLayouts(JSONArray blocks) throws JSONException { + private static void removeUnsupportedLayouts(JSONArray blocks) { for (int i = blocks.length() - 1; i >= 0; i--) { JSONObject block = blocks.optJSONObject(i); + if (block == null) continue; + JSONObject layout = block.optJSONObject("layout"); + if (layout == null) continue; + String data_type = block.optString("data_type"); if (Objects.equals(data_type, "music_recommended_playlists") || Objects.equals(data_type, "radiostations")) { @@ -233,8 +237,6 @@ public class CatalogJsonInjector { continue; // Skip to the next iteration after removing } - if (layout == null) continue; // Skip to the next iteration if layout is null - String name = layout.optString("name"); if (!name.equals("header_extended")) { continue; // Skip to the next iteration if not header_extended @@ -243,11 +245,14 @@ public class CatalogJsonInjector { if (layout.has("top_title")) { blocks.remove(i); } - layout.put("name", "header"); + try { + layout.put("name", "header"); + } catch (JSONException e) { + e.fillInStackTrace(); + } } } - private static void setDefaultAudioPage(JSONArray jsonArray, JSONObject catalog) throws JSONException { for (int i = 0; i < jsonArray.length(); i++) { var item = jsonArray.optJSONObject(i);