Exemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup parent, Bundle savedInstanceState)
        {
            /* Inflate the layout for the fragment                           */
            AnnouncementsView = inflater.Inflate(
                Resource.Layout.AnnouncementsFragmentLayout, parent, false);

            /* Get the recyclerview layout                                   */
            AnnouncementRecyclerView =
                AnnouncementsView.FindViewById <RecyclerView>(
                    Resource.Id.AnnouncementsRecyclerView);

            /* Create a new layout manager using the activity containing     */
            /* this fragment as the context                                  */
            AnnouncementLayoutManager = new LinearLayoutManager(Activity);

            /* Create a custom adapter and pass it the data that it will be  */
            /* recycling through                                             */
            AnnouncementAdapter =
                new announcementsRecyclerViewAdapter(Activity as mainActivity, Announcements);

            /* Helps with performance: HasStableIds = true
             * ALTHOUGH FOR NOW, DO NOT INCLUDE THIS: DATA DOES NOT DISPLAY
             * CORRECTLY                                                     */
            //AnnouncementAdapter.HasStableIds = true;

            /* Selecting the tab will automatically scroll back to the top   */
            /* of the list                                                   */
            TabLayout = ParentFragment.View.FindViewById <TabLayout>(
                Resource.Id.MainTabLayout);
            TabLayout.TabReselected += TabReselected;

            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                AnnouncementsView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshAnnouncements);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;

            /* Setup the recyclerview with the created adapter and layout    */
            /* manager                                                       */
            AnnouncementRecyclerView.SetLayoutManager(AnnouncementLayoutManager);
            AnnouncementRecyclerView.SetAdapter(AnnouncementAdapter);


            return(AnnouncementsView);
        }
Exemplo n.º 2
0
        /*********************************************************************/
        /* On CreateView                                                     */
        /*********************************************************************/
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup container, Bundle savedInstanceState)
        {
            /* Inflate the layout for the fragment                                 */
            _gradesView = inflater.Inflate(Resource.Layout.GradesFragmentLayout,
                                           container, false);

            /* Get the parent recyclerview                                         */
            _gradesRecyclerView =
                _gradesView.FindViewById <RecyclerView>(
                    Resource.Id.GradesRecyclerView);

            _gradesAdapter =
                ViewModel.Grades.GetRecyclerAdapter(BindViewHolder,
                                                    Resource.Layout.GradesCardLayout);

            /* Setup the recyclerview with the created adapter and layout manager  */
            _gradesRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
            _gradesRecyclerView.SetAdapter(_gradesAdapter);

            /* Get the tablayout so we can scroll back up                          */
            _currentTabLayout =
                ParentFragment.View.FindViewById <TabLayout>(Resource.Id.MainTabLayout);

            _currentTabLayout.TabReselected += TabLayoutTabReselected;

            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                _gradesView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshGrades);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;

            return(_gradesView);
        }
Exemplo n.º 3
0
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup container, Bundle savedInstanceState)
        {
            // Inflate the layout for the fragment
            _eventSignUpView =
                inflater.Inflate(Resource.Layout.EventsFragmentLayout,
                                 container, false);
            /* Get the view pager                                            */
            _eventRecyclerView =
                _eventSignUpView.FindViewById <RecyclerView>(
                    Resource.Id.EventSignUpRecyclerView);

            _adapter = ViewModel.Events.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.EventCardLayout,
                OnItemClick);


            /* "Pulling" down on the page will refresh the view              */
            RefreshLayout =
                _eventSignUpView.FindViewById <SwipeRefreshLayout>(
                    Resource.Id.SwipeRefreshEvents);

            RefreshLayout.SetColorSchemeResources(Resource.Color.primary,
                                                  Resource.Color.accent, Resource.Color.primary_text,
                                                  Resource.Color.secondary_text);
            RefreshLayout.Refresh += RefreshLayoutRefresh;


            _eventRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
            _eventRecyclerView.SetAdapter(_adapter);

            _currentTabLayout = ParentFragment.View.FindViewById <TabLayout>(Resource.Id.MainTabLayout);
            _currentTabLayout.TabReselected += TabLayoutTabReselected;

            return(_eventSignUpView);
        }
Exemplo n.º 4
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);
        }