private void CleanUpCenteredGridView()
 {
     if (numericIndexView != null)
     {
         numericIndexView.ItemClick -= libraryView_ItemClick;
         if (numericIndexView.Adapter != null)
         {
             numericIndexView.Adapter.Dispose();
         }
         numericIndexView.Dispose();
         numericIndexView = null;
     }
 }
        private void SetNativeView()
        {
            var inflater = LayoutInflater.From(Forms.Context);

            if (!Element.IsNumber)
            {
                CleanUpLibraryGridView();

                containerView        = inflater.Inflate(Resource.Layout.LibraryFragment, null);
                libraryView          = containerView.FindViewById <LibraryGridView>(Resource.Id.primaryLibraryGridView);
                bibleBookNameAdapter = new BibleBookNameAdapter(Context as Activity, (Element.ItemsSource as ObservableCollection <BibleBook>).ToList());

                if (Element.Animate)
                {
                    GridLayoutAnimationController controller = (GridLayoutAnimationController)AnimationUtils.LoadLayoutAnimation(Context, Resource.Animation.grid_layout_animation_from_bottom);
                    libraryView.LayoutAnimation = controller;
                }

                libraryView.Adapter    = bibleBookNameAdapter;
                libraryView.ItemClick += libraryView_ItemClick;
            }
            else
            {
                CleanUpCenteredGridView();

                containerView               = inflater.Inflate(Resource.Layout.NumbersFragment, null);
                numericIndexView            = containerView.FindViewById <CenteredGridView>(Resource.Id.primaryCenteredGridView);
                numericIndexView.Visibility = ViewStates.Invisible;
                numericIndexView.VerticalScrollBarEnabled = false;

                if (Element.NumberOfElements > 0)
                {
                    numericIndexAdapter = new NumericIndexGridAdapter(Context as Activity, (int)Element.NumberOfElements);
                }
                else
                {
                    numericIndexAdapter = new NumericIndexGridAdapter(Context as Activity, Element.ItemsSource.Cast <object>().Count());
                }

                //AnimationSet set = new AnimationSet(true);

                //Android.Views.Animations.Animation animation = new AlphaAnimation(0.0f, 1.0f)
                //{
                //    Duration = 500
                //};
                //set.AddAnimation(animation);

                //animation = new TranslateAnimation(Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, -1.0f, Dimension.RelativeToSelf, 0.0f)
                //{
                //    Duration = 500
                //};
                //set.AddAnimation(animation);

                //GridLayoutAnimationController controller = new GridLayoutAnimationController(set, 0.5f, 0.5f);

                //numericIndexView.LayoutAnimation = controller;

                if (Element.Animate)
                {
                    GridLayoutAnimationController controller = (GridLayoutAnimationController)AnimationUtils.LoadLayoutAnimation(Context, Resource.Animation.grid_layout_animation_from_bottom);
                    numericIndexView.LayoutAnimation = controller;
                }

                numericIndexView.Adapter    = numericIndexAdapter;
                numericIndexView.ItemClick += libraryView_ItemClick;
            }

            SetNativeControl(containerView);
        }
Пример #3
0
 public CenteredGridViewListener(CenteredGridView paramCenteredGridView)
 {
     this.paramCenteredGridView = paramCenteredGridView;
 }