Пример #1
0
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup container, Bundle savedInstanceState)
        {
            /* Use this to return your custom view for this Fragment         */
            _examScheduleFragmentView = inflater
                                        .Inflate(Resource.Layout.ExamScheduleFragmentLayout, container, false);

            _recyclerView =
                _examScheduleFragmentView.FindViewById <RecyclerView>(
                    Resource.Id.ExamScheduleRecyclerView);

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

            Activity.RunOnUiThread(() => _adapter =
                                       ViewModel.Classes.GetRecyclerAdapter(BindViewHolder,
                                                                            Resource.Layout.ExamScheduleCardLayout));

            Activity.RunOnUiThread(() => _recyclerView.SetLayoutManager(
                                       new LinearLayoutManager(Activity)));

            Activity.RunOnUiThread(() => _recyclerView.SetAdapter(_adapter));

            return(_examScheduleFragmentView);
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            RefreshButton.SetCommand(Vm.RefreshCommand);

            // Saving the binding to avoid garbage collection
            _bindings.Add(this.SetBinding(
                              () => Vm.LastLoadedFormatted,
                              () => LastLoadedText.Text));

            _adapter = Vm.Flowers.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.FlowerTemplate,
                OnItemClick);

            FlowersList.SetLayoutManager(new LinearLayoutManager(this));
            FlowersList.SetAdapter(_adapter);

            // Subscribing to events to avoid linker issues in release mode ---------------------------------

            // This "fools" the linker into believing that the events are used.
            // In fact we don't even subscribe to them.
            // See https://developer.xamarin.com/guides/android/advanced_topics/linking/

            if (_falseFlag)
            {
                RefreshButton.Click += (s, e) => { };
            }
        }
Пример #3
0
        public void SelectMealTime(string mealTime)
        {
            switch (mealTime)
            {
            case App.MealTimes.Lunch:
            {
                Activity.RunOnUiThread(() =>
                    {
                        for (int count = 0; count < _lineCount; count++)
                        {
                            _adapter             = RecyclerviewList[count].GetAdapter() as ObservableRecyclerAdapter <GrabAndGoItem, CachingViewHolder>;
                            _adapter.DataSource  = ViewModel.GrabAndGoMenu.LunchMenu[count];
                            LineList[count].Text = ViewModel.GrabAndGoMenu.LunchMenu[count][0].MealTheme;
                            _adapter.NotifyDataSetChanged();
                        }
                    });
            }
            break;

            case App.MealTimes.Dinner:
            {
                Activity.RunOnUiThread(() =>
                    {
                        for (int count = 0; count < _lineCount; count++)
                        {
                            _adapter             = RecyclerviewList[count].GetAdapter() as ObservableRecyclerAdapter <GrabAndGoItem, CachingViewHolder>;
                            _adapter.DataSource  = ViewModel.GrabAndGoMenu.DinnerMenu[count];
                            LineList[count].Text = ViewModel.GrabAndGoMenu.DinnerMenu[count][0].MealTheme;
                            _adapter.NotifyDataSetChanged();
                        }
                    });
            }
            break;
            }
        }
Пример #4
0
        public override View OnCreateView(LayoutInflater inflater,
                                          ViewGroup container, Bundle savedInstanceState)
        {
            /* Use this to return your custom view for this Fragment         */
            _scheduleFragmentView = inflater.Inflate(Resource.Layout.ScheduleFragmentLayout,
                                                     container, false);

            _parentView = ParentFragment.View.FindViewById <Spinner>(Resource.Id.DaySpinner);

            _recyclerview = _scheduleFragmentView.FindViewById <RecyclerView>(Resource.Id.StudentScheduleRecyclerview);

            _adapter = ViewModel.Schedule[0].GetRecyclerAdapter
                       (
                BindViewHolder, Resource.Layout.StudentScheduleRecyclerViewLayout
                       );

            _title = _scheduleFragmentView.FindViewById <TextView>(Resource.Id.StudentScheduleDay);

            ParentFragment.View.FindViewById <Spinner>(Resource.Id.DaySpinner).ItemSelected += DayClicked;

            _recyclerview.SetAdapter(_adapter);

            _recyclerview.SetLayoutManager(new LinearLayoutManager(Activity));

            return(_scheduleFragmentView);
        }
 public IMultipleViewsAdapterGroupBuilder <TGroupItem, TGroupHolder> WithDataTemplate(
     ObservableRecyclerAdapter <TItem, THolder> .SpecializedDataTemplateDelegate <TGroupHolder, TGroupItem>
     template)
 {
     _dataTemplate = template;
     return(this);
 }
Пример #6
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     HomeAdapter = VM.Boilers.GetRecyclerAdapter(
         HolderDelegate,
         Resource.Layout.adapter_home,
         (oldIndex, oldView, newIndex, newView) => VM.GoToBoilersDetail(VM.Boilers[newIndex]));
 }
 void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (nameof(ViewModel.Items).Equals(e.PropertyName) && ViewModel.Items != null)
     {
         _adapter = ViewModel.Items.ToList().GetRecyclerAdapter(BindViewHolder, CreateView, null);
         _recyclerView.SetAdapter(_adapter);
     }
 }
        private void BindCollection()
        {
            adapter = Vm.Images.GetRecyclerAdapter(BindViewHolder, Resource.Layout.Tmpl_SubredditThumbnail, ItemClicked);
            SubGalleryRecyclerView.SetAdapter(adapter);
            SubGalleryRecyclerView.ClearOnScrollListeners();
			var listener = new ScrollListener(Vm.Images);
            SubGalleryRecyclerView.AddOnScrollListener(listener);
        }
        private void BindCollection()
        {
            adapter = Vm.Images.GetRecyclerAdapter(BindViewHolder, Resource.Layout.Tmpl_SubredditThumbnail, ItemClicked);
            SubGalleryRecyclerView.SetAdapter(adapter);
            SubGalleryRecyclerView.ClearOnScrollListeners();
            var listener = new ScrollListener(Vm.Images);

            SubGalleryRecyclerView.AddOnScrollListener(listener);
        }
 private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (nameof(ViewModel.Images).Equals(e.PropertyName) && ViewModel.Images != null)
     {
         _adapter             = ViewModel.Images.GetRecyclerAdapter(BindViewHolder, Resource.Layout.Item_Picture, ItemClick);
         _selectedItemBinding = this.SetBinding(() => _adapter.SelectedItem, () => ViewModel.SelectedItem, BindingMode.TwoWay);
         ImagesList.SetAdapter(_adapter);
     }
 }
Пример #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Lists);

            // Create the adapter using the default CachingViewHolder
            _adapter = Vm.Items.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.ItemTemplate,
                OnItemClick);

            MyRecycler.SetLayoutManager(new LinearLayoutManager(this));
            MyRecycler.SetAdapter(_adapter);

            _bindings.Add(
                this.SetBinding(
                    () => _adapter.SelectedItem.Name,
                    () => SelectedItemNameText.Text,
                    fallbackValue: "Nothing selected"));

            _bindings.Add(
                this.SetBinding(
                    () => Vm.ToggledItems,
                    () => ToggledItemsText.Text));

            AddButton.SetCommand(Vm.AddCommand);

            var selectedItemBinding = this.SetBinding(() => _adapter.SelectedItem);

            _bindings.Add(selectedItemBinding);
            RemoveButton.SetCommand(Vm.DeleteCommand, selectedItemBinding);

            // Subscribing to events to avoid linker issues in release mode ---------------------------------
            // This "fools" the linker into believing that the events are used.
            // In fact we don't even subscribe to them.
            // See https://developer.xamarin.com/guides/android/advanced_topics/linking/

            if (_falseFlag)
            {
                AddButton.Click += (s, e) =>
                {
                };
                RemoveButton.Click += (s, e) =>
                {
                };
            }
        }
Пример #12
0
        public Task <Measurment> ShowAsync(FragmentManager manager, Boiler boiler)
        {
            Boiler = boiler;

            Measurments.Add("");
            Measurments.Add("");
            for (int i = 0; i < Boiler.Template?.Count; i++)
            {
                Measurments.Add("");
            }

            recyclerAdapter = Measurments.GetRecyclerAdapter(BindViewHolderDelegate, Resource.Layout.adapter_control_CreateMeasurement);

            ShowNow(manager, "CreateMeasurementDialog");
            return(completionSource.Task);
        }
Пример #13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            _adapter = Vm.Places.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.PlaceTemplate,
                OnItemClick);

            _bindings.Add(this.SetBinding(
                              () => Vm.Loading,
                              () => RefreshLayout.Refreshing));

            PlacesList.SetLayoutManager(new LinearLayoutManager(this));
            PlacesList.SetAdapter(_adapter);
            RefreshLayout.SetColorSchemeColors(Color.Red, Color.Yellow, Color.Green);
            RefreshLayout.Refresh += RefreshLayoutOnRefresh;
        }
Пример #14
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);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            SetContentView(Resource.Layout.DetailsPage);
            ViewModel.LoadDataCommand.Execute(null);

            bindings.Add(this.SetBinding(
                             () => ViewModel.CityName,
                             () => TvCityName.Text,
                             BindingMode.OneWay));

            bindings.Add(this.SetBinding(
                             () => ViewModel.CurrentTemperature,
                             () => CurrentTemperature,
                             BindingMode.OneWay));

            bindings.Add(this.SetBinding(
                             () => ViewModel.TodayDayName,
                             () => TvTodayName.Text,
                             BindingMode.OneWay));



            _adapterDaily =
                ViewModel.DailyWeatherList.GetRecyclerAdapter(BindingViewHolderDaily, Resource.Layout.DailyWeatherAdapter);
            RecyclerDaily.SetLayoutManager(new LinearLayoutManager(this));
            RecyclerDaily.SetAdapter(_adapterDaily);

            _adapterHourly =
                ViewModel.HourlyWeatherList.GetRecyclerAdapter(BindingViewHolderHourly, Resource.Layout.HourlyWeatherAdapter);
            RecyclerHourly.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false));
            RecyclerHourly.SetAdapter(_adapterHourly);



            Picasso.With(this).Load(ViewModel.WeatherIconBasePath + ViewModel.CurrentWeatherIconName + ".png").Into(IvIcon);
        }
Пример #16
0
        public override void SetupBindings()
        {
            SetContentView(Resource.Layout.Weather);
            _bindings.Add(this.SetBinding(
                              () => Vm.SearchLocation,
                              () => LocationTextView.Text));
            _bindings.Add(this.SetBinding(
                              () => Vm.CurrentWeather.Description,
                              () => DescriptionTextView.Text));
            _bindings.Add(this.SetBinding(
                              () => Vm.CurrentWeather.Temp,
                              () => TempTextView.Text));

            //TODO: This needs to happen as a binding
            ImageDownloader.AssignImageAsync(IconImageView, Vm.CurrentWeather.Icon, this);

            _adapter = Vm.Forecasts.GetRecyclerAdapter(
                BindViewHolder,
                Resource.Layout.ForecastTemplate);

            ForecastList.SetLayoutManager(new LinearLayoutManager(this));
            ForecastList.SetAdapter(_adapter);
        }
Пример #17
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);
        }
Пример #18
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            template.Add(GetString(Resource.String.Temperature));
            template.Add(GetString(Resource.String.Level));
            template.AddRange(Boiler.Template ?? new List <string>());

            recyclerAdapter = template.GetRecyclerAdapter(BindViewHolder, Resource.Layout.adapter_control_CreateTemplateDialog);

            var rootView = inflater.Inflate(Resource.Layout.control_CreateTemplateDialog, container, false);

            recycler = rootView.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            recycler.SetLayoutManager(new LinearLayoutManager(Context));
            recycler.SetAdapter(recyclerAdapter);

            rootView.FindViewById <Button>(Resource.Id.SaveButton).Click += SaveButton;
            rootView.FindViewById <Button>(Resource.Id.AddButton).Click  += (s, e) =>
            {
                template.Add("");
                recyclerAdapter.NotifyItemInserted(template.Count - 1);
            };
            rootView.FindViewById <Button>(Resource.Id.CancelButton).Click += (s, e) => Dismiss();

            return(rootView);
        }
Пример #19
0
 public IAdapterBuilder WithHolderTemplate(
     ObservableRecyclerAdapter <TItem, THolder> .HolderFactoryDelegate <THolder> template)
 {
     _holderTemplate = template;
     return(this);
 }
Пример #20
0
 public IAdapterBuilder WithDataTemplate(
     ObservableRecyclerAdapter <TItem, THolder> .DataTemplateDelegate <THolder> template)
 {
     _dataTemplate = template;
     return(this);
 }
Пример #21
0
 public IAdapterBuilder WithItemTemplate(ObservableRecyclerAdapter <TItem, THolder> .ItemTemplateDelegate template)
 {
     _itemTemplate = template;
     return(this);
 }
Пример #22
0
 public IMultipleViewsAdapterGroupBuilder <TGroupItem, TGroupHolder> WithItemTemplate(
     ObservableRecyclerAdapter <TItem, THolder> .ItemTemplateDelegate template)
 {
     _itemTemplate = template;
     return(this);
 }
Пример #23
0
 public IMultipleViewsAdapterGroupBuilder <TGroupItem, TGroupHolder> WithHolderTemplate(
     ObservableRecyclerAdapter <TItem, THolder> .HolderFactoryDelegate <TGroupHolder> template)
 {
     _holderTemplate = template;
     return(this);
 }
Пример #24
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);
        }
Пример #25
0
        /*********************************************************************/
        /* Bind ViewHolder                                                   */
        /*********************************************************************/
        private void BindViewHolder(CachingViewHolder holder, GradeCard gradeCard, int position)
        {
            _position = holder.AdapterPosition;

            LinearLayout _expandArea =
                holder.FindCachedViewById <LinearLayout>(Resource.Id.llExpandArea);

            /* Handle the closing of the previous recyclerview */
            if (position == _expandedPosition)
            {
                /*DEBUG*/ //System.Diagnostics.Debug.Write("OPEN-POSITION(" + position + ")");
                /*DEBUG*/ //System.Diagnostics.Debug.Write("OPEN-VH.POSITION(" + holder.AdapterPosition + ")");
                holder.FindCachedViewById <ImageView>(Resource.Id.ShowGradesArrowIcon)
                .StartAnimation(_rotateArrow);
                _expandArea.Visibility = ViewStates.Visible;
            }
            else
            {
                /*DEBUG*/ //System.Diagnostics.Debug.Write("CLOSE-POSITION(" + position + ")");
                /*DEBUG*/ //System.Diagnostics.Debug.Write("CLOSE-VH.POSITION(" + holder.AdapterPosition + ")");
                Activity.RunOnUiThread(() => _expandArea.Visibility = ViewStates.Gone);
            }

            TextView _className =
                holder.FindCachedViewById <TextView>(Resource.Id.GradesCardClassName);

            TextView _courseGrade =
                holder.FindCachedViewById <TextView>(Resource.Id.CourseGrade);

            Button _showTeacher =
                holder.FindCachedViewById <Button>(Resource.Id.TeacherInfoButton);

            if (!_showTeacher.HasOnClickListeners)
            {
                _showTeacher.Tag    = holder;
                _showTeacher.Click += ShowTeacherInfo;
            }

            Button _showGrades =
                holder.FindCachedViewById <Button>(Resource.Id.ShowGradesButton);

            if (!_showGrades.HasOnClickListeners)
            {
                _showGrades.Tag    = holder;
                _showGrades.Click += ShowGrades;
            }

            /* Set up the child recyclerview for the assignments             */
            _assignmentsRecyclerView =
                holder.FindCachedViewById <RecyclerView>(
                    Resource.Id.AssignmentsRecyclerView);

            /* Bind to the data                                              */
            _assignmentAdapter =
                gradeCard.ClassAssignments.GetRecyclerAdapter(ChildBindViewHolder,
                                                              Resource.Layout.GradesAssignment);

            /* Set the nested recyclerview layout manager and adapter        */
            _assignmentsRecyclerView.SetLayoutManager(new LinearLayoutManager(Activity));

            _assignmentsRecyclerView.SetAdapter(_assignmentAdapter);

            /* Delete the binding for memory purposes                        */
            holder.DeleteBinding(_className);
            holder.DeleteBinding(_courseGrade);

            /* Create new binding and bind the properties to the view         */
            var _titleBinding = new Binding <string, string>(
                gradeCard,
                () => gradeCard.CourseTitle,
                _className,
                () => _className.Text,
                BindingMode.OneWay);

            var _gradeBinding = new Binding <string, string>(
                gradeCard,
                () => gradeCard.CourseGrade,
                _courseGrade,
                () => _courseGrade.Text,
                BindingMode.OneWay);

            /* Save the binding; remember to delete it later                 */
            holder.SaveBinding(_className, _titleBinding);
            holder.SaveBinding(_courseGrade, _gradeBinding);
        }
Пример #26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            _taskRecyclerView = (RecyclerView)FindViewById(Resource.Id.ToDoRecyclerView);

            _adapter = Vm.Tasks.GetRecyclerAdapter(BindViewHolder,
                                                   Resource.Layout.task_list_row, (int position1, View view1, int position2, View view2) =>
            {
                try
                {
                    Vm.NavigateCommand.Execute(Vm.Tasks[position2]);
                }
                catch (Exception e)
                {
                    throw e;
                }
            });

            //tAdapter = new TasksAdapter(tasksList);
            //tAdapter.ItemClick += OnItemClick;
            //prepareToDoListData();
            _taskRecyclerView.SetLayoutManager(new LinearLayoutManager(this));
            //recyclerView.SetLayoutManager(mLayoutManager);
            //recyclerView.AddItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.Vertical));
            //recyclerView.SetItemAnimator(new DefaultItemAnimator());

            _taskRecyclerView.SetAdapter(_adapter);


            // Illustrates how to use the Messenger by receiving a message
            // and sending a message back.
            Messenger.Default.Register <NotificationMessageAction <string> >(
                this,
                HandleNotificationMessage);


            // Binding and commanding

            // Binding between the first TextView and the WelcomeTitle property on the VM.
            // Keep track of the binding to avoid premature garbage collection
            //_bindings.Add(
            //    this.SetBinding(
            //        () => Vm.WelcomeTitle,
            //        () => WelcomeText.Text));

            //// Actuate the IncrementCommand on the VM.
            //IncrementButton.SetCommand(
            //    "Click",
            //    Vm.IncrementCommand);

            //// Create a binding that fires every time that the EditingChanged event is called
            //var dialogNavBinding = this.SetBinding(
            //        () => DialogNavText.Text);

            //// Keep track of the binding to avoid premature garbage collection
            //_bindings.Add(dialogNavBinding);

            //// Actuate the NavigateCommand on the VM.
            //// This command needs a CommandParameter of type string.
            //// This is what the dialogNavBinding provides.
            //TapText.SetCommand(
            //    "Click",
            //    Vm.NavigateCommand,
            //    dialogNavBinding);

            //// Actuate the ShowDialogCommand on the VM.
            //// This command needs a CommandParameter of type string.
            //// This is what the dialogNavBinding provides.
            //// This button will be disabled when the content of DialogNavText
            //// is empty (see ShowDialogCommand on the MainViewModel class).
            //ShowDialogButton.SetCommand(
            //    "Click",
            //    Vm.ShowDialogCommand,
            //    dialogNavBinding);

            //// Create a binding between the Clock property of the VM
            //// and the ClockText TextView.
            //// Keep track of the binding to avoid premature garbage collection
            //_bindings.Add(this.SetBinding(
            //    () => Vm.Clock,
            //    () => ClockText.Text));

            //// Actuate the SendMessageCommand on the VM.
            //SendMessageButton.SetCommand(
            //    "Click",
            //    Vm.SendMessageCommand);
        }