WIP Removing library fragment
This commit is contained in:
parent
1145aa1918
commit
1174cbb477
12 changed files with 484 additions and 42 deletions
|
@ -1,33 +1,66 @@
|
||||||
package code.name.monkey.retromusic.activities
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
|
import android.app.ActivityOptions
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.SubMenu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.R.drawable
|
||||||
|
import code.name.monkey.retromusic.R.id
|
||||||
|
import code.name.monkey.retromusic.R.layout
|
||||||
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||||
|
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog.Companion.create
|
||||||
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.AlbumsFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.ArtistsFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.GenresFragment
|
||||||
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
|
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.PlayingQueueFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.PlaylistsFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.SongsFragment
|
||||||
import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment
|
import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment
|
||||||
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
|
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.helper.SearchQueryHelper
|
import code.name.monkey.retromusic.helper.SearchQueryHelper
|
||||||
|
import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder
|
||||||
|
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder
|
||||||
|
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder
|
||||||
|
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||||
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.loaders.AlbumLoader
|
import code.name.monkey.retromusic.loaders.AlbumLoader
|
||||||
import code.name.monkey.retromusic.loaders.ArtistLoader
|
import code.name.monkey.retromusic.loaders.ArtistLoader
|
||||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.AppRater
|
import code.name.monkey.retromusic.util.AppRater
|
||||||
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
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.MaterialCab.Callback
|
||||||
|
import com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener
|
||||||
|
import kotlinx.android.synthetic.main.activity_main_content.appBarLayout
|
||||||
|
import kotlinx.android.synthetic.main.activity_main_content.toolbar
|
||||||
|
import kotlinx.android.synthetic.main.activity_main_content.toolbarContainer
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
|
class MainActivity : AbsSlidingMusicPanelActivity(), CabHolder, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private lateinit var currentFragment: MainActivityFragmentCallbacks
|
private lateinit var currentFragment: MainActivityFragmentCallbacks
|
||||||
|
|
||||||
|
@ -71,6 +104,23 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
||||||
|
|
||||||
checkShowChangelog()
|
checkShowChangelog()
|
||||||
AppRater.appLaunched(this)
|
AppRater.appLaunched(this)
|
||||||
|
setupToolbar()
|
||||||
|
setBottomBarVisibility(View.VISIBLE)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupToolbar() {
|
||||||
|
toolbar.setBackgroundColor(Color.TRANSPARENT)
|
||||||
|
toolbarContainer.backgroundTintList =
|
||||||
|
ColorStateList.valueOf(resolveColor(this, R.attr.colorSurface))
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
toolbar.setOnClickListener {
|
||||||
|
val options = ActivityOptions
|
||||||
|
.makeSceneTransitionAnimation(
|
||||||
|
this, toolbarContainer,
|
||||||
|
getString(R.string.transition_toolbar)
|
||||||
|
)
|
||||||
|
NavigationUtil.goToSearch(this, options)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkShowChangelog() {
|
private fun checkShowChangelog() {
|
||||||
|
@ -238,12 +288,12 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
||||||
|
|
||||||
private fun selectedFragment(itemId: Int) {
|
private fun selectedFragment(itemId: Int) {
|
||||||
when (itemId) {
|
when (itemId) {
|
||||||
R.id.action_album,
|
R.id.action_album -> setCurrentFragment(AlbumsFragment.newInstance(), itemId.toString())
|
||||||
R.id.action_artist,
|
R.id.action_artist -> setCurrentFragment(ArtistsFragment.newInstance(), itemId.toString())
|
||||||
R.id.action_playlist,
|
R.id.action_playlist -> setCurrentFragment(PlaylistsFragment.newInstance(), itemId.toString())
|
||||||
R.id.action_genre,
|
R.id.action_genre -> setCurrentFragment(GenresFragment.newInstance(), itemId.toString())
|
||||||
R.id.action_playing_queue,
|
R.id.action_playing_queue -> setCurrentFragment(PlayingQueueFragment.newInstance(), itemId.toString())
|
||||||
R.id.action_song -> setCurrentFragment(LibraryFragment.newInstance(itemId), itemId.toString())
|
R.id.action_song -> setCurrentFragment(SongsFragment.newInstance(), itemId.toString())
|
||||||
R.id.action_home -> setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
|
R.id.action_home -> setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
|
||||||
else -> {
|
else -> {
|
||||||
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
|
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
|
||||||
|
@ -269,4 +319,286 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
|
||||||
private const val REQUEST_CODE_THEME = 9002
|
private const val REQUEST_CODE_THEME = 9002
|
||||||
private const val PURCHASE_REQUEST = 101
|
private const val PURCHASE_REQUEST = 101
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private lateinit var cab: MaterialCab
|
||||||
|
|
||||||
|
fun getTotalAppBarScrollingRange(): Int {
|
||||||
|
return appBarLayout.totalScrollRange
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addOnAppBarOffsetChangedListener(
|
||||||
|
onOffsetChangedListener: OnOffsetChangedListener
|
||||||
|
) {
|
||||||
|
appBarLayout.addOnOffsetChangedListener(onOffsetChangedListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeOnAppBarOffsetChangedListener(
|
||||||
|
onOffsetChangedListener: OnOffsetChangedListener
|
||||||
|
) {
|
||||||
|
appBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openCab(menuRes: Int, callback: Callback): MaterialCab {
|
||||||
|
if (cab != null && cab.isActive()) {
|
||||||
|
cab.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
cab = MaterialCab(this, R.id.cab_stub)
|
||||||
|
.setMenu(menuRes)
|
||||||
|
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||||
|
.setBackgroundColor(
|
||||||
|
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||||
|
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.start(callback)
|
||||||
|
return cab
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getCurrentFragment(): Fragment? {
|
||||||
|
return if (supportFragmentManager == null) {
|
||||||
|
SongsFragment.newInstance()
|
||||||
|
} else supportFragmentManager.findFragmentByTag(LibraryFragment.TAG)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.menu_main, menu)
|
||||||
|
val currentFragment: Fragment? = getCurrentFragment()
|
||||||
|
if (currentFragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>
|
||||||
|
&& currentFragment.isAdded()
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (currentFragment is SongsFragment) {
|
||||||
|
menu!!.removeItem(id.action_grid_size)
|
||||||
|
menu.removeItem(id.action_layout_type)
|
||||||
|
} else {
|
||||||
|
val gridSizeItem = menu!!.findItem(id.action_grid_size)
|
||||||
|
if (RetroUtil.isLandscape()) {
|
||||||
|
gridSizeItem.setTitle(string.action_grid_size_land)
|
||||||
|
}
|
||||||
|
setUpGridSizeMenu(currentFragment, gridSizeItem.subMenu)
|
||||||
|
val layoutItem = menu.findItem(id.action_layout_type)
|
||||||
|
setupLayoutMenu(currentFragment, layoutItem.subMenu)
|
||||||
|
}
|
||||||
|
setUpSortOrderMenu(currentFragment, menu.findItem(id.action_sort_order).subMenu)
|
||||||
|
} else if (currentFragment is GenresFragment || currentFragment is PlayingQueueFragment) {
|
||||||
|
menu!!.removeItem(id.action_new_playlist)
|
||||||
|
menu.removeItem(id.action_layout_type)
|
||||||
|
menu.removeItem(id.action_grid_size)
|
||||||
|
menu.removeItem(id.action_sort_order)
|
||||||
|
} else {
|
||||||
|
menu!!.add(0, id.action_new_playlist, 0, string.new_playlist_title)
|
||||||
|
.setIcon(drawable.ic_playlist_add_white_24dp)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||||
|
menu.removeItem(id.action_grid_size)
|
||||||
|
menu.removeItem(id.action_layout_type)
|
||||||
|
}
|
||||||
|
return super.onCreateOptionsMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpGridSizeMenu(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
gridSizeMenu: SubMenu
|
||||||
|
) {
|
||||||
|
when (fragment.getGridSize()) {
|
||||||
|
1 -> gridSizeMenu.findItem(id.action_grid_size_1).isChecked = true
|
||||||
|
2 -> gridSizeMenu.findItem(id.action_grid_size_2).isChecked = true
|
||||||
|
3 -> gridSizeMenu.findItem(id.action_grid_size_3).isChecked = true
|
||||||
|
4 -> gridSizeMenu.findItem(id.action_grid_size_4).isChecked = true
|
||||||
|
5 -> gridSizeMenu.findItem(id.action_grid_size_5).isChecked = true
|
||||||
|
6 -> gridSizeMenu.findItem(id.action_grid_size_6).isChecked = true
|
||||||
|
7 -> gridSizeMenu.findItem(id.action_grid_size_7).isChecked = true
|
||||||
|
8 -> gridSizeMenu.findItem(id.action_grid_size_8).isChecked = true
|
||||||
|
}
|
||||||
|
val maxGridSize = fragment.maxGridSize
|
||||||
|
if (maxGridSize < 8) {
|
||||||
|
gridSizeMenu.findItem(id.action_grid_size_8).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 7) {
|
||||||
|
gridSizeMenu.findItem(id.action_grid_size_7).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 6) {
|
||||||
|
gridSizeMenu.findItem(id.action_grid_size_6).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 5) {
|
||||||
|
gridSizeMenu.findItem(id.action_grid_size_5).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 4) {
|
||||||
|
gridSizeMenu.findItem(id.action_grid_size_4).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 3) {
|
||||||
|
gridSizeMenu.findItem(id.action_grid_size_3).isVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpSortOrderMenu(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
sortOrderMenu: SubMenu
|
||||||
|
) {
|
||||||
|
val currentSortOrder = fragment.getSortOrder()
|
||||||
|
sortOrderMenu.clear()
|
||||||
|
when (fragment) {
|
||||||
|
is AlbumsFragment -> {
|
||||||
|
sortOrderMenu.add(0, id.action_album_sort_order_asc, 0, string.sort_order_a_z).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_A_Z
|
||||||
|
sortOrderMenu.add(0, id.action_album_sort_order_desc, 1, string.sort_order_z_a).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_Z_A
|
||||||
|
sortOrderMenu.add(0, id.action_album_sort_order_artist, 2, string.sort_order_artist).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_ARTIST
|
||||||
|
sortOrderMenu.add(0, id.action_album_sort_order_year, 3, string.sort_order_year).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_YEAR
|
||||||
|
}
|
||||||
|
is ArtistsFragment -> {
|
||||||
|
sortOrderMenu.add(0, id.action_artist_sort_order_asc, 0, string.sort_order_a_z).isChecked =
|
||||||
|
currentSortOrder == ArtistSortOrder.ARTIST_A_Z
|
||||||
|
sortOrderMenu.add(0, id.action_artist_sort_order_desc, 1, string.sort_order_z_a).isChecked =
|
||||||
|
currentSortOrder == ArtistSortOrder.ARTIST_Z_A
|
||||||
|
}
|
||||||
|
is SongsFragment -> {
|
||||||
|
sortOrderMenu.add(0, id.action_song_sort_order_asc, 0, string.sort_order_a_z).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_A_Z
|
||||||
|
sortOrderMenu.add(0, id.action_song_sort_order_desc, 1, string.sort_order_z_a).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_Z_A
|
||||||
|
sortOrderMenu.add(0, id.action_song_sort_order_artist, 2, string.sort_order_artist).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_ARTIST
|
||||||
|
sortOrderMenu.add(0, id.action_song_sort_order_album, 3, string.sort_order_album).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_ALBUM
|
||||||
|
sortOrderMenu.add(0, id.action_song_sort_order_year, 4, string.sort_order_year).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_YEAR
|
||||||
|
sortOrderMenu.add(0, id.action_song_sort_order_date, 5, string.sort_order_date).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_DATE
|
||||||
|
sortOrderMenu.add(0, id.action_song_sort_order_composer, 6, string.sort_order_composer).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.COMPOSER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sortOrderMenu.setGroupCheckable(0, true, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupLayoutMenu(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
subMenu: SubMenu
|
||||||
|
) {
|
||||||
|
when (fragment.itemLayoutRes()) {
|
||||||
|
layout.item_card -> subMenu.findItem(id.action_layout_card).isChecked = true
|
||||||
|
layout.item_grid -> subMenu.findItem(id.action_layout_normal).isChecked = true
|
||||||
|
layout.item_card_color -> subMenu.findItem(id.action_layout_colored_card).isChecked = true
|
||||||
|
layout.item_grid_circle -> subMenu.findItem(id.action_layout_circular).isChecked = true
|
||||||
|
layout.image -> subMenu.findItem(id.action_layout_image).isChecked = true
|
||||||
|
layout.item_image_gradient -> subMenu.findItem(id.action_layout_gradient_image).isChecked = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
//if (pager == null) return false;
|
||||||
|
val currentFragment = getCurrentFragment()
|
||||||
|
if (currentFragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>) {
|
||||||
|
if (handleGridSizeMenuItem(currentFragment, item)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (handleLayoutResType(currentFragment, item)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (handleSortOrderMenuItem(currentFragment, item)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_search -> {
|
||||||
|
val options = ActivityOptions
|
||||||
|
.makeSceneTransitionAnimation(
|
||||||
|
this, toolbarContainer,
|
||||||
|
getString(string.transition_toolbar)
|
||||||
|
)
|
||||||
|
NavigationUtil.goToSearch(this, options)
|
||||||
|
}
|
||||||
|
R.id.action_new_playlist -> {
|
||||||
|
create().show(supportFragmentManager, "CREATE_PLAYLIST")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleGridSizeMenuItem(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
item: MenuItem
|
||||||
|
): Boolean {
|
||||||
|
var gridSize = 0
|
||||||
|
when (item.itemId) {
|
||||||
|
id.action_grid_size_1 -> gridSize = 1
|
||||||
|
id.action_grid_size_2 -> gridSize = 2
|
||||||
|
id.action_grid_size_3 -> gridSize = 3
|
||||||
|
id.action_grid_size_4 -> gridSize = 4
|
||||||
|
id.action_grid_size_5 -> gridSize = 5
|
||||||
|
id.action_grid_size_6 -> gridSize = 6
|
||||||
|
id.action_grid_size_7 -> gridSize = 7
|
||||||
|
id.action_grid_size_8 -> gridSize = 8
|
||||||
|
}
|
||||||
|
if (gridSize > 0) {
|
||||||
|
item.isChecked = true
|
||||||
|
fragment.setAndSaveGridSize(gridSize)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleLayoutResType(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
item: MenuItem
|
||||||
|
): Boolean {
|
||||||
|
var layoutRes = -1
|
||||||
|
when (item.itemId) {
|
||||||
|
id.action_layout_normal -> layoutRes = layout.item_grid
|
||||||
|
id.action_layout_card -> layoutRes = layout.item_card
|
||||||
|
id.action_layout_colored_card -> layoutRes = layout.item_card_color
|
||||||
|
id.action_layout_circular -> layoutRes = layout.item_grid_circle
|
||||||
|
id.action_layout_image -> layoutRes = layout.image
|
||||||
|
id.action_layout_gradient_image -> layoutRes = layout.item_image_gradient
|
||||||
|
}
|
||||||
|
if (layoutRes != -1) {
|
||||||
|
item.isChecked = true
|
||||||
|
fragment.setAndSaveLayoutRes(layoutRes)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleSortOrderMenuItem(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>, item: MenuItem
|
||||||
|
): Boolean {
|
||||||
|
var sortOrder: String? = null
|
||||||
|
when (fragment) {
|
||||||
|
is SongsFragment -> {
|
||||||
|
when (item.itemId) {
|
||||||
|
id.action_song_sort_order_asc -> sortOrder = SongSortOrder.SONG_A_Z
|
||||||
|
id.action_song_sort_order_desc -> sortOrder = SongSortOrder.SONG_Z_A
|
||||||
|
id.action_song_sort_order_artist -> sortOrder = SongSortOrder.SONG_ARTIST
|
||||||
|
id.action_song_sort_order_album -> sortOrder = SongSortOrder.SONG_ALBUM
|
||||||
|
id.action_song_sort_order_year -> sortOrder = SongSortOrder.SONG_YEAR
|
||||||
|
id.action_song_sort_order_date -> sortOrder = SongSortOrder.SONG_DATE
|
||||||
|
id.action_song_sort_order_composer -> sortOrder = SongSortOrder.COMPOSER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is AlbumsFragment -> {
|
||||||
|
when (item.itemId) {
|
||||||
|
id.action_album_sort_order_asc -> sortOrder = AlbumSortOrder.ALBUM_A_Z
|
||||||
|
id.action_album_sort_order_desc -> sortOrder = AlbumSortOrder.ALBUM_Z_A
|
||||||
|
id.action_album_sort_order_artist -> sortOrder = AlbumSortOrder.ALBUM_ARTIST
|
||||||
|
id.action_album_sort_order_year -> sortOrder = AlbumSortOrder.ALBUM_YEAR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ArtistsFragment -> {
|
||||||
|
when (item.itemId) {
|
||||||
|
id.action_artist_sort_order_asc -> sortOrder = ArtistSortOrder.ARTIST_A_Z
|
||||||
|
id.action_artist_sort_order_desc -> sortOrder = ArtistSortOrder.ARTIST_Z_A
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sortOrder != null) {
|
||||||
|
item.isChecked = true
|
||||||
|
fragment.setAndSaveSortOrder(sortOrder)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package code.name.monkey.retromusic.fragments.base
|
package code.name.monkey.retromusic.fragments.base
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
|
import code.name.monkey.retromusic.activities.MainActivity
|
||||||
|
|
||||||
open class AbsLibraryPagerFragment : AbsMusicServiceFragment() {
|
open class AbsLibraryPagerFragment : AbsMusicServiceFragment() {
|
||||||
|
|
||||||
|
val mainActivity: MainActivity
|
||||||
val libraryFragment: LibraryFragment
|
get() = requireActivity() as MainActivity
|
||||||
get() = parentFragment as LibraryFragment
|
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
|
@ -35,7 +35,7 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
libraryFragment.addOnAppBarOffsetChangedListener(this)
|
mainActivity.addOnAppBarOffsetChangedListener(this)
|
||||||
initLayoutManager()
|
initLayoutManager()
|
||||||
initAdapter()
|
initAdapter()
|
||||||
setUpRecyclerView()
|
setUpRecyclerView()
|
||||||
|
@ -109,7 +109,7 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
||||||
container.paddingLeft,
|
container.paddingLeft,
|
||||||
container.paddingTop,
|
container.paddingTop,
|
||||||
container.paddingRight,
|
container.paddingRight,
|
||||||
libraryFragment.totalAppBarScrollingRange + i
|
mainActivity.getTotalAppBarScrollingRange() + i
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
libraryFragment.removeOnAppBarOffsetChangedListener(this)
|
mainActivity.removeOnAppBarOffsetChangedListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun recyclerView(): RecyclerView {
|
fun recyclerView(): RecyclerView {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import code.name.monkey.retromusic.App
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||||
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.model.Album
|
import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
|
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
|
||||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsView
|
import code.name.monkey.retromusic.mvp.presenter.AlbumsView
|
||||||
|
@ -14,7 +15,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
||||||
AlbumsView {
|
AlbumsView, MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var albumsPresenter: AlbumsPresenter
|
lateinit var albumsPresenter: AlbumsPresenter
|
||||||
|
@ -49,16 +50,16 @@ class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAd
|
||||||
get() = R.string.no_albums
|
get() = R.string.no_albums
|
||||||
|
|
||||||
override fun createLayoutManager(): GridLayoutManager {
|
override fun createLayoutManager(): GridLayoutManager {
|
||||||
return GridLayoutManager(activity, getGridSize())
|
return GridLayoutManager(requireActivity(), getGridSize())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createAdapter(): AlbumAdapter {
|
override fun createAdapter(): AlbumAdapter {
|
||||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||||
return AlbumAdapter(
|
return AlbumAdapter(
|
||||||
libraryFragment.mainActivity,
|
mainActivity,
|
||||||
dataSet,
|
dataSet,
|
||||||
itemLayoutRes(),
|
itemLayoutRes(),
|
||||||
libraryFragment
|
mainActivity
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,4 +126,8 @@ class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAd
|
||||||
return fragment
|
return fragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun handleBackPress(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import code.name.monkey.retromusic.App
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||||
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
|
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
|
||||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsView
|
import code.name.monkey.retromusic.mvp.presenter.ArtistsView
|
||||||
|
@ -14,7 +15,11 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
|
class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
|
||||||
ArtistsView {
|
ArtistsView, MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
|
override fun handleBackPress(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun artists(artists: List<Artist>) {
|
override fun artists(artists: List<Artist>) {
|
||||||
adapter?.swapDataSet(artists)
|
adapter?.swapDataSet(artists)
|
||||||
|
@ -57,21 +62,21 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createLayoutManager(): GridLayoutManager {
|
override fun createLayoutManager(): GridLayoutManager {
|
||||||
return GridLayoutManager(activity, getGridSize())
|
return GridLayoutManager(requireActivity(), getGridSize())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createAdapter(): ArtistAdapter {
|
override fun createAdapter(): ArtistAdapter {
|
||||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||||
return ArtistAdapter(
|
return ArtistAdapter(
|
||||||
libraryFragment.mainActivity,
|
mainActivity,
|
||||||
dataSet,
|
dataSet,
|
||||||
itemLayoutRes(),
|
itemLayoutRes(),
|
||||||
libraryFragment
|
mainActivity
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSize(): Int {
|
override fun loadGridSize(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getArtistGridSize(activity!!)
|
return PreferenceUtil.getInstance(requireContext()).getArtistGridSize(requireActivity())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSize(gridColumns: Int) {
|
override fun saveGridSize(gridColumns: Int) {
|
||||||
|
@ -79,7 +84,7 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSizeLand(): Int {
|
override fun loadGridSizeLand(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getArtistGridSizeLand(activity!!)
|
return PreferenceUtil.getInstance(requireContext()).getArtistGridSizeLand(requireActivity())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSizeLand(gridColumns: Int) {
|
override fun saveGridSizeLand(gridColumns: Int) {
|
||||||
|
|
|
@ -21,12 +21,19 @@ import code.name.monkey.retromusic.App
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.GenreAdapter
|
import code.name.monkey.retromusic.adapter.GenreAdapter
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
||||||
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.model.Genre
|
import code.name.monkey.retromusic.model.Genre
|
||||||
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter
|
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter
|
||||||
import code.name.monkey.retromusic.mvp.presenter.GenresView
|
import code.name.monkey.retromusic.mvp.presenter.GenresView
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(), GenresView {
|
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
|
||||||
|
GenresView, MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
|
override fun handleBackPress(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun genres(genres: List<Genre>) {
|
override fun genres(genres: List<Genre>) {
|
||||||
adapter?.swapDataSet(genres)
|
adapter?.swapDataSet(genres)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +47,7 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearL
|
||||||
|
|
||||||
override fun createAdapter(): GenreAdapter {
|
override fun createAdapter(): GenreAdapter {
|
||||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||||
return GenreAdapter(libraryFragment.mainActivity, dataSet, R.layout.item_list_no_image)
|
return GenreAdapter(mainActivity, dataSet, R.layout.item_list_no_image)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val emptyMessage: Int
|
override val emptyMessage: Int
|
||||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator
|
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager
|
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager
|
||||||
|
@ -32,7 +33,12 @@ import kotlinx.android.synthetic.main.activity_playing_queue.recyclerView
|
||||||
/**
|
/**
|
||||||
* Created by hemanths on 2019-12-08.
|
* Created by hemanths on 2019-12-08.
|
||||||
*/
|
*/
|
||||||
class PlayingQueueFragment : AbsLibraryPagerRecyclerViewFragment<PlayingQueueAdapter, LinearLayoutManager>() {
|
class PlayingQueueFragment : AbsLibraryPagerRecyclerViewFragment<PlayingQueueAdapter, LinearLayoutManager>(),
|
||||||
|
MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
|
override fun handleBackPress(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private lateinit var wrappedAdapter: RecyclerView.Adapter<*>
|
private lateinit var wrappedAdapter: RecyclerView.Adapter<*>
|
||||||
private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null
|
private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null
|
||||||
|
|
|
@ -9,12 +9,18 @@ import code.name.monkey.retromusic.App
|
||||||
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.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewFragment
|
||||||
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.model.Playlist
|
||||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistView
|
import code.name.monkey.retromusic.mvp.presenter.PlaylistView
|
||||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter
|
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistView {
|
class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistView,
|
||||||
|
MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
|
override fun handleBackPress(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var playlistsPresenter: PlaylistsPresenter
|
lateinit var playlistsPresenter: PlaylistsPresenter
|
||||||
|
@ -38,8 +44,10 @@ class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, L
|
||||||
|
|
||||||
override fun createAdapter(): PlaylistAdapter {
|
override fun createAdapter(): PlaylistAdapter {
|
||||||
return PlaylistAdapter(
|
return PlaylistAdapter(
|
||||||
libraryFragment.mainActivity, ArrayList(),
|
mainActivity,
|
||||||
R.layout.item_list, libraryFragment
|
ArrayList(),
|
||||||
|
R.layout.item_list,
|
||||||
|
mainActivity
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.song.ShuffleButtonSongAdapter
|
import code.name.monkey.retromusic.adapter.song.ShuffleButtonSongAdapter
|
||||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||||
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
||||||
import code.name.monkey.retromusic.mvp.presenter.SongView
|
import code.name.monkey.retromusic.mvp.presenter.SongView
|
||||||
|
@ -17,7 +18,7 @@ import java.util.ArrayList
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, LinearLayoutManager>(),
|
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, LinearLayoutManager>(),
|
||||||
SongView {
|
SongView, MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var songPresenter: SongPresenter
|
lateinit var songPresenter: SongPresenter
|
||||||
|
@ -36,16 +37,16 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createLayoutManager(): LinearLayoutManager {
|
override fun createLayoutManager(): LinearLayoutManager {
|
||||||
return LinearLayoutManager(activity)
|
return LinearLayoutManager(requireActivity())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createAdapter(): SongAdapter {
|
override fun createAdapter(): SongAdapter {
|
||||||
val dataSet = if (adapter == null) mutableListOf() else adapter!!.dataSet
|
val dataSet = if (adapter == null) mutableListOf() else adapter!!.dataSet
|
||||||
return ShuffleButtonSongAdapter(
|
return ShuffleButtonSongAdapter(
|
||||||
libraryFragment.mainActivity,
|
mainActivity,
|
||||||
dataSet,
|
dataSet,
|
||||||
R.layout.item_list,
|
R.layout.item_list,
|
||||||
libraryFragment
|
mainActivity
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSize(): Int {
|
override fun loadGridSize(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getSongGridSize(activity!!)
|
return PreferenceUtil.getInstance(requireContext()).getSongGridSize(requireActivity())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSize(gridColumns: Int) {
|
override fun saveGridSize(gridColumns: Int) {
|
||||||
|
@ -66,7 +67,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSizeLand(): Int {
|
override fun loadGridSizeLand(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getSongGridSizeLand(activity!!)
|
return PreferenceUtil.getInstance(requireContext()).getSongGridSizeLand(requireActivity())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSizeLand(gridColumns: Int) {
|
override fun saveGridSizeLand(gridColumns: Int) {
|
||||||
|
@ -109,6 +110,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
||||||
@JvmField
|
@JvmField
|
||||||
var TAG: String = SongsFragment::class.java.simpleName
|
var TAG: String = SongsFragment::class.java.simpleName
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
fun newInstance(): SongsFragment {
|
fun newInstance(): SongsFragment {
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
val fragment = SongsFragment()
|
val fragment = SongsFragment()
|
||||||
|
@ -127,4 +129,8 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
||||||
|
|
||||||
override fun saveLayoutRes(@LayoutRes layoutRes: Int) {
|
override fun saveLayoutRes(@LayoutRes layoutRes: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun handleBackPress(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ class SortOrder {
|
||||||
* Artist sort order entries.
|
* Artist sort order entries.
|
||||||
*/
|
*/
|
||||||
interface ArtistSortOrder {
|
interface ArtistSortOrder {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Artist sort order A-Z */
|
/* Artist sort order A-Z */
|
||||||
|
@ -41,6 +42,7 @@ class SortOrder {
|
||||||
* Album sort order entries.
|
* Album sort order entries.
|
||||||
*/
|
*/
|
||||||
interface AlbumSortOrder {
|
interface AlbumSortOrder {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Album sort order A-Z */
|
/* Album sort order A-Z */
|
||||||
|
@ -65,6 +67,7 @@ class SortOrder {
|
||||||
* Song sort order entries.
|
* Song sort order entries.
|
||||||
*/
|
*/
|
||||||
interface SongSortOrder {
|
interface SongSortOrder {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Song sort order A-Z */
|
/* Song sort order A-Z */
|
||||||
|
@ -88,6 +91,9 @@ class SortOrder {
|
||||||
/* Song sort order date */
|
/* Song sort order date */
|
||||||
const val SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC"
|
const val SONG_DATE = MediaStore.Audio.Media.DATE_ADDED + " DESC"
|
||||||
|
|
||||||
|
/* Song sort modified date */
|
||||||
|
const val SONG_MODIFIED = MediaStore.Audio.Media.DATE_MODIFIED + " DESC"
|
||||||
|
|
||||||
/* Song sort order composer*/
|
/* Song sort order composer*/
|
||||||
const val COMPOSER = MediaStore.Audio.Media.COMPOSER
|
const val COMPOSER = MediaStore.Audio.Media.COMPOSER
|
||||||
}
|
}
|
||||||
|
@ -97,6 +103,7 @@ class SortOrder {
|
||||||
* Album song sort order entries.
|
* Album song sort order entries.
|
||||||
*/
|
*/
|
||||||
interface AlbumSongSortOrder {
|
interface AlbumSongSortOrder {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Album song sort order A-Z */
|
/* Album song sort order A-Z */
|
||||||
|
@ -118,6 +125,7 @@ class SortOrder {
|
||||||
* Artist song sort order entries.
|
* Artist song sort order entries.
|
||||||
*/
|
*/
|
||||||
interface ArtistSongSortOrder {
|
interface ArtistSongSortOrder {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Artist song sort order A-Z */
|
/* Artist song sort order A-Z */
|
||||||
|
@ -144,6 +152,7 @@ class SortOrder {
|
||||||
* Artist album sort order entries.
|
* Artist album sort order entries.
|
||||||
*/
|
*/
|
||||||
interface ArtistAlbumSortOrder {
|
interface ArtistAlbumSortOrder {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Artist album sort order A-Z */
|
/* Artist album sort order A-Z */
|
||||||
|
@ -164,6 +173,7 @@ class SortOrder {
|
||||||
* Genre sort order entries.
|
* Genre sort order entries.
|
||||||
*/
|
*/
|
||||||
interface GenreSortOrder {
|
interface GenreSortOrder {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Genre sort order A-Z */
|
/* Genre sort order A-Z */
|
||||||
|
@ -173,5 +183,4 @@ class SortOrder {
|
||||||
const val ALBUM_Z_A = "$GENRE_A_Z DESC"
|
const val ALBUM_Z_A = "$GENRE_A_Z DESC"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,7 +19,6 @@ package code.name.monkey.retromusic.interfaces
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface MainActivityFragmentCallbacks {
|
interface MainActivityFragmentCallbacks {
|
||||||
fun handleBackPress(): Boolean
|
|
||||||
|
|
||||||
//void selectedFragment(Fragment fragment);
|
fun handleBackPress(): Boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,71 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?colorSurface"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:elevation="0dp"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
|
<include layout="@layout/status_bar" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appBarLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:elevation="0dp"
|
||||||
|
app:elevation="0dp"
|
||||||
|
app:liftOnScroll="true">
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:id="@+id/toolbarContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="8dp"
|
||||||
|
app:cardUseCompatPadding="true"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/toolbar_height"
|
||||||
|
android:background="?colorSurface"
|
||||||
|
app:navigationIcon="@drawable/ic_menu_white_24dp"
|
||||||
|
app:popupTheme="?attr/toolbarPopupTheme"
|
||||||
|
app:title="@string/action_search"
|
||||||
|
app:titleTextAppearance="@style/TextViewHeadline6"
|
||||||
|
app:titleTextColor="?android:attr/textColorSecondary"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
|
<ViewStub
|
||||||
|
android:id="@+id/cab_stub"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/toolbar_height" />
|
||||||
|
</FrameLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
android:id="@+id/fragment_container"
|
android:id="@+id/fragment_container"
|
||||||
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" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
</LinearLayout>
|
Loading…
Reference in a new issue