move getFormattedDuration into MediaUtils so we can use it without a song object.
This commit is contained in:
parent
b847279578
commit
f517fcc467
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
||||
* Copyright (C) 2017 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
* Copyright (C) 2017-2018 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -46,6 +46,7 @@ import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.text.format.DateUtils;
|
||||
import android.text.TextUtils;
|
||||
import android.database.MatrixCursor;
|
||||
import android.util.Log;
|
||||
@ -626,4 +627,11 @@ public class MediaUtils {
|
||||
return TYPE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration of this song.duration in the form "MM:SS" or "H:MM:SS"
|
||||
*/
|
||||
public static String getFormattedDuration(long duration) {
|
||||
return DateUtils.formatElapsedTime(duration / 1000);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import android.database.Cursor;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -114,7 +113,7 @@ public class PlaylistAdapter extends CursorAdapter implements Handler.Callback {
|
||||
textView.setText(cursor.getString(1));
|
||||
textView.setTag(cursor.getLong(3));
|
||||
|
||||
String duration = DateUtils.formatElapsedTime(cursor.getLong(6) / 1000);
|
||||
String duration = MediaUtils.getFormattedDuration(cursor.getLong(6));
|
||||
dview.getDurationView().setText(duration);
|
||||
|
||||
LazyCoverView cover = dview.getCoverView();
|
||||
|
@ -142,7 +142,7 @@ public class ShowQueueAdapter extends BaseAdapter {
|
||||
sb.setSpan(new ForegroundColorSpan(Color.GRAY), song.title.length() + 1, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
row.getTextView().setText(sb);
|
||||
row.getCoverView().setCover(MediaUtils.TYPE_ALBUM, song.albumId, null);
|
||||
row.getDurationView().setText(song.getFormattedDuration());
|
||||
row.getDurationView().setText(MediaUtils.getFormattedDuration(song.duration));
|
||||
}
|
||||
|
||||
row.highlightRow(position == mHighlightRow);
|
||||
|
@ -27,7 +27,6 @@ import ch.blinkenlights.android.medialibrary.MediaLibrary;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.format.DateUtils;
|
||||
|
||||
/**
|
||||
* Represents a Song backed by the MediaStore. Includes basic metadata and
|
||||
@ -204,13 +203,6 @@ public class Song implements Comparable<Song> {
|
||||
return song.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration of this song in the form "MM:SS" or "H:MM:SS"
|
||||
*/
|
||||
public String getFormattedDuration() {
|
||||
return DateUtils.formatElapsedTime(duration / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the large album art for this song.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user