fix #1607
This commit is contained in:
@@ -4,7 +4,6 @@ import android.util.Log;
|
|||||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||||
import com.vk.core.network.Network;
|
import com.vk.core.network.Network;
|
||||||
import com.vk.core.util.DeviceIdProvider;
|
import com.vk.core.util.DeviceIdProvider;
|
||||||
import okhttp3.Headers;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@@ -58,7 +57,11 @@ public class CatalogJsonInjector {
|
|||||||
if (!MusicCacheImpl.isEmpty() && !LibVKXClient.isIntegrationEnabled()) { // inj in playlist list
|
if (!MusicCacheImpl.isEmpty() && !LibVKXClient.isIntegrationEnabled()) { // inj in playlist list
|
||||||
var noPlaylists = !json.has("playlists");
|
var noPlaylists = !json.has("playlists");
|
||||||
|
|
||||||
PlaylistHelper.addCachedPlaylists(json.optJSONArray("playlists"), noPlaylists);
|
if (noPlaylists) {
|
||||||
|
PlaylistHelper.addCachedPlaylists(new JSONArray());
|
||||||
|
} else {
|
||||||
|
PlaylistHelper.addCachedPlaylists(json.optJSONArray("playlists"));
|
||||||
|
}
|
||||||
|
|
||||||
if (!useOldAppVer || noPlaylists) {
|
if (!useOldAppVer || noPlaylists) {
|
||||||
var newBlocks = new JSONArray();
|
var newBlocks = new JSONArray();
|
||||||
@@ -99,7 +102,11 @@ public class CatalogJsonInjector {
|
|||||||
|
|
||||||
var noPlaylists = !json.has("playlists");
|
var noPlaylists = !json.has("playlists");
|
||||||
|
|
||||||
PlaylistHelper.addCachedPlaylists(json.optJSONArray("playlists"), noPlaylists);
|
if (noPlaylists) {
|
||||||
|
PlaylistHelper.addCachedPlaylists(new JSONArray());
|
||||||
|
} else {
|
||||||
|
PlaylistHelper.addCachedPlaylists(json.optJSONArray("playlists"));
|
||||||
|
}
|
||||||
|
|
||||||
if (!useOldAppVer && !noPlaylists) {
|
if (!useOldAppVer && !noPlaylists) {
|
||||||
var newBlocks = new JSONArray();
|
var newBlocks = new JSONArray();
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ public class TracklistInjector {
|
|||||||
boolean noPlaylists = hasNoPlaylists(blocks);
|
boolean noPlaylists = hasNoPlaylists(blocks);
|
||||||
|
|
||||||
if (noPlaylists) {
|
if (noPlaylists) {
|
||||||
PlaylistHelper.addCachedPlaylists(catalogNode.optJSONArray("playlists"), true);
|
PlaylistHelper.addCachedPlaylists(new JSONArray());
|
||||||
|
|
||||||
firstSection.put("blocks", createNewBlocks(blocks));
|
firstSection.put("blocks", createNewBlocks(blocks));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
PlaylistHelper.addCachedPlaylists(catalogNode.optJSONArray("playlists"), false);
|
PlaylistHelper.addCachedPlaylists(catalogNode.optJSONArray("playlists"));
|
||||||
|
|
||||||
updatePlaylistsIds(blocks);
|
updatePlaylistsIds(blocks);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -270,7 +270,7 @@ public class TracklistInjector {
|
|||||||
|
|
||||||
return new JSONObject()
|
return new JSONObject()
|
||||||
.put("catalog", catalog)
|
.put("catalog", catalog)
|
||||||
.put("playlists", addCachedPlaylists(new JSONArray(), false))
|
.put("playlists", addCachedPlaylists(new JSONArray()))
|
||||||
.put("audios", TracklistHelper.tracksToJsons(tracks));
|
.put("audios", TracklistHelper.tracksToJsons(tracks));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,8 @@ public class PlaylistHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JSONArray addCachedPlaylists(JSONArray jsonArray, Boolean noPlaylists) {
|
public static JSONArray addCachedPlaylists(JSONArray jsonArray) {
|
||||||
try {
|
try {
|
||||||
if (noPlaylists) {
|
|
||||||
jsonArray.put(new JSONArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PlaylistCacheDbDelegate.isPlaylistEmpty(AndroidUtils.getGlobalContext(), AccountManagerUtils.getUserId() + "_-1")) {
|
if (!PlaylistCacheDbDelegate.isPlaylistEmpty(AndroidUtils.getGlobalContext(), AccountManagerUtils.getUserId() + "_-1")) {
|
||||||
jsonArray.put(getCachedSongsPlaylist());
|
jsonArray.put(getCachedSongsPlaylist());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user