mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Fixed a lot of possible issues raised by a code inspection
This commit is contained in:
parent
0299f909fb
commit
d169e3b188
7 changed files with 13 additions and 24 deletions
|
|
@ -3,6 +3,8 @@ package com.cappielloantonio.play.model;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class Playlist implements Parcelable {
|
||||
public static final String ALL = "ALL";
|
||||
public static final String DOWNLOADED = "DOWNLOADED";
|
||||
|
|
@ -66,6 +68,7 @@ public class Playlist implements Parcelable {
|
|||
return id.hashCode();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class MultiPlayer implements Playback {
|
|||
String uri = MusicUtil.getSongFileUri(song);
|
||||
MediaItem mediaItem = exoPlayer.getCurrentMediaItem();
|
||||
|
||||
if (mediaItem != null && mediaItem.playbackProperties.uri.toString().equals(uri)) {
|
||||
if (mediaItem != null && mediaItem.playbackProperties != null && mediaItem.playbackProperties.uri.toString().equals(uri)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.helper.ThemeHelper;
|
||||
import com.cappielloantonio.play.interfaces.ScanCallback;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.viewmodel.SettingViewModel;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
|
|
@ -36,7 +35,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
|
||||
someActivityResultLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> { });
|
||||
result -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -63,19 +63,6 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
findPreference("logout").setOnPreferenceClickListener(preference -> {
|
||||
PreferenceUtil.getInstance(requireContext()).setUser(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setServer(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setPassword(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setToken(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setSalt(null);
|
||||
PreferenceUtil.getInstance(requireContext()).setServerId(null);
|
||||
|
||||
activity.quit();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("scan_library").setOnPreferenceClickListener(preference -> {
|
||||
settingViewModel.launchScan(new ScanCallback() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import com.cappielloantonio.play.viewmodel.SongBottomSheetViewModel;
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
toPosition = target.getBindingAdapterPosition();
|
||||
|
||||
Collections.swap(playlistDialogSongHorizontalAdapter.getItems(), fromPosition, toPosition);
|
||||
recyclerView.getAdapter().notifyItemMoved(fromPosition, toPosition);
|
||||
Objects.requireNonNull(recyclerView.getAdapter()).notifyItemMoved(fromPosition, toPosition);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,10 +112,10 @@ public class ServerSignupDialog extends DialogFragment {
|
|||
}
|
||||
|
||||
private boolean validateInput() {
|
||||
serverName = bind.serverNameTextView.getText().toString().trim();
|
||||
username = bind.usernameTextView.getText().toString().trim();
|
||||
password = bind.passwordTextView.getText().toString();
|
||||
server = bind.serverTextView.getText().toString().trim();
|
||||
serverName = Objects.requireNonNull(bind.serverNameTextView.getText()).toString().trim();
|
||||
username = Objects.requireNonNull(bind.usernameTextView.getText()).toString().trim();
|
||||
password = Objects.requireNonNull(bind.passwordTextView.getText()).toString();
|
||||
server = Objects.requireNonNull(bind.serverTextView.getText()).toString().trim();
|
||||
directAccess = bind.directAccessCheckbox.isChecked();
|
||||
|
||||
if (TextUtils.isEmpty(serverName)) {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ public class MusicUtil {
|
|||
}
|
||||
|
||||
public static String getReadableDurationString(long duration, boolean millis) {
|
||||
long minutes = 0;
|
||||
long seconds = 0;
|
||||
long minutes;
|
||||
long seconds;
|
||||
|
||||
if (millis) {
|
||||
minutes = (duration / 1000) / 60;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue