-
-
Notifications
You must be signed in to change notification settings - Fork 86
PdfViewer
The integration of a PdfViewer allows a userfriendly way of displaying Pdf-files without leaving the TCA app. Therefore it was necessary to implement a new fragment: "PdfViewFragment". It uses the dependency: https://github.com/barteksc/AndroidPdfViewer
The dependency introduces a new view called "PDFView", which is the only UI component of the fragment. In its onResume() method, it loads the currently referenced pdf file. After it is loaded, the pdf is automatically displayed. To verify that a file is a pdf file, the method isFilePdf checks the first four bytes of the file for the String "%PDF". To change the currently assigned pdf file, it's necessary to call the fragment's setPdf(File) method. Before the assignment is done, isFilePdf is evaluated, so that there are only valid Pdfs assigned. Additionally it was necessary to call the pdfView's fitToWidth() each time a layout change occured. (addOnLayoutChangeListener) This way the pdf gets correctly resized when the user holds the phone horizontally.
This fragment is currently in use in the PlansActivity. Originally it contained a listview of all the plans. The view has been moved to a PlansViewFragment. This made it possible to swap out the PlansViewFragment (containing the list) with the PdfViewFragment. That makes it possible to click a pdf plan within the listview and instantly display it in the PdfViewFragment.