Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

listPlaylists returning list of LinkedTreeMap not Playlists #40

Closed
Vichy97 opened this issue Jul 28, 2018 · 10 comments
Closed

listPlaylists returning list of LinkedTreeMap not Playlists #40

Vichy97 opened this issue Jul 28, 2018 · 10 comments

Comments

@Vichy97
Copy link

Vichy97 commented Jul 28, 2018

I think this has something to do with Gson
screen shot 2018-07-28 at 12 43 58 pm

@FelixGail
Copy link
Owner

FelixGail commented Jul 30, 2018

Could you elaborate further on what you are doing? This seems to work fine for me.
screenshot from 2018-07-30 11-14-29

Edit
Are you maybe not displaying the desired List<Playlist>, but an internal object used by Gson while parsing the incoming JSON?

@Vichy97
Copy link
Author

Vichy97 commented Jul 30, 2018

That is what the method listPlaylists() was returning and it was crashing when I tried to cast it to List<Playlist>. I will investigate some more though. It could be because Im using kotlin, but I'm not sure

@Vichy97
Copy link
Author

Vichy97 commented Jul 31, 2018

I can't figure out what is going wrong.
Here is my code:

return Observable.fromCallable {
            val playlists: List<Playlist>  = googlePlayMusicService!!.playlistApi.listPlaylists()
            return@fromCallable playlists
        }

I dont think it has anything to do with Kotlin or RxJava. Apparently a lot of people have run into this issue with Gson when using Java generics.

@Vichy97
Copy link
Author

Vichy97 commented Jul 31, 2018

The only way I was able to fix it was to serialize and deserialize

return Observable.fromCallable {
            val jsonString: String = Gson().toJson(googlePlayMusicService!!.playlistApi.listPlaylists())
            val playlists: List<Playlist> = Gson().fromJson(jsonString, object : TypeToken<List<Playlist>>() {}.type)
            return@fromCallable playlists
        }

but this is not ideal... :/

@FelixGail
Copy link
Owner

What Java version are you using?

@Vichy97
Copy link
Author

Vichy97 commented Jul 31, 2018

8

@FelixGail
Copy link
Owner

Does gplaymusic:0.3.6-R0-SNAPSHOTwork for you?

@Vichy97
Copy link
Author

Vichy97 commented Aug 29, 2018

hey I have not had a chance to test this since my app is not really building properly now (unrelated refactoring). I will let you know whenever I do test it though

@FelixGail
Copy link
Owner

It seems that a temporary solution has been found: #44 (comment)

@FelixGail
Copy link
Owner

This has been resolved in version 0.3.6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants