mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-04 00:03:07 +00:00
Add function to increase song count when track is changed
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.cappielloantonio.play.repository;
|
package com.cappielloantonio.play.repository;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
@@ -14,6 +15,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SongRepository {
|
public class SongRepository {
|
||||||
|
private static final String TAG = "SongRepository";
|
||||||
|
|
||||||
private SongDao songDao;
|
private SongDao songDao;
|
||||||
private SongGenreCrossDao songGenreCrossDao;
|
private SongGenreCrossDao songGenreCrossDao;
|
||||||
private LiveData<List<Song>> searchListLiveSongs;
|
private LiveData<List<Song>> searchListLiveSongs;
|
||||||
@@ -192,11 +195,13 @@ public class SongRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void increasePlayCount(Song song) {
|
public void increasePlayCount(Song song) {
|
||||||
song.nowPlaying();
|
boolean isIncreased = song.nowPlaying();
|
||||||
|
|
||||||
UpdateThreadSafe update = new UpdateThreadSafe(songDao, song);
|
if(isIncreased) {
|
||||||
Thread thread = new Thread(update);
|
UpdateThreadSafe update = new UpdateThreadSafe(songDao, song);
|
||||||
thread.start();
|
Thread thread = new Thread(update);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFavoriteStatus(Song song) {
|
public void setFavoriteStatus(Song song) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import com.cappielloantonio.play.R;
|
|||||||
import com.cappielloantonio.play.model.Playlist;
|
import com.cappielloantonio.play.model.Playlist;
|
||||||
import com.cappielloantonio.play.model.Song;
|
import com.cappielloantonio.play.model.Song;
|
||||||
import com.cappielloantonio.play.repository.QueueRepository;
|
import com.cappielloantonio.play.repository.QueueRepository;
|
||||||
|
import com.cappielloantonio.play.repository.SongRepository;
|
||||||
import com.cappielloantonio.play.service.notification.PlayingNotification;
|
import com.cappielloantonio.play.service.notification.PlayingNotification;
|
||||||
import com.cappielloantonio.play.service.playback.Playback;
|
import com.cappielloantonio.play.service.playback.Playback;
|
||||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||||
@@ -436,6 +437,8 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
|||||||
nextPosition = getNextPosition();
|
nextPosition = getNextPosition();
|
||||||
playback.queueDataSource(getSongAt(nextPosition));
|
playback.queueDataSource(getSongAt(nextPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
increaseSongCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean requestFocus() {
|
private boolean requestFocus() {
|
||||||
@@ -735,6 +738,11 @@ public class MusicService extends Service implements Playback.PlaybackCallbacks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void increaseSongCount() {
|
||||||
|
SongRepository songRepository = new SongRepository(App.getInstance());
|
||||||
|
songRepository.increasePlayCount(getCurrentSong());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStateChanged(int state) {
|
public void onStateChanged(int state) {
|
||||||
notifyChange(STATE_CHANGED);
|
notifyChange(STATE_CHANGED);
|
||||||
|
|||||||
Reference in New Issue
Block a user