Add java8 support
This commit is contained in:
parent
723912d928
commit
7793cc822d
44 changed files with 512 additions and 929 deletions
|
|
@ -49,19 +49,16 @@ public class AddToPlaylistDialog extends DialogFragment {
|
|||
return new MaterialDialog.Builder(getActivity())
|
||||
.title(R.string.add_playlist_title)
|
||||
.items(playlistNames)
|
||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||
@Override
|
||||
public void onSelection(@NonNull MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
if (songs == null) return;
|
||||
if (i == 0) {
|
||||
materialDialog.dismiss();
|
||||
CreatePlaylistDialog.create(songs).show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
|
||||
} else {
|
||||
materialDialog.dismiss();
|
||||
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlists.get(i - 1).id, true);
|
||||
}
|
||||
.itemsCallback((materialDialog, view, i, charSequence) -> {
|
||||
//noinspection unchecked
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
if (songs == null) return;
|
||||
if (i == 0) {
|
||||
materialDialog.dismiss();
|
||||
CreatePlaylistDialog.create(songs).show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
|
||||
} else {
|
||||
materialDialog.dismiss();
|
||||
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlists.get(i - 1).id, true);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -98,19 +98,11 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
|
|||
.items((CharSequence[]) getContentsArray())
|
||||
.itemsCallback(this)
|
||||
.autoDismiss(false)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
dismiss();
|
||||
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
|
||||
}
|
||||
})
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
|
||||
dismiss();
|
||||
}
|
||||
.onPositive((dialog, which) -> {
|
||||
dismiss();
|
||||
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
|
||||
})
|
||||
.onNegative((materialDialog, dialogAction) -> dismiss())
|
||||
.positiveText(R.string.add_action)
|
||||
.negativeText(android.R.string.cancel);
|
||||
if (File.pathSeparator.equals(initialPath)) {
|
||||
|
|
|
|||
|
|
@ -54,12 +54,9 @@ public class ChangelogDialog extends DialogFragment {
|
|||
.title(R.string.changelog)
|
||||
.customView(customView, false)
|
||||
.positiveText(android.R.string.ok)
|
||||
.showListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
if (getActivity() != null)
|
||||
setChangelogRead(getActivity());
|
||||
}
|
||||
.showListener(dialog1 -> {
|
||||
if (getActivity() != null)
|
||||
setChangelogRead(getActivity());
|
||||
})
|
||||
.build();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,14 +39,11 @@ public class ClearSmartPlaylistDialog extends DialogFragment {
|
|||
.content(content)
|
||||
.positiveText(R.string.clear_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
playlist.clear(getActivity());
|
||||
.onPositive((dialog, which) -> {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
playlist.clear(getActivity());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,26 +54,23 @@ public class CreatePlaylistDialog extends DialogFragment {
|
|||
.inputType(InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_VARIATION_PERSON_NAME |
|
||||
InputType.TYPE_TEXT_FLAG_CAP_WORDS)
|
||||
.input(R.string.playlist_name_empty, 0, false, new MaterialDialog.InputCallback() {
|
||||
@Override
|
||||
public void onInput(@NonNull MaterialDialog materialDialog, @NonNull CharSequence charSequence) {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
final String name = charSequence.toString().trim();
|
||||
if (!name.isEmpty()) {
|
||||
if (!PlaylistsUtil.doesPlaylistExist(getActivity(), name)) {
|
||||
final int playlistId = PlaylistsUtil.createPlaylist(getActivity(), name);
|
||||
if (getActivity() != null) {
|
||||
//noinspection unchecked
|
||||
ArrayList<Song> songs = getArguments().getParcelableArrayList(SONGS);
|
||||
if (songs != null && !songs.isEmpty()) {
|
||||
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlistId, true);
|
||||
}
|
||||
.input(R.string.playlist_name_empty, 0, false, (materialDialog, charSequence) -> {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
final String name = charSequence.toString().trim();
|
||||
if (!name.isEmpty()) {
|
||||
if (!PlaylistsUtil.doesPlaylistExist(getActivity(), name)) {
|
||||
final int playlistId = PlaylistsUtil.createPlaylist(getActivity(), name);
|
||||
if (getActivity() != null) {
|
||||
//noinspection unchecked
|
||||
ArrayList<Song> songs = getArguments().getParcelableArrayList(SONGS);
|
||||
if (songs != null && !songs.isEmpty()) {
|
||||
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlistId, true);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getActivity().getResources().getString(
|
||||
R.string.playlist_exists, name), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getActivity(), getActivity().getResources().getString(
|
||||
R.string.playlist_exists, name), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -55,13 +55,10 @@ public class DeletePlaylistDialog extends DialogFragment {
|
|||
.content(content)
|
||||
.positiveText(R.string.delete_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
PlaylistsUtil.deletePlaylists(getActivity(), playlists);
|
||||
}
|
||||
.onPositive((dialog, which) -> {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
PlaylistsUtil.deletePlaylists(getActivity(), playlists);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,13 +54,10 @@ public class DeleteSongsDialog extends DialogFragment {
|
|||
.content(content)
|
||||
.positiveText(R.string.delete_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
MusicUtil.deleteTracks(getActivity(), songs);
|
||||
}
|
||||
.onPositive((dialog, which) -> {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
MusicUtil.deleteTracks(getActivity(), songs);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,19 +211,9 @@ public class DonationsDialog extends DialogFragment implements BillingProcessor.
|
|||
strikeThrough(viewHolder.text, purchased);
|
||||
strikeThrough(viewHolder.price, purchased);
|
||||
|
||||
convertView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
return purchased;
|
||||
}
|
||||
});
|
||||
convertView.setOnTouchListener((v, event) -> purchased);
|
||||
|
||||
convertView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
donationsDialog.donate(position);
|
||||
}
|
||||
});
|
||||
convertView.setOnClickListener(v -> donationsDialog.donate(position));
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,13 +54,10 @@ public class RemoveFromPlaylistDialog extends DialogFragment {
|
|||
.content(content)
|
||||
.positiveText(R.string.remove_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
PlaylistsUtil.removeFromPlaylist(getActivity(), songs);
|
||||
}
|
||||
.onPositive((dialog, which) -> {
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
PlaylistsUtil.removeFromPlaylist(getActivity(), songs);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,14 +38,11 @@ public class RenamePlaylistDialog extends DialogFragment {
|
|||
InputType.TYPE_TEXT_VARIATION_PERSON_NAME |
|
||||
InputType.TYPE_TEXT_FLAG_CAP_WORDS)
|
||||
.input(getString(R.string.playlist_name_empty), PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId), false,
|
||||
new MaterialDialog.InputCallback() {
|
||||
@Override
|
||||
public void onInput(@NonNull MaterialDialog materialDialog, @NonNull CharSequence charSequence) {
|
||||
final String name = charSequence.toString().trim();
|
||||
if (!name.isEmpty()) {
|
||||
long playlistId = getArguments().getLong(PLAYLIST_ID);
|
||||
PlaylistsUtil.renamePlaylist(getActivity(), playlistId, name);
|
||||
}
|
||||
(materialDialog, charSequence) -> {
|
||||
final String name = charSequence.toString().trim();
|
||||
if (!name.isEmpty()) {
|
||||
long playlistId1 = getArguments().getLong(PLAYLIST_ID);
|
||||
PlaylistsUtil.renamePlaylist(getActivity(), playlistId1, name);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -55,51 +55,42 @@ public class SleepTimerDialog extends DialogFragment {
|
|||
materialDialog = new MaterialDialog.Builder(getActivity())
|
||||
.title(getActivity().getResources().getString(R.string.action_sleep_timer))
|
||||
.positiveText(R.string.action_set)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (!App.isProVersion()) {
|
||||
Toast.makeText(getActivity(), getString(R.string.sleep_timer_is_a_pro_feature), Toast.LENGTH_LONG).show();
|
||||
startActivity(new Intent(getContext(), PurchaseActivity.class));
|
||||
return;
|
||||
}
|
||||
.onPositive((dialog, which) -> {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (!App.isProVersion()) {
|
||||
Toast.makeText(getActivity(), getString(R.string.sleep_timer_is_a_pro_feature), Toast.LENGTH_LONG).show();
|
||||
startActivity(new Intent(getContext(), PurchaseActivity.class));
|
||||
return;
|
||||
}
|
||||
|
||||
final int minutes = seekArcProgress;
|
||||
final int minutes = seekArcProgress;
|
||||
|
||||
PendingIntent pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
PendingIntent pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
final long nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000;
|
||||
PreferenceUtil.getInstance(getActivity()).setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime);
|
||||
final long nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000;
|
||||
PreferenceUtil.getInstance(getActivity()).setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime);
|
||||
AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
|
||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi);
|
||||
|
||||
Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.sleep_timer_set, minutes), Toast.LENGTH_SHORT).show();
|
||||
})
|
||||
.onNeutral((dialog, which) -> {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
final PendingIntent previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE);
|
||||
if (previous != null) {
|
||||
AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
|
||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi);
|
||||
|
||||
Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.sleep_timer_set, minutes), Toast.LENGTH_SHORT).show();
|
||||
am.cancel(previous);
|
||||
previous.cancel();
|
||||
Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.sleep_timer_canceled), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
})
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
final PendingIntent previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE);
|
||||
if (previous != null) {
|
||||
AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
|
||||
am.cancel(previous);
|
||||
previous.cancel();
|
||||
Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.sleep_timer_canceled), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
})
|
||||
.showListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
if (makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE) != null) {
|
||||
timerUpdater.start();
|
||||
}
|
||||
.showListener(dialog -> {
|
||||
if (makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE) != null) {
|
||||
timerUpdater.start();
|
||||
}
|
||||
})
|
||||
.customView(R.layout.dialog_sleep_timer, false)
|
||||
|
|
@ -114,17 +105,14 @@ public class SleepTimerDialog extends DialogFragment {
|
|||
seekArc.setProgressColor(ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
seekArc.setThumbColor(ThemeSingleton.get().positiveColor.getDefaultColor());
|
||||
|
||||
seekArc.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int width = seekArc.getWidth();
|
||||
int height = seekArc.getHeight();
|
||||
int small = Math.min(width, height);
|
||||
seekArc.post(() -> {
|
||||
int width = seekArc.getWidth();
|
||||
int height = seekArc.getHeight();
|
||||
int small = Math.min(width, height);
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(seekArc.getLayoutParams());
|
||||
layoutParams.height = small;
|
||||
seekArc.setLayoutParams(layoutParams);
|
||||
}
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(seekArc.getLayoutParams());
|
||||
layoutParams.height = small;
|
||||
seekArc.setLayoutParams(layoutParams);
|
||||
});
|
||||
|
||||
seekArcProgress = PreferenceUtil.getInstance(getActivity()).getLastSleepTimerValue();
|
||||
|
|
|
|||
|
|
@ -33,25 +33,22 @@ public class SongShareDialog extends DialogFragment {
|
|||
return new MaterialDialog.Builder(getActivity())
|
||||
.title(R.string.what_do_you_want_to_share)
|
||||
.items(getString(R.string.the_audio_file), "\u201C" + currentlyListening + "\u201D")
|
||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||
@Override
|
||||
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, getContext()), null));
|
||||
break;
|
||||
case 1:
|
||||
getActivity().startActivity(
|
||||
Intent.createChooser(
|
||||
new Intent()
|
||||
.setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||
.setType("text/plain"),
|
||||
null
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
.itemsCallback((materialDialog, view, i, charSequence) -> {
|
||||
switch (i) {
|
||||
case 0:
|
||||
startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, getContext()), null));
|
||||
break;
|
||||
case 1:
|
||||
getActivity().startActivity(
|
||||
Intent.createChooser(
|
||||
new Intent()
|
||||
.setAction(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, currentlyListening)
|
||||
.setType("text/plain"),
|
||||
null
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue