public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view;

            if (this._OrderList.Count == 0)
            {
                view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.NoPaymentTrackerItem1, null, false);
            }
            else
            {
                view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.InstalmentSummaryList, parent, false);
                var tv_Date   = view.FindViewById <TextView>(Resource.Id.tv_Date);
                var tv_Amount = view.FindViewById <TextView>(Resource.Id.tv_Amount);

                var linearLayout = view.FindViewById <LinearLayout>(Resource.Id.layout_middle);

                tv_Date.Text = _OrderList[position].PaymentDate;

                var amount = _OrderList[position].Amount;

                tv_Amount.Text = MoneyFormat.Convert(decimal.Parse(amount.ToString()));


                if (position % 2 == 0)
                {
                    linearLayout.SetBackgroundColor(Color.ParseColor("#EDEDED"));
                }
                else
                {
                    linearLayout.SetBackgroundColor(Color.ParseColor("#FFFFFF"));
                }
            }
            return(view);
        }
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            this.HasOptionsMenu = true;
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            var view = inflater.Inflate(Resource.Layout.MainContentLayout2, null);

            tv_AccountNumber      = view.FindViewById <TextView>(Resource.Id.tv_ClientAccountNumber);
            tv_AccountNumber.Text = Settings.ClientAccountNumber;

            tv_OurClient      = view.FindViewById <TextView>(Resource.Id.tv_OurClient);
            tv_OurClient.Text = Settings.OurClient;

            tv_RefNumber      = view.FindViewById <TextView>(Resource.Id.tv_RefNumber);
            tv_RefNumber.Text = Settings.RefNumber;

            tv_OutStanding      = view.FindViewById <TextView>(Resource.Id.tv_OutStanding);
            tv_OutStanding.Text = MoneyFormat.Convert(Settings.TotalOutstanding);


            tv_NextInstalment = view.FindViewById <TextView>(Resource.Id.tv_NextInstalment);

            ll_NextInstalment = view.FindViewById <LinearLayout>(Resource.Id.ll_NextInstalment_0);

            if (Settings.NextPaymentInstallment > 0)
            {
                tv_NextInstalment.Text = MoneyFormat.Convert(Settings.NextPaymentInstallment);
            }
            else
            {
                ll_NextInstalment.Visibility = ViewStates.Invisible;
            }


            ln_make_payment        = view.FindViewById <LinearLayout>(Resource.Id.ln_make_payment);
            ln_make_payment.Touch += ln_make_paymentTouch;

            ln_payment_tracker        = view.FindViewById <LinearLayout>(Resource.Id.ln_payment_tracker);
            ln_payment_tracker.Touch += Ln_payment_tracker_Touch;

            ln_installment_info        = view.FindViewById <LinearLayout>(Resource.Id.ln_instalment_info);
            ln_installment_info.Touch += Ln_installment_Info;

            ln_defer_payment        = view.FindViewById <LinearLayout>(Resource.Id.ln_defer_payment);
            ln_defer_payment.Touch += Ln_defer_payment_Touch;

            ln_schedule_callback        = view.FindViewById <LinearLayout>(Resource.Id.ln_schedule_callback);
            ln_schedule_callback.Touch += Ln_schedule_callback_Touch;

            ln_inbox        = view.FindViewById <LinearLayout>(Resource.Id.ln_inbox);
            ln_inbox.Touch += Ln_inbox_Touch;

            return(view);
        }
        private void LoadData()
        {
            AndHUD.Shared.Show(this, "Please wait ...", -1, MaskType.Clear);

            string url  = Settings.InstanceURL;
            var    url2 = url + "/Api/GetArrangeDetails";

            var json = new
            {
                Item = new
                {
                    ReferenceNumber = Settings.RefNumber
                }
            };

            try
            {
                string results = ConnectWebAPI.Request(url2, json);



                if (string.IsNullOrEmpty(results))
                {
                    AndHUD.Shared.Dismiss();
                    this.RunOnUiThread(() => alert = new Alert(this, "Error", Resources.GetString(Resource.String.NoServer)));
                    this.RunOnUiThread(() => alert.Show());
                }

                var ObjectReturn = new ArrangeDetails();


                ObjectReturn = Newtonsoft.Json.JsonConvert.DeserializeObject <ArrangeDetails>(results);

                AndHUD.Shared.Dismiss();

                if (ObjectReturn.IsSuccess)
                {
                    this.tv_Amount.Text      = MoneyFormat.Convert(ObjectReturn.ArrangeAmount);
                    this.tv_Paid.Text        = MoneyFormat.Convert(ObjectReturn.PaidAmount);
                    this.tv_Status.Text      = ObjectReturn.Status;
                    this.tv_Overdue.Text     = MoneyFormat.Convert(ObjectReturn.OverdueAmount);
                    this.tv_Frequency.Text   = ObjectReturn.Frequency;
                    this.tv_Remaining.Text   = MoneyFormat.Convert(ObjectReturn.LeftToPay);
                    this.tv_NextPayment.Text = ObjectReturn.NextInstalmentDate;

                    Settings.TotalPaid    = ObjectReturn.PaidAmount;
                    Settings.TotalOverDue = ObjectReturn.OverdueAmount;

                    pieChartView = this.createChart();
                    ln_Chart.AddView(pieChartView);
                    ln_right.AddView(this.createLegend());
                }
                else
                {
                    //Hide Top View
                    var params_Top = this.ln_top.LayoutParameters;
                    params_Top.Height            = 0;
                    this.ln_top.LayoutParameters = params_Top;
                    ln_top.Visibility            = ViewStates.Invisible;

                    //Hide Left View
                    LinearLayout.LayoutParams params_Left = new LinearLayout.LayoutParams(0, 0, 0);
                    this.ln_left.LayoutParameters = params_Left;
                    ln_left.Visibility            = ViewStates.Invisible;

                    //Add label into Middle View
                    var aLabel = new TextView(this);
                    aLabel.Text    = Resources.GetString(Resource.String.NoArrangement);
                    aLabel.Gravity = GravityFlags.Center;
                    aLabel.SetTextColor(Color.ParseColor("#006571"));
                    aLabel.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);

                    this.ln_Chart.AddView(aLabel);

                    //Add button into Left View
                    var aButton = new Button(this);
                    aButton.Text = "Make a Payment";
                    aButton.SetTextColor(Color.White);
                    aButton.SetBackgroundColor(Color.ParseColor("#006571"));
                    aButton.Click += Bt_Make_Payment_Click;

                    //Make this Left view big as parent
                    this.ln_right.AddView(aButton);
                    this.ln_right.WeightSum = 0;

                    var param_Bottom = this.ln_BottomChart.LayoutParameters;
                    param_Bottom.Height = 0;
                    this.ln_BottomChart.LayoutParameters = param_Bottom;
                }
            }
            catch (Exception ee)
            {
                AndHUD.Shared.Dismiss();
            }
        }
        //public string GetItemName(int position)
        //{
        //    return _OrderList[position].StockName;
        //}

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view;

            if (this._OrderList.Count == 0)
            {
                if (this.type == "Defer")
                {
                    view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.NoPaymentDeferItem, null, false);
                }
                else if (this.type == "Schedule")
                {
                    view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.NoPaymentTrackerItem1, null, false);
                }
                else
                {
                    view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.NoPaymentTrackerItem2, null, false);
                }
            }
            else
            {
                view = convertView ?? _activity.LayoutInflater.Inflate(Resource.Layout.PaymentTrackerList, parent, false);
                var tv_Date      = view.FindViewById <TextView>(Resource.Id.tv_Date);
                var tv_Amount    = view.FindViewById <TextView>(Resource.Id.tv_Amount);
                var iv_Status    = view.FindViewById <ImageView>(Resource.Id.iv_Status);
                var linearLayout = view.FindViewById <LinearLayout>(Resource.Id.layout_middle);


                if (this.type == "Schedule")
                {
                    tv_Date.Text = _OrderList[position].InstalmentDate;

                    var amount = _OrderList[position].InstalmentAmount;
                    tv_Amount.Text = MoneyFormat.Convert(decimal.Parse(amount));


                    var DueDate = DateTime.ParseExact(tv_Date.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);

                    if (DueDate < DateTime.Today)
                    {
                        iv_Status.SetBackgroundResource(Resource.Drawable.red);
                    }
                    else
                    {
                        iv_Status.SetBackgroundResource(Resource.Color.transparent);
                    }
                }
                else if (this.type == "History")
                {
                    tv_Date.Text = _OrderList[position].HistInstalDate;


                    var amount = _OrderList[position].HistInstalAmount;
                    tv_Amount.Text = MoneyFormat.Convert(decimal.Parse(amount));


                    //var DueDate = DateTime.ParseExact(tv_Date.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    //var PayDate = DateTime.ParseExact(tv_Date.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    var     dueAmount   = decimal.Parse(amount);
                    decimal deferAmount = 0;
                    if (!string.IsNullOrEmpty(_OrderList[position].HistDeferredAmount))
                    {
                        deferAmount = decimal.Parse(_OrderList[position].HistDeferredAmount);
                    }

                    decimal payAmount = 0;
                    if (!string.IsNullOrEmpty(_OrderList[position].HistPaymentAmount))
                    {
                        payAmount = decimal.Parse(_OrderList[position].HistPaymentAmount);
                    }

                    var payDate = _OrderList[position].HistPaymentDate;

                    if (decimal.Parse(amount) <= 0)
                    {
                        iv_Status.SetBackgroundResource(Resource.Drawable.red);
                    }
                    else if (deferAmount > 0)
                    {
                        iv_Status.SetBackgroundResource(Resource.Drawable.yellow);
                    }
                    else if (payAmount == 0 && string.IsNullOrEmpty(payDate))
                    {
                        iv_Status.SetBackgroundResource(Resource.Drawable.red);
                    }
                    else if (dueAmount < Settings.NextPaymentInstallment)
                    {
                        iv_Status.SetBackgroundResource(Resource.Drawable.red);
                    }
                    else
                    {
                        iv_Status.SetBackgroundResource(Resource.Drawable.blue);
                    }
                }
                else if (this.type == "Defer")
                {
                    tv_Date.Text = _OrderList[position].HistInstalDate;

                    var amount = _OrderList[position].HistInstalAmount;
                    tv_Amount.Text = MoneyFormat.Convert(decimal.Parse(amount));

                    iv_Status.SetBackgroundResource(Resource.Drawable.red);
                }

                if (position % 2 == 0)
                {
                    linearLayout.SetBackgroundColor(Color.ParseColor("#EDEDED"));
                }
                else
                {
                    linearLayout.SetBackgroundColor(Color.ParseColor("#FFFFFF"));
                }
            }
            return(view);
        }