|
2 | 2 |
|
3 | 3 | import android.content.Context; |
4 | 4 | import android.net.Uri; |
5 | | -import androidx.annotation.NonNull; |
6 | | -import androidx.annotation.Nullable; |
7 | | -import androidx.fragment.app.FragmentManager; |
8 | | - |
9 | 5 | import android.util.AttributeSet; |
10 | 6 | import android.util.Pair; |
11 | 7 | import android.view.Choreographer; |
12 | 8 | import android.view.Gravity; |
13 | 9 | import android.view.View; |
14 | 10 | import android.widget.FrameLayout; |
15 | 11 |
|
| 12 | +import androidx.annotation.NonNull; |
| 13 | +import androidx.annotation.Nullable; |
| 14 | +import androidx.fragment.app.FragmentManager; |
| 15 | + |
16 | 16 | import com.facebook.react.bridge.ReadableMap; |
17 | 17 | import com.facebook.react.uimanager.events.EventDispatcher; |
18 | 18 | import com.pspdfkit.annotations.Annotation; |
|
30 | 30 | import com.pspdfkit.forms.TextFormElement; |
31 | 31 | import com.pspdfkit.listeners.OnPreparePopupToolbarListener; |
32 | 32 | import com.pspdfkit.listeners.SimpleDocumentListener; |
33 | | -import com.pspdfkit.react.R; |
34 | 33 | import com.pspdfkit.react.events.PdfViewDataReturnedEvent; |
35 | 34 | import com.pspdfkit.react.events.PdfViewDocumentLoadFailedEvent; |
36 | 35 | import com.pspdfkit.react.events.PdfViewDocumentSaveFailedEvent; |
@@ -449,11 +448,17 @@ public PdfDocument apply(PdfFragment pdfFragment) { |
449 | 448 | }).flatMap(new Function<PdfDocument, ObservableSource<Annotation>>() { |
450 | 449 | @Override |
451 | 450 | public ObservableSource<Annotation> apply(PdfDocument pdfDocument) { |
452 | | - return pdfDocument.getAnnotationProvider().getAllAnnotationsOfType(getTypeFromString(type), pageIndex, 1); |
| 451 | + return pdfDocument.getAnnotationProvider().getAllAnnotationsOfTypeAsync(getTypeFromString(type), pageIndex, 1); |
453 | 452 | } |
454 | 453 | }).toList(); |
455 | 454 | } |
456 | 455 |
|
| 456 | + public Single<List<Annotation>> getAllAnnotations(@Nullable final String type) { |
| 457 | + return fragmentGetter.take(1).map(PdfFragment::getDocument) |
| 458 | + .flatMap(pdfDocument -> pdfDocument.getAnnotationProvider().getAllAnnotationsOfTypeAsync(getTypeFromString(type))) |
| 459 | + .toList(); |
| 460 | + } |
| 461 | + |
457 | 462 | private EnumSet<AnnotationType> getTypeFromString(@Nullable String type) { |
458 | 463 | if (type == null) { |
459 | 464 | return EnumSet.allOf(AnnotationType.class); |
|
0 commit comments