Skip to content
Snippets Groups Projects
Commit f55f1fdf authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Artists albums grid : fix layout issue

parent 8a658134
No related branches found
No related tags found
No related merge requests found
Pipeline #7502 failed with stage
in 10 minutes and 43 seconds
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:background="?attr/background_default" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<include layout="@layout/button_search"
<include
layout="@layout/button_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
......@@ -14,12 +14,12 @@
<org.videolan.vlc.gui.view.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="@dimen/default_content_width"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton"
app:layout_constraintBottom_toBottomOf="parent" >
app:layout_constraintTop_toBottomOf="@+id/searchButton">
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager"
......@@ -27,11 +27,15 @@
android:layout_height="match_parent"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
app:layout_constraintTop_toBottomOf="@+id/searchButton"
app:layout_constraintBottom_toBottomOf="parent" >
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton">
<include layout="@layout/audio_recyclerview" />
<include layout="@layout/audio_recyclerview" />
<include layout="@layout/audio_recyclerview" />
<include layout="@layout/audio_recyclerview" />
</androidx.viewpager.widget.ViewPager>
</org.videolan.vlc.gui.view.SwipeRefreshLayout>
......@@ -51,11 +55,6 @@
android:id="@+id/no_media"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton"
app:layout_constraintBottom_toTopOf="@+id/button_nomedia"
app:layout_constraintVertical_chainStyle="packed"
android:layout_margin="@dimen/default_margin"
android:drawableBottom="@drawable/ic_no_media"
android:drawablePadding="@dimen/default_margin"
......@@ -63,17 +62,22 @@
android:maxWidth="600dp"
android:text="@string/nomedia"
android:textSize="20sp"
android:visibility="gone"/>
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/button_nomedia"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton"
app:layout_constraintVertical_chainStyle="packed" />
<Button
android:id="@+id/button_nomedia"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:text="@string/button_medialibrary_preferences"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/no_media"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone" />
app:layout_constraintTop_toBottomOf="@id/no_media" />
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:background="?attr/background_default" />
\ No newline at end of file
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/audio_list"
android:layout_width="@dimen/default_content_width"
android:layout_height="match_parent"
android:background="?attr/background_default"
android:layout_gravity="center_horizontal"
android:clipToPadding="false" />
</FrameLayout>
\ No newline at end of file
......@@ -2,4 +2,6 @@
<resources>
<integer name="tv_songs_col_count">5</integer>
<integer name="tv_videos_col_count">2</integer>
<integer name="mobile_card_columns">4</integer>
</resources>
\ No newline at end of file
......@@ -2,4 +2,5 @@
<resources>
<integer name="tv_songs_col_count">6</integer>
<integer name="tv_videos_col_count">3</integer>
<integer name="mobile_card_columns">5</integer>
</resources>
\ No newline at end of file
......@@ -2,4 +2,5 @@
<resources>
<integer name="tv_songs_col_count">7</integer>
<integer name="tv_videos_col_count">4</integer>
<integer name="mobile_card_columns">7</integer>
</resources>
\ No newline at end of file
......@@ -62,7 +62,7 @@ import org.videolan.vlc.util.Util
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class AudioBrowserAdapter @JvmOverloads constructor(private val type: Int, private val mIEventsHandler: IEventsHandler, private val mListEventsHandler: IListEventsHandler? = null, private val mReorder: Boolean = false) : PagedListAdapter<MediaLibraryItem, AudioBrowserAdapter.AbstractMediaItemViewHolder<ViewDataBinding>>(DIFF_CALLBACK), FastScroller.SeparatedAdapter, MultiSelectAdapter<MediaLibraryItem>, SwipeDragHelperAdapter {
private var itemSize = -1
var itemSize = -1
val multiSelectHelper: MultiSelectHelper<MediaLibraryItem> = MultiSelectHelper(this, UPDATE_SELECTION)
private val mDefaultCover: BitmapDrawable?
var focusNext = -1
......
......@@ -22,13 +22,13 @@ package org.videolan.vlc.gui.audio
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Configuration
import android.os.Bundle
import android.os.Message
import android.util.Log
import android.view.*
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.view.ActionMode
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.lifecycle.Observer
import androidx.paging.PagedList
......@@ -56,7 +56,6 @@ import org.videolan.vlc.reloadLibrary
import org.videolan.vlc.util.*
import org.videolan.vlc.viewmodels.mobile.AudioBrowserViewModel
import org.videolan.vlc.viewmodels.mobile.getViewModel
import java.util.*
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
......@@ -126,12 +125,17 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewPager?.let { viewPager ->
for (i in 0 until MODE_TOTAL) lists[i] = viewPager.getChildAt(i) as RecyclerView
val views = ArrayList<View>(MODE_TOTAL)
for (i in 0 until MODE_TOTAL) {
views.add(viewPager.getChildAt(i))
lists[i] = viewPager.getChildAt(i).findViewById(R.id.audio_list) as RecyclerView
}
val titles = arrayOf(getString(R.string.artists), getString(R.string.albums), getString(R.string.tracks), getString(R.string.genres))
viewPager.offscreenPageLimit = MODE_TOTAL - 1
val audioPagerAdapter = AudioPagerAdapter(views.toTypedArray(), titles)
@Suppress("UNCHECKED_CAST")
viewPager.adapter = AudioPagerAdapter(lists as Array<View>, titles)
viewPager.adapter = audioPagerAdapter
val tabPosition = settings.getInt(KEY_AUDIO_CURRENT_TAB, 0)
currentTab = tabPosition
val positions = savedInstanceState?.getIntegerArrayList(KEY_LISTS_POSITIONS)
......@@ -143,6 +147,11 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
list.adapter = adapters[i]
if (positions != null) list.scrollToPosition(positions[i])
list.addOnScrollListener(scrollListener)
if (i < 2) {
val lp = list.layoutParams
lp.width = ViewGroup.LayoutParams.MATCH_PARENT
list.layoutParams = lp
}
}
viewPager.setOnTouchListener(swipeFilter)
swipeRefreshLayout?.setOnRefreshListener(this)
......@@ -159,18 +168,30 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
}
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
nbColumns = resources.getInteger(R.integer.mobile_card_columns)
val itemSize = RecyclerSectionItemGridDecoration.getItemSize(requireActivity().getScreenWidth(), nbColumns, spacing)
for (i in 0 until MODE_TOTAL) {
if (lists[i]?.layoutManager is GridLayoutManager) {
val gridLayoutManager = lists[i]?.layoutManager as GridLayoutManager
gridLayoutManager.spanCount = nbColumns
lists[i]?.layoutManager = gridLayoutManager
adapters[i].itemSize = itemSize
adapters[i].notifyItemRangeChanged(gridLayoutManager.findFirstVisibleItemPosition(), gridLayoutManager.findLastVisibleItemPosition() - gridLayoutManager.findFirstVisibleItemPosition())
}
}
}
private fun getLayoutManager(index: Int): LinearLayoutManager {
return when (viewModel.providersInCard[index]) {
true -> {
val provider = viewModel.providers[index]
val layoutManager = GridLayoutManager(requireActivity(), nbColumns)
//size of an item
lists[index]!!.addItemDecoration(RecyclerSectionItemGridDecoration(resources.getDimensionPixelSize(R.dimen.recycler_section_header_height), spacing, true, nbColumns, provider))
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
......@@ -187,7 +208,6 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
return nbColumns - nbItems % nbColumns
}
return 1
}
}
......@@ -355,13 +375,11 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
setFabPlayShuffleAllVisibility()
}
override fun getCurrentRV() = lists[currentTab]!!
override fun getCurrentAdapter() = adapters[currentTab]
private class AudioBrowserHandler internal constructor(owner: AudioBrowserFragment) : WeakHandler<AudioBrowserFragment>(owner) {
override fun handleMessage(msg: Message) {
val fragment = owner ?: return
when (msg.what) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment