Migrated to Kotlin version of Material cab
This commit is contained in:
parent
4620c22479
commit
6aedfbc2cb
17 changed files with 823 additions and 877 deletions
|
@ -133,8 +133,8 @@ dependencies {
|
|||
implementation "com.afollestad.material-dialogs:input:$material_dialog_version"
|
||||
implementation "com.afollestad.material-dialogs:color:$material_dialog_version"
|
||||
implementation "com.afollestad.material-dialogs:bottomsheets:$material_dialog_version"
|
||||
//noinspection GradleDependency
|
||||
implementation 'com.afollestad:material-cab:0.1.12'
|
||||
|
||||
implementation 'com.afollestad:material-cab:2.0.1'
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
|
||||
|
@ -159,6 +159,7 @@ dependencies {
|
|||
implementation 'com.heinrichreimersoftware:material-intro:2.0.0'
|
||||
implementation 'com.github.dhaval2404:imagepicker:1.7.1'
|
||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
|
||||
implementation "com.github.YvesCheung.RollingText:RollingText:1.2.10"
|
||||
implementation 'cat.ereza:customactivityoncrash:2.3.0'
|
||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
||||
}
|
||||
|
|
|
@ -8,46 +8,38 @@ import androidx.fragment.app.FragmentActivity
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.util.ColorAnimUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
import com.afollestad.materialcab.attached.destroy
|
||||
import com.afollestad.materialcab.attached.isActive
|
||||
import java.util.*
|
||||
|
||||
abstract class AbsMultiSelectAdapter<V : RecyclerView.ViewHolder?, I>(
|
||||
open val activity: FragmentActivity, private val ICabHolder: ICabHolder?, @MenuRes menuRes: Int
|
||||
) : RecyclerView.Adapter<V>(), MaterialCab.Callback {
|
||||
private var cab: MaterialCab? = null
|
||||
) : RecyclerView.Adapter<V>(), ICabCallback {
|
||||
private var cab: AttachedCab? = null
|
||||
private val checked: MutableList<I>
|
||||
private var menuRes: Int
|
||||
override fun onCabCreated(materialCab: MaterialCab, menu: Menu): Boolean {
|
||||
// Animate the color change
|
||||
ColorAnimUtil.createColorAnimator(
|
||||
activity.surfaceColor(),
|
||||
RetroColorUtil.shiftBackgroundColor(activity.surfaceColor())
|
||||
).apply {
|
||||
addUpdateListener {
|
||||
// Change color of status bar too
|
||||
activity.window.statusBarColor = animatedValue as Int
|
||||
materialCab.setBackgroundColor(animatedValue as Int)
|
||||
}
|
||||
start()
|
||||
}
|
||||
override fun onCabCreated(cab: AttachedCab, menu: Menu): Boolean {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onCabFinished(materialCab: MaterialCab): Boolean {
|
||||
override fun onCabFinished(cab: AttachedCab): Boolean {
|
||||
clearChecked()
|
||||
activity.window.statusBarColor = Color.TRANSPARENT
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onCabItemClicked(menuItem: MenuItem): Boolean {
|
||||
if (menuItem.itemId == R.id.action_multi_select_adapter_check_all) {
|
||||
override fun onCabItemClicked(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.action_multi_select_adapter_check_all) {
|
||||
checkAll()
|
||||
} else {
|
||||
onMultipleItemAction(menuItem, ArrayList(checked))
|
||||
cab?.finish()
|
||||
onMultipleItemAction(item, ArrayList(checked))
|
||||
cab?.destroy()
|
||||
clearChecked()
|
||||
}
|
||||
return true
|
||||
|
@ -77,7 +69,7 @@ abstract class AbsMultiSelectAdapter<V : RecyclerView.ViewHolder?, I>(
|
|||
}
|
||||
|
||||
protected val isInQuickSelectMode: Boolean
|
||||
get() = cab != null && cab!!.isActive
|
||||
get() = cab != null && cab!!.isActive()
|
||||
|
||||
protected abstract fun onMultipleItemAction(menuItem: MenuItem, selection: List<I>)
|
||||
protected fun setMultiSelectMenuRes(@MenuRes menuRes: Int) {
|
||||
|
@ -104,19 +96,19 @@ abstract class AbsMultiSelectAdapter<V : RecyclerView.ViewHolder?, I>(
|
|||
|
||||
private fun updateCab() {
|
||||
if (ICabHolder != null) {
|
||||
if (cab == null || !cab!!.isActive) {
|
||||
if (cab == null || !cab!!.isActive()) {
|
||||
cab = ICabHolder.openCab(menuRes, this)
|
||||
}
|
||||
val size = checked.size
|
||||
when {
|
||||
size <= 0 -> {
|
||||
cab?.finish()
|
||||
cab?.destroy()
|
||||
}
|
||||
size == 1 -> {
|
||||
cab?.setTitle(getName(checked[0]))
|
||||
cab?.title(literal = getName(checked[0]))
|
||||
}
|
||||
else -> {
|
||||
cab?.setTitle(activity.getString(R.string.x_selected, size))
|
||||
cab?.title(literal = activity.getString(R.string.x_selected, size))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.helper.SortOrder
|
||||
import code.name.monkey.retromusic.helper.menu.SongMenuHelper
|
||||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ open class SongAdapter(
|
|||
activity,
|
||||
ICabHolder,
|
||||
R.menu.menu_media_selection
|
||||
), MaterialCab.Callback, PopupTextProvider {
|
||||
), ICabCallback, PopupTextProvider {
|
||||
|
||||
private var showSectionName = true
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder.Companion
|
|||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder.Companion.SONG_TRACK_LIST
|
||||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder.Companion.SONG_Z_A
|
||||
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
|
@ -68,7 +69,10 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
|||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
import com.afollestad.materialcab.attached.destroy
|
||||
import com.afollestad.materialcab.attached.isActive
|
||||
import com.afollestad.materialcab.createCab
|
||||
import com.google.android.material.transition.MaterialArcMotion
|
||||
import com.google.android.material.transition.MaterialContainerTransform
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -450,28 +454,34 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
|
||||
private fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
private var cab: AttachedCab? = null
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
override fun openCab(menuRes: Int, callback: ICabCallback): AttachedCab {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
cab = createCab(R.id.cab_stub) {
|
||||
menu(menuRes)
|
||||
closeDrawable(R.drawable.ic_close)
|
||||
backgroundColor(literal = RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
slideDown()
|
||||
onCreate { cab, menu -> callback.onCabCreated(cab, menu) }
|
||||
onSelection {
|
||||
callback.onCabItemClicked(it)
|
||||
}
|
||||
onDestroy { callback.onCabFinished(it) }
|
||||
}
|
||||
return cab as AttachedCab
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
|
@ -29,11 +29,15 @@ import code.name.monkey.retromusic.fragments.ReloadType
|
|||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder
|
||||
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
import com.afollestad.materialcab.attached.destroy
|
||||
import com.afollestad.materialcab.attached.isActive
|
||||
import com.afollestad.materialcab.createCab
|
||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||
|
||||
class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
||||
|
@ -325,28 +329,34 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
|
|||
|
||||
private fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
private var cab: AttachedCab? = null
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
override fun openCab(menuRes: Int, callback: ICabCallback): AttachedCab {
|
||||
cab?.let {
|
||||
println("Cab")
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
cab = createCab(R.id.cab_stub) {
|
||||
menu(menuRes)
|
||||
closeDrawable(R.drawable.ic_close)
|
||||
backgroundColor(literal = RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
slideDown()
|
||||
onCreate { cab, menu -> callback.onCabCreated(cab, menu) }
|
||||
onSelection {
|
||||
callback.onCabItemClicked(it)
|
||||
}
|
||||
onDestroy { callback.onCabFinished(it) }
|
||||
}
|
||||
return cab as AttachedCab
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import code.name.monkey.retromusic.glide.RetroGlideExtension
|
|||
import code.name.monkey.retromusic.glide.SingleColorTarget
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.network.Result
|
||||
|
@ -42,7 +43,10 @@ import code.name.monkey.retromusic.util.CustomArtistImageUtil
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
import com.afollestad.materialcab.attached.destroy
|
||||
import com.afollestad.materialcab.attached.isActive
|
||||
import com.afollestad.materialcab.createCab
|
||||
import com.google.android.material.transition.MaterialContainerTransform
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -306,28 +310,34 @@ abstract class AbsArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragm
|
|||
|
||||
private fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
private var cab: AttachedCab? = null
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
override fun openCab(menuRes: Int, callback: ICabCallback): AttachedCab {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
cab = createCab(R.id.cab_stub) {
|
||||
menu(menuRes)
|
||||
closeDrawable(R.drawable.ic_close)
|
||||
backgroundColor(literal = RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
slideDown()
|
||||
onCreate { cab, menu -> callback.onCabCreated(cab, menu) }
|
||||
onSelection {
|
||||
callback.onCabItemClicked(it)
|
||||
}
|
||||
onDestroy { callback.onCabFinished(it) }
|
||||
}
|
||||
return cab as AttachedCab
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,11 +31,15 @@ import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeF
|
|||
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder
|
||||
import code.name.monkey.retromusic.interfaces.IAlbumArtistClickListener
|
||||
import code.name.monkey.retromusic.interfaces.IArtistClickListener
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
import com.afollestad.materialcab.attached.destroy
|
||||
import com.afollestad.materialcab.attached.isActive
|
||||
import com.afollestad.materialcab.createCab
|
||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||
|
||||
class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
|
||||
|
@ -324,28 +328,34 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
|
|||
|
||||
private fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
private var cab: AttachedCab? = null
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
override fun openCab(menuRes: Int, callback: ICabCallback): AttachedCab {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
cab = createCab(R.id.cab_stub) {
|
||||
menu(menuRes)
|
||||
closeDrawable(R.drawable.ic_close)
|
||||
backgroundColor(literal = RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
slideDown()
|
||||
onCreate { cab, menu -> callback.onCabCreated(cab, menu) }
|
||||
onSelection {
|
||||
callback.onCabItemClicked(it)
|
||||
}
|
||||
onDestroy { callback.onCabFinished(it) }
|
||||
}
|
||||
return cab as AttachedCab
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,10 +22,14 @@ import code.name.monkey.retromusic.extensions.dipToPix
|
|||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
import com.afollestad.materialcab.attached.destroy
|
||||
import com.afollestad.materialcab.attached.isActive
|
||||
import com.afollestad.materialcab.createCab
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator
|
||||
|
@ -158,29 +162,35 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
|
||||
private fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
private var cab: AttachedCab? = null
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
override fun openCab(menuRes: Int, callback: ICabCallback): AttachedCab {
|
||||
cab?.let {
|
||||
println("Cab")
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
cab = createCab(R.id.cab_stub) {
|
||||
menu(menuRes)
|
||||
closeDrawable(R.drawable.ic_close)
|
||||
backgroundColor(literal = RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
slideDown()
|
||||
onCreate { cab, menu -> callback.onCabCreated(cab, menu) }
|
||||
onSelection {
|
||||
callback.onCabItemClicked(it)
|
||||
}
|
||||
onDestroy { callback.onCabFinished(it) }
|
||||
}
|
||||
return cab as AttachedCab
|
||||
}
|
||||
|
||||
}
|
|
@ -26,11 +26,15 @@ import code.name.monkey.retromusic.extensions.surfaceColor
|
|||
import code.name.monkey.retromusic.fragments.ReloadType
|
||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder
|
||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
import com.afollestad.materialcab.attached.destroy
|
||||
import com.afollestad.materialcab.attached.isActive
|
||||
import com.afollestad.materialcab.createCab
|
||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||
|
||||
class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
|
||||
|
@ -348,30 +352,36 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
|||
}
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
private var cab: AttachedCab? = null
|
||||
|
||||
private fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
override fun openCab(menuRes: Int, callback: ICabCallback): AttachedCab {
|
||||
cab?.let {
|
||||
println("Cab")
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
if (it.isActive()) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
cab = createCab(R.id.cab_stub) {
|
||||
menu(menuRes)
|
||||
closeDrawable(R.drawable.ic_close)
|
||||
backgroundColor(literal = RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
slideDown()
|
||||
onCreate { cab, menu -> callback.onCabCreated(cab, menu) }
|
||||
onSelection {
|
||||
callback.onCabItemClicked(it)
|
||||
}
|
||||
onDestroy { callback.onCabFinished(it) }
|
||||
}
|
||||
return cab as AttachedCab
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
package code.name.monkey.retromusic.interfaces
|
||||
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
|
||||
interface ICabCallback {
|
||||
fun onCabCreated(cab: AttachedCab, menu: Menu): Boolean
|
||||
|
||||
fun onCabItemClicked(item: MenuItem): Boolean
|
||||
|
||||
fun onCabFinished(cab: AttachedCab): Boolean
|
||||
}
|
|
@ -14,9 +14,9 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.interfaces
|
||||
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
|
||||
interface ICabHolder {
|
||||
|
||||
fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab
|
||||
fun openCab(menuRes: Int, callback: ICabCallback): AttachedCab
|
||||
}
|
||||
|
|
|
@ -544,7 +544,7 @@ object PreferenceUtil {
|
|||
|
||||
var startDirectory: File
|
||||
get() {
|
||||
val folderPath = FoldersFragment.getDefaultStartDirectory().path
|
||||
val folderPath = FoldersFragment.defaultStartDirectory.path
|
||||
val filePath: String = sharedPreferences.getStringOrDefault(START_DIRECTORY, folderPath)
|
||||
return File(filePath)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
<item name="rectSelector">@drawable/rect_selector</item>
|
||||
|
@ -37,7 +36,6 @@
|
|||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
<item name="rectSelector">@drawable/rect_selector</item>
|
||||
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
<item name="rectSelector">@drawable/rect_selector</item>
|
||||
|
@ -25,7 +24,6 @@
|
|||
<item name="android:windowActivityTransitions">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
<item name="rectSelector">@drawable/rect_selector</item>
|
||||
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
|
||||
|
@ -53,7 +51,6 @@
|
|||
<item name="colorSurface">@color/blackColorSurface</item>
|
||||
<item name="colorOnBackground">@color/blackColorSurface</item>
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
<item name="popupMenuStyle">@style/MaterialPopupMenuStyle</item>
|
||||
<item name="materialCardViewStyle">@style/Widget.Material3.CardView.Elevated</item>
|
||||
<item name="bottomSheetTint">@color/bottomSheetColorBlack</item>
|
||||
|
|
Loading…
Reference in a new issue