Пример #1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)             // no view to re-use, create new
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.custom_listview_item_explorer, null);
            }

            var textView = view.FindViewById <TextView> (Resource.Id.list_item_textview_explorer);


            var imageViewLeft  = view.FindViewById <ImageView> (Resource.Id.list_item_image_explorer);
            var imageViewRight = view.FindViewById <ImageView> (Resource.Id.list_item_image_explorer_special_type);

            TreeNode treeNodeToShow = foundTreeNodes [position];

            textView.Text = treeNodeToShow.Name;

            //Juiste icoon tonen bij bestandstype
            string mimeType = MimeTypeHelper.GetMimeType(treeNodeToShow.Path);

            //LINKER ICOON LISTITEM
            if (treeNodeToShow.IsDirectory == true)
            {
                if (treeNodeToShow.HasKeys)                   //Encrypted
                {
                    imageViewLeft.SetImageResource(Resource.Drawable.ic_type_map_versleuteld);
                }
                else
                {
                    //Unencrypted?? Check if folder is subfolder of encrypted folder - then it is also encrypted..
                    imageViewLeft.SetImageResource(Resource.Drawable.ic_type_map);

                    if (adapterUsedToMoveFile)                       //Used in MoveFileFragment
                    {
                        if (!MoveFileFragment.openedFolderIsUnencrypted)
                        {
                            if (MoveFileFragment.openedDirectories.Count > 1)
                            {
                                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_map_versleuteld);
                            }
                        }
                    }
                    else                         //Used in ExplorerFragment
                    {
                        if (!ExplorerFragment.openedFolderIsUnencrypted)
                        {
                            if (ExplorerFragment.openedDirectories.Count > 1)
                            {
                                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_map_versleuteld);
                            }
                        }
                    }
                }
            }
            else if (treeNodeToShow.Type.Equals("favorite"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_lijst_favorieten);
            }
            else if (mimeType.Equals("image/jpeg") ||
                     mimeType.Equals("image/png"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_foto);
            }
            else if (mimeType.Equals("video/mp4"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_film);
            }
            else if (mimeType.Equals("application/pdf"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_p_d_f);
            }
            else if (mimeType.Equals("application/zip"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_gecompileerd);
            }
            else if (mimeType.Equals("application/mp4"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_film);
            }
            else if (mimeType.Equals("application/vnd.ms-excel") ||
                     mimeType.Equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_berekeningen);
            }
            else if (mimeType.Equals("application/vnd.ms-powerpoint") ||
                     mimeType.Equals("application/vnd.openxmlformats-officedocument.presentationml.presentation"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_presentatie);
            }
            else if (mimeType.Equals("application/msword") ||
                     mimeType.Equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document"))
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_tekstdocumenten);
            }
            else
            {
                imageViewLeft.SetImageResource(Resource.Drawable.ic_type_onbekend);
            }


            //RECHTER ICOON LISTITEM
            if (treeNodeToShow.IsFavorite == true)
            {
                imageViewRight.SetImageResource(Resource.Drawable.ic_ind_favorieten);
                imageViewRight.Visibility = ViewStates.Visible;
            }
            else if (treeNodeToShow.IsShare == true)
            {
                imageViewRight.SetImageResource(Resource.Drawable.ic_ind_met_mij_gedeeld);
                imageViewRight.Visibility = ViewStates.Visible;
            }
            else if (treeNodeToShow.IsShared == true)
            {
                imageViewRight.SetImageResource(Resource.Drawable.ic_ind_zelf_gedeeld);
                imageViewRight.Visibility = ViewStates.Visible;
            }
            else
            {
                imageViewRight.Visibility = ViewStates.Invisible;
            }

            //Set font
            FontHelper.SetFont(textView);

            return(view);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_document_fullscreen);

            //Hide action bar
            this.ActionBar.Hide();

            //Change color of custom action bar
            LinearLayout documentActionBar = FindViewById <LinearLayout> (Resource.Id.document_fullscreen_custom_actionbar);

            if (!String.IsNullOrEmpty(HomeActivity.colorOfSelectedLocalBox))
            {
                documentActionBar.SetBackgroundColor(Color.ParseColor(HomeActivity.colorOfSelectedLocalBox));
            }
            else
            {
                documentActionBar.SetBackgroundColor(Color.ParseColor(Constants.lightblue));
            }

            try{
                //Open file in webview
                WebView webViewDocumentFullscreen = FindViewById <WebView> (Resource.Id.webview_document_fullscreen);

                var fullPath = DocumentFragment.pathOfFile;

                //Resize webview + make it scrollable
                webViewDocumentFullscreen.Settings.LoadWithOverviewMode             = true;
                webViewDocumentFullscreen.Settings.UseWideViewPort                  = true;
                webViewDocumentFullscreen.Settings.BuiltInZoomControls              = true;
                webViewDocumentFullscreen.Settings.AllowFileAccess                  = true;
                webViewDocumentFullscreen.Settings.AllowContentAccess               = true;
                webViewDocumentFullscreen.Settings.DomStorageEnabled                = true;
                webViewDocumentFullscreen.Settings.AllowFileAccessFromFileURLs      = true;
                webViewDocumentFullscreen.Settings.AllowUniversalAccessFromFileURLs = true;
                webViewDocumentFullscreen.Settings.JavaScriptEnabled                = true;
                webViewDocumentFullscreen.SetWebChromeClient(new WebChromeClient());

                if (fullPath.Contains(".pdf"))
                {
                    webViewDocumentFullscreen.LoadUrl("file:///android_asset/pdf-viewer/viewer.html?file=" + fullPath.Replace(" ", "%20").Replace(".", "%2E"));
                }
                else if (fullPath.Contains(".odt"))
                {
                    webViewDocumentFullscreen.LoadUrl("file:///android_asset/odf-viewer/viewer.html?file=" + fullPath.Replace(" ", "%20").Replace(".", "%2E"));
                }
                else
                {
                    webViewDocumentFullscreen.LoadUrl("file:///" + fullPath);
                }

                //Set file name
                TextView textviewFilename = FindViewById <TextView> (Resource.Id.textview_filename_document_fullscreen);
                textviewFilename.Text = DocumentFragment.fileName;

                //Set Font
                FontHelper.SetFont(textviewFilename);
            }catch (Exception ex) {
                Insights.Report(ex);
                Toast.MakeText(this, "Het openen van het bestand is mislukt", ToastLength.Short).Show();
                this.Finish();
            }
        }