From fea94f7d788cc5ae743456a59ef0027f813b41f1 Mon Sep 17 00:00:00 2001 From: h4h13 Date: Sun, 26 Apr 2020 15:47:09 +0530 Subject: [PATCH] Fix blacklist dialog --- .../adapter/song/ShuffleButtonSongAdapter.kt | 39 ++++++++++++++++--- .../res/layout/item_list_quick_actions.xml | 16 +++++++- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt index 8a64d624..32a4d141 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/ShuffleButtonSongAdapter.kt @@ -2,7 +2,6 @@ package code.name.monkey.retromusic.adapter.song import android.view.View import androidx.appcompat.app.AppCompatActivity -import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.PopupMenu import code.name.monkey.retromusic.R import code.name.monkey.retromusic.helper.MusicPlayerRemote @@ -25,8 +24,13 @@ class ShuffleButtonSongAdapter( override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) { if (holder.itemViewType == OFFSET_ITEM) { val viewHolder = holder as ViewHolder - viewHolder.info?.text = - activity.resources.getQuantityString(R.plurals.numSongs, dataSet.size, dataSet.size) + val info = + activity.resources.getQuantityString( + R.plurals.numSongs, + dataSet.size, + dataSet.size + ) + viewHolder.info?.text = info viewHolder.shuffleAction?.setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(dataSet, true) } @@ -42,20 +46,45 @@ class ShuffleButtonSongAdapter( viewHolder.changeLayoutType?.setOnClickListener { val popupMenu = PopupMenu(activity, viewHolder.changeLayoutType) popupMenu.inflate(R.menu.menu_layout_types) + popupMenu.setOnMenuItemClickListener { + when (it.itemId) { + R.layout.item_card -> + popupMenu.menu.findItem(R.id.action_layout_card).isChecked = true + R.layout.item_grid -> + popupMenu.menu.findItem(R.id.action_layout_normal).isChecked = true + + R.layout.item_card_color -> + popupMenu.menu.findItem(R.id.action_layout_colored_card).isChecked = true + + R.layout.item_grid_circle -> + popupMenu.menu.findItem(R.id.action_layout_circular).isChecked = true + + R.layout.image -> + popupMenu.menu.findItem(R.id.action_layout_image).isChecked = true + + R.layout.item_image_gradient -> + popupMenu.menu.findItem(R.id.action_layout_gradient_image).isChecked = true + } + PreferenceUtil.getInstance(activity).songGridStyle = it.itemId + true + } popupMenu.show() + popupMenu.menu + .findItem(PreferenceUtil.getInstance(activity).songGridStyle).isChecked = true } } private fun showSortMenu(viewHolder: ViewHolder) { viewHolder.sortOrder?.setOnClickListener { val popupMenu = PopupMenu(activity, viewHolder.sortOrder) + popupMenu.inflate(R.menu.menu_song_sort_order) popupMenu.show() } } inner class ViewHolder(itemView: View) : AbsOffsetSongAdapter.ViewHolder(itemView) { - val sortOrder: AppCompatImageView? = itemView.findViewById(R.id.sortOrder) - val changeLayoutType: AppCompatImageView? = itemView.findViewById(R.id.changeLayoutType) + val sortOrder: View? = itemView.findViewById(R.id.sortOrder) + val changeLayoutType: View? = itemView.findViewById(R.id.changeLayoutType) val shuffleAction: View? = itemView.findViewById(R.id.shuffleAction) val info: MaterialTextView? = itemView.findViewById(R.id.info) } diff --git a/app/src/main/res/layout/item_list_quick_actions.xml b/app/src/main/res/layout/item_list_quick_actions.xml index 19a3ae8e..4339cd71 100644 --- a/app/src/main/res/layout/item_list_quick_actions.xml +++ b/app/src/main/res/layout/item_list_quick_actions.xml @@ -26,11 +26,23 @@ android:layout_height="wrap_content" android:padding="16dp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/sortOrder" + app:layout_constraintEnd_toStartOf="@id/gridSize" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" tools:text="@tools:sample/full_names" /> + +