Replace some loadStateStream calls with progressTime field
This commit is contained in:
parent
37ceddd11b
commit
ebe9f518d0
2 changed files with 10 additions and 30 deletions
|
@ -11,7 +11,6 @@ import androidx.core.content.ContextCompat;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.database.LocalItem;
|
import org.schabi.newpipe.database.LocalItem;
|
||||||
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry;
|
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry;
|
||||||
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
|
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.local.LocalItemBuilder;
|
import org.schabi.newpipe.local.LocalItemBuilder;
|
||||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
|
@ -21,7 +20,6 @@ import org.schabi.newpipe.util.Localization;
|
||||||
import org.schabi.newpipe.views.AnimatedProgressBar;
|
import org.schabi.newpipe.views.AnimatedProgressBar;
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class LocalPlaylistStreamItemHolder extends LocalItemHolder {
|
public class LocalPlaylistStreamItemHolder extends LocalItemHolder {
|
||||||
|
@ -70,15 +68,11 @@ public class LocalPlaylistStreamItemHolder extends LocalItemHolder {
|
||||||
R.color.duration_background_color));
|
R.color.duration_background_color));
|
||||||
itemDurationView.setVisibility(View.VISIBLE);
|
itemDurationView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
final StreamStateEntity state = historyRecordManager
|
if (item.getProgressTime() > 0) {
|
||||||
.loadLocalStreamStateBatch(new ArrayList<LocalItem>() {{
|
|
||||||
add(localItem);
|
|
||||||
}}).blockingGet().get(0);
|
|
||||||
if (state != null) {
|
|
||||||
itemProgressView.setVisibility(View.VISIBLE);
|
itemProgressView.setVisibility(View.VISIBLE);
|
||||||
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
||||||
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
||||||
.toSeconds(state.getProgressTime()));
|
.toSeconds(item.getProgressTime()));
|
||||||
} else {
|
} else {
|
||||||
itemProgressView.setVisibility(View.GONE);
|
itemProgressView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -115,18 +109,14 @@ public class LocalPlaylistStreamItemHolder extends LocalItemHolder {
|
||||||
}
|
}
|
||||||
final PlaylistStreamEntry item = (PlaylistStreamEntry) localItem;
|
final PlaylistStreamEntry item = (PlaylistStreamEntry) localItem;
|
||||||
|
|
||||||
final StreamStateEntity state = historyRecordManager
|
if (item.getProgressTime() > 0 && item.getStreamEntity().getDuration() > 0) {
|
||||||
.loadLocalStreamStateBatch(new ArrayList<LocalItem>() {{
|
|
||||||
add(localItem);
|
|
||||||
}}).blockingGet().get(0);
|
|
||||||
if (state != null && item.getStreamEntity().getDuration() > 0) {
|
|
||||||
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
||||||
if (itemProgressView.getVisibility() == View.VISIBLE) {
|
if (itemProgressView.getVisibility() == View.VISIBLE) {
|
||||||
itemProgressView.setProgressAnimated((int) TimeUnit.MILLISECONDS
|
itemProgressView.setProgressAnimated((int) TimeUnit.MILLISECONDS
|
||||||
.toSeconds(state.getProgressTime()));
|
.toSeconds(item.getProgressTime()));
|
||||||
} else {
|
} else {
|
||||||
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
||||||
.toSeconds(state.getProgressTime()));
|
.toSeconds(item.getProgressTime()));
|
||||||
AnimationUtils.animateView(itemProgressView, true, 500);
|
AnimationUtils.animateView(itemProgressView, true, 500);
|
||||||
}
|
}
|
||||||
} else if (itemProgressView.getVisibility() == View.VISIBLE) {
|
} else if (itemProgressView.getVisibility() == View.VISIBLE) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import androidx.core.content.ContextCompat;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.database.LocalItem;
|
import org.schabi.newpipe.database.LocalItem;
|
||||||
import org.schabi.newpipe.database.stream.StreamStatisticsEntry;
|
import org.schabi.newpipe.database.stream.StreamStatisticsEntry;
|
||||||
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
|
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.local.LocalItemBuilder;
|
import org.schabi.newpipe.local.LocalItemBuilder;
|
||||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
|
@ -21,7 +20,6 @@ import org.schabi.newpipe.util.Localization;
|
||||||
import org.schabi.newpipe.views.AnimatedProgressBar;
|
import org.schabi.newpipe.views.AnimatedProgressBar;
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,15 +96,11 @@ public class LocalStatisticStreamItemHolder extends LocalItemHolder {
|
||||||
R.color.duration_background_color));
|
R.color.duration_background_color));
|
||||||
itemDurationView.setVisibility(View.VISIBLE);
|
itemDurationView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
final StreamStateEntity state = historyRecordManager
|
if (item.getProgressTime() > 0) {
|
||||||
.loadLocalStreamStateBatch(new ArrayList<LocalItem>() {{
|
|
||||||
add(localItem);
|
|
||||||
}}).blockingGet().get(0);
|
|
||||||
if (state != null) {
|
|
||||||
itemProgressView.setVisibility(View.VISIBLE);
|
itemProgressView.setVisibility(View.VISIBLE);
|
||||||
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
||||||
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
||||||
.toSeconds(state.getProgressTime()));
|
.toSeconds(item.getProgressTime()));
|
||||||
} else {
|
} else {
|
||||||
itemProgressView.setVisibility(View.GONE);
|
itemProgressView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -146,18 +140,14 @@ public class LocalStatisticStreamItemHolder extends LocalItemHolder {
|
||||||
}
|
}
|
||||||
final StreamStatisticsEntry item = (StreamStatisticsEntry) localItem;
|
final StreamStatisticsEntry item = (StreamStatisticsEntry) localItem;
|
||||||
|
|
||||||
final StreamStateEntity state = historyRecordManager
|
if (item.getProgressTime() > 0 && item.getStreamEntity().getDuration() > 0) {
|
||||||
.loadLocalStreamStateBatch(new ArrayList<LocalItem>() {{
|
|
||||||
add(localItem);
|
|
||||||
}}).blockingGet().get(0);
|
|
||||||
if (state != null && item.getStreamEntity().getDuration() > 0) {
|
|
||||||
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
itemProgressView.setMax((int) item.getStreamEntity().getDuration());
|
||||||
if (itemProgressView.getVisibility() == View.VISIBLE) {
|
if (itemProgressView.getVisibility() == View.VISIBLE) {
|
||||||
itemProgressView.setProgressAnimated((int) TimeUnit.MILLISECONDS
|
itemProgressView.setProgressAnimated((int) TimeUnit.MILLISECONDS
|
||||||
.toSeconds(state.getProgressTime()));
|
.toSeconds(item.getProgressTime()));
|
||||||
} else {
|
} else {
|
||||||
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
itemProgressView.setProgress((int) TimeUnit.MILLISECONDS
|
||||||
.toSeconds(state.getProgressTime()));
|
.toSeconds(item.getProgressTime()));
|
||||||
AnimationUtils.animateView(itemProgressView, true, 500);
|
AnimationUtils.animateView(itemProgressView, true, 500);
|
||||||
}
|
}
|
||||||
} else if (itemProgressView.getVisibility() == View.VISIBLE) {
|
} else if (itemProgressView.getVisibility() == View.VISIBLE) {
|
||||||
|
|
Loading…
Reference in a new issue