kotlin conversion

This commit is contained in:
h4h13 2018-11-30 06:36:16 +05:30
parent 8e6ab40d93
commit b2c15ef186
316 changed files with 13055 additions and 22983 deletions

View file

@ -75,7 +75,7 @@ public class AddToPlaylistDialog extends RoundedBottomSheetDialogFragment {
super.onViewCreated(view, savedInstanceState);
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
final ArrayList<Playlist> playlists = PlaylistLoader.getAllPlaylists(getActivity()).blockingFirst();
final ArrayList<Playlist> playlists = PlaylistLoader.INSTANCE.getAllPlaylists(getActivity()).blockingFirst();
final AddToPlaylist playlistAdapter = new AddToPlaylist(getActivity(), playlists, R.layout.item_playlist, songs, getDialog());
playlist.setLayoutManager(new LinearLayoutManager(getContext()));
playlist.setItemAnimator(new DefaultItemAnimator());

View file

@ -82,7 +82,7 @@ public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment {
if (songs.size() > 1) {
content = Html.fromHtml(getString(R.string.delete_x_songs, songs.size()));
} else {
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title));
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).getTitle()));
}
this.title.setText(content);
}

View file

@ -81,8 +81,8 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.fragment_main_options, container, false);
ButterKnife.bind(this, layout);
layout.findViewById(R.id.action_buy_pro).setVisibility(RetroApplication.isProVersion() ? View.GONE : View.VISIBLE);
ButterKnife.apply(materialButtons, textColor, ThemeStore.textColorPrimary(getContext()));
layout.findViewById(R.id.action_buy_pro).setVisibility(RetroApplication.Companion.isProVersion() ? View.GONE : View.VISIBLE);
//ButterKnife.apply(materialButtons, textColor, ThemeStore.textColorPrimary(getContext()));
return layout;
}
@ -157,7 +157,7 @@ public class MainOptionsBottomSheetDialogFragment extends RoundedBottomSheetDial
.setQuality(75)
.setCompressFormat(Bitmap.CompressFormat.WEBP)
.compressToBitmapAsFlowable(
new File(PreferenceUtil.getInstance().getProfileImage(), USER_PROFILE))
new File(PreferenceUtil.getInstance().getProfileImage(),USER_PROFILE))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(userImageBottom::setImageBitmap,

View file

@ -1,93 +0,0 @@
package code.name.monkey.retromusic.dialogs;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.PlaylistSong;
import code.name.monkey.retromusic.util.PlaylistsUtil;
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
public class RemoveFromPlaylistDialog extends RoundedBottomSheetDialogFragment {
@BindView(R.id.action_remove)
TextView remove;
@BindView(R.id.title)
TextView title;
@BindView(R.id.action_cancel)
TextView cancel;
@NonNull
public static RemoveFromPlaylistDialog create(PlaylistSong song) {
ArrayList<PlaylistSong> list = new ArrayList<>();
list.add(song);
return create(list);
}
@NonNull
public static RemoveFromPlaylistDialog create(ArrayList<PlaylistSong> songs) {
RemoveFromPlaylistDialog dialog = new RemoveFromPlaylistDialog();
Bundle args = new Bundle();
args.putParcelableArrayList("songs", songs);
dialog.setArguments(args);
return dialog;
}
@OnClick({R.id.action_cancel, R.id.action_remove})
void actions(View view) {
final ArrayList<PlaylistSong> songs = getArguments().getParcelableArrayList("songs");
switch (view.getId()) {
case R.id.action_remove:
if (getActivity() == null)
return;
PlaylistsUtil.removeFromPlaylist(getActivity(), songs);
break;
default:
}
dismiss();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.dialog_remove_from_playlist, container, false);
ButterKnife.bind(this, layout);
return layout;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//noinspection unchecked
final ArrayList<PlaylistSong> songs = getArguments().getParcelableArrayList("songs");
int title;
CharSequence content;
if (songs != null && songs.size() > 1) {
title = R.string.remove_songs_from_playlist_title;
content = Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size()));
} else {
title = R.string.remove_song_from_playlist_title;
content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs.get(0).title));
}
this.remove.setText(content);
this.title.setText(title);
this.title.setTextColor(ThemeStore.textColorPrimary(getContext()));
this.remove.setTextColor(ThemeStore.textColorSecondary(getContext()));
this.cancel.setTextColor(ThemeStore.textColorSecondary(getContext()));
}
}

View file

@ -0,0 +1,91 @@
package code.name.monkey.retromusic.dialogs
import android.os.Build
import android.os.Bundle
import android.text.Html
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import butterknife.BindView
import butterknife.ButterKnife
import butterknife.OnClick
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.PlaylistSong
import code.name.monkey.retromusic.util.PlaylistsUtil
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
import java.util.*
class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
@BindView(R.id.action_remove)
internal var remove: TextView? = null
@BindView(R.id.title)
internal var title: TextView? = null
@BindView(R.id.action_cancel)
internal var cancel: TextView? = null
@OnClick(R.id.action_cancel, R.id.action_remove)
internal fun actions(view: View) {
val songs = arguments!!.getParcelableArrayList<PlaylistSong>("songs")
when (view.id) {
R.id.action_remove -> {
if (activity == null)
return
PlaylistsUtil.removeFromPlaylist(activity!!, songs!!)
}
}
dismiss()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val layout = inflater.inflate(R.layout.dialog_remove_from_playlist, container, false)
ButterKnife.bind(this, layout)
return layout
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val songs = arguments!!.getParcelableArrayList<PlaylistSong>("songs")
val title: Int
val content: CharSequence
if (songs != null && songs.size > 1) {
title = R.string.remove_songs_from_playlist_title
content = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size), Html.FROM_HTML_MODE_LEGACY)
} else {
Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size))
}
} else {
title = R.string.remove_song_from_playlist_title
content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs!![0].title))
}
this.remove!!.text = content
this.title!!.setText(title)
this.title!!.setTextColor(ThemeStore.textColorPrimary(context!!))
this.remove!!.setTextColor(ThemeStore.textColorSecondary(context!!))
this.cancel!!.setTextColor(ThemeStore.textColorSecondary(context!!))
}
companion object {
fun create(song: PlaylistSong): RemoveFromPlaylistDialog {
val list = ArrayList<PlaylistSong>()
list.add(song)
return create(list)
}
fun create(songs: ArrayList<PlaylistSong>): RemoveFromPlaylistDialog {
val dialog = RemoveFromPlaylistDialog()
val args = Bundle()
args.putParcelableArrayList("songs", songs)
dialog.arguments = args
return dialog
}
}
}

View file

@ -168,7 +168,7 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
private Intent makeTimerIntent() {
return new Intent(getActivity(), MusicService.class)
.setAction(ACTION_QUIT);
.setAction( ACTION_QUIT);
}
private class TimerUpdater extends CountDownTimer {

View file

@ -94,7 +94,7 @@ public class SongDetailDialog extends RoundedBottomSheetDialogFragment {
final Song song = getArguments().getParcelable("song");
if (song != null) {
final File songFile = new File(song.data);
final File songFile = new File(song.getData());
if (songFile.exists()) {
textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
textViews.get(2).setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
@ -110,12 +110,12 @@ public class SongDetailDialog extends RoundedBottomSheetDialogFragment {
} catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
Log.e(TAG, "error while reading the song file", e);
// fallback
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.getDuration())));
}
} else {
// fallback
textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, song.getTitle()));
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.getDuration())));
}
}

View file

@ -51,7 +51,7 @@ public class SongShareDialog extends RoundedBottomSheetDialogFragment {
super.onViewCreated(view, savedInstanceState);
final Song song = getArguments().getParcelable("song");
audioFile.setText(getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName));
audioFile.setText(getString(R.string.currently_listening_to_x_by_x, song.getTitle(), song.getArtistName()));
audioFile.setTextColor(ThemeStore.textColorSecondary(getContext()));
audioText.setTextColor(ThemeStore.textColorSecondary(getContext()));
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
@ -60,7 +60,7 @@ public class SongShareDialog extends RoundedBottomSheetDialogFragment {
@OnClick({R.id.option_2, R.id.option_1})
void onClick(View view) {
final Song song = getArguments().getParcelable("song");
final String currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName);
final String currentlyListening = getString(R.string.currently_listening_to_x_by_x, song.getTitle(), song.getArtistName());
switch (view.getId()) {
case R.id.option_1:
startActivity(Intent.createChooser(