Commit 7b3b0830 authored by Shivansh Saini's avatar Shivansh Saini Committed by Geoffrey Métais

Marquee effect for long names in directory browser.

parent c2f8e42f
Pipeline #6794 passed with stage
in 3 minutes and 37 seconds
......@@ -104,9 +104,10 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginLeft="@dimen/default_margin"
android:ellipsize="end"
android:ellipsize="marquee"
android:marqueeRepeatLimit="1"
android:scrollHorizontally="true"
android:lineSpacingMultiplier="1.1"
android:maxLines="1"
android:singleLine="true"
android:text="@{filename ?? item.title}"
android:textColor="?attr/list_title"
......
......@@ -30,6 +30,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.libvlc.util.AndroidUtil
......@@ -104,6 +106,32 @@ open class BaseBrowserAdapter() : DiffUtilAdapter<MediaLibraryItem, BaseBrowserA
SeparatorViewHolder(BrowserItemSeparatorBinding.inflate(inflater, parent, false)) as ViewHolder<ViewDataBinding>
}
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
super.onAttachedToRecyclerView(recyclerView)
val layoutManager = recyclerView.layoutManager
if (layoutManager is LinearLayoutManager) {
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
val doScroll = newState == RecyclerView.SCROLL_STATE_IDLE
val firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition()
val lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition()
for (i in firstVisibleItemPosition..lastVisibleItemPosition) {
val holder = recyclerView.findViewHolderForLayoutPosition(i)
if (holder is MediaViewHolder) {
// Show marquee effect only for those view holders which are visible.
// If not visible or dragging scroll state, then stop the marquee effect.
holder.binding.title.isSelected = doScroll
}
}
}
})
}
}
override fun onBindViewHolder(holder: ViewHolder<ViewDataBinding>, position: Int) {
val viewType = getItemViewType(position)
if (viewType == TYPE_MEDIA) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment