protected override RecyclerView.Adapter BuildWrappedAdapter(IMvxTemplateSelector templateSelector)
        {
            var advancedRecyclerViewAdapter = new MvxNonExpandableAdapter(BindingContext);

            RecyclerView.Adapter adapter = advancedRecyclerViewAdapter;

            var itemUniqueIdProvider =
                MvxAdvancedRecyclerViewAttributeExtensions.BuildUniqueItemIdProvider(Context, Attrs);

            advancedRecyclerViewAdapter.UniqueIdProvider     = itemUniqueIdProvider;
            advancedRecyclerViewAdapter.ItemTemplateSelector = templateSelector;

            AdvancedRecyclerViewAdapter = advancedRecyclerViewAdapter;

            bool isSwipeEnabled = MvxAdvancedRecyclerViewAttributeExtensions.IsSwipeSupported(Context, Attrs);

            if (isSwipeEnabled)
            {
                var swipeableTemplate =
                    MvxAdvancedRecyclerViewAttributeExtensions.BuildSwipeableTemplate(Context, Attrs);
                advancedRecyclerViewAdapter.SwipeableTemplate = swipeableTemplate;

                _mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
                _mRecyclerViewTouchActionGuardManager.SetInterceptVerticalScrollingWhileAnimationRunning(true);
                _mRecyclerViewTouchActionGuardManager.Enabled = true;

                _mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
                return(_mRecyclerViewSwipeManager.CreateWrappedAdapter(advancedRecyclerViewAdapter));
            }

            return(advancedRecyclerViewAdapter);
        }
Ejemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            Dialog.RequestWindowFeature((int)WindowFeatures.NoTitle);
            Dialog.SetCanceledOnTouchOutside(true);

            var vwDialog = inflater.Inflate(Resource.Layout.annotation_edittags_popup, container);

            rcAnnotationList = vwDialog.FindViewById <RecyclerView>(Resource.Id.rcAnnotationList);
            vwDialog.FindViewById <View>(Resource.Id.ivAddTag).Click += delegate
            {
                NewEditTagDialogFragment.NewInstance().Show(
                    Activity.SupportFragmentManager.BeginTransaction(),
                    NewEditTagDialogFragment.NewEditTagDialogFragmentTag);
                Dismiss();
            };

            llm             = new LinearLayoutManager(Activity);
            llm.Orientation = LinearLayoutManager.Vertical;
            llm.ScrollToPosition(0);
            rcAnnotationList.SetLayoutManager(llm);

            tagm = new RecyclerViewTouchActionGuardManager();
            tagm.SetInterceptVerticalScrollingWhileAnimationRunning(true);
            tagm.Enabled = true;

            ddm = new RecyclerViewDragDropManager();
            ddm.SetInitiateOnLongPress(true);
            ddm.SetInitiateOnMove(false);

            sm = new RecyclerViewSwipeManager();
            sm.UserHandleSwipeUi = true;

            if (editTagsListAdaptor == null)
            {
                editTagsListAdaptor = new EditTagsListAdaptor(OnEditTag, OnDeleteTag, OnSortTag);
            }

            editTagsListAdaptor.SetTagList(AnnCategoryTagUtil.Instance.GetTags());

            wrappedAdapter = ddm.CreateWrappedAdapter(editTagsListAdaptor);
            wrappedAdapter = sm.CreateWrappedAdapter(wrappedAdapter);

            ia = new SwipeDismissItemAnimator();

            rcAnnotationList.SetAdapter(wrappedAdapter);
            rcAnnotationList.SetItemAnimator(ia);

            tagm.AttachRecyclerView(rcAnnotationList);
            sm.AttachRecyclerView(rcAnnotationList);
            ddm.AttachRecyclerView(rcAnnotationList);

            return(vwDialog);
        }
        protected override RecyclerView.Adapter BuildWrappedAdapter(IMvxTemplateSelector templateSelector)
        {
            bool isGroupingSupported = MvxAdvancedRecyclerViewAttributeExtensions.IsGroupingSupported(Context, Attrs);

            if (!isGroupingSupported)
            {
                throw new InvalidOperationException($"You are using {nameof(MvxAdvancedExpandableRecyclerView)} without using grouping attributes. Check documentation.");
            }

            expandableItemManager = new RecyclerViewExpandableItemManager(expandCollapseSavedState);
            var expandableAdapter = new MvxExpandableItemAdapter(BindingContext as IMvxAndroidBindingContext);

            expandableAdapter.TemplateSelector               = templateSelector;
            expandableAdapter.GroupExpandController          = MvxAdvancedRecyclerViewAttributeExtensions.BuildGroupExpandController(Context, Attrs);
            expandableItemManager.DefaultGroupsExpandedState = expandableAdapter.GroupExpandController.AreGroupsExpandedByDefault;
            expandableAdapter.GroupExpandController.ExpandableItemManager = expandableItemManager;

            AdvancedRecyclerViewAdapter = expandableAdapter;
            var groupedDataConverter = MvxAdvancedRecyclerViewAttributeExtensions.BuildMvxGroupedDataConverter(Context, Attrs);

            expandableAdapter.ExpandableDataConverter = groupedDataConverter;
            wrappedAdapter = expandableItemManager.CreateWrappedAdapter(expandableAdapter);

            bool isSwipeForExpandableSupported = MvxAdvancedRecyclerViewAttributeExtensions.IsSwipeForExpandableSupported(Context, Attrs);

            if (isSwipeForExpandableSupported)
            {
                if (MvxAdvancedRecyclerViewAttributeExtensions.IsGroupedSwipeSupported(Context, Attrs))
                {
                    var groupedSwipeableTemplate =
                        MvxAdvancedRecyclerViewAttributeExtensions.BuildGroupSwipeableTemplate(Context, Attrs);
                    expandableAdapter.GroupSwipeableTemplate = groupedSwipeableTemplate;
                }

                if (MvxAdvancedRecyclerViewAttributeExtensions.IsGroupedChildSwipeSupported(Context, Attrs))
                {
                    var childSwipeableTemplate =
                        MvxAdvancedRecyclerViewAttributeExtensions.BuildGroupChildSwipeableTemplate(Context, Attrs);
                    expandableAdapter.ChildSwipeableTemplate = childSwipeableTemplate;
                }

                _mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
                _mRecyclerViewTouchActionGuardManager.SetInterceptVerticalScrollingWhileAnimationRunning(true);
                _mRecyclerViewTouchActionGuardManager.Enabled = true;

                _mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
                return(_mRecyclerViewSwipeManager.CreateWrappedAdapter(wrappedAdapter));
            }

            return(wrappedAdapter);
        }
Ejemplo n.º 4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var v = inflater.Inflate(Resource.Layout.organise_publications_fragment, container, false);

            rvPublicationList = v.FindViewById <RecyclerView>(Resource.Id.rvPublicationList);

            llm             = new LinearLayoutManager(Activity);
            llm.Orientation = LinearLayoutManager.Vertical;
            llm.ScrollToPosition(0);
            rvPublicationList.SetLayoutManager(llm);

            tagm = new RecyclerViewTouchActionGuardManager();
            tagm.SetInterceptVerticalScrollingWhileAnimationRunning(true);
            tagm.Enabled = true;

            ddm = new RecyclerViewDragDropManager();
            ddm.SetInitiateOnLongPress(true);
            ddm.SetInitiateOnMove(false);

            sm = new RecyclerViewSwipeManager();
            sm.UserHandleSwipeUi = true;

            if (organisePublicationsListAdaptor == null)
            {
                organisePublicationsListAdaptor = new OrganisePublicationsListAdaptor(OnDeletePub, OnSortPub);
            }

            organisePublicationsListAdaptor.SetPubList(DataCache.INSTATNCE.PublicationManager.PublicationList);

            wrappedAdapter = ddm.CreateWrappedAdapter(organisePublicationsListAdaptor);
            wrappedAdapter = sm.CreateWrappedAdapter(wrappedAdapter);

            ia = new SwipeDismissItemAnimator();

            rvPublicationList.SetAdapter(wrappedAdapter);
            rvPublicationList.SetItemAnimator(ia);

            tagm.AttachRecyclerView(rvPublicationList);
            sm.AttachRecyclerView(rvPublicationList);
            ddm.AttachRecyclerView(rvPublicationList);
            return(v);
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            StatusBarTintHelper.SetStatusBarColor(this);

            // Create your application here
            SetContentView(Resource.Layout.annotations_edittags_activity);

            llRootView = FindViewById <LinearLayout>(Resource.Id.llRootView);

            FindViewById <View>(Resource.Id.ivAddTag).Click += delegate
            {
                var intent = new Intent(this, typeof(NewTagActivity));
                StartActivity(intent);
            };

            FindViewById <LinearLayout>(Resource.Id.llStatusBarStub).LayoutParameters =
                new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, StatusBarTintHelper.GetStatusBarHeight());

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar_actionbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            Title = MainApp.ThisApp.Resources.GetString(Resource.String.AnnotationEditTagsPage_EditTags);

            //------------------------
            rcAnnotationList = FindViewById <RecyclerView>(Resource.Id.rcAnnotationList);
            var llm = new LinearLayoutManager(this);

            llm.Orientation = LinearLayoutManager.Vertical;
            llm.ScrollToPosition(0);
            rcAnnotationList.SetLayoutManager(llm);

            var tagm = new RecyclerViewTouchActionGuardManager();

            tagm.SetInterceptVerticalScrollingWhileAnimationRunning(true);
            tagm.Enabled = true;

            var ddm = new RecyclerViewDragDropManager();

            ddm.SetInitiateOnLongPress(true);
            ddm.SetInitiateOnMove(false);

            var sm = new RecyclerViewSwipeManager();

            sm.UserHandleSwipeUi = true;

            var sa = new EditTagsListAdaptor(this);

            sa.SetTagList(tagList);

            RecyclerView.Adapter wrappedAdapter = ddm.CreateWrappedAdapter(sa);
            wrappedAdapter = sm.CreateWrappedAdapter(wrappedAdapter);

            GeneralItemAnimator ia = new SwipeDismissItemAnimator();

            rcAnnotationList.SetAdapter(wrappedAdapter);
            rcAnnotationList.SetItemAnimator(ia);

            tagm.AttachRecyclerView(rcAnnotationList);
            sm.AttachRecyclerView(rcAnnotationList);
            ddm.AttachRecyclerView(rcAnnotationList);
        }