LyricsDialog displays lyrics without timestamps
Refactoring
This commit is contained in:
parent
3122923d5f
commit
c047ea96a7
7 changed files with 142 additions and 112 deletions
|
|
@ -2,22 +2,21 @@ package com.kabouzeid.gramophone.dialogs;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.kabouzeid.gramophone.model.lyrics.Lyrics;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class LyricsDialog extends DialogFragment {
|
||||
|
||||
public static LyricsDialog create(@NonNull LyricInfo lyricInfo) {
|
||||
public static LyricsDialog create(@NonNull Lyrics lyrics) {
|
||||
LyricsDialog dialog = new LyricsDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable("LyricInfo", lyricInfo);
|
||||
args.putString("title", lyrics.song.title);
|
||||
args.putString("lyrics", lyrics.getText());
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
|
@ -25,49 +24,10 @@ public class LyricsDialog extends DialogFragment {
|
|||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
LyricInfo lyricInfo = getArguments().getParcelable("LyricInfo");
|
||||
//noinspection ConstantConditions
|
||||
return new MaterialDialog.Builder(getActivity())
|
||||
.title(lyricInfo.title)
|
||||
.content(lyricInfo.lyrics)
|
||||
.title(getArguments().getString("title"))
|
||||
.content(getArguments().getString("lyrics"))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static class LyricInfo implements Parcelable {
|
||||
public final String title;
|
||||
public final String lyrics;
|
||||
|
||||
public LyricInfo(String title, String lyrics) {
|
||||
this.title = title;
|
||||
this.lyrics = lyrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(this.title);
|
||||
dest.writeString(this.lyrics);
|
||||
}
|
||||
|
||||
protected LyricInfo(Parcel in) {
|
||||
this.title = in.readString();
|
||||
this.lyrics = in.readString();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<LyricInfo> CREATOR = new Parcelable.Creator<LyricInfo>() {
|
||||
@Override
|
||||
public LyricInfo createFromParcel(Parcel source) {
|
||||
return new LyricInfo(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LyricInfo[] newArray(int size) {
|
||||
return new LyricInfo[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue