akoscz / YouTubePlaylist

A sample Android application which demonstrates the use of the YouTube Data v3 API.
Apache License 2.0
153 stars 84 forks source link

Weird behaviour when refresh/load another data on RecyclerView #10

Closed indrac closed 8 years ago

indrac commented 8 years ago

I use your code to my app, and add spinned menu on top of recyclerview. Each menu have different value/playlist id, I successfully load the data from that API playlist. But the weird thing, when I select second/third option from spinned menu, the result of recyclerview is new data placed on bottom layout, I have to scroll it up to view the result. Any solution for this? Or why this is happen? Much appreciate for your help and thanks for the code.

akoscz commented 8 years ago

@indrac can you provide some code for me to look at? Prefereably if you could link to your project so I can see all the code that is in question would be best.

Also, see which branch of the YouTubePlaylist are you using ? I have a couple of branches with various changes. I would recommend you to try the data-binding branch or the rx-java branch as those are a bit further along than the master branch.

indrac commented 8 years ago

I posted my code on gist github 3 files, the YoutubeViewFragment.java is the main view of youtube playlist, I hardcoded it and set playlist ID value on number 1 and 2 on that spinner menu. PlaylistCardAdapter.java is same like your code, I changed a lil bit image loader to Universal Image Loader. And the last file fragment_youtubeview.xml is the layout for my YoutubeViewFragment class.

YoutubeViewFragment.java Link PlaylistCardAdapter.java Link fragment_youtubeview.xml Link

So thanksful for your reply in this issue.

akoscz commented 8 years ago

@indrac Not sure what exactly is wrong with your code. It might have something to do with the StatefulLayout class that you are using. Take a look at the recent changes I just made in the master branch. I added support for selecting a playlist using a spinner from a list of playlist id's. As an added bonus I also added the capability of fetching the playlist titles and updating the spinner with the playlist title data.

indrac commented 8 years ago

Thanks for answering my question, and finally I know what is wrong with my code. I compile and debug with my Nexus tablet, and I just have to declare this :

mLayoutManager = new StaggeredGridLayoutManager(resources.getInteger(R.integer.columns), StaggeredGridLayoutManager.VERTICAL);

to my OnItemSelected inside spinner.setOnItemSelectedListener.

akoscz commented 8 years ago

Glad to hear you were able to figure out the issue you were facing!