Fix text over lapping #967
This commit is contained in:
parent
2d9d12f0bf
commit
4cfa8cc561
9 changed files with 93 additions and 40 deletions
|
@ -53,6 +53,7 @@ object Constants {
|
|||
)
|
||||
const val NUMBER_OF_TOP_TRACKS = 99
|
||||
}
|
||||
const val EXTRA_PLAYLIST_TYPE = "type"
|
||||
const val EXTRA_GENRE = "extra_genre"
|
||||
const val EXTRA_PLAYLIST = "extra_playlist"
|
||||
const val EXTRA_PLAYLIST_ID = "extra_playlist_id"
|
||||
|
|
|
@ -17,13 +17,12 @@ package code.name.monkey.retromusic.adapter
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.EXTRA_GENRE
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.interfaces.IGenreClickListener
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import java.util.*
|
||||
|
||||
|
@ -34,7 +33,8 @@ import java.util.*
|
|||
class GenreAdapter(
|
||||
private val activity: FragmentActivity,
|
||||
var dataSet: List<Genre>,
|
||||
private val mItemLayoutRes: Int
|
||||
private val mItemLayoutRes: Int,
|
||||
private val listener: IGenreClickListener
|
||||
) : RecyclerView.Adapter<GenreAdapter.ViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder(LayoutInflater.from(activity).inflate(mItemLayoutRes, parent, false))
|
||||
|
@ -62,10 +62,8 @@ class GenreAdapter(
|
|||
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
override fun onClick(v: View?) {
|
||||
activity.findNavController(R.id.fragment_container).navigate(
|
||||
R.id.genreDetailsFragment,
|
||||
bundleOf(EXTRA_GENRE to dataSet[layoutPosition])
|
||||
)
|
||||
ViewCompat.setTransitionName(itemView, "genre")
|
||||
listener.onClickGenre(dataSet[layoutPosition], itemView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
|
|||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
|
||||
import code.name.monkey.retromusic.interfaces.IArtistClickListener
|
||||
import code.name.monkey.retromusic.interfaces.IGenreClickListener
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -45,7 +46,8 @@ import com.google.android.material.card.MaterialCardView
|
|||
|
||||
class HomeAdapter(
|
||||
private val activity: AppCompatActivity
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>(), IArtistClickListener, IAlbumClickListener {
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>(), IArtistClickListener, IAlbumClickListener,
|
||||
IGenreClickListener {
|
||||
|
||||
private var list = listOf<Home>()
|
||||
|
||||
|
@ -220,7 +222,8 @@ class HomeAdapter(
|
|||
val genreAdapter = GenreAdapter(
|
||||
activity,
|
||||
home.arrayList as List<Genre>,
|
||||
R.layout.item_grid_genre
|
||||
R.layout.item_grid_genre,
|
||||
this@HomeAdapter
|
||||
)
|
||||
recyclerView.apply {
|
||||
layoutManager = GridLayoutManager(activity, 3, GridLayoutManager.HORIZONTAL, false)
|
||||
|
@ -267,4 +270,16 @@ class HomeAdapter(
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onClickGenre(genre: Genre, view: View) {
|
||||
activity.findNavController(R.id.fragment_container).navigate(
|
||||
R.id.genreDetailsFragment,
|
||||
bundleOf(EXTRA_GENRE to genre),
|
||||
null,
|
||||
FragmentNavigatorExtras(
|
||||
view to "genre"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,15 +50,6 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
protected var adapter: A? = null
|
||||
protected var layoutManager: LM? = null
|
||||
|
||||
private fun setUpTransitions() {
|
||||
exitTransition = Hold()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setUpTransitions()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mainActivity.setBottomBarVisibility(View.VISIBLE)
|
||||
|
|
|
@ -19,10 +19,12 @@ import android.view.Menu
|
|||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||
import code.name.monkey.retromusic.extensions.dipToPix
|
||||
|
@ -30,11 +32,11 @@ import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
|||
import code.name.monkey.retromusic.helper.menu.GenreMenuHelper
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import java.util.*
|
||||
import com.google.android.material.transition.MaterialContainerTransform
|
||||
import kotlinx.android.synthetic.main.fragment_playlist_detail.*
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
|
||||
class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_detail) {
|
||||
private val arguments by navArgs<GenreDetailsFragmentArgs>()
|
||||
|
@ -43,22 +45,31 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
|||
}
|
||||
private lateinit var genre: Genre
|
||||
private lateinit var songAdapter: SongAdapter
|
||||
private fun setUpTransitions() {
|
||||
val transform = MaterialContainerTransform()
|
||||
transform.setAllContainerColors(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
|
||||
sharedElementEnterTransition = transform
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setUpTransitions()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
mainActivity.setBottomBarVisibility(View.GONE)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
progressIndicator.hide()
|
||||
ViewCompat.setTransitionName(container, "genre")
|
||||
genre = arguments.extraGenre
|
||||
toolbar?.title = arguments.extraGenre.name
|
||||
setupRecyclerView()
|
||||
detailsViewModel.getSongs().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
|
||||
detailsViewModel.getSongs().observe(viewLifecycleOwner, {
|
||||
songs(it)
|
||||
})
|
||||
detailsViewModel.getGenre().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
|
||||
genre = it
|
||||
toolbar?.title = it.name
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
|
@ -77,7 +88,9 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
|||
}
|
||||
|
||||
fun songs(songs: List<Song>) {
|
||||
songAdapter.swapDataSet(songs)
|
||||
progressIndicator.hide()
|
||||
if (songs.isNotEmpty()) songAdapter.swapDataSet(songs)
|
||||
else songAdapter.swapDataSet(emptyList())
|
||||
}
|
||||
|
||||
private fun getEmojiByUnicode(unicode: Int): String {
|
||||
|
|
|
@ -16,13 +16,20 @@ package code.name.monkey.retromusic.fragments.genres
|
|||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.retromusic.EXTRA_GENRE
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.GenreAdapter
|
||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
|
||||
import code.name.monkey.retromusic.interfaces.IGenreClickListener
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
|
||||
class GenresFragment : AbsRecyclerViewFragment<GenreAdapter, LinearLayoutManager>() {
|
||||
class GenresFragment : AbsRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
|
||||
IGenreClickListener {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
libraryViewModel.getGenre().observe(viewLifecycleOwner, Observer {
|
||||
|
@ -39,7 +46,7 @@ class GenresFragment : AbsRecyclerViewFragment<GenreAdapter, LinearLayoutManager
|
|||
|
||||
override fun createAdapter(): GenreAdapter {
|
||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||
return GenreAdapter(requireActivity(), dataSet, R.layout.item_list_no_image)
|
||||
return GenreAdapter(requireActivity(), dataSet, R.layout.item_list_no_image, this)
|
||||
}
|
||||
|
||||
override val emptyMessage: Int
|
||||
|
@ -54,4 +61,15 @@ class GenresFragment : AbsRecyclerViewFragment<GenreAdapter, LinearLayoutManager
|
|||
return GenresFragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClickGenre(genre: Genre, view: View) {
|
||||
findNavController().navigate(
|
||||
R.id.genreDetailsFragment,
|
||||
bundleOf(EXTRA_GENRE to genre),
|
||||
null,
|
||||
FragmentNavigatorExtras(
|
||||
view to "genre"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,17 +29,13 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.HISTORY_PLAYLIST
|
||||
import code.name.monkey.retromusic.LAST_ADDED_PLAYLIST
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.TOP_PLAYED_PLAYLIST
|
||||
import code.name.monkey.retromusic.*
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter
|
||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
||||
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest
|
||||
import code.name.monkey.retromusic.glide.UserProfileGlideRequest
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -68,14 +64,14 @@ class HomeFragment :
|
|||
lastAdded.setOnClickListener {
|
||||
findNavController().navigate(
|
||||
R.id.detailListFragment,
|
||||
bundleOf("type" to LAST_ADDED_PLAYLIST)
|
||||
bundleOf(EXTRA_PLAYLIST_TYPE to LAST_ADDED_PLAYLIST)
|
||||
)
|
||||
}
|
||||
|
||||
topPlayed.setOnClickListener {
|
||||
findNavController().navigate(
|
||||
R.id.detailListFragment,
|
||||
bundleOf("type" to TOP_PLAYED_PLAYLIST)
|
||||
bundleOf(EXTRA_PLAYLIST_TYPE to TOP_PLAYED_PLAYLIST)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -86,7 +82,7 @@ class HomeFragment :
|
|||
history.setOnClickListener {
|
||||
findNavController().navigate(
|
||||
R.id.detailListFragment,
|
||||
bundleOf("type" to HISTORY_PLAYLIST)
|
||||
bundleOf(EXTRA_PLAYLIST_TYPE to HISTORY_PLAYLIST)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package code.name.monkey.retromusic.interfaces
|
||||
|
||||
import android.view.View
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
|
||||
interface IGenreClickListener {
|
||||
fun onClickGenre(genre: Genre, view: View)
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package code.name.monkey.retromusic.interfaces
|
||||
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
|
||||
interface IHomeClickListener {
|
||||
fun onAlbumClick(album: Album)
|
||||
|
||||
fun onArtistClick(artist: Artist)
|
||||
|
||||
fun onGenreClick(genre: Genre)
|
||||
}
|
Loading…
Reference in a new issue