code clean
This commit is contained in:
parent
c5a4b4b4c6
commit
6845f75ea0
3 changed files with 84 additions and 83 deletions
|
@ -16,52 +16,70 @@ package code.name.monkey.retromusic.adapter.base;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
|
|
||||||
import com.google.android.material.card.MaterialCardView;
|
import com.google.android.material.card.MaterialCardView;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
|
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
|
||||||
|
|
||||||
public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHolder
|
public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHolder
|
||||||
implements View.OnLongClickListener, View.OnClickListener {
|
implements View.OnLongClickListener, View.OnClickListener {
|
||||||
|
|
||||||
@Nullable public View dragView;
|
@Nullable
|
||||||
|
public View dragView;
|
||||||
|
|
||||||
@Nullable public View dummyContainer;
|
@Nullable
|
||||||
|
public View dummyContainer;
|
||||||
|
|
||||||
@Nullable public ImageView image;
|
@Nullable
|
||||||
|
public ImageView image;
|
||||||
|
|
||||||
@Nullable public ImageView artistImage;
|
@Nullable
|
||||||
|
public ImageView artistImage;
|
||||||
|
|
||||||
@Nullable public ImageView playerImage;
|
@Nullable
|
||||||
|
public ImageView playerImage;
|
||||||
|
|
||||||
@Nullable public MaterialCardView imageContainerCard;
|
@Nullable
|
||||||
|
public MaterialCardView imageContainerCard;
|
||||||
|
|
||||||
@Nullable public TextView imageText;
|
@Nullable
|
||||||
|
public TextView imageText;
|
||||||
|
|
||||||
@Nullable public MaterialCardView imageTextContainer;
|
@Nullable
|
||||||
|
public MaterialCardView imageTextContainer;
|
||||||
|
|
||||||
@Nullable public View mask;
|
@Nullable
|
||||||
|
public View mask;
|
||||||
|
|
||||||
@Nullable public AppCompatImageView menu;
|
@Nullable
|
||||||
|
public AppCompatImageView menu;
|
||||||
|
|
||||||
@Nullable public View paletteColorContainer;
|
@Nullable
|
||||||
|
public View paletteColorContainer;
|
||||||
|
|
||||||
|
|
||||||
@Nullable public RecyclerView recyclerView;
|
@Nullable
|
||||||
|
public RecyclerView recyclerView;
|
||||||
|
|
||||||
@Nullable public TextView text;
|
@Nullable
|
||||||
|
public TextView text;
|
||||||
|
|
||||||
@Nullable public TextView text2;
|
@Nullable
|
||||||
|
public TextView text2;
|
||||||
|
|
||||||
@Nullable public TextView time;
|
@Nullable
|
||||||
|
public TextView time;
|
||||||
|
|
||||||
@Nullable public TextView title;
|
@Nullable
|
||||||
|
public TextView title;
|
||||||
|
|
||||||
public MediaEntryViewHolder(@NonNull View itemView) {
|
public MediaEntryViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -99,7 +117,8 @@ public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHold
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {}
|
public void onClick(View v) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
|
|
|
@ -95,13 +95,7 @@ fun SeekBar.addAccentColor() {
|
||||||
thumbTintList = colorState
|
thumbTintList = colorState
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Button.accentTextColor() {
|
fun Button.accentTextColor() = setTextColor(ThemeStore.accentColor(App.getContext()))
|
||||||
setTextColor(ThemeStore.accentColor(App.getContext()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun MaterialButton.accentTextColor() {
|
|
||||||
setTextColor(ThemeStore.accentColor(App.getContext()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun MaterialButton.accentBackgroundColor() {
|
fun MaterialButton.accentBackgroundColor() {
|
||||||
backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(App.getContext()))
|
backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(App.getContext()))
|
||||||
|
@ -154,9 +148,7 @@ fun MaterialButton.applyColor(color: Int) {
|
||||||
iconTint = textColorColorStateList
|
iconTint = textColorColorStateList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MaterialButton.accentColor() {
|
fun MaterialButton.accentColor() = applyColor(ThemeStore.accentColor(context))
|
||||||
this.applyColor(ThemeStore.accentColor(context))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun MaterialButton.applyOutlineColor(color: Int) {
|
fun MaterialButton.applyOutlineColor(color: Int) {
|
||||||
val textColorColorStateList = ColorStateList.valueOf(color)
|
val textColorColorStateList = ColorStateList.valueOf(color)
|
||||||
|
@ -183,12 +175,7 @@ fun CircularProgressIndicator.applyColor(color: Int) {
|
||||||
trackColor = ColorUtil.withAlpha(color, 0.2f)
|
trackColor = ColorUtil.withAlpha(color, 0.2f)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun TextInputEditText.accentColor() {
|
fun AppCompatImageView.accentColor(): Int = ThemeStore.accentColor(context)
|
||||||
}
|
|
||||||
|
|
||||||
fun AppCompatImageView.accentColor(): Int {
|
|
||||||
return ThemeStore.accentColor(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
@CheckResult
|
@CheckResult
|
||||||
fun Drawable.tint(@ColorInt color: Int): Drawable {
|
fun Drawable.tint(@ColorInt color: Int): Drawable {
|
||||||
|
@ -198,9 +185,8 @@ fun Drawable.tint(@ColorInt color: Int): Drawable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@CheckResult
|
@CheckResult
|
||||||
fun Drawable.tint(context: Context, @ColorRes color: Int): Drawable {
|
fun Drawable.tint(context: Context, @ColorRes color: Int): Drawable =
|
||||||
return tint(context.getColorCompat(color))
|
tint(context.getColorCompat(color))
|
||||||
}
|
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun Context.getColorCompat(@ColorRes colorRes: Int): Int {
|
fun Context.getColorCompat(@ColorRes colorRes: Int): Int {
|
||||||
|
|
|
@ -100,7 +100,6 @@ class RealRoomRepository(
|
||||||
playlistDao.insertSongsToPlaylist(songs)
|
playlistDao.insertSongsToPlaylist(songs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getSongs(playListId: Long): LiveData<List<SongEntity>> =
|
override fun getSongs(playListId: Long): LiveData<List<SongEntity>> =
|
||||||
playlistDao.songsFromPlaylist(playListId)
|
playlistDao.songsFromPlaylist(playListId)
|
||||||
|
|
||||||
|
@ -160,8 +159,7 @@ class RealRoomRepository(
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun favoritePlaylistSongs(favorite: String): List<SongEntity> =
|
override suspend fun favoritePlaylistSongs(favorite: String): List<SongEntity> =
|
||||||
if (playlistDao.isPlaylistExists(favorite).isNotEmpty())
|
if (playlistDao.isPlaylistExists(favorite).isNotEmpty()) playlistDao.favoritesSongs(
|
||||||
playlistDao.favoritesSongs(
|
|
||||||
playlistDao.isPlaylistExists(favorite).first().playListId
|
playlistDao.isPlaylistExists(favorite).first().playListId
|
||||||
) else emptyList()
|
) else emptyList()
|
||||||
|
|
||||||
|
@ -192,11 +190,9 @@ class RealRoomRepository(
|
||||||
override suspend fun blackListPaths(): List<BlackListStoreEntity> =
|
override suspend fun blackListPaths(): List<BlackListStoreEntity> =
|
||||||
blackListStoreDao.blackListPaths()
|
blackListStoreDao.blackListPaths()
|
||||||
|
|
||||||
override suspend fun deleteSongs(songs: List<Song>) {
|
override suspend fun deleteSongs(songs: List<Song>) = songs.forEach {
|
||||||
songs.forEach {
|
|
||||||
playCountDao.deleteSong(it.id)
|
playCountDao.deleteSong(it.id)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun deleteBlacklistPath(blackListStoreEntity: BlackListStoreEntity) =
|
override suspend fun deleteBlacklistPath(blackListStoreEntity: BlackListStoreEntity) =
|
||||||
blackListStoreDao.deleteBlacklistPath(blackListStoreEntity)
|
blackListStoreDao.deleteBlacklistPath(blackListStoreEntity)
|
||||||
|
|
Loading…
Reference in a new issue