1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

fix item addition to list

This commit is contained in:
yausername 2019-08-07 15:31:14 +05:30
parent 5aced46345
commit a64f520644

View File

@ -75,17 +75,14 @@ public abstract class StateObjectsListAdapter extends RecyclerView.Adapter<Recyc
protected void loadStates(List<InfoItem> list, int offset, Runnable callback) { protected void loadStates(List<InfoItem> list, int offset, Runnable callback) {
if (isPlaybackStatesVisible()) { if (isPlaybackStatesVisible()) {
stateLoaders.add( List<StreamStateEntity> streamStateEntities = null;
recordManager.loadStreamStateBatch(list) try {
.observeOn(AndroidSchedulers.mainThread()) streamStateEntities = recordManager.loadStreamStateBatch(list).blockingGet();
.subscribe(streamStateEntities -> { } catch (Exception e) {
appendStates(streamStateEntities, offset); if (BuildConfig.DEBUG) e.printStackTrace();
callback.run(); }
}, throwable -> { if(streamStateEntities != null) appendStates(streamStateEntities, offset);
if (BuildConfig.DEBUG) throwable.printStackTrace(); callback.run();
callback.run();
})
);
} else { } else {
callback.run(); callback.run();
} }
@ -93,17 +90,14 @@ public abstract class StateObjectsListAdapter extends RecyclerView.Adapter<Recyc
protected void loadState(InfoItem item, int offset, Runnable callback) { protected void loadState(InfoItem item, int offset, Runnable callback) {
if (isPlaybackStatesVisible()) { if (isPlaybackStatesVisible()) {
stateLoaders.add( StreamStateEntity[] streamStateEntities = null;
recordManager.loadStreamState(item) try {
.observeOn(AndroidSchedulers.mainThread()) streamStateEntities = recordManager.loadStreamState(item).blockingGet();
.subscribe(streamStateEntities -> { } catch (Exception e) {
appendState(streamStateEntities[0], offset); if (BuildConfig.DEBUG) e.printStackTrace();
callback.run(); }
}, throwable -> { if(streamStateEntities != null && streamStateEntities.length > 0) appendState(streamStateEntities[0], offset);
if (BuildConfig.DEBUG) throwable.printStackTrace(); callback.run();
callback.run();
})
);
} else { } else {
callback.run(); callback.run();
} }
@ -111,17 +105,14 @@ public abstract class StateObjectsListAdapter extends RecyclerView.Adapter<Recyc
protected void loadStatesForLocal(List<? extends LocalItem> list, int offset, Runnable callback) { protected void loadStatesForLocal(List<? extends LocalItem> list, int offset, Runnable callback) {
if (isPlaybackStatesVisible()) { if (isPlaybackStatesVisible()) {
stateLoaders.add( List<StreamStateEntity> streamStateEntities = null;
recordManager.loadLocalStreamStateBatch(list) try {
.observeOn(AndroidSchedulers.mainThread()) streamStateEntities = recordManager.loadLocalStreamStateBatch(list).blockingGet();
.subscribe(streamStateEntities -> { } catch (Exception e) {
appendStates(streamStateEntities, offset); if (BuildConfig.DEBUG) e.printStackTrace();
callback.run(); }
}, throwable -> { if(streamStateEntities != null) appendStates(streamStateEntities, offset);
if (BuildConfig.DEBUG) throwable.printStackTrace(); callback.run();
callback.run();
})
);
} else { } else {
callback.run(); callback.run();
} }