Move lastPlayedItem to DataRefreshService
This commit is contained in:
committed by
Niels van Velzen
parent
25ea47962d
commit
c9d6553486
@@ -4,11 +4,8 @@ import android.app.Application;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||
|
||||
public class TvApp extends Application {
|
||||
private static TvApp app;
|
||||
private BaseItemDto lastPlayedItem;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -21,13 +18,4 @@ public class TvApp extends Application {
|
||||
public static TvApp getApplication() {
|
||||
return app;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BaseItemDto getLastPlayedItem() {
|
||||
return lastPlayedItem;
|
||||
}
|
||||
|
||||
public void setLastPlayedItem(BaseItemDto lastPlayedItem) {
|
||||
this.lastPlayedItem = lastPlayedItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.jellyfin.androidtv.data.model
|
||||
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
|
||||
class DataRefreshService {
|
||||
var lastDeletedItemId: String? = null
|
||||
var lastPlayback: Long = 0
|
||||
@@ -9,4 +11,5 @@ class DataRefreshService {
|
||||
var lastLibraryChange: Long = 0
|
||||
var lastVideoQueueChange: Long = 0
|
||||
var lastFavoriteUpdate: Long = 0
|
||||
var lastPlayedItem: BaseItemDto? = null
|
||||
}
|
||||
|
||||
@@ -254,10 +254,11 @@ public class FullDetailsActivity extends BaseActivity implements RecordingIndica
|
||||
// if last playback event exists, and event time is greater than last sync or within 2 seconds of current time
|
||||
// the third condition accounts for a situation where a sync (dataRefresh) coincides with the end of playback
|
||||
if (lastPlaybackTime > 0 && (lastPlaybackTime > mLastUpdated.getTimeInMillis() || System.currentTimeMillis() - lastPlaybackTime < 2000) && mBaseItem.getBaseItemType() != BaseItemType.MusicArtist) {
|
||||
if (mBaseItem.getBaseItemType() == BaseItemType.Episode && TvApp.getApplication().getLastPlayedItem() != null && !mBaseItem.getId().equals(TvApp.getApplication().getLastPlayedItem().getId()) && TvApp.getApplication().getLastPlayedItem().getBaseItemType() == BaseItemType.Episode) {
|
||||
org.jellyfin.sdk.model.api.BaseItemDto lastPlayedItem = dataRefreshService.getValue().getLastPlayedItem();
|
||||
if (mBaseItem.getBaseItemType() == BaseItemType.Episode && lastPlayedItem != null && !mBaseItem.getId().equals(lastPlayedItem.getId().toString()) && lastPlayedItem.getType().equalsIgnoreCase(BaseItemType.Episode.toString())) {
|
||||
Timber.i("Re-loading after new episode playback");
|
||||
loadItem(TvApp.getApplication().getLastPlayedItem().getId());
|
||||
TvApp.getApplication().setLastPlayedItem(null); //blank this out so a detail screen we back up to doesn't also do this
|
||||
loadItem(lastPlayedItem.getId().toString());
|
||||
dataRefreshService.getValue().setLastPlayedItem(null); //blank this out so a detail screen we back up to doesn't also do this
|
||||
} else {
|
||||
Timber.d("Updating info after playback");
|
||||
apiClient.getValue().GetItemAsync(mBaseItem.getId(), KoinJavaComponent.<UserRepository>get(UserRepository.class).getCurrentUser().getValue().getId().toString(), new Response<BaseItemDto>() {
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jellyfin.androidtv.util.apiclient.StreamHelper;
|
||||
import org.jellyfin.androidtv.util.profile.BaseProfile;
|
||||
import org.jellyfin.androidtv.util.profile.ExoPlayerProfile;
|
||||
import org.jellyfin.androidtv.util.profile.LibVlcProfile;
|
||||
import org.jellyfin.androidtv.util.sdk.compat.ModelCompat;
|
||||
import org.jellyfin.apiclient.interaction.ApiClient;
|
||||
import org.jellyfin.apiclient.interaction.Response;
|
||||
import org.jellyfin.apiclient.model.dlna.DeviceProfile;
|
||||
@@ -69,6 +70,7 @@ public class PlaybackController {
|
||||
private Lazy<SystemPreferences> systemPreferences = inject(SystemPreferences.class);
|
||||
private Lazy<MediaManager> mediaManager = inject(MediaManager.class);
|
||||
private Lazy<org.jellyfin.sdk.api.client.ApiClient> api = inject(org.jellyfin.sdk.api.client.ApiClient.class, AppModuleKt.getUserApiClient());
|
||||
private Lazy<DataRefreshService> dataRefreshService = inject(DataRefreshService.class);
|
||||
|
||||
List<BaseItemDto> mItems;
|
||||
VideoManager mVideoManager;
|
||||
@@ -813,7 +815,7 @@ public class PlaybackController {
|
||||
}
|
||||
}, 750);
|
||||
|
||||
TvApp.getApplication().setLastPlayedItem(item);
|
||||
dataRefreshService.getValue().setLastPlayedItem(ModelCompat.asSdk(item));
|
||||
ReportingHelper.reportStart(item, mbPos);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user