mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
Fixed a lot of possible issues raised by a code inspection
This commit is contained in:
parent
39ff821aee
commit
042bf3077f
76 changed files with 148 additions and 225 deletions
|
|
@ -107,9 +107,7 @@ public class AlbumCatalogueFragment extends Fragment {
|
|||
albumAdapter = new AlbumCatalogueAdapter(activity, requireContext());
|
||||
albumAdapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
|
||||
bind.albumCatalogueRecyclerView.setAdapter(albumAdapter);
|
||||
albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> {
|
||||
albumAdapter.setItems(albums);
|
||||
});
|
||||
albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> albumAdapter.setItems(albums));
|
||||
|
||||
bind.albumCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -84,9 +84,7 @@ public class AlbumListPageFragment extends Fragment {
|
|||
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
bind.toolbar.setNavigationOnClickListener(v -> {
|
||||
activity.navController.navigateUp();
|
||||
});
|
||||
bind.toolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
if ((bind.albumInfoSector.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.toolbar))) {
|
||||
|
|
|
|||
|
|
@ -121,16 +121,14 @@ public class AlbumPageFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void initAlbumInfoTextButton() {
|
||||
bind.albumArtistLabel.setOnClickListener(v -> {
|
||||
albumPageViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
activity.navController.navigate(R.id.action_albumPageFragment_to_artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
});
|
||||
bind.albumArtistLabel.setOnClickListener(v -> albumPageViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
activity.navController.navigate(R.id.action_albumPageFragment_to_artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
}));
|
||||
}
|
||||
|
||||
private void initMusicButton() {
|
||||
|
|
@ -181,8 +179,6 @@ public class AlbumPageFragment extends Fragment {
|
|||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), false);
|
||||
bind.songRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
|
||||
albumPageViewModel.getAlbumSongLiveList(requireActivity()).observe(requireActivity(), songs -> {
|
||||
songHorizontalAdapter.setItems(songs);
|
||||
});
|
||||
albumPageViewModel.getAlbumSongLiveList(requireActivity()).observe(requireActivity(), songs -> songHorizontalAdapter.setItems(songs));
|
||||
}
|
||||
}
|
||||
|
|
@ -107,9 +107,7 @@ public class ArtistCatalogueFragment extends Fragment {
|
|||
artistAdapter = new ArtistCatalogueAdapter(activity, requireContext());
|
||||
artistAdapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
|
||||
bind.artistCatalogueRecyclerView.setAdapter(artistAdapter);
|
||||
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artistList -> {
|
||||
artistAdapter.setItems(artistList);
|
||||
});
|
||||
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artistList -> artistAdapter.setItems(artistList));
|
||||
|
||||
bind.artistCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ public class ArtistListPageFragment extends Fragment {
|
|||
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
bind.toolbar.setNavigationOnClickListener(v -> {
|
||||
activity.navController.navigateUp();
|
||||
});
|
||||
bind.toolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
if ((bind.artistInfoSector.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.toolbar))) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -77,9 +76,7 @@ public class FilterFragment extends Fragment {
|
|||
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
|
||||
bind.toolbar.setNavigationOnClickListener(v -> {
|
||||
activity.navController.navigateUp();
|
||||
});
|
||||
bind.toolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
|
|
|
|||
|
|
@ -114,9 +114,7 @@ public class GenreCatalogueFragment extends Fragment {
|
|||
activity.navController.navigate(R.id.action_genreCatalogueFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
||||
genreCatalogueViewModel.getGenreList().observe(requireActivity(), genres -> {
|
||||
genreCatalogueAdapter.setItems(genres);
|
||||
});
|
||||
genreCatalogueViewModel.getGenreList().observe(requireActivity(), genres -> genreCatalogueAdapter.setItems(genres));
|
||||
|
||||
bind.genreCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
|
@ -11,7 +10,6 @@ import android.view.ViewGroup;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
|
@ -27,8 +25,8 @@ import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
|
|||
import com.cappielloantonio.play.adapter.ArtistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.DiscoverSongAdapter;
|
||||
import com.cappielloantonio.play.adapter.SimilarTrackAdapter;
|
||||
import com.cappielloantonio.play.adapter.TrackAdapter;
|
||||
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.TrackAdapter;
|
||||
import com.cappielloantonio.play.adapter.YearAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentHomeBinding;
|
||||
import com.cappielloantonio.play.helper.recyclerview.CustomLinearSnapHelper;
|
||||
|
|
@ -37,9 +35,6 @@ import com.cappielloantonio.play.model.Album;
|
|||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.util.UIUtil;
|
||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||
|
||||
|
|
@ -345,7 +340,8 @@ public class HomeFragment extends Fragment {
|
|||
} else {
|
||||
if (bind != null) bind.homeStarredTracksPlaceholder.placeholder.setVisibility(View.GONE);
|
||||
if (bind != null) bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null) bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
if (bind != null)
|
||||
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
starredSongAdapter.setItems(songs);
|
||||
}
|
||||
|
|
@ -376,7 +372,8 @@ public class HomeFragment extends Fragment {
|
|||
} else {
|
||||
if (bind != null) bind.homeStarredAlbumsPlaceholder.placeholder.setVisibility(View.GONE);
|
||||
if (bind != null) bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null) bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
if (bind != null)
|
||||
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
starredAlbumAdapter.setItems(albums);
|
||||
}
|
||||
|
|
@ -407,7 +404,8 @@ public class HomeFragment extends Fragment {
|
|||
} else {
|
||||
if (bind != null) bind.homeStarredArtistsPlaceholder.placeholder.setVisibility(View.GONE);
|
||||
if (bind != null) bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
if (bind != null) bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
if (bind != null)
|
||||
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||
|
||||
starredArtistAdapter.setItems(artists);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
|
@ -14,9 +13,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.ServerAdapter;
|
||||
|
|
@ -25,8 +22,6 @@ import com.cappielloantonio.play.ui.activity.MainActivity;
|
|||
import com.cappielloantonio.play.ui.fragment.dialog.ServerSignupDialog;
|
||||
import com.cappielloantonio.play.viewmodel.LoginViewModel;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class LoginFragment extends Fragment {
|
||||
private static final String TAG = "LoginFragment";
|
||||
|
||||
|
|
@ -88,12 +83,11 @@ public class LoginFragment extends Fragment {
|
|||
serverAdapter = new ServerAdapter(activity, requireContext());
|
||||
bind.serverListRecyclerView.setAdapter(serverAdapter);
|
||||
loginViewModel.getServerList().observe(requireActivity(), servers -> {
|
||||
if(servers.size() > 0) {
|
||||
if (servers.size() > 0) {
|
||||
if (bind != null) bind.noServerAddedTextView.setVisibility(View.GONE);
|
||||
if (bind != null) bind.serverListRecyclerView.setVisibility(View.VISIBLE);
|
||||
serverAdapter.setItems(servers);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (bind != null) bind.noServerAddedTextView.setVisibility(View.VISIBLE);
|
||||
if (bind != null) bind.serverListRecyclerView.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -102,13 +96,10 @@ public class LoginFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_add:
|
||||
ServerSignupDialog dialog = new ServerSignupDialog();
|
||||
dialog.show(activity.getSupportFragmentManager(), null);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
if (item.getItemId() == R.id.action_add) {
|
||||
ServerSignupDialog dialog = new ServerSignupDialog();
|
||||
dialog.show(activity.getSupportFragmentManager(), null);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.cappielloantonio.play.util.PreferenceUtil;
|
|||
import com.cappielloantonio.play.viewmodel.PlayerBottomSheetViewModel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlayerBottomSheetFragment extends Fragment implements MusicServiceEventListener, MusicProgressViewUpdateHelper.Callback {
|
||||
private static final String TAG = "PlayerBottomSheetFragment";
|
||||
|
|
@ -166,7 +167,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
int toPosition = -1;
|
||||
|
||||
@Override
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||
if (originalPosition == -1)
|
||||
originalPosition = viewHolder.getBindingAdapterPosition();
|
||||
|
||||
|
|
@ -185,7 +186,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
*/
|
||||
|
||||
Collections.swap(playerSongQueueAdapter.getItems(), fromPosition, toPosition);
|
||||
recyclerView.getAdapter().notifyItemMoved(fromPosition, toPosition);
|
||||
Objects.requireNonNull(recyclerView.getAdapter()).notifyItemMoved(fromPosition, toPosition);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -212,7 +213,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
if (!(viewHolder.getBindingAdapterPosition() == MusicPlayerRemote.getPosition()) && !(MusicPlayerRemote.getPlayingQueue().size() <= 1)) {
|
||||
MusicPlayerRemote.removeFromQueue(viewHolder.getBindingAdapterPosition());
|
||||
playerBottomSheetViewModel.removeSong(viewHolder.getBindingAdapterPosition());
|
||||
bodyBind.playerQueueRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
Objects.requireNonNull(bodyBind.playerQueueRecyclerView.getAdapter()).notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
bodyBind.playerSongCoverViewPager.setCurrentItem(MusicPlayerRemote.getPosition(), false);
|
||||
} else {
|
||||
bodyBind.playerQueueRecyclerView.getAdapter().notifyDataSetChanged();
|
||||
|
|
@ -271,11 +272,6 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
}
|
||||
|
||||
private void setViewPageDelayed(int position) {
|
||||
/*bodyBind.playerSongCoverViewPager.post(() -> {
|
||||
int restoredPosition = PreferenceManager.getDefaultSharedPreferences(requireContext()).getInt(PreferenceUtil.POSITION, -1);
|
||||
bodyBind.playerSongCoverViewPager.setCurrentItem(restoredPosition, true);
|
||||
});*/
|
||||
|
||||
final Handler handler = new Handler();
|
||||
final Runnable r = () -> {
|
||||
if (bind != null) bodyBind.playerSongCoverViewPager.setCurrentItem(position, false);
|
||||
|
|
@ -308,7 +304,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
}
|
||||
|
||||
public View getPlayerHeader() {
|
||||
return getView().findViewById(R.id.player_header_layout);
|
||||
return requireView().findViewById(R.id.player_header_layout);
|
||||
}
|
||||
|
||||
public void scrollOnTop() {
|
||||
|
|
@ -322,7 +318,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
setSongInfo(MusicPlayerRemote.getCurrentSong());
|
||||
setSongInfo(Objects.requireNonNull(MusicPlayerRemote.getCurrentSong()));
|
||||
updatePlayPauseState();
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +335,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
@Override
|
||||
public void onPlayMetadataChanged() {
|
||||
setViewPageDelayed(MusicPlayerRemote.getPosition());
|
||||
setSongInfo(MusicPlayerRemote.getCurrentSong());
|
||||
setSongInfo(Objects.requireNonNull(MusicPlayerRemote.getCurrentSong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -107,9 +107,7 @@ public class PlaylistCatalogueFragment extends Fragment {
|
|||
|
||||
playlistCatalogueAdapter = new PlaylistCatalogueAdapter(activity, requireContext(), playlistCatalogueViewModel.getType().equals(Playlist.DOWNLOADED));
|
||||
bind.playlistCatalogueRecyclerView.setAdapter(playlistCatalogueAdapter);
|
||||
playlistCatalogueViewModel.getPlaylistList(requireActivity()).observe(requireActivity(), playlist -> {
|
||||
playlistCatalogueAdapter.setItems(playlist);
|
||||
});
|
||||
playlistCatalogueViewModel.getPlaylistList(requireActivity()).observe(requireActivity(), playlist -> playlistCatalogueAdapter.setItems(playlist));
|
||||
|
||||
bind.playlistCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||
hideKeyboard(v);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SongBottomSheetDialog extends BottomSheetDialogFragment implements View.OnClickListener {
|
||||
|
|
@ -146,13 +147,13 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
|
||||
TextView download = view.findViewById(R.id.download_text_view);
|
||||
download.setOnClickListener(v -> {
|
||||
DownloadUtil.getDownloadTracker(requireContext()).download(Arrays.asList(song), null, null);
|
||||
DownloadUtil.getDownloadTracker(requireContext()).download(Collections.singletonList(song), null, null);
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
TextView remove = view.findViewById(R.id.remove_text_view);
|
||||
remove.setOnClickListener(v -> {
|
||||
DownloadUtil.getDownloadTracker(requireContext()).remove(Arrays.asList(song));
|
||||
DownloadUtil.getDownloadTracker(requireContext()).remove(Collections.singletonList(song));
|
||||
dismissBottomSheet();
|
||||
});
|
||||
|
||||
|
|
@ -171,32 +172,28 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
});
|
||||
|
||||
TextView goToAlbum = view.findViewById(R.id.go_to_album_text_view);
|
||||
goToAlbum.setOnClickListener(v -> {
|
||||
songBottomSheetViewModel.getAlbum().observe(requireActivity(), album -> {
|
||||
if (album != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", album);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.albumPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving album", Toast.LENGTH_SHORT).show();
|
||||
goToAlbum.setOnClickListener(v -> songBottomSheetViewModel.getAlbum().observe(requireActivity(), album -> {
|
||||
if (album != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("album_object", album);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.albumPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving album", Toast.LENGTH_SHORT).show();
|
||||
|
||||
dismissBottomSheet();
|
||||
});
|
||||
});
|
||||
dismissBottomSheet();
|
||||
}));
|
||||
|
||||
TextView goToArtist = view.findViewById(R.id.go_to_artist_text_view);
|
||||
goToArtist.setOnClickListener(v -> {
|
||||
songBottomSheetViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
goToArtist.setOnClickListener(v -> songBottomSheetViewModel.getArtist().observe(requireActivity(), artist -> {
|
||||
if (artist != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("artist_object", artist);
|
||||
NavHostFragment.findNavController(this).navigate(R.id.artistPageFragment, bundle);
|
||||
} else
|
||||
Toast.makeText(requireContext(), "Error retrieving artist", Toast.LENGTH_SHORT).show();
|
||||
|
||||
dismissBottomSheet();
|
||||
});
|
||||
});
|
||||
dismissBottomSheet();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -108,9 +108,7 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
playlistDialogSongHorizontalAdapter = new PlaylistDialogSongHorizontalAdapter(requireContext());
|
||||
bind.playlistSongRecyclerView.setAdapter(playlistDialogSongHorizontalAdapter);
|
||||
|
||||
playlistEditorViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> {
|
||||
playlistDialogSongHorizontalAdapter.setItems(songs);
|
||||
});
|
||||
playlistEditorViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> playlistDialogSongHorizontalAdapter.setItems(songs));
|
||||
|
||||
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT) {
|
||||
int originalPosition = -1;
|
||||
|
|
@ -118,7 +116,7 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
int toPosition = -1;
|
||||
|
||||
@Override
|
||||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||
if (originalPosition == -1)
|
||||
originalPosition = viewHolder.getBindingAdapterPosition();
|
||||
|
||||
|
|
@ -147,16 +145,16 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
playlistEditorViewModel.removeFromPlaylistSongLiveList(viewHolder.getBindingAdapterPosition());
|
||||
bind.playlistSongRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
Objects.requireNonNull(bind.playlistSongRecyclerView.getAdapter()).notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||
}
|
||||
}
|
||||
).attachToRecyclerView(bind.playlistSongRecyclerView);
|
||||
}
|
||||
|
||||
private boolean validateInput() {
|
||||
playlistName = bind.playlistNameTextView.getText().toString().trim();
|
||||
playlistName = Objects.requireNonNull(bind.playlistNameTextView.getText()).toString().trim();
|
||||
|
||||
if (TextUtils.isEmpty(playlistName)) {
|
||||
bind.playlistNameTextView.setError("Required");
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ public class RatingDialog extends DialogFragment {
|
|||
builder.setView(bind.getRoot())
|
||||
.setTitle("Rate")
|
||||
.setNegativeButton("Cancel", (dialog, id) -> dialog.cancel())
|
||||
.setPositiveButton("Save", (dialog, id) -> {
|
||||
ratingViewModel.rate((int) bind.ratingBar.getRating());
|
||||
});
|
||||
.setPositiveButton("Save", (dialog, id) -> ratingViewModel.rate((int) bind.ratingBar.getRating()));
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue