protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Category); var toolbar = FindViewById<Toolbar> (Resource.Id.toolbar_cat); SetSupportActionBar (toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled (true); SupportActionBar.SetHomeButtonEnabled (true); var CatName = Intent.GetStringExtra ("CatName"); App.Instance.tracker.SetScreenName ("Category Drilldown Screen - Category: " + CatName); App.Instance.tracker.Send (new HitBuilders.ScreenViewBuilder().Build()); var dashboardInfo = App.Instance.GetCacheItem<DashboardInfo> (DataCacheEnum.DASHBOARD); SupportActionBar.Title = CatName; chartView = FindViewById<ChartView> (Resource.Id.cat_chart); chartTable = FindViewById<ListView> (Resource.Id.lst_chart_table); totalText = FindViewById<TextView> (Resource.Id.txt_cat_balance_amount); changeViewBtn = FindViewById<Button> (Resource.Id.switch_chart); chartTableView = FindViewById<View> (Resource.Id.cat_list_layout); changeViewBtn.Click += (object sender, EventArgs e) => { if (!isListDisplay) { chartView.Visibility = ViewStates.Gone; chartTableView.Visibility = ViewStates.Visible; changeViewBtn.Text = "View Chart"; } else { chartTableView.Visibility = ViewStates.Gone; chartView.Visibility = ViewStates.Visible; changeViewBtn.Text = "View List"; } isListDisplay = !isListDisplay; }; //adjust the size of changeViewButton here according to the screen width changeViewBtn.LayoutParameters.Width = Resources.DisplayMetrics.WidthPixels * 2 / 7; var CatTotal = dashboardInfo.fundsInfo.funds.Where (x => x.assetCategoryDescripton == CatName).Sum (x =>x.fundBalance); totalText.Text = String.Format ("{0:C}", CatTotal); var result = dashboardInfo.fundsInfo.funds.Where (x => x.assetCategoryDescripton == CatName).Select (fc => new GenericChartInput () { Name = fc.fundName, Amount = fc.fundBalance }).ToList(); var catChartData = new List<IChartInput> (); foreach (var gi in result.OrderByDescending(x => x.Amount).ToList()) { catChartData.Add (gi); } chartData = ChartBuilder.ChartSourceBuilder (catChartData, RSColors.chartColorArray, false); chartView.updateData (chartData); chartView.NavType = ChartView.ChartNavType.Fund; adapter = new ChartListAdapter (this, chartData); chartTable.Adapter = adapter; chartTable.ItemClick += OnListItemClick; }
private void updateFields() { try{ totalHeaderText.Text = String.Format("Total Balance as of {0}", Convert.ToDateTime(dashboard.totalBalanceValDate).ToString("MM/dd/yy")); totalText.Text = String.Format ("{0:C}", dashboard.totalBalance); rateOfReturnPeriod.Text = String.Format("Rate of Return {0} - {1}", Convert.ToDateTime(dashboard.rorStartDate).ToString("MM/dd/yy"), Convert.ToDateTime(dashboard.rorEndDate).ToString("MM/dd/yy")); rateOfReturnAmount.Text = String.Format("{0:P}", dashboard.rateOfReturn); lastContribution.Text = String.Format ("Last Contrib/Payroll Amt {0}", dashboard.lastContributionDate.Trim() != "" ? Convert.ToDateTime(dashboard.lastContributionDate).ToString("MM/dd/yy") : "N/A"); lastContributionAmount.Text = String.Format ("{0:C}", dashboard.lastContributionAmount); if (dashboard.fundsInfo == null) { changeViewBtn.Visibility = ViewStates.Gone; } if(dashboard.fundsInfo.funds != null && dashboard.fundsInfo.funds.Count > 0) { var result = dashboard.fundsInfo.funds.GroupBy (x => x.assetCategoryDescripton).Select (fc => new GenericChartInput () { Name = fc.Key, Amount = fc.Sum (s => s.fundBalance) }).ToList (); var catChartData = new List<IChartInput> (); foreach (var gi in result.OrderByDescending(x => x.Amount).ToList()) { catChartData.Add (gi); } chartData = ChartBuilder.ChartSourceBuilder (catChartData, RSColors.chartColorArray, false); chartView.updateData (chartData); chartView.NavType = ChartView.ChartNavType.Category; adapter = new ChartListAdapter (Activity, chartData); table.Adapter = adapter; } if(dashboard.HasLoans) { lastContributionAmount.Click += ShowDisclaimer; lastContributionAmountMore.Click += ShowDisclaimer; lastContributionAmountMore.Visibility = ViewStates.Visible; } } catch (Exception e) { Insights.Report (e,new Dictionary <string, string> { {"Source", "Dashboard Update Fields"} }, ReportSeverity.Error); } }