crash fixes

This commit is contained in:
Yuriy Liskov
2025-05-22 19:10:45 +03:00
parent 8fc65f9181
commit 89a0e23eb5
5 changed files with 31 additions and 10 deletions
@@ -162,6 +162,10 @@ public class VideoStateController extends BasePlayerController {
@Override
public void onEngineError(int type, int rendererIndex, Throwable error) {
if (getPlayer() == null) {
return;
}
// Oops. Error happens while playing (network lost etc).
if (getPlayer().getPositionMs() > 1_000) {
saveState();
@@ -122,9 +122,26 @@ public class MultiVideoGridFragment extends MultiGridFragment implements VideoSe
public void update(VideoGroup group) {
if (group.getPosition() == 0) {
addSearchHeader();
freeze1(true);
updateGroup1(group);
freeze1(false);
} else if (group.getPosition() == 1) {
int action = group.getAction();
// Attempt to fix: IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
if (action == VideoGroup.ACTION_SYNC && getBrowseGrid2() != null && getBrowseGrid2().isComputingLayout()) {
return;
}
// Smooth remove animation
if (action == VideoGroup.ACTION_REMOVE) {
updateGroup2(group);
return;
}
freeze2(true);
updateGroup2(group);
freeze2(false);
}
}
@@ -240,12 +257,8 @@ public class MultiVideoGridFragment extends MultiGridFragment implements VideoSe
return;
}
freeze1(true);
mGridAdapter1.add(group);
freeze1(false);
restorePosition1();
}
@@ -271,12 +284,8 @@ public class MultiVideoGridFragment extends MultiGridFragment implements VideoSe
return;
}
freeze2(true);
mGridAdapter2.add(group);
freeze2(false);
// TODO: Do we need to restore position on second group?
//restorePosition2();
}
@@ -204,6 +204,14 @@ public abstract class MultipleRowsFragment extends RowsSupportFragment implement
return;
}
int action = group.getAction();
// Smooth remove animation
if (action == VideoGroup.ACTION_REMOVE) {
updateInt(group);
return;
}
freeze(true);
updateInt(group);
@@ -141,7 +141,7 @@ public class VideoGridFragment extends GridFragment implements VideoSection {
int action = group.getAction();
// Attempt to fix: IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
if (action == VideoGroup.ACTION_SYNC && getBrowseGrid() != null && getBrowseGrid().isComputingLayout()) {
if ((action == VideoGroup.ACTION_SYNC || action == VideoGroup.ACTION_REPLACE) && getBrowseGrid() != null && getBrowseGrid().isComputingLayout()) {
return;
}