Skip to content

Commit e2270f1

Browse files
committed
CrashRestore: fix position reset
1 parent a3ff082 commit e2270f1

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/data/Video.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public final class Video {
8686
public long startTimeMs;
8787
public long pendingPosMs;
8888
public boolean fromQueue;
89+
public boolean fromCrashRestorer;
8990
public boolean isPending;
9091
public boolean finishOnEnded;
9192
public boolean incognito;

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/playback/controllers/VideoStateController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ private void resetPositionIfNeeded(Video item) {
334334
return;
335335
}
336336

337+
if (item.fromCrashRestorer) {
338+
item.fromCrashRestorer = false;
339+
return;
340+
}
341+
337342
State state = getStateService().getByVideoId(item.videoId);
338343

339344
// Reset position of music videos

common/src/main/java/com/liskovsoft/smartyoutubetv2/common/misc/CrashRestorer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void restorePlayback() {
6161
VideoStateService stateService = VideoStateService.instance(mContext);
6262
boolean isVideoStateSynced = mSelectedVideo == null || stateService.getByVideoId(mSelectedVideo.videoId) != null;
6363
State lastState = stateService.getLastState();
64-
PlaybackPresenter.instance(mContext).openVideo(lastState != null && isVideoStateSynced ? lastState.video : mSelectedVideo);
64+
openVideo(lastState != null && isVideoStateSynced ? lastState.video : mSelectedVideo);
6565
}
6666

6767
// Restore can be called only once
@@ -76,4 +76,12 @@ public void restoreHeader(OnRestoreHeader onRestoreHeader) {
7676
// Restore can be called only once
7777
mSelectedHeaderIndex = -1;
7878
}
79+
80+
private void openVideo(Video video) {
81+
if (video != null) {
82+
video.fromCrashRestorer = true; // tell the state controller to not reset the position
83+
}
84+
85+
PlaybackPresenter.instance(mContext).openVideo(video);
86+
}
7987
}

0 commit comments

Comments
 (0)