mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Removed unused code
This commit is contained in:
parent
02d6ad9629
commit
05d2e0b9ec
2 changed files with 23 additions and 37 deletions
|
|
@ -40,9 +40,12 @@ import com.cappielloantonio.play.util.PreferenceUtil;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
|
||||
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED;
|
||||
|
|
@ -800,6 +803,24 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
|||
case TRACK_ENDED:
|
||||
}
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
if (executorService != null) executorService.shutdownNow();
|
||||
|
||||
executorService = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
public void onNext() {
|
||||
|
||||
}
|
||||
|
||||
public void onProgress() {
|
||||
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class MusicBinder extends Binder {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
package com.cappielloantonio.play.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class MusicUtil {
|
||||
private static final String TAG = "MusicUtil";
|
||||
|
|
@ -35,16 +30,14 @@ public class MusicUtil {
|
|||
long minutes = 0;
|
||||
long seconds = 0;
|
||||
|
||||
if(millis) {
|
||||
if (millis) {
|
||||
minutes = (duration / 1000) / 60;
|
||||
seconds = (duration / 1000) % 60;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
minutes = duration / 60;
|
||||
seconds = duration % 60;
|
||||
}
|
||||
|
||||
|
||||
if (minutes < 60) {
|
||||
return String.format(Locale.getDefault(), "%01d:%02d", minutes, seconds);
|
||||
} else {
|
||||
|
|
@ -68,37 +61,9 @@ public class MusicUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static List<MediaItem> getMediaItemsFromSongs(List<Song> songs) {
|
||||
List<MediaItem> mediaItems = new ArrayList<>();
|
||||
|
||||
for (Song song : songs) {
|
||||
mediaItems.add(getMediaItemFromSong(song));
|
||||
}
|
||||
|
||||
return mediaItems;
|
||||
}
|
||||
|
||||
public static MediaItem getMediaItemFromSong(Song song) {
|
||||
String uri = MusicUtil.getSongFileUri(song);
|
||||
MediaItem mediaItem = MediaItem.fromUri(uri);
|
||||
return mediaItem;
|
||||
}
|
||||
|
||||
public static List<Integer> getRandomSongNumber(Context context, int numberOfNumbers, int refreshAfterXHours) {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < numberOfNumbers; i++) {
|
||||
list.add(getRandomNumber(0, PreferenceUtil.getInstance(context).getSongNumber(), getMidnightTimestamp(System.currentTimeMillis() / 1000, refreshAfterXHours) + i));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static long getMidnightTimestamp(long timestamp, int hours) {
|
||||
return timestamp - timestamp % (hours * 60 * 60); // 24 * 60 * 60 sec in one day
|
||||
}
|
||||
|
||||
private static int getRandomNumber(int min, int max, long seed) {
|
||||
return new Random(seed).nextInt((max - min) + 1) + min;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue