Comments (5)
Share your code so i can check it
from videoplayerinsiderecyclerview.
Hi, this is the code with notifyItemChanged
of your InstagramRecyclerAdapter
class
package app.videoplayerinsiderecyclerview.views.instagramScreen
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import app.videoplayerinsiderecyclerview.R
import app.videoplayerinsiderecyclerview.databinding.InstagramTimelineItemRecyclerBinding
import app.videoplayerinsiderecyclerview.models.MediaObject
import app.videoplayerinsiderecyclerview.utils.PlayerStateCallback
import app.videoplayerinsiderecyclerview.utils.PlayerViewAdapter
import com.google.android.exoplayer2.Player
import java.util.*
/**
* A custom adapter to use with the RecyclerView widget.
*/
class InstagramRecyclerAdapter(
private val mContext: Context,
private var modelList: ArrayList<MediaObject>) : RecyclerView.Adapter<RecyclerView.ViewHolder>(),
PlayerStateCallback {
private var mItemClickListener: OnItemClickListener? = null
fun updateList(modelList: ArrayList<MediaObject>) {
this.modelList = modelList
notifyDataSetChanged()
}
override fun onCreateViewHolder(
viewGroup: ViewGroup,
viewType: Int
): VideoPlayerViewHolder {
val binding: InstagramTimelineItemRecyclerBinding = DataBindingUtil.inflate(LayoutInflater.from(viewGroup.context)
, R.layout.instagram_timeline_item_recycler, viewGroup, false)
return VideoPlayerViewHolder(binding)
}
override fun onBindViewHolder(
holder: RecyclerView.ViewHolder,
position: Int
) {
//Here you can fill your row view
if (holder is VideoPlayerViewHolder) {
val model = getItem(position)
val genericViewHolder = holder
// send data to view holder
genericViewHolder.onBind(model)
}
}
override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
val position = holder.adapterPosition
PlayerViewAdapter.releaseRecycledPlayers(position)
super.onViewRecycled(holder)
}
override fun getItemCount(): Int {
return modelList.size
}
private fun getItem(position: Int): MediaObject {
return modelList[position]
}
fun SetOnItemClickListener(mItemClickListener: OnItemClickListener?) {
this.mItemClickListener = mItemClickListener
}
interface OnItemClickListener {
fun onItemClick(
view: View?,
position: Int,
model: MediaObject?
)
}
inner class VideoPlayerViewHolder(private val binding: InstagramTimelineItemRecyclerBinding) : RecyclerView.ViewHolder(binding.root) {
fun onBind(model: MediaObject) {
// handel on item click
binding.root.setOnClickListener {
//TODO : Added this line
model.isMute = !model.isMute
notifyItemChanged(adapterPosition)
mItemClickListener!!.onItemClick(
it,
adapterPosition,
model
)
}
binding.apply {
dataModel = model
callback = this@InstagramRecyclerAdapter
index = adapterPosition
executePendingBindings()
}
}
}
override fun onVideoDurationRetrieved(duration: Long, player: Player) {
}
override fun onVideoBuffering(player: Player) {
}
override fun onStartedPlaying(player: Player) {
}
override fun onFinishedPlaying(player: Player) {
}
}
from videoplayerinsiderecyclerview.
Is there any update on this. I am facing similar issue exo player become black after notify data set change.
from videoplayerinsiderecyclerview.
i am using kohii library
from videoplayerinsiderecyclerview.
@Krutika-chotara @Faiyyazauxy @MostafaAnter any update on above issue ? I am also facing the same issue when I call "notifyItemCahnged(adapterPosition)".
from videoplayerinsiderecyclerview.
Related Issues (8)
- error: cannot find symbol HOT 1
- FacebookTimelineItemRecyclerListBinding HOT 1
- Please Implement Exoplayer 2.12.0 with ViewPager2 using RecyclerViewAdapter HOT 6
- Deleting item but next item not starts playing automatically HOT 9
- VideoPlayer for Grid Layout Manager isn't working
- how can i mute and unmute the volume on the double tap
- SDK Version 33 Compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from videoplayerinsiderecyclerview.