Fixed refreshing playlist on HTTP connections (#740)

When Kore retrieves the data over HTTP the playlist would be
refreshed every 4 seconds. This caused the playlist to jump to
the top when scrolled down. This has been fixed by checking if
the new playlist is different from the current playlist. If not
nothing changes.
This commit is contained in:
Martijn Brekhof 2020-05-25 20:53:23 +02:00 committed by GitHub
parent a9a833ddfe
commit 6ed64bf9f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -594,8 +594,11 @@ public class HostConnectionObserver
return; return;
} }
for (PlaylistEventsObserver observer : playlistEventsObservers) { if (!(hostState.lastGetPlaylistResults != null &&
observer.playlistsAvailable(result); hostState.lastGetPlaylistResults.equals(result))) {
for (PlaylistEventsObserver observer : playlistEventsObservers) {
observer.playlistsAvailable(result);
}
} }
// Handle cleared playlists // Handle cleared playlists

View File

@ -17,6 +17,8 @@
package org.xbmc.kore.host.actions; package org.xbmc.kore.host.actions;
import androidx.annotation.Nullable;
import org.xbmc.kore.jsonrpc.ApiMethod; import org.xbmc.kore.jsonrpc.ApiMethod;
import org.xbmc.kore.jsonrpc.HostConnection; import org.xbmc.kore.jsonrpc.HostConnection;
import org.xbmc.kore.jsonrpc.method.Playlist; import org.xbmc.kore.jsonrpc.method.Playlist;
@ -172,5 +174,11 @@ public class GetPlaylist implements Callable<ArrayList<GetPlaylist.GetPlaylistRe
this.type = type; this.type = type;
this.items = items; this.items = items;
} }
@Override
public boolean equals(@Nullable Object obj) {
return obj instanceof GetPlaylistResult &&
this.items.equals(((GetPlaylistResult) obj).items);
}
} }
} }

View File

@ -18,10 +18,13 @@ package org.xbmc.kore.jsonrpc.type;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import androidx.annotation.Nullable;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.xbmc.kore.host.actions.GetPlaylist;
import org.xbmc.kore.utils.JsonUtils; import org.xbmc.kore.utils.JsonUtils;
import java.util.List; import java.util.List;
@ -287,6 +290,12 @@ public class ListType {
writer = JsonUtils.stringListFromJsonNode(node, WRITER); writer = JsonUtils.stringListFromJsonNode(node, WRITER);
year = JsonUtils.intFromJsonNode(node, YEAR, -1); year = JsonUtils.intFromJsonNode(node, YEAR, -1);
} }
@Override
public boolean equals(@Nullable Object obj) {
return obj instanceof ItemBase &&
this.id == ((ItemBase) obj).id;
}
} }
public static class ItemsAll extends ItemBase { public static class ItemsAll extends ItemBase {