Optimized selection creator overlay, global subscription progress listener

This commit is contained in:
Kelvin 2023-12-20 21:54:39 +01:00
parent ed9a65b2f0
commit 0d80424799
3 changed files with 22 additions and 4 deletions

View file

@ -141,8 +141,10 @@ class SubscriptionsFeedFragment : MainFragment() {
recyclerData.lastLoad.getNowDiffSeconds() > 60 ) {
recyclerData.lastLoad = OffsetDateTime.now();
if(StateSubscriptions.instance.getOldestUpdateTime().getNowDiffMinutes() > 5 && Settings.instance.subscriptions.fetchOnTabOpen)
if(StateSubscriptions.instance.getOldestUpdateTime().getNowDiffMinutes() > 5 && Settings.instance.subscriptions.fetchOnTabOpen) {
loadCache();
loadResults(false);
}
else if(recyclerData.results.size == 0) {
loadCache();
setLoading(false);

View file

@ -51,10 +51,16 @@ class StateSubscriptions {
val global: CentralizedFeed = CentralizedFeed();
val feeds: HashMap<String, CentralizedFeed> = hashMapOf();
val onFeedProgress = Event3<String, Int, Int>();
val onFeedProgress = Event3<String?, Int, Int>();
val onSubscriptionsChanged = Event2<List<Subscription>, Boolean>();
init {
global.onUpdateProgress.subscribe { progress, total ->
onFeedProgress.emit(null, progress, total);
}
}
fun getOldestUpdateTime(): OffsetDateTime {
val subs = getSubscriptions();
if(subs.size == 0)

View file

@ -112,8 +112,18 @@ class CreatorSelectOverlay: ConstraintLayout {
}
fun updateSelected() {
_creators.forEach { p -> p.active = _selected.contains(p.channel.url) };
_recyclerCreators.notifyContentChanged();
val changed = arrayListOf<SelectableCreatorBarViewHolder.Selectable>()
for(creator in _creators) {
val act = _selected.contains(creator.channel.url);
if(creator.active != act) {
creator.active = act;
changed.add(creator);
}
}
for(change in changed) {
val index = _creatorsFiltered.indexOf(change);
_recyclerCreators.notifyContentChanged(index);
}
if(_selected.isNotEmpty())
_buttonSelect.alpha = 1f;