public override View GetView(int position, View convertView, ViewGroup parent)
            {
                if (convertView == null)
                {
                    var layoutInflator = (LayoutInflater)webBrowserContext.GetSystemService(Service.LayoutInflaterService);
                    convertView = layoutInflator.Inflate(Resource.Layout.download_listview_single_item, parent, false);
                    VAdapterViewHolder vholder = new VAdapterViewHolder(convertView);
                    convertView.Tag = vholder;
                }
                VAdapterViewHolder vHolder = (VAdapterViewHolder)convertView.Tag;
                var data = this.data[position];

                vHolder.nameTextView.Text        = data.Name;
                vHolder.websiteNameTextView.Text = data.websiteName;



                if (data.src.thumbnil != string.Empty)
                {
                    Picasso.With(parent.Context).Load(data.src.thumbnil).Resize(128, 128).CenterInside().Into(vHolder.imageView);
                }
                else
                {
                    vHolder.imageView.SetImageResource(DefaultPic);
                }

                if (data.isFailed)
                {
                    vHolder.statueTextView.Text = "Failed";
                    vHolder.statueTextView.SetTextColor(Android.Graphics.Color.ParseColor("#C62828"));
                }
                else
                {
                    if (data.isDownloading)
                    {
                        vHolder.statueTextView.Text = "Downloading...";
                        vHolder.statueTextView.SetTextColor(Android.Graphics.Color.ParseColor("#2E7D32"));
                    }
                    else
                    {
                        if (data.isFinished)
                        {
                            vHolder.statueTextView.Text = "Finished";
                            vHolder.statueTextView.SetTextColor(Android.Graphics.Color.ParseColor("#2E7D32"));
                        }
                        else
                        {
                            vHolder.statueTextView.Text = "Waiting...";
                            vHolder.statueTextView.SetTextColor(Android.Graphics.Color.ParseColor("#0277BD"));
                        }
                    }
                }


                if (data.totalSize > 0)
                {
                    vHolder.progressBar.Indeterminate = false;
                    int progress = (int)((float)((float)data.currentSize * 100 / (float)data.totalSize));
                    vHolder.progressBar.Progress = progress;
                }
                else
                {
                    vHolder.progressBar.Indeterminate = true;
                }

                return(convertView);
            }
Exemplo n.º 2
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                if (convertView == null)
                {
                    var layoutInflator = (LayoutInflater)webBrowserContext.GetSystemService(Service.LayoutInflaterService);
                    switch (currentWebPage.Viewing)
                    {
                    case PreferedViewing.List:
                        convertView = layoutInflator.Inflate(Resource.Layout.website_browser_listview_single_row, parent, false);
                        break;

                    case PreferedViewing.Grid:
                        convertView = layoutInflator.Inflate(Resource.Layout.website_browser_gridview_single_item, parent, false);
                        break;

                    default:
                        break;
                    }

                    VAdapterViewHolder vholder = new VAdapterViewHolder(convertView);
                    convertView.Tag = vholder;
                }
                VAdapterViewHolder vHolder = (VAdapterViewHolder)convertView.Tag;
                WebPageData        data    = this.data[position];

                vHolder.mainTextView.Text = data.mainText;
                vHolder.subTextView.Text  = data.subText;

                if (vHolder.imageView != null)
                {
                    if (data.ImageUrl != string.Empty)
                    {
                        Picasso.With(parent.Context).Load(data.ImageUrl).Resize(128, 128).CenterInside().Into(vHolder.imageView);
                    }
                    else
                    {
                        vHolder.imageView.SetImageResource(DefaultPic);
                    }
                }
                else
                {
                    vHolder.comicContainerLinearLayout?.SetBackgroundColor(Android.Graphics.Color.ParseColor(data.color));
                    vHolder.comicTextView.Text = data.mainText[0].ToString() + data.mainText[1].ToString();
                    if (data.NoOfItemsIncluded != -1)
                    {
                        vHolder.noOfItemIncludedTextView.Visibility = ViewStates.Visible;
                        vHolder.noOfItemIncludedTextView.Text       = data.NoOfItemsIncluded.ToString();
                    }
                    else
                    {
                        vHolder.noOfItemIncludedTextView.Visibility = ViewStates.Gone;
                    }
                }

                //if (!data.IsFinal) vHolder.mainTextView.SetTextColor(Android.Graphics.Color.Red);
                //else vHolder.mainTextView.SetTextColor(Android.Graphics.Color.White);

                if (data.subText == string.Empty)
                {
                    vHolder.subTextView.Visibility = ViewStates.Gone;
                }
                else
                {
                    vHolder.subTextView.Visibility = ViewStates.Visible;
                }

                if (!this.parent.IsNextPageRequestSent && currentWebPage.IsMultiPaged)
                {
                    float indexReched = (float)position / this.data.Length;
                    if (indexReched >= NextPageLoadingIndex)
                    {
                        var nextPage = currentWebPage.GetNextPage();
                        if (nextPage != null)
                        {
                            analysisModule.RequestStringData(UidGenerator(), nextPage, this.parent);
                            this.parent.IsNextPageRequestSent = true;
                        }
                    }
                }


                //Android.Util.Log.Debug("UI", parent.Id == liv.Id ? "ListView" : "Grid Called ===================================");
                return(convertView);
            }