mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 00:01:08 +01:00
Add support for story archiving.
This commit is contained in:
committed by
jeffrey-signal
parent
ff50755ba2
commit
e7d1db446b
@@ -8,6 +8,8 @@ import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
import io.reactivex.rxjava3.subjects.Subject;
|
||||
import kotlinx.coroutines.flow.MutableStateFlow;
|
||||
import kotlinx.coroutines.flow.StateFlow;
|
||||
|
||||
/**
|
||||
* The primary entry point for creating paged data.
|
||||
@@ -36,6 +38,14 @@ public class PagedData<Key> {
|
||||
return new ObservablePagedData<>(subject, controller);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public static <Key, Data> StateFlowPagedData<Key, Data> createForStateFlow(@NonNull PagedDataSource<Key, Data> dataSource, @NonNull PagingConfig config) {
|
||||
MutableStateFlow<List<Data>> stateFlow = kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow(java.util.Collections.emptyList());
|
||||
PagingController<Key> controller = new BufferedPagingController<>(dataSource, config, stateFlow::setValue);
|
||||
|
||||
return new StateFlowPagedData<>(stateFlow, controller);
|
||||
}
|
||||
|
||||
public PagingController<Key> getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.signal.paging
|
||||
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
/**
|
||||
* An implementation of [PagedData] that will provide data as a [StateFlow].
|
||||
*/
|
||||
class StateFlowPagedData<Key, Data>(
|
||||
val data: StateFlow<List<Data>>,
|
||||
controller: PagingController<Key>
|
||||
) : PagedData<Key>(controller)
|
||||
Reference in New Issue
Block a user