Example #1
0
 internal ViewGroupItemsSourceGenerator([NotNull] ViewGroup viewGroup)
 {
     Should.NotBeNull(viewGroup, nameof(viewGroup));
     _viewGroup = viewGroup;
     _adapter   = ItemsSourceAdapter.Factory(viewGroup, viewGroup.Context, Context);
     _collectionViewManagerMember = BindingServiceProvider
                                    .MemberProvider
                                    .GetBindingMember(viewGroup.GetType(), AttachedMembers.ViewGroup.CollectionViewManager, false, false);
     TryListenActivity(viewGroup.Context);
 }
        public void SetGestureEnabled(bool enabled)
        {
            if (_currentViewPager == null)
            {
                return;
            }
            var type = _currentViewPager.GetType();

            type.InvokeMember("EnableGesture",
                              BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty,
                              Type.DefaultBinder, _currentViewPager, new object[] { enabled });
        }
Example #3
0
        internal static void SetDisableHierarchyListener(this ViewGroup viewGroup, bool value)
        {
            if (!viewGroup.IsAlive())
            {
                return;
            }
            var member = BindingServiceProvider.MemberProvider.GetBindingMember(viewGroup.GetType(), AttachedMembers.ViewGroup.DisableHierarchyListener, false, false);

            if (member != null && member.CanWrite)
            {
                member.SetSingleValue(viewGroup, Empty.BooleanToObject(value));
            }
        }
        /// <summary>
        /// Helper method for printing on output all children from ViewGroup.
        /// </summary>
        public static void PrintChildren(this ViewGroup viewGroup)
        {
            System.Diagnostics.Debug.WriteLine(_currentPadding + viewGroup.GetType().Name + " (ViewGroup)");

            _currentPadding += PADDING_STRING;

            for (int i = 0; i < viewGroup.ChildCount; i++)
            {
                View child = viewGroup.GetChildAt(i);

                if (!(child is ViewGroup))
                {
                    System.Diagnostics.Debug.WriteLine(_currentPadding + child.GetType().Name);
                }

                if (child is ViewGroup childViewGroup)
                {
                    PrintChildren(childViewGroup);
                }
            }

            _currentPadding = _currentPadding.Remove(_currentPadding.Length - PADDING_STRING.Length);
        }
        private View GetViewDir(int position, View convertView, ViewGroup parent)
        {
            var dir = _Items[position] as DownDir;

            GridView grid = null;

            if (parent.GetType() == typeof(GridView))
            {
                grid = parent as GridView;
            }

            View view = null;

            if (grid != null && grid.NumColumns == 1)
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.DownloadListItem, parent, false);
            }
            else
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.DownloadDirItem, parent, false);
            }

            var txtTitolo   = view.FindViewById <TextView>(Resource.Id.downloadTxtTitolo);
            var txtDettagli = view.FindViewById <TextView>(Resource.Id.downloadTxtDettagli);
            var imgCover    = view.FindViewById <ImageView>(Resource.Id.downloadImgCover);
            var btnDownload = view.FindViewById <ImageView>(Resource.Id.btnDownload);
            var btnBuy      = view.FindViewById <TextView>(Resource.Id.btnBuy);

            /*var prgDownload = view.FindViewById<ProgressBar>(Resource.Id.downloadProgress);
             * var overlay = view.FindViewById<RelativeLayout>(Resource.Id.downloadOverlay);*/

            //copertina
            imgCover.SetImageResource(Resource.Drawable.ic_folder);
            imgCover.SetScaleType(ImageView.ScaleType.CenterInside);
            imgCover.Colorize(DataManager.Get <ISettingsManager>().Settings.ButtonColor);

            //campo titolo
            txtTitolo.Tag = position;
            txtTitolo.SetText(dir.Nome, TextView.BufferType.Normal);

            //dettagli
            if (txtDettagli != null)
            {
                //txtDettagli.SetText(context.GetString(Resource.String.pub_cartella), TextView.BufferType.Normal);
                txtDettagli.Visibility = ViewStates.Gone;
            }

            //pulsante info
            if (btnDownload != null)
            {
                btnDownload.Visibility = ViewStates.Invisible;
            }

            //pulsante buy
            if (btnBuy != null)
            {
                btnBuy.Visibility = ViewStates.Gone;
            }

            return(view);
        }
        private View GetViewThumb(int position, View convertView, ViewGroup parent)
        {
            var down = _Items[position] as Download;

            GridView grid = null;

            if (parent.GetType() == typeof(GridView))
            {
                grid = parent as GridView;
            }

            bool list = (grid != null && grid.NumColumns == 1);

            DownloadItem view = null;

            if (convertView != null && convertView is DownloadItem)
            {
                view = convertView as DownloadItem;

                if (view.DownloadUri == down.Uri)
                {
                    return(view);
                }
                else
                {
                    view = null;
                }
            }

            if (view == null)
            {
                view = new DownloadItem(this.context, list);
            }

            view.Tag = position;

            view.DownloadUri = down.Uri;
            view.Stato       = view.InitStato = down.Stato;

            view.Prezzo = down.IapPrezzo;

            //copertina
            if (down.Tipo == "pdf")
            {
                view.ImgCover.SetImageResource(Resource.Drawable.pdf_icon);
                view.ImgCover.SetScaleType(ImageView.ScaleType.FitCenter);
            }
            else
            {
                string key = down.ImageKey;
                var    uri = new Uri(DataManager.Get <ISettingsManager>().Settings.DownloadUrl +
                                     "services/edicola_services.php?action=pubCover&zip=" + down.RelativePath +
                                     "&img=copertina.jpg&key=" + key +
                                     "&app=" + DataManager.Get <ISettingsManager>().Settings.AppId);

                view.ImgCover.Tag = uri.ToString();
                //MBImageLoader.DisplayNetworkImage(uri, view.ImgCover, new PointF(280, 280));
                Koush.UrlImageViewHelper.SetUrlDrawable(view.ImgCover, uri.AbsoluteUri);
            }

            //titolo
            view.Title = down.Titolo;

            //dettagli
            if (view.Details != null)
            {
                string autore = down.Autore;

                if (autore == "")
                {
                    autore = context.GetString(Resource.String.pub_sconosciuto);
                }

                view.Details = autore;
            }

            //pulsante apri
            EventHandler openClick = delegate
            {
                if (_OpenAction != null)
                {
                    OpenAction(down.GetLocalPath());
                }
            };

            view.OpenButton.Click -= openClick;
            view.OpenButton.Click += openClick;

            //download finito
            Action downFinish = () =>
            {
                down.Stato = DownloadStato.NoUpdate;
            };

            view.DownloadFinish -= downFinish;
            view.DownloadFinish += downFinish;

            //pulsante buy
            EventHandler buyClick = delegate
            {
                if (_BuyAction != null)
                {
                    _BuyAction(down.IapID);
                }
            };

            view.BuyButton.Click -= buyClick;
            view.BuyButton.Click += buyClick;

            view.ConfigureForDownload();


            /*if(grid != null && grid.NumColumns == 1)
             * {
             *      view = new DownloadGridItem(this.context, doc, true); //context.LayoutInflater.Inflate(Resource.Layout.EdicolaListItem, parent, false);
             *
             * }
             * else
             * {
             *      view = new DownloadGridItem(this.context, doc);
             *
             * }
             *
             * var btnOpen = view.FindViewById<ImageView>(Resource.Id.btnOpen);
             *
             * btnOpen.Click += delegate
             * {
             *      if(_OpenAction != null)
             *      {
             *              OpenAction(doc.GetLocalPath());
             *      }
             * };*/

            return(view);
        }
Example #7
0
        private View GetViewDir(int position, View convertView, ViewGroup parent)
        {
            var dir = _Items[position] as DirectoryInfo;

            GridView grid = null;

            if (parent.GetType() == typeof(GridView))
            {
                grid = parent as GridView;
            }

            View view = null;

            if (grid != null && grid.NumColumns == 1)
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.EdicolaListItem, parent, false);
            }
            else
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.EdicolaDirItem, parent, false);
            }

            var imgCover    = view.FindViewById <ImageView>(Resource.Id.edicolaImgCover);
            var txtTitolo   = view.FindViewById <TextView>(Resource.Id.edicolaTxtTitolo);
            var txtDettagli = view.FindViewById <TextView>(Resource.Id.edicolaTxtDettagli);
            var btnInfo     = view.FindViewById <ImageView>(Resource.Id.btnInfo);

            //copertina
            imgCover.SetImageResource(Resource.Drawable.ic_folder);
            imgCover.SetScaleType(ImageView.ScaleType.CenterInside);
            imgCover.Colorize(DataManager.Get <ISettingsManager>().Settings.ButtonColor);

            //campo titolo
            txtTitolo.SetText(dir.Name, TextView.BufferType.Normal);

            //dettagli
            if (txtDettagli != null)
            {
                //txtDettagli.SetText(context.GetString(Resource.String.pub_cartella), TextView.BufferType.Normal);
                txtDettagli.Visibility = ViewStates.Gone;
            }

            //pulsante info
            btnInfo.Tag = position;
            btnInfo.Drawable.Colorize(DataManager.Get <ISettingsManager>().Settings.ButtonColor);
            btnInfo.Click += (sender, e) =>
            {
                //_InfoClick(position);
                PopupMenu popup = new PopupMenu(this.context, btnInfo);
                popup.MenuInflater.Inflate(Resource.Menu.EdicolaDirMenu, popup.Menu);

                var el = popup.Menu.FindItem(Resource.Id.EdicolaItemOption_Delete);
                el.SetTitle(context.GetString(Resource.String.gen_delete));

                popup.MenuItemClick += (object send, PopupMenu.MenuItemClickEventArgs ev) =>
                {
                    _ItemOptionClick(ev, position);
                };

                popup.Show();
            };

            if (ActionMode)
            {
                btnInfo.Visibility = ViewStates.Invisible;
            }
            else
            {
                btnInfo.Visibility = ViewStates.Visible;
            }

            return(view);
        }
Example #8
0
        private View GetViewThumb(int position, View convertView, ViewGroup parent)
        {
            var doc = _Items[position] as Pubblicazione;

            GridView grid = null;

            if (parent.GetType() == typeof(GridView))
            {
                grid = parent as GridView;
            }

            bool list = (grid != null && grid.NumColumns == 1);

            EdicolaItem view = null;

            if (convertView != null && convertView is CheckableLayout)
            {
                var v = convertView as CheckableLayout;

                if (v.MainView != null && v.MainView is EdicolaItem)
                {
                    view = v.MainView as EdicolaItem;

                    if (view.IdDoc == doc.ID)
                    {
                        SetUpdate(view, doc.ID);

                        if (ActionMode)
                        {
                            view.ActionButton.Visibility = ViewStates.Invisible;
                        }
                        else
                        {
                            view.ActionButton.Visibility = ViewStates.Visible;
                        }

                        return(v);
                    }
                    else
                    {
                        view = null;
                    }
                }
            }

            if (view == null)
            {
                view = new EdicolaItem(this.context, list);
            }

            view.Tag   = position;
            view.IdDoc = doc.ID;

            //copertina
            if (doc.IsPDF)
            {
                view.ImgCover.SetImageResource(Resource.Drawable.pdf_icon);
                view.ImgCover.SetScaleType(ImageView.ScaleType.FitCenter);
            }
            else
            {
                string imgPath = System.IO.Path.Combine(doc.Path, "copertina.jpg");
                if (System.IO.File.Exists(imgPath))
                {
                    /*using(Bitmap bmp = ImageUtility.DecodeSampledBitmapFromFile(imgPath, 280, 280))
                     *                  {
                     *                          view.ImgCover.SetImageBitmap(bmp);
                     *                  }*/

                    //imgPath += "_" + doc.DataPubblicazione.ToString("yyMMddhhmmss");

                    /*Uri uri = new Uri(imgPath);
                     *
                     * var options = new DisplayImageOptions.Builder()
                     * .CacheInMemory(false)
                     * .CacheOnDisk(true)
                     * .ConsiderExifParams(true)
                     * .BitmapConfig(Bitmap.Config.Rgb565)
                     * .Build();
                     *
                     * var targetSize = new ImageSize(280, 280);
                     *
                     * ImageLoader.Instance.LoadImage(
                     *  uri.ToString(),
                     *  targetSize,
                     *  options,
                     *  new ImageLoadingListener(
                     *      loadingComplete: (imageUri, v, loadedImage) => {
                     *          view.ImgCover.SetImageBitmap(loadedImage);
                     *      }));*/

                    //MBImageLoader.DisplayDiskImage(imgPath, view.ImgCover, new PointF(280, 280));

                    Koush.UrlImageViewHelper.SetUrlDrawable(view.ImgCover, new Uri(imgPath).AbsoluteUri);
                }
            }

            //pulsante info
            EventHandler onClick = (sender, e) =>
            {
                //_InfoClick(position);
                PopupMenu popup = new PopupMenu(this.context, view.ActionButton);
                popup.MenuInflater.Inflate(Resource.Menu.EdicolaThumbMenu, popup.Menu);

                var menu = popup.Menu;

                var el = menu.FindItem(Resource.Id.EdicolaItemOption_Delete);
                el.SetTitle(context.GetString(Resource.String.gen_delete));

                el = menu.FindItem(Resource.Id.EdicolaItemOption_Details);
                el.SetTitle(context.GetString(Resource.String.pub_details));

                popup.MenuItemClick += (object send, PopupMenu.MenuItemClickEventArgs ev) =>
                {
                    _ItemOptionClick(ev, position);
                };

                popup.Show();
            };

            view.ActionButton.Click -= onClick;
            view.ActionButton.Click += onClick;

            //titolo
            view.Title = doc.Titolo;

            //dettagli
            if (view.Details != null)
            {
                string autore = doc.Autore;

                if (autore == "")
                {
                    autore = context.GetString(Resource.String.pub_sconosciuto);
                }

                view.Details = autore;
            }

            //update
            SetUpdate(view, doc.ID);

            if (ActionMode)
            {
                view.ActionButton.Visibility = ViewStates.Invisible;
            }
            else
            {
                view.ActionButton.Visibility = ViewStates.Visible;
            }

            return(view);
        }