コード例 #1
0
        public View DrawFragment()
        {
            Stream inputStream = Platform.AppContext.Assets.Open(fileName);

            using (var outputStream = Platform.CurrentActivity.OpenFileOutput("_sample.pdf", Android.Content.FileCreationMode.Private))
            {
                inputStream.CopyTo(outputStream);
            }

            var          fileStreamPath = Platform.CurrentActivity.GetFileStreamPath("_sample.pdf");
            MemoryStream m_memoryStream = new MemoryStream();

            File.OpenRead(fileStreamPath.AbsolutePath).CopyTo(m_memoryStream);

            // Instantiate the pdf file:
            mPdfFile = new PdfFile
            {
                ScreenWidth = (int)DeviceDisplay.MainDisplayInfo.Width
            };

            mPdfFile.RenderPDFPagesIntoImages(fileStreamPath);

            // Get our RecyclerView layout:
            var v = LayoutInflater.From(Platform.AppContext).Inflate(Resource.Layout.pdf_fragment, null);

            mRecyclerView = v.FindViewById <RecyclerView>(Resource.Id.recyclerView);

            // Use the built-in linear layout manager:
            mLayoutManager = new LinearLayoutManager(Platform.CurrentActivity);

            // Plug the layout manager into the RecyclerView:
            mRecyclerView.SetLayoutManager(mLayoutManager);

            // Create an adapter for the RecyclerView, and pass it the
            // data set (the pdf file) to manage:
            mAdapter = new PdfFileAdapter(mPdfFile);

            // Plug the adapter into the RecyclerView:

            mRecyclerView.SetAdapter(mAdapter);

            return(v);
        }
コード例 #2
0
 // Load the adapter with the data set (pdf file) at construction time:
 public PdfFileAdapter(PdfFile pdfFile)
 {
     PdfFile = pdfFile;
 }