eneim / kohii

Android Video Playback made easy.
https://eneim.github.io/kohii/
Apache License 2.0
372 stars 50 forks source link

First video not playing in the nested recyclerview #66

Open farazahmed7 opened 4 years ago

farazahmed7 commented 4 years ago

Hi First of all I wanna thank you for this amazing library Videos that are visible right away and are on the top of the list in a nested recyclerview wont play until you scroll down the list and then scroll up again so that views are attached again . EDIT: The code set up

Heres how I set Kohii in main activity and add the main recyclerview to the bucket. I pass the instance of Kohii and the manager in the adapter

        val kohii= Kohii[this]
        val manager=kohii.register(this).addBucket(recyclerView)
         adapter = TweetsPageAdapter(this,kohii,manager)
        recyclerView.layoutManager = LinearLayoutManager(this)
        recyclerView.adapter = adapter

Then I add the nested recyclerview to the bucket in this adapter's viewholder

class TweetViewHolder(var view: View) : RecyclerView.ViewHolder(view) {
        fun bind(tweet: Tweet?) {
            view.tweet.text = tweet?.text
            val dpUrl=tweet?.user?.profile_image_url_https
            val newDpurl= dpUrl?.replace("_normal","")
            Glide.with(view).load(newDpurl).into(view.imageViewDp)
            view.screenName.text="@"+tweet?.user?.screen_name
            view.name.text=tweet?.user?.name
            val recyclerView = view.recyclerView
            manager.addBucket(recyclerView)
            val noOfCol= Utility.calculateNoOfColumns(view.context,200f);
            val child=SpanningGridLayoutManager(view.context,noOfCol)
            recyclerView.layoutManager=child
            child.initialPrefetchItemCount=4
            val adapter= MediaAdapter(context,kohii)
           ................................................................
           .................................................................
}

The video viewholder in the MediaAdapter is as follow

 class SimpleExoPlayerViewHolder internal constructor(itemView: View) :
    RecyclerView.ViewHolder(itemView) {
    var playerView: PlayerView

    fun bind(kohii: Kohii,item: Uri) {
        kohii.setUp(item).bind(playerView);

    }

    init {
        playerView = itemView.findViewById(R.id.playerView)
    }
} 
eneim commented 4 years ago

Can you share the code of your setup?

farazahmed7 commented 4 years ago

I have updated with the code. Sorry but the highlighting is messed up. I can upload the whole project if you want. Its just a small project that fetches tweets

OhJeongGyu commented 3 years ago

Hello. Thanks for your good library. @eneim Is this issue on going? I'm looking for library to make new feature that shows horizontal recyclerview in vertical recyclerview with zoomable exoplayer.. like instagram Thanks :)

eneim commented 3 years ago

@OhJeongGyu sorry to get back to you late. Currently I could not reproduce this issue, so I think you can try it out and if it doesn't work for you please let me know. The sample for RV inside RV is here: https://github.com/eneim/kohii/tree/dev-v1/kohii-sample/src/main/java/kohii/v1/sample/ui/nested5