mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
style: pull request refactoring
This commit is contained in:
parent
a17de1de8d
commit
c26aba8b2d
6 changed files with 67 additions and 40 deletions
|
|
@ -285,37 +285,35 @@ public class DownloadHorizontalAdapter extends RecyclerView.Adapter<DownloadHori
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onLongClick() {
|
private boolean onLongClick() {
|
||||||
|
ArrayList<Child> filteredSongs = new ArrayList<>();
|
||||||
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
if (view.equals(Constants.DOWNLOAD_TYPE_TRACK)) {
|
|
||||||
bundle.putParcelable(Constants.TRACK_OBJECT, grouped.get(getBindingAdapterPosition()));
|
|
||||||
click.onMediaLongClick(bundle);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Child> filteredSongs = null;
|
|
||||||
switch (view) {
|
switch (view) {
|
||||||
|
case Constants.DOWNLOAD_TYPE_TRACK:
|
||||||
|
filteredSongs.add(grouped.get(getBindingAdapterPosition()));
|
||||||
|
break;
|
||||||
case Constants.DOWNLOAD_TYPE_ALBUM:
|
case Constants.DOWNLOAD_TYPE_ALBUM:
|
||||||
filteredSongs = filterSong(Constants.DOWNLOAD_TYPE_ALBUM, grouped.get(getBindingAdapterPosition()).getAlbumId(), songs);
|
filteredSongs.addAll(filterSong(Constants.DOWNLOAD_TYPE_ALBUM, grouped.get(getBindingAdapterPosition()).getAlbumId(), songs));
|
||||||
break;
|
break;
|
||||||
case Constants.DOWNLOAD_TYPE_ARTIST:
|
case Constants.DOWNLOAD_TYPE_ARTIST:
|
||||||
filteredSongs = filterSong(Constants.DOWNLOAD_TYPE_ARTIST, grouped.get(getBindingAdapterPosition()).getArtistId(), songs);
|
filteredSongs.addAll(filterSong(Constants.DOWNLOAD_TYPE_ARTIST, grouped.get(getBindingAdapterPosition()).getArtistId(), songs));
|
||||||
break;
|
break;
|
||||||
case Constants.DOWNLOAD_TYPE_GENRE:
|
case Constants.DOWNLOAD_TYPE_GENRE:
|
||||||
filteredSongs = filterSong(Constants.DOWNLOAD_TYPE_GENRE, grouped.get(getBindingAdapterPosition()).getGenre(), songs);
|
filteredSongs.addAll(filterSong(Constants.DOWNLOAD_TYPE_GENRE, grouped.get(getBindingAdapterPosition()).getGenre(), songs));
|
||||||
break;
|
break;
|
||||||
case Constants.DOWNLOAD_TYPE_YEAR:
|
case Constants.DOWNLOAD_TYPE_YEAR:
|
||||||
filteredSongs = filterSong(Constants.DOWNLOAD_TYPE_YEAR, grouped.get(getBindingAdapterPosition()).getYear().toString(), songs);
|
filteredSongs.addAll(filterSong(Constants.DOWNLOAD_TYPE_YEAR, grouped.get(getBindingAdapterPosition()).getYear().toString(), songs));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filteredSongs == null) {
|
if (filteredSongs.isEmpty()) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bundle.putParcelableArrayList(Constants.DOWNLOAD_TYPE_GROUP, new ArrayList<>(filteredSongs));
|
bundle.putParcelableArrayList(Constants.DOWNLOAD_GROUP, new ArrayList<>(filteredSongs));
|
||||||
bundle.putString(Constants.DOWNLOAD_TYPE_GROUP_NAME, item.downloadedItemTitleTextView.getText().toString());
|
bundle.putString(Constants.DOWNLOAD_GROUP_TITLE, item.downloadedItemTitleTextView.getText().toString());
|
||||||
|
bundle.putString(Constants.DOWNLOAD_GROUP_SUBTITLE, item.downloadedItemSubtitleTextView.getText().toString());
|
||||||
click.onDownloadGroupLongClick(bundle);
|
click.onDownloadGroupLongClick(bundle);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,14 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public class DownloadedBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
|
public class DownloadedBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
|
||||||
private List<Child> songs;
|
private List<Child> songs;
|
||||||
|
private String groupTitle;
|
||||||
private String groupName;
|
private String groupSubtitle;
|
||||||
|
|
||||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||||
|
|
||||||
|
|
@ -45,9 +46,11 @@ public class DownloadedBottomSheetDialog extends BottomSheetDialogFragment imple
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.bottom_sheet_downloaded_dialog, container, false);
|
View view = inflater.inflate(R.layout.bottom_sheet_downloaded_dialog, container, false);
|
||||||
|
|
||||||
songs = this.requireArguments().getParcelableArrayList(Constants.DOWNLOAD_TYPE_GROUP);
|
songs = this.requireArguments().getParcelableArrayList(Constants.DOWNLOAD_GROUP);
|
||||||
groupName = this.requireArguments().getString(Constants.DOWNLOAD_TYPE_GROUP_NAME);
|
groupTitle = this.requireArguments().getString(Constants.DOWNLOAD_GROUP_TITLE);
|
||||||
|
groupSubtitle = this.requireArguments().getString(Constants.DOWNLOAD_GROUP_SUBTITLE);
|
||||||
|
|
||||||
|
initUI(view);
|
||||||
init(view);
|
init(view);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
|
@ -66,16 +69,25 @@ public class DownloadedBottomSheetDialog extends BottomSheetDialogFragment imple
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(View view) {
|
private void initUI(View view) {
|
||||||
ImageView coverAlbum = view.findViewById(R.id.album_cover_image_view);
|
TextView playRandom = view.findViewById(R.id.play_random_text_view);
|
||||||
CustomGlideRequest.Builder
|
playRandom.setVisibility(songs.size() > 1 ? View.VISIBLE : View.GONE);
|
||||||
.from(requireContext(), songs.get(0).getCoverArtId())
|
|
||||||
.build()
|
|
||||||
.into(coverAlbum);
|
|
||||||
|
|
||||||
TextView groupNameView = view.findViewById(R.id.group_name_text_view);
|
TextView remove = view.findViewById(R.id.remove_all_text_view);
|
||||||
groupNameView.setText(MusicUtil.getReadableString(this.groupName));
|
remove.setText(songs.size() > 1 ? getText(R.string.downloaded_bottom_sheet_remove_all) : getText(R.string.downloaded_bottom_sheet_remove));
|
||||||
groupNameView.setSelected(true);
|
}
|
||||||
|
|
||||||
|
private void init(View view) {
|
||||||
|
ImageView coverAlbum = view.findViewById(R.id.group_cover_image_view);
|
||||||
|
CustomGlideRequest.Builder.from(requireContext(), songs.get(new Random().nextInt(songs.size())).getCoverArtId()).build().into(coverAlbum);
|
||||||
|
|
||||||
|
TextView groupTitleView = view.findViewById(R.id.group_title_text_view);
|
||||||
|
groupTitleView.setText(MusicUtil.getReadableString(this.groupTitle));
|
||||||
|
groupTitleView.setSelected(true);
|
||||||
|
|
||||||
|
TextView groupSubtitleView = view.findViewById(R.id.group_subtitle_text_view);
|
||||||
|
groupSubtitleView.setText(MusicUtil.getReadableString(this.groupSubtitle));
|
||||||
|
groupSubtitleView.setSelected(true);
|
||||||
|
|
||||||
TextView playRandom = view.findViewById(R.id.play_random_text_view);
|
TextView playRandom = view.findViewById(R.id.play_random_text_view);
|
||||||
playRandom.setOnClickListener(v -> {
|
playRandom.setOnClickListener(v -> {
|
||||||
|
|
@ -93,8 +105,7 @@ public class DownloadedBottomSheetDialog extends BottomSheetDialogFragment imple
|
||||||
((MainActivity) requireActivity()).setBottomSheetInPeek(true);
|
((MainActivity) requireActivity()).setBottomSheetInPeek(true);
|
||||||
|
|
||||||
dismissBottomSheet();
|
dismissBottomSheet();
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
TextView addToQueue = view.findViewById(R.id.add_to_queue_text_view);
|
TextView addToQueue = view.findViewById(R.id.add_to_queue_text_view);
|
||||||
addToQueue.setOnClickListener(v -> {
|
addToQueue.setOnClickListener(v -> {
|
||||||
|
|
@ -105,11 +116,12 @@ public class DownloadedBottomSheetDialog extends BottomSheetDialogFragment imple
|
||||||
});
|
});
|
||||||
|
|
||||||
TextView removeAll = view.findViewById(R.id.remove_all_text_view);
|
TextView removeAll = view.findViewById(R.id.remove_all_text_view);
|
||||||
|
|
||||||
removeAll.setOnClickListener(v -> {
|
removeAll.setOnClickListener(v -> {
|
||||||
List<MediaItem> mediaItems = MappingUtil.mapDownloads(songs);
|
List<MediaItem> mediaItems = MappingUtil.mapDownloads(songs);
|
||||||
List<Download> downloads = songs.stream().map(Download::new).collect(Collectors.toList());
|
List<Download> downloads = songs.stream().map(Download::new).collect(Collectors.toList());
|
||||||
|
|
||||||
DownloadUtil.getDownloadTracker(requireContext()).remove(mediaItems, downloads);
|
DownloadUtil.getDownloadTracker(requireContext()).remove(mediaItems, downloads);
|
||||||
|
|
||||||
dismissBottomSheet();
|
dismissBottomSheet();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,11 +79,13 @@ object Constants {
|
||||||
const val DOWNLOAD_TYPE_TRACK = "download_type_track"
|
const val DOWNLOAD_TYPE_TRACK = "download_type_track"
|
||||||
const val DOWNLOAD_TYPE_ALBUM = "download_type_album"
|
const val DOWNLOAD_TYPE_ALBUM = "download_type_album"
|
||||||
const val DOWNLOAD_TYPE_ARTIST = "download_type_artist"
|
const val DOWNLOAD_TYPE_ARTIST = "download_type_artist"
|
||||||
const val DOWNLOAD_TYPE_GROUP = "download_type_group"
|
|
||||||
const val DOWNLOAD_TYPE_GROUP_NAME = "download_type_group_name"
|
|
||||||
const val DOWNLOAD_TYPE_GENRE = "download_type_genre"
|
const val DOWNLOAD_TYPE_GENRE = "download_type_genre"
|
||||||
const val DOWNLOAD_TYPE_YEAR = "download_type_year"
|
const val DOWNLOAD_TYPE_YEAR = "download_type_year"
|
||||||
|
|
||||||
|
const val DOWNLOAD_GROUP = "download_group"
|
||||||
|
const val DOWNLOAD_GROUP_TITLE = "download_group_title"
|
||||||
|
const val DOWNLOAD_GROUP_SUBTITLE = "download_group_subtitle"
|
||||||
|
|
||||||
const val PLAYABLE_MEDIA_LIMIT = 100
|
const val PLAYABLE_MEDIA_LIMIT = 100
|
||||||
const val PRE_PLAYABLE_MEDIA = 15
|
const val PRE_PLAYABLE_MEDIA = 15
|
||||||
}
|
}
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/album_cover_image_view"
|
android:id="@+id/group_cover_image_view"
|
||||||
android:layout_width="54dp"
|
android:layout_width="54dp"
|
||||||
android:layout_height="54dp"
|
android:layout_height="54dp"
|
||||||
android:layout_margin="2dp"
|
android:layout_margin="2dp"
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/group_name_text_view"
|
android:id="@+id/group_title_text_view"
|
||||||
style="@style/LabelMedium"
|
style="@style/LabelMedium"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -32,15 +32,28 @@
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:marqueeRepeatLimit="marquee_forever"
|
android:marqueeRepeatLimit="marquee_forever"
|
||||||
android:paddingStart="12dp"
|
android:paddingStart="12dp"
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:paddingEnd="12dp"
|
android:paddingEnd="12dp"
|
||||||
android:scrollHorizontally="true"
|
android:scrollHorizontally="true"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="@string/label_placeholder"
|
android:text="@string/label_placeholder"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/group_subtitle_text_view"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/album_cover_image_view"
|
app:layout_constraintStart_toEndOf="@+id/group_cover_image_view"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="@+id/group_cover_image_view" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/group_subtitle_text_view"
|
||||||
|
style="@style/LabelSmall"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="12dp"
|
||||||
|
android:paddingEnd="12dp"
|
||||||
|
android:text="@string/label_placeholder"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/group_cover_image_view"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/group_title_text_view"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/group_cover_image_view"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -300,5 +300,6 @@
|
||||||
<string name="downloaded_bottom_sheet_shuffle">Mischen</string>
|
<string name="downloaded_bottom_sheet_shuffle">Mischen</string>
|
||||||
<string name="downloaded_bottom_sheet_play_next">Nächsten Titel spielen</string>
|
<string name="downloaded_bottom_sheet_play_next">Nächsten Titel spielen</string>
|
||||||
<string name="downloaded_bottom_sheet_add_to_queue">Zur Warteschlange hinzufügen</string>
|
<string name="downloaded_bottom_sheet_add_to_queue">Zur Warteschlange hinzufügen</string>
|
||||||
|
<string name="downloaded_bottom_sheet_remove">Entfernen</string>
|
||||||
<string name="downloaded_bottom_sheet_remove_all">Alle entfernen</string>
|
<string name="downloaded_bottom_sheet_remove_all">Alle entfernen</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -303,6 +303,7 @@
|
||||||
<string name="downloaded_bottom_sheet_shuffle">Shuffle</string>
|
<string name="downloaded_bottom_sheet_shuffle">Shuffle</string>
|
||||||
<string name="downloaded_bottom_sheet_play_next">Play next</string>
|
<string name="downloaded_bottom_sheet_play_next">Play next</string>
|
||||||
<string name="downloaded_bottom_sheet_add_to_queue">Add to queue</string>
|
<string name="downloaded_bottom_sheet_add_to_queue">Add to queue</string>
|
||||||
|
<string name="downloaded_bottom_sheet_remove">Remove</string>
|
||||||
<string name="downloaded_bottom_sheet_remove_all">Remove all</string>
|
<string name="downloaded_bottom_sheet_remove_all">Remove all</string>
|
||||||
<string name="track_info_dialog_positive_button">OK</string>
|
<string name="track_info_dialog_positive_button">OK</string>
|
||||||
<string name="track_info_dialog_title">Track info</string>
|
<string name="track_info_dialog_title">Track info</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue