Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify reportPlaybackStopped code #1993

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void reportPlaybackProgress(PlaybackProgressInfo info, final StreamInfo s
apiClient.ReportPlaybackProgressAsync(info, response);
}

public void reportPlaybackStopped(PlaybackStopInfo info, final StreamInfo streamInfo, final String serverId, String userId, final ApiClient apiClient, final EmptyResponse response) {
public void reportPlaybackStopped(PlaybackStopInfo info, final StreamInfo streamInfo, final ApiClient apiClient, final EmptyResponse response) {

Check notice

Code scanning / Android Lint

Unknown nullness

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations

Check notice

Code scanning / Android Lint

Unknown nullness

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations

Check notice

Code scanning / Android Lint

Unknown nullness

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations

Check notice

Code scanning / Android Lint

Unknown nullness

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
MediaSourceInfo mediaSource = streamInfo.getMediaSource();

if (mediaSource != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import androidx.annotation.Nullable;

import org.jellyfin.androidtv.auth.repository.Session;
import org.jellyfin.androidtv.auth.repository.SessionRepository;
import org.jellyfin.androidtv.data.compat.StreamInfo;
import org.jellyfin.androidtv.data.model.DataRefreshService;
import org.jellyfin.androidtv.ui.playback.PlaybackController;
Expand All @@ -16,32 +14,25 @@
import org.jellyfin.apiclient.model.session.PlaybackStopInfo;
import org.koin.java.KoinJavaComponent;

import java.util.UUID;

import timber.log.Timber;

public class ReportingHelper {
public static void reportStopped(BaseItemDto item, StreamInfo streamInfo, long pos) {
if (item != null && streamInfo != null) {
Session currentSession = KoinJavaComponent.<SessionRepository>get(SessionRepository.class).getCurrentSession().getValue();
if (currentSession != null) {
UUID userId = currentSession.getUserId();

PlaybackStopInfo info = new PlaybackStopInfo();
info.setItemId(item.getId());
info.setPositionTicks(pos);
KoinJavaComponent.<PlaybackManager>get(PlaybackManager.class).reportPlaybackStopped(info, streamInfo, KoinJavaComponent.<ApiClient>get(ApiClient.class).getServerInfo().getId(), userId.toString(), KoinJavaComponent.<ApiClient>get(ApiClient.class), new EmptyResponse());

DataRefreshService dataRefreshService = KoinJavaComponent.<DataRefreshService>get(DataRefreshService.class);
dataRefreshService.setLastPlayback(System.currentTimeMillis());
switch (item.getBaseItemType()) {
case Movie:
dataRefreshService.setLastMoviePlayback(System.currentTimeMillis());
break;
case Episode:
dataRefreshService.setLastTvPlayback(System.currentTimeMillis());
break;
}
PlaybackStopInfo info = new PlaybackStopInfo();
info.setItemId(item.getId());
info.setPositionTicks(pos);
KoinJavaComponent.<PlaybackManager>get(PlaybackManager.class).reportPlaybackStopped(info, streamInfo, KoinJavaComponent.<ApiClient>get(ApiClient.class), new EmptyResponse());

DataRefreshService dataRefreshService = KoinJavaComponent.<DataRefreshService>get(DataRefreshService.class);
dataRefreshService.setLastPlayback(System.currentTimeMillis());
switch (item.getBaseItemType()) {
case Movie:
dataRefreshService.setLastMoviePlayback(System.currentTimeMillis());
break;
case Episode:
dataRefreshService.setLastTvPlayback(System.currentTimeMillis());
break;
}
}
}
Expand Down