Fix padding for list #933
parent
02ff1b92cb
commit
a39a9bd592
|
@ -112,7 +112,7 @@ abstract class AbsRecyclerViewCustomGridSizeFragment<A : RecyclerView.Adapter<*>
|
|||
} else {
|
||||
0
|
||||
}
|
||||
recyclerView.setPadding(padding, padding, padding, padding)
|
||||
//recyclerView.setPadding(padding, padding, padding, padding)
|
||||
}
|
||||
|
||||
protected abstract fun setGridSize(gridSize: Int)
|
||||
|
|
|
@ -15,10 +15,14 @@
|
|||
package code.name.monkey.retromusic.fragments.base
|
||||
|
||||
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.StringRes
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
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.ImportPlaylistDialog
|
||||
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.ThemedFastScroller.create
|
||||
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.transition.Hold
|
||||
import kotlinx.android.synthetic.main.fragment_main_recycler.*
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
|
@ -83,12 +84,7 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
layoutManager = this@AbsRecyclerViewFragment.layoutManager
|
||||
adapter = this@AbsRecyclerViewFragment.adapter
|
||||
val fastScroller = create(this)
|
||||
setOnApplyWindowInsetsListener(
|
||||
ScrollingViewOnApplyWindowInsetsListener(
|
||||
recyclerView,
|
||||
fastScroller
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
checkForPadding()
|
||||
}
|
||||
|
@ -122,13 +118,13 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
|
||||
private fun checkForPadding() {
|
||||
val itemCount: Int = adapter?.itemCount ?: 0
|
||||
val params = container.layoutParams as ViewGroup.MarginLayoutParams
|
||||
|
||||
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
val height = DensityUtil.dip2px(requireContext(), 104f)
|
||||
params.bottomMargin = height
|
||||
val height = DensityUtil.dip2px(requireContext(), 112f)
|
||||
recyclerView.updatePadding(0, 0, 0, height)
|
||||
} else {
|
||||
val height = DensityUtil.dip2px(requireContext(), 52f)
|
||||
params.bottomMargin = height
|
||||
val height = DensityUtil.dip2px(requireContext(), 56f)
|
||||
recyclerView.updatePadding(0, 0, 0, height)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,12 +138,12 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
protected abstract fun createAdapter(): A
|
||||
|
||||
override fun onOffsetChanged(p0: AppBarLayout?, i: Int) {
|
||||
container.setPadding(
|
||||
container.paddingLeft,
|
||||
container.paddingTop,
|
||||
container.paddingRight,
|
||||
/*recyclerView.setPadding(
|
||||
recyclerView.paddingLeft,
|
||||
recyclerView.paddingTop,
|
||||
recyclerView.paddingRight,
|
||||
i
|
||||
)
|
||||
)*/
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
|
|
|
@ -42,51 +42,44 @@
|
|||
</FrameLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="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"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
<LinearLayout
|
||||
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:clipToPadding="false"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
android:transitionGroup="true"
|
||||
app:layout_dodgeInsetEdges="bottom"
|
||||
tools:listitem="@layout/item_list" />
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/empty_text_emoji"
|
||||
android:textAppearance="@style/TextViewHeadline3" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/empty"
|
||||
<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: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_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>
|
||||
|
||||
android:text="@string/empty"
|
||||
android:textAppearance="@style/TextViewHeadline5"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
tools:visibility="visible" />
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue