-
Notifications
You must be signed in to change notification settings - Fork 67
[jnigen] Fixed an issue with how java.io.File is created #2196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,8 +67,6 @@ class PDFInfoAppState extends State<PDFInfoApp> { | |
final isDir = (await item.stat()).type == FileSystemEntityType.directory; | ||
if (item.path.endsWith('.pdf') && !isDir) { | ||
pdfs.add(item.path); | ||
} else if (isDir) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently the example app shows all of directories even if the app aims to show the summary of pdf files found in $HOME directory. I thought better to exclude directories and included only pdf files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't created this example so I don't know what has been the purpose of this. I'm fine with not removing these lines as it doesn't make the example non-functional. Feel free to open another PR that deletes this line (and cleans the unused variables as a result of your change) that explains why you are making this change. I'd rather this PR remains focused on solving the bug that you fixed. |
||
dirs.add(item.path); | ||
} | ||
} | ||
setState(() { | ||
|
@@ -158,9 +156,10 @@ class PDFFileInfo { | |
// Since java.io is not directly available, use package:jni API to | ||
// create a java.io.File object. | ||
final fileClass = JClass.forName("java/io/File"); | ||
final inputFile = fileClass | ||
.constructorId("(Ljava/lang/String;)V") | ||
.call(fileClass, JObject.type, [filename]); | ||
final fileConstructor = fileClass.constructorId("(Ljava/lang/String;)V"); | ||
final inputFile = fileConstructor( | ||
fileClass, JObject.type, [JString.fromString(filename)]); | ||
lucaskimnz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Static method call PDDocument.load -> PDDocument | ||
final pdf = PDDocument.load(inputFile)!; | ||
// Instance method call getNumberOfPages() -> int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not actually required for the Flutter example at
/example
but is for the Dart-standalone example at/dart_example
and the readme there already has it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running from IDE wouldn't require it, but running the built executable requires them. Please correct me if I'm wrong. Thanks. If it's too much, I will remove the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure what you mean by running it from IDE. Flutter Linux build has a CMake that does the job of jni:setup making it unnecessary.
Yeah I would remove this line.