示例#1
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            RecyclerView.ViewHolder vh;
            LayoutInflater          inflater = LayoutInflater.From(parent.Context);

            switch (viewType)
            {
            case 0:
                View v1 = inflater.Inflate(Resource.Layout.notam_airports, parent, false);
                vh = new AirportViewHolder(v1);
                break;

            case 1:
                View v2 = inflater.Inflate(Resource.Layout.notam_cards, parent, false);
                vh = new NotamViewHolder(v2, MapClick, ShareClick);
                break;

            case 2:
                View v3 = inflater.Inflate(Resource.Layout.notam_error_card, parent, false);
                vh = new ErrorViewHolder(v3);
                break;

            case 3:
                View v4 = inflater.Inflate(Resource.Layout.notam_category_card, parent, false);
                vh = new CategoryViewHolder(v4);
                break;

            default:
                View vDef = inflater.Inflate(Resource.Layout.notam_error_card, parent, false);
                vh = new ErrorViewHolder(vDef);
                break;
            }

            return(vh);
        }
示例#2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            switch (holder.ItemViewType)
            {
            case 0:
                AirportViewHolder vh1         = (AirportViewHolder)holder;
                MyAirportRecycler airportCard = (MyAirportRecycler)mRecyclerNotamList[position];

                if (!airportCard.ShowHorizontalBar)
                {
                    vh1.AirportCardMainLayout.RemoveView(vh1.HorizontalBar);
                }

                vh1.AirportNameTextView.Text = airportCard.Name;

                break;

            case 1:
                NotamViewHolder     vh2       = (NotamViewHolder)holder;
                MyNotamCardRecycler notamCard = (MyNotamCardRecycler)mRecyclerNotamList[position];


                // Red frame in case of certain parameters (e.g.: "Runway + Close" categories
                if (notamCard.paintBorderRed)
                {
                    GradientDrawable categoryTitleBackground = new GradientDrawable();
                    categoryTitleBackground.SetCornerRadius(8);
                    categoryTitleBackground.SetColor(new ApplyTheme().GetColor(DesiredColor.CardViews));
                    categoryTitleBackground.SetStroke(3, Color.ParseColor("#d60000"));
                    vh2.NotamMainCardView.Background = categoryTitleBackground;

                    // Add extra margin to avoid notamCards leaving no margin when frame is placed
                    var cardWithFrameViewParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                                               ViewGroup.LayoutParams.WrapContent);
                    cardWithFrameViewParams.SetMargins(0, 15, 5, 0);
                    vh2.NotamMainCardView.LayoutParameters = cardWithFrameViewParams;
                }


                // TOPLAYOUT: ID, MAP, SHARE
                if (notamCard.DisableTopLayout)
                {
                    vh2.NotamCardMainLayout.RemoveView(vh2.NotamCardTopLayout);
                }
                else
                {
                    vh2.NotamIdTextView.TextFormatted  = notamCard.NotamId;
                    vh2.NotamIdTextView.MovementMethod = new LinkMovementMethod();

                    vh2.NotamShareImage.SetImageResource(Resource.Drawable.ic_share_variant_black_48dp);
                    vh2.NotamShareString       = notamCard.NotamShareString;
                    vh2.NotamSharedAirportIcao = notamCard.NotamSharedAirportIcao;

                    if (notamCard.NotamMapLatitude == 9999)
                    {
                        vh2.NotamCardMapShareLayout.RemoveView(vh2.NotamMapImageView);
                    }
                    else
                    {
                        vh2.NotamMapImageView.SetImageResource(Resource.Drawable.ic_world_map);
                        vh2.NotamMapLatitude  = notamCard.NotamMapLatitude;
                        vh2.NotamMapLongitude = notamCard.NotamMapLongitude;
                        vh2.NotamMapRadius    = notamCard.NotamMapRadius;
                    }
                }

                // SUBCATEGORIES
                if (!notamCard.DisableCategories)
                {
                    vh2.NotamMainSubcategoryTextView.Text = notamCard.NotamMainSubcategory;

                    if (!notamCard.DisableSecondarySubcategory)
                    {
                        vh2.NotamSecondarySubcategoryArrowImageView.SetImageResource(Resource.Drawable.ic_menu_right_black_48dp);
                        vh2.NotamSecondarySubcategoryTextView.Text = notamCard.NotamSecondarySubcategory;
                    }
                    else
                    {
                        vh2.NotamSecondarySubcategoryLayout.RemoveView(vh2.NotamSecondarySubcategoryTextView);
                        vh2.NotamSecondarySubcategoryLayout.RemoveView(vh2.NotamSecondarySubcategoryArrowImageView);
                        vh2.NotamSubcategoriesLayout.RemoveView(vh2.NotamSecondarySubcategoryLayout);
                    }
                }
                else
                {
                    vh2.NotamCardMainLayout.RemoveView(vh2.NotamSubcategoriesLayout);
                }

                // MAIN NOTAM TEXT
                vh2.NotamFreeTextTextView.Text = notamCard.NotamFreeText;

                // TIME FROM TO
                if (!notamCard.DisableFromToLayout)
                {
                    if (notamCard.NotamTimeIsActive)
                    {
                        vh2.NotamTimeFromToCalendarImageView.SetImageResource(Resource.Drawable.ic_calendar_multiple_red_48dp);
                    }
                    else
                    {
                        vh2.NotamTimeFromToCalendarImageView.SetImageResource(Resource.Drawable.ic_calendar_multiple_black_48dp);
                    }

                    vh2.NotamTimeFromTextView.Text = notamCard.NotamTimeFrom;

                    vh2.NotamTimeFromToArrowImageView.SetImageResource(Resource.Drawable.ic_menu_right_black_48dp);

                    vh2.NotamTimeToTextView.Text = notamCard.NotamTimeTo;
                }
                else
                {
                    vh2.NotamCardMainLayout.RemoveView(vh2.NotamFromToLayout);
                }

                // SPAN
                if (!notamCard.DisableSpanLayout)
                {
                    vh2.NotamSpanImageView.SetImageResource(Resource.Drawable.ic_clock_black_48dp);

                    vh2.NotamSpanTextView.Text = notamCard.NotamSpan;
                }
                else
                {
                    vh2.NotamCardMainLayout.RemoveView(vh2.NotamSpanLayout);
                }

                // BOTTOM TOP
                if (!notamCard.DisableBottomTopLayout)
                {
                    vh2.NotamBottomImageView.SetImageResource(Resource.Drawable.ic_format_vertical_align_bottom_black_48dp);
                    vh2.NotamBottomTextView.Text = notamCard.NotamBottom;

                    vh2.NotamTopImageView.SetImageResource(Resource.Drawable.ic_format_vertical_align_top_black_48dp);
                    vh2.NotamTopTextView.Text = notamCard.NotamTop;
                }
                else
                {
                    vh2.NotamCardMainLayout.RemoveView(vh2.NotamBottomTopLayout);
                }


                break;

            case 2:
                ErrorViewHolder vh3       = (ErrorViewHolder)holder;
                MyErrorRecycler errorCard = (MyErrorRecycler)mRecyclerNotamList[position];
                vh3.ErrorTextView.Text = errorCard.ErrorString;
                break;

            case 3:
                CategoryViewHolder vh4          = (CategoryViewHolder)holder;
                MyCategoryRecycler categoryCard = (MyCategoryRecycler)mRecyclerNotamList[position];
                vh4.CategoryTextView.Text = categoryCard.CategoryString;
                break;
            }
        }