code clean

main
Hemanth S 2020-12-05 11:33:31 +05:30
parent c5a4b4b4c6
commit 6845f75ea0
3 changed files with 84 additions and 83 deletions

View File

@ -16,103 +16,122 @@ 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);
title = itemView.findViewById(R.id.title); title = itemView.findViewById(R.id.title);
text = itemView.findViewById(R.id.text); text = itemView.findViewById(R.id.text);
text2 = itemView.findViewById(R.id.text2); text2 = itemView.findViewById(R.id.text2);
image = itemView.findViewById(R.id.image); image = itemView.findViewById(R.id.image);
artistImage = itemView.findViewById(R.id.artistImage); artistImage = itemView.findViewById(R.id.artistImage);
playerImage = itemView.findViewById(R.id.player_image); playerImage = itemView.findViewById(R.id.player_image);
time = itemView.findViewById(R.id.time); time = itemView.findViewById(R.id.time);
imageText = itemView.findViewById(R.id.imageText); imageText = itemView.findViewById(R.id.imageText);
imageTextContainer = itemView.findViewById(R.id.imageTextContainer); imageTextContainer = itemView.findViewById(R.id.imageTextContainer);
imageContainerCard = itemView.findViewById(R.id.imageContainerCard); imageContainerCard = itemView.findViewById(R.id.imageContainerCard);
menu = itemView.findViewById(R.id.menu); menu = itemView.findViewById(R.id.menu);
dragView = itemView.findViewById(R.id.drag_view); dragView = itemView.findViewById(R.id.drag_view);
paletteColorContainer = itemView.findViewById(R.id.paletteColorContainer); paletteColorContainer = itemView.findViewById(R.id.paletteColorContainer);
recyclerView = itemView.findViewById(R.id.recycler_view); recyclerView = itemView.findViewById(R.id.recycler_view);
mask = itemView.findViewById(R.id.mask); mask = itemView.findViewById(R.id.mask);
dummyContainer = itemView.findViewById(R.id.dummy_view); dummyContainer = itemView.findViewById(R.id.dummy_view);
if (imageContainerCard != null) { if (imageContainerCard != null) {
imageContainerCard.setCardBackgroundColor(Color.TRANSPARENT); imageContainerCard.setCardBackgroundColor(Color.TRANSPARENT);
}
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
} }
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
}
@Nullable @Nullable
@Override @Override
public View getSwipeableContainerView() { public View getSwipeableContainerView() {
return null; return null;
} }
@Override @Override
public void onClick(View v) {} public void onClick(View v) {
}
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
return false; return false;
} }
public void setImageTransitionName(@NonNull String transitionName) { public void setImageTransitionName(@NonNull String transitionName) {
itemView.setTransitionName(transitionName); itemView.setTransitionName(transitionName);
/* if (imageContainerCard != null) { /* if (imageContainerCard != null) {
imageContainerCard.setTransitionName(transitionName); imageContainerCard.setTransitionName(transitionName);
} }
if (image != null) { if (image != null) {
image.setTransitionName(transitionName); image.setTransitionName(transitionName);
}*/ }*/
} }
} }

View File

@ -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 {

View File

@ -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,10 +159,9 @@ 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()
override suspend fun insertSongInPlayCount(playCountEntity: PlayCountEntity) = override suspend fun insertSongInPlayCount(playCountEntity: PlayCountEntity) =
playCountDao.insertSongInPlayCount(playCountEntity) playCountDao.insertSongInPlayCount(playCountEntity)
@ -192,10 +190,8 @@ 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) =