Added multi-select in playlists tab (#1132)
This commit is contained in:
parent
e1b9d518a7
commit
b78452b589
2 changed files with 44 additions and 6 deletions
|
@ -16,7 +16,7 @@ android {
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|
||||||
applicationId "code.name.monkey.retromusic"
|
applicationId "code.name.monkey.retromusic"
|
||||||
versionCode 10519
|
versionCode 10520
|
||||||
versionName '5.0.0' + "_" + getDate()
|
versionName '5.0.0' + "_" + getDate()
|
||||||
|
|
||||||
buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"")
|
buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"")
|
||||||
|
@ -139,7 +139,7 @@ dependencies {
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
|
||||||
def kotlin_coroutines_version = "1.5.1"
|
def kotlin_coroutines_version = "1.5.2-native-mt"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ package code.name.monkey.retromusic.fragments.playlists
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import androidx.activity.addCallback
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.MenuCompat
|
import androidx.core.view.MenuCompat
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
@ -24,17 +25,21 @@ import code.name.monkey.retromusic.EXTRA_PLAYLIST
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.playlist.PlaylistAdapter
|
import code.name.monkey.retromusic.adapter.playlist.PlaylistAdapter
|
||||||
import code.name.monkey.retromusic.db.PlaylistWithSongs
|
import code.name.monkey.retromusic.db.PlaylistWithSongs
|
||||||
|
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||||
import code.name.monkey.retromusic.fragments.ReloadType
|
import code.name.monkey.retromusic.fragments.ReloadType
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
||||||
import code.name.monkey.retromusic.helper.SortOrder.PlaylistSortOrder
|
import code.name.monkey.retromusic.helper.SortOrder.PlaylistSortOrder
|
||||||
|
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||||
import code.name.monkey.retromusic.interfaces.IPlaylistClickListener
|
import code.name.monkey.retromusic.interfaces.IPlaylistClickListener
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||||
|
import com.afollestad.materialcab.MaterialCab
|
||||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
|
|
||||||
class PlaylistsFragment :
|
class PlaylistsFragment :
|
||||||
AbsRecyclerViewCustomGridSizeFragment<PlaylistAdapter, GridLayoutManager>(),
|
AbsRecyclerViewCustomGridSizeFragment<PlaylistAdapter, GridLayoutManager>(),
|
||||||
IPlaylistClickListener {
|
IPlaylistClickListener, ICabHolder {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
@ -44,6 +49,12 @@ class PlaylistsFragment :
|
||||||
else
|
else
|
||||||
adapter?.swapDataSet(listOf())
|
adapter?.swapDataSet(listOf())
|
||||||
})
|
})
|
||||||
|
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
||||||
|
if (!handleBackPress()) {
|
||||||
|
remove()
|
||||||
|
requireActivity().onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val titleRes: Int
|
override val titleRes: Int
|
||||||
|
@ -60,7 +71,7 @@ class PlaylistsFragment :
|
||||||
requireActivity(),
|
requireActivity(),
|
||||||
ArrayList(),
|
ArrayList(),
|
||||||
itemLayoutRes(),
|
itemLayoutRes(),
|
||||||
null,
|
this,
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -170,7 +181,7 @@ class PlaylistsFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadLayoutRes(): Int {
|
override fun loadLayoutRes(): Int {
|
||||||
return R.layout.item_card
|
return R.layout.item_grid
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveLayoutRes(layoutRes: Int) {
|
override fun saveLayoutRes(layoutRes: Int) {
|
||||||
|
@ -187,4 +198,31 @@ class PlaylistsFragment :
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private fun handleBackPress(): Boolean {
|
||||||
|
cab?.let {
|
||||||
|
if (it.isActive) {
|
||||||
|
it.finish()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private var cab: MaterialCab? = null
|
||||||
|
|
||||||
|
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||||
|
cab?.let {
|
||||||
|
println("Cab")
|
||||||
|
if (it.isActive) {
|
||||||
|
it.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||||
|
.setMenu(menuRes)
|
||||||
|
.setCloseDrawableRes(R.drawable.ic_close)
|
||||||
|
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||||
|
.start(callback)
|
||||||
|
return cab as MaterialCab
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue