private void TabReselected(object sender, TabLayout.TabReselectedEventArgs e) { if (e.Tab.Text == "Student Court") { StudentCourtView.FindViewById <NestedScrollView>(Resource.Id.StudentCourtScrollView).SmoothScrollTo(0, 0); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StudentCourtView = inflater.Inflate(Resource.Layout.StudentCourtFragmentLayout, container, false); #region NICK's REFRESH LAYOUT CODE /* "Pulling" down on the page will refresh the view */ /*RefreshLayout = * StudentCourtView.FindViewById<SwipeRefreshLayout>( * Resource.Id.SwipeRefreshStudentCourt);*/ /*RefreshLayout.SetColorSchemeResources(Resource.Color.primary, * Resource.Color.accent, Resource.Color.primary_text, * Resource.Color.secondary_text); * RefreshLayout.Refresh += RefreshLayoutRefresh;*/ #endregion RecyclerView _recyclerview = StudentCourtView.FindViewById <RecyclerView>(Resource.Id.PendingReportSlips); _adapter = ViewModel.StudentOffenseCard.Offenses.GetRecyclerAdapter ( BindViewHolder, Resource.Layout.StudentCourtInfractionCardLayout ); /* "Pulling" down on the page will refresh the view */ RefreshLayout = StudentCourtView.FindViewById <SwipeRefreshLayout>( Resource.Id.SwipeRefreshStudentCourt); RefreshLayout.SetColorSchemeResources(Resource.Color.primary, Resource.Color.accent, Resource.Color.primary_text, Resource.Color.secondary_text); RefreshLayout.Refresh += RefreshLayoutRefresh; _recyclerview.SetLayoutManager(new LinearLayoutManager(Activity)); _recyclerview.SetAdapter(_adapter); ParentFragment.View.FindViewById <TabLayout>(Resource.Id.MainTabLayout).TabReselected += TabReselected; /* Student court progress bars */ DemeritsProgBar = new ProgressBar(Activity); DormInfractionsProgBar = new ProgressBar(Activity); AbsencesProgBar = new ProgressBar(Activity); LateDormProgBar = new ProgressBar(Activity); DemeritsProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.DemeritsProgressBar); DormInfractionsProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.DormInfractionsProgressBar); AbsencesProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.AbsencesProgressBar); LateDormProgBar = StudentCourtView.FindViewById <ProgressBar>(Resource.Id.LateDormProgressBar); /* Set max value for progress bars */ DemeritsProgBar.Max = App.StudentCourt.MaxDemerits; DormInfractionsProgBar.Max = App.StudentCourt.MaxDormInfractions; AbsencesProgBar.Max = App.StudentCourt.MaxAbsences; LateDormProgBar.Max = App.StudentCourt.MaxLateDormInfraction; StudentCourtView.Post(() => SetUpProgressBars()); /*****************************************************************/ /* Create Student Court Gradient */ /*****************************************************************/ int startColor = Color.Transparent; int endColor; Color startColorAndroidGraphics; TextView statusText = StudentCourtView.FindViewById <TextView>(Resource.Id.StudentCourtStatusText); ImageView studentCourtImage = StudentCourtView.FindViewById <ImageView>(Resource.Id.StudentCourtCircle); Drawable imageBackground = studentCourtImage.Background; /* Convert dp stroke width to pixels for student court circle */ int strokeWidthDp = 4; DisplayMetrics displayMetrics = Resources.DisplayMetrics; float strokeWidth = TypedValue.ApplyDimension( ComplexUnitType.Dip, strokeWidthDp, displayMetrics); switch (ViewModel.StudentOffenseCard.StudentCourtStatus) { case App.StudentCourtStatus.Green: { startColor = ResourcesCompat.GetColor( Resources, Resource.Color.green_500, null); statusText.Text = "You are not required to attend Student Court."; } break; case App.StudentCourtStatus.Gray: { startColor = ResourcesCompat.GetColor( Resources, Resource.Color.body_text_soft_light_theme, null); statusText.Text = "You are not required to attend Student Court."; } break; case App.StudentCourtStatus.Red: { startColor = ResourcesCompat.GetColor( Resources, Resource.Color.red_a700, null); statusText.Text = "You are required to attend Student Court."; } break; } /* Set color for circle image */ startColorAndroidGraphics = new Color(startColor); GradientDrawable shapeDrawable = (GradientDrawable)imageBackground; shapeDrawable.SetStroke((int)strokeWidth, startColorAndroidGraphics); /* Set text color for student court status */ StudentCourtView.FindViewById <TextView>(Resource.Id.StudentCourtStatusText) .SetTextColor(startColorAndroidGraphics); /* Get the name of the current theme */ TypedValue attrValue = new TypedValue(); Activity.Theme.ResolveAttribute( Resource.Attribute.modThemeName, attrValue, true); /* Set the end color for gradient based on the current theme */ if (attrValue.String.ToString() == "ModAppCompatLightTheme") { endColor = ResourcesCompat.GetColor( Resources, Resource.Color.window_background, null); } else { endColor = ResourcesCompat.GetColor( Resources, Resource.Color.window_background_dark_theme, null); } int[] gradientColors = { startColor, endColor }; /* Set the gradient's start and end colors */ GradientDrawable gradient = new GradientDrawable( GradientDrawable.Orientation.TopBottom, gradientColors); StudentCourtView.FindViewById <ImageView>(Resource.Id.GradientStudentCourt) .Background = gradient; /*****************************************************************/ /* Click events for info icons */ /*****************************************************************/ StudentCourtView.FindViewById <ImageView>(Resource.Id.DormInfractionsInfoIcon).Click += ShowInfoIconDialog; StudentCourtView.FindViewById <ImageView>(Resource.Id.AbsencesInfoIcon).Click += ShowInfoIconDialog; StudentCourtView.FindViewById <ImageView>(Resource.Id.LateDormInfoIcon).Click += ShowInfoIconDialog; /* Use this to return your custom view for this Fragment */ return(StudentCourtView); }
private void SetUpProgressBars() { /* Progress bar animations */ AndroidAnimation.ObjectAnimator _demeritsProgBarAnim, _dormInfractionsProgBarAnim, _absencesProgBarAnim, _lateDormProgBarAnim; /* Set student total demerits and infractions */ TotalDemerits = 50 * App.StudentCourt.ProgBarMultiplier; TotalDormInfractions = 7 * App.StudentCourt.ProgBarMultiplier; TotalAbsences = 5 * App.StudentCourt.ProgBarMultiplier; TotalLateDorm = 6 * App.StudentCourt.ProgBarMultiplier; //HAVE TO BE BINDED TextView _demerits = StudentCourtView.FindViewById <TextView>(Resource.Id.totalDemerits); _demerits.Text = ViewModel.StudentOffenseCard.TotalDemerits; TextView _resInfractions = StudentCourtView.FindViewById <TextView>(Resource.Id.totalResidenceHallInfractions); _resInfractions.Text = ViewModel.StudentOffenseCard.TotalResidenceHallInfractions; TextView _unexcusedAbsences = StudentCourtView.FindViewById <TextView>(Resource.Id.totalAbsences); _unexcusedAbsences.Text = ViewModel.StudentOffenseCard.TotalUnexcusedAbsences; TextView _resLateInfractions = StudentCourtView.FindViewById <TextView>(Resource.Id.totalLateResidenceHallInfractions); _resLateInfractions.Text = ViewModel.StudentOffenseCard.TotalLateOutIntoInfractions; TotalDemerits = int.Parse(ViewModel.StudentOffenseCard.TotalDemerits) * App.StudentCourt.ProgBarMultiplier; TotalDormInfractions = int.Parse(ViewModel.StudentOffenseCard.TotalResidenceHallInfractions) * App.StudentCourt.ProgBarMultiplier; TotalAbsences = int.Parse(ViewModel.StudentOffenseCard.TotalUnexcusedAbsences) * App.StudentCourt.ProgBarMultiplier; TotalLateDorm = int.Parse(ViewModel.StudentOffenseCard.TotalLateOutIntoInfractions) * App.StudentCourt.ProgBarMultiplier; /* Set progress bar animations */ _demeritsProgBarAnim = AndroidAnimation.ObjectAnimator.OfInt(DemeritsProgBar, "progress", 0, TotalDemerits); _dormInfractionsProgBarAnim = AndroidAnimation.ObjectAnimator.OfInt(DormInfractionsProgBar, "progress", 0, TotalDormInfractions); _absencesProgBarAnim = AndroidAnimation.ObjectAnimator.OfInt(AbsencesProgBar, "progress", 0, TotalAbsences); _lateDormProgBarAnim = AndroidAnimation.ObjectAnimator.OfInt(LateDormProgBar, "progress", 0, TotalLateDorm); /* Set animation interpolaters */ _demeritsProgBarAnim.SetInterpolator(new DecelerateInterpolator()); _dormInfractionsProgBarAnim.SetInterpolator(new DecelerateInterpolator()); _absencesProgBarAnim.SetInterpolator(new DecelerateInterpolator()); _lateDormProgBarAnim.SetInterpolator(new DecelerateInterpolator()); /* Set animation durations */ _demeritsProgBarAnim.SetDuration(600); _dormInfractionsProgBarAnim.SetDuration(600); _absencesProgBarAnim.SetDuration(600); _lateDormProgBarAnim.SetDuration(600); /* Start animation */ _demeritsProgBarAnim.Start(); _dormInfractionsProgBarAnim.Start(); _absencesProgBarAnim.Start(); _lateDormProgBarAnim.Start(); }