Fix padding for list #933
This commit is contained in:
parent
02ff1b92cb
commit
a39a9bd592
3 changed files with 49 additions and 60 deletions
|
@ -112,7 +112,7 @@ abstract class AbsRecyclerViewCustomGridSizeFragment<A : RecyclerView.Adapter<*>
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
recyclerView.setPadding(padding, padding, padding, padding)
|
//recyclerView.setPadding(padding, padding, padding, padding)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun setGridSize(gridSize: Int)
|
protected abstract fun setGridSize(gridSize: Int)
|
||||||
|
|
|
@ -15,10 +15,14 @@
|
||||||
package code.name.monkey.retromusic.fragments.base
|
package code.name.monkey.retromusic.fragments.base
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
|
import androidx.core.view.updatePadding
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
|
@ -28,12 +32,9 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
|
||||||
import code.name.monkey.retromusic.util.DensityUtil
|
import code.name.monkey.retromusic.util.DensityUtil
|
||||||
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
||||||
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener
|
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.transition.Hold
|
|
||||||
import kotlinx.android.synthetic.main.fragment_main_recycler.*
|
import kotlinx.android.synthetic.main.fragment_main_recycler.*
|
||||||
import me.zhanghai.android.fastscroll.FastScroller
|
import me.zhanghai.android.fastscroll.FastScroller
|
||||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||||
|
@ -83,12 +84,7 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
||||||
layoutManager = this@AbsRecyclerViewFragment.layoutManager
|
layoutManager = this@AbsRecyclerViewFragment.layoutManager
|
||||||
adapter = this@AbsRecyclerViewFragment.adapter
|
adapter = this@AbsRecyclerViewFragment.adapter
|
||||||
val fastScroller = create(this)
|
val fastScroller = create(this)
|
||||||
setOnApplyWindowInsetsListener(
|
|
||||||
ScrollingViewOnApplyWindowInsetsListener(
|
|
||||||
recyclerView,
|
|
||||||
fastScroller
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
checkForPadding()
|
checkForPadding()
|
||||||
}
|
}
|
||||||
|
@ -122,13 +118,13 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
||||||
|
|
||||||
private fun checkForPadding() {
|
private fun checkForPadding() {
|
||||||
val itemCount: Int = adapter?.itemCount ?: 0
|
val itemCount: Int = adapter?.itemCount ?: 0
|
||||||
val params = container.layoutParams as ViewGroup.MarginLayoutParams
|
|
||||||
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||||
val height = DensityUtil.dip2px(requireContext(), 104f)
|
val height = DensityUtil.dip2px(requireContext(), 112f)
|
||||||
params.bottomMargin = height
|
recyclerView.updatePadding(0, 0, 0, height)
|
||||||
} else {
|
} else {
|
||||||
val height = DensityUtil.dip2px(requireContext(), 52f)
|
val height = DensityUtil.dip2px(requireContext(), 56f)
|
||||||
params.bottomMargin = height
|
recyclerView.updatePadding(0, 0, 0, height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,12 +138,12 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
||||||
protected abstract fun createAdapter(): A
|
protected abstract fun createAdapter(): A
|
||||||
|
|
||||||
override fun onOffsetChanged(p0: AppBarLayout?, i: Int) {
|
override fun onOffsetChanged(p0: AppBarLayout?, i: Int) {
|
||||||
container.setPadding(
|
/*recyclerView.setPadding(
|
||||||
container.paddingLeft,
|
recyclerView.paddingLeft,
|
||||||
container.paddingTop,
|
recyclerView.paddingTop,
|
||||||
container.paddingRight,
|
recyclerView.paddingRight,
|
||||||
i
|
i
|
||||||
)
|
)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueueChanged() {
|
override fun onQueueChanged() {
|
||||||
|
|
|
@ -42,51 +42,44 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/container"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
android:clipToPadding="false"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:transitionGroup="true"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||||
|
tools:listitem="@layout/item_list" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recyclerView"
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@android:id/empty"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/emptyEmoji"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:layout_marginBottom="16dp"
|
||||||
android:overScrollMode="never"
|
android:text="@string/empty_text_emoji"
|
||||||
android:scrollbars="none"
|
android:textAppearance="@style/TextViewHeadline3" />
|
||||||
android:transitionGroup="true"
|
|
||||||
app:layout_dodgeInsetEdges="bottom"
|
|
||||||
tools:listitem="@layout/item_list" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@android:id/empty"
|
android:id="@+id/emptyText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center"
|
android:text="@string/empty"
|
||||||
android:orientation="vertical"
|
android:textAppearance="@style/TextViewHeadline5"
|
||||||
android:visibility="gone"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible" />
|
||||||
|
</LinearLayout>
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:id="@+id/emptyEmoji"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:text="@string/empty_text_emoji"
|
|
||||||
android:textAppearance="@style/TextViewHeadline3" />
|
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:id="@+id/emptyText"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="@string/empty"
|
|
||||||
android:textAppearance="@style/TextViewHeadline5"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in a new issue