|
@@ -34,6 +34,7 @@ import com.compdfkit.core.document.CPDFDocument.PDFDocumentError;
|
|
|
import com.compdfkit.flutter.compdfkit_flutter.utils.FileUtils;
|
|
|
import com.compdfkit.tools.common.utils.CFileUtils;
|
|
|
import com.compdfkit.tools.common.utils.threadpools.CThreadPoolUtils;
|
|
|
+import com.compdfkit.tools.common.views.pdfview.CPDFViewCtrl;
|
|
|
import com.compdfkit.ui.reader.CPDFReaderView;
|
|
|
import io.flutter.plugin.common.BinaryMessenger;
|
|
|
import io.flutter.plugin.common.MethodCall;
|
|
@@ -44,7 +45,7 @@ public class CPDFDocumentPlugin extends BaseMethodChannelPlugin {
|
|
|
|
|
|
private String documentUid;
|
|
|
|
|
|
- private CPDFReaderView readerView;
|
|
|
+ private CPDFViewCtrl pdfView;
|
|
|
|
|
|
public CPDFDocumentPlugin(Context context,
|
|
|
BinaryMessenger binaryMessenger, String documentUid) {
|
|
@@ -52,8 +53,8 @@ public class CPDFDocumentPlugin extends BaseMethodChannelPlugin {
|
|
|
this.documentUid = documentUid;
|
|
|
}
|
|
|
|
|
|
- public void setReaderView(CPDFReaderView readerView) {
|
|
|
- this.readerView = readerView;
|
|
|
+ public void setReaderView(CPDFViewCtrl pdfView) {
|
|
|
+ this.pdfView = pdfView;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -64,26 +65,26 @@ public class CPDFDocumentPlugin extends BaseMethodChannelPlugin {
|
|
|
|
|
|
@Override
|
|
|
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
|
|
|
- if (readerView == null || readerView.getPDFDocument() == null) {
|
|
|
+ if (pdfView == null || pdfView.getCPdfReaderView().getPDFDocument() == null) {
|
|
|
result.error("-1", "CPDFReaderView isnull or CPDFDocument is null", null);
|
|
|
return;
|
|
|
}
|
|
|
+ CPDFReaderView readerView = pdfView.getCPdfReaderView();
|
|
|
CPDFDocument document = readerView.getPDFDocument();
|
|
|
switch (call.method) {
|
|
|
case OPEN_DOCUMENT:
|
|
|
String filePath = call.argument("filePath");
|
|
|
- String fileUri = call.argument("fileUri");
|
|
|
String openPwd = call.argument("password");
|
|
|
PDFDocumentError error;
|
|
|
- if (!TextUtils.isEmpty(filePath)) {
|
|
|
- error = document.open(filePath, openPwd);
|
|
|
- } else {
|
|
|
- error = document.open(Uri.parse(fileUri), openPwd);
|
|
|
+ if (filePath.startsWith(FileUtils.CONTENT_SCHEME) || filePath.startsWith(FileUtils.FILE_SCHEME)){
|
|
|
+ pdfView.openPDF(Uri.parse(filePath), openPwd, ()->{
|
|
|
+ result.success(true);
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ pdfView.openPDF(filePath,openPwd, ()->{
|
|
|
+ result.success(true);
|
|
|
+ });
|
|
|
}
|
|
|
- if (error == PDFDocumentError.PDFDocumentErrorSuccess) {
|
|
|
- readerView.setPDFDocument(document);
|
|
|
- }
|
|
|
- result.success(error.ordinal());
|
|
|
break;
|
|
|
case GET_FILE_NAME:
|
|
|
result.success(document.getFileName());
|