convert Song to kotlin
This commit is contained in:
parent
deb6f6d36c
commit
ae5f660d7d
7 changed files with 30 additions and 79 deletions
|
@ -33,6 +33,7 @@ import com.simplemobiletools.musicplayer.activities.MainActivity;
|
|||
import com.simplemobiletools.musicplayer.helpers.BusProvider;
|
||||
import com.simplemobiletools.musicplayer.helpers.Config;
|
||||
import com.simplemobiletools.musicplayer.models.Events;
|
||||
import com.simplemobiletools.musicplayer.models.Song;
|
||||
import com.simplemobiletools.musicplayer.receivers.ControlActionsListener;
|
||||
import com.simplemobiletools.musicplayer.receivers.HeadsetPlugReceiver;
|
||||
import com.simplemobiletools.musicplayer.receivers.IncomingCallReceiver;
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.RemoteViews;
|
|||
import com.simplemobiletools.musicplayer.activities.MainActivity;
|
||||
import com.simplemobiletools.musicplayer.helpers.BusProvider;
|
||||
import com.simplemobiletools.musicplayer.models.Events;
|
||||
import com.simplemobiletools.musicplayer.models.Song;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
package com.simplemobiletools.musicplayer;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Song implements Serializable {
|
||||
private static final long serialVersionUID = 6717978783256842145L;
|
||||
|
||||
private String mTitle;
|
||||
private String mArtist;
|
||||
private String mPath;
|
||||
|
||||
private long mId;
|
||||
private int mDuration;
|
||||
|
||||
public Song(long id, String title, String artist, String path, int duration) {
|
||||
mId = id;
|
||||
mTitle = title;
|
||||
mArtist = artist;
|
||||
mPath = path;
|
||||
mDuration = duration;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
public String getArtist() {
|
||||
return mArtist;
|
||||
}
|
||||
|
||||
public void setArtist(String newArtist) {
|
||||
mArtist = newArtist;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
public void setmTitle(String newTitle) {
|
||||
mTitle = newTitle;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
}
|
||||
|
||||
public void setPath(String newPath) {
|
||||
mPath = newPath;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Song{" + "mId=" + getId() +
|
||||
", mTitle=" + getTitle() +
|
||||
", mArtist=" + getArtist() +
|
||||
", mPath=" + getPath() +
|
||||
", mDuration=" + getDuration() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
|
||||
if (o == null)
|
||||
return false;
|
||||
|
||||
return this.toString().equals(o.toString());
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ import android.view.ViewGroup;
|
|||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.simplemobiletools.musicplayer.models.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.support.design.widget.Snackbar;
|
|||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.ActionMode;
|
||||
import android.view.Menu;
|
||||
|
@ -32,14 +33,14 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog;
|
||||
import com.simplemobiletools.musicplayer.helpers.BusProvider;
|
||||
import com.simplemobiletools.musicplayer.Constants;
|
||||
import com.simplemobiletools.musicplayer.models.Events;
|
||||
import com.simplemobiletools.musicplayer.MusicService;
|
||||
import com.simplemobiletools.musicplayer.R;
|
||||
import com.simplemobiletools.musicplayer.Song;
|
||||
import com.simplemobiletools.musicplayer.models.Song;
|
||||
import com.simplemobiletools.musicplayer.SongAdapter;
|
||||
import com.simplemobiletools.musicplayer.Utils;
|
||||
import com.simplemobiletools.musicplayer.helpers.BusProvider;
|
||||
import com.simplemobiletools.musicplayer.models.Events;
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
|
@ -225,6 +226,7 @@ public class MainActivity extends SimpleActivity
|
|||
@Subscribe
|
||||
public void songChangedEvent(Events.SongChanged event) {
|
||||
mCurrentSong = event.getSong();
|
||||
Log.e("DEBUG", "cur " + mCurrentSong);
|
||||
updateSongInfo(mCurrentSong);
|
||||
}
|
||||
|
||||
|
@ -352,7 +354,7 @@ public class MainActivity extends SimpleActivity
|
|||
}
|
||||
|
||||
final Song songInList = mSongs.get(songIndex);
|
||||
songInList.setmTitle(newTitle);
|
||||
songInList.setTitle(newTitle);
|
||||
songInList.setArtist(newArtist);
|
||||
|
||||
if (currSongChanged) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simplemobiletools.musicplayer.models
|
||||
|
||||
import com.simplemobiletools.musicplayer.Song
|
||||
import java.util.*
|
||||
|
||||
class Events {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.simplemobiletools.musicplayer.models
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
class Song(val id: Long, var title: String, var artist: String, var path: String, val duration: Int) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = 6717978793256842145L
|
||||
}
|
||||
|
||||
override fun toString() = "Song {id=$id, title=$title, artist=$artist, path=$path, duration=$duration}"
|
||||
|
||||
override fun equals(o: Any?): Boolean {
|
||||
return if (this === o)
|
||||
true
|
||||
else if (o == null)
|
||||
false
|
||||
else
|
||||
toString() == o.toString()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue