コード例 #1
0
ファイル: AccountViewHolder.cs プロジェクト: mmdmine/Unfollow
        public AccountViewHolder(View item, IAccountItemClickListener listener) : base(item)
        {
            _tvFullName    = item.FindViewById <MaterialTextView>(Resource.Id.item_account_fullname);
            _tvUserName    = item.FindViewById <MaterialTextView>(Resource.Id.item_account_username);
            _tvFollowings  = item.FindViewById <MaterialTextView>(Resource.Id.item_account_followings);
            _tvFollowers   = item.FindViewById <MaterialTextView>(Resource.Id.item_account_followers);
            _tvUnfollowers = item.FindViewById <MaterialTextView>(Resource.Id.item_account_unfollowers);

            var menu = new MenuBuilder(ItemView.Context);

            menu.SetCallback(this);

            var inflater = new SupportMenuInflater(ItemView.Context);

            inflater.Inflate(Resource.Menu.popup_account, menu);

            _popup = new MenuPopupHelper(ItemView.Context, menu);
            _popup.SetAnchorView(ItemView);
            _popup.SetForceShowIcon(true);

            _listener = listener;

            var card = item.FindViewById <MaterialCardView>(Resource.Id.item_account_card);

            if (card == null)
            {
                return;
            }
            card.Click     += Item_Click;
            card.LongClick += Item_LongClick;
        }
コード例 #2
0
        public UnfollowerViewHolder(View item, ICacheProvider cacheProvider, IUnfollowerItemClickListener listener) : base(item)
        {
            _cacheProvider = cacheProvider;
            _listener      = listener;

            _card             = item.FindViewById <MaterialCardView>(Resource.Id.item_user_card);
            _fullNameTextView = item.FindViewById <TextView>(Resource.Id.item_user_fullname);
            _userNameTextView = item.FindViewById <TextView>(Resource.Id.item_user_username);
            _avatarImageView  = item.FindViewById <ImageView>(Resource.Id.item_user_avatar);

            var menu = new MenuBuilder(ItemView.Context);

            menu.SetCallback(this);
            var inflater = new SupportMenuInflater(ItemView.Context);

            inflater.Inflate(Resource.Menu.popup_unfollower, menu);

            var optionMenuButton = item.FindViewById(Resource.Id.item_user_more);

            _popup = new MenuPopupHelper(ItemView.Context, menu);
            _popup.SetAnchorView(optionMenuButton);
            _popup.SetForceShowIcon(true);

            _card.Click            += Item_Click;
            _card.LongClick        += Item_LongClick;
            optionMenuButton.Click += More_Click;
        }
コード例 #3
0
        private void HandleSetPopupMenu(CrawlerSetViewModel item, CrawlerSetHolder holder)
        {
            var menuBuilder = new MenuBuilder(Activity);

            menuBuilder.Add(0, 0, 0, AppResources.Generic_Delete).SetIcon(Resource.Drawable.icon_delete);
            if (item.IsFavourite)
            {
                menuBuilder.Add(0, 1, 0, AppResources.Item_CrawlerSet_Unfavourite).SetIcon(Resource.Drawable.icon_star_off);
            }
            else
            {
                menuBuilder.Add(0, 2, 0, AppResources.Item_CrawlerSet_Favourite).SetIcon(Resource.Drawable.icon_star);
            }

            menuBuilder.SetCallback(new MenuCallback((sender, menuItem) =>
            {
                if (menuItem.ItemId == 0)
                {
                    ViewModel.RemoveSet(item);
                }
                else if (menuItem.ItemId == 1)
                {
                    item.IsFavourite = false;
                }
                else if (menuItem.ItemId == 2)
                {
                    item.IsFavourite = true;
                }
            }));
            var menuPopupHelper = new MenuPopupHelper(Context, menuBuilder);

            menuPopupHelper.SetAnchorView(holder.MoreButton);
            menuPopupHelper.SetForceShowIcon(true);
            menuPopupHelper.Show();
        }
コード例 #4
0
        private void HandleJumpToPopup(View obj)
        {
            var menuBuilder = new MenuBuilder(Activity);

            int i = 0;
            int j = ViewModel.ContainsAggregate ? 0 : 1;

            foreach (var tabEntry in ViewModel.FeedTabEntries)
            {
                menuBuilder.Add(0, i++, 0, tabEntry.Name).SetIcon(Util.IndexToIconResource(j++));
            }

            menuBuilder.SetCallback(new MenuCallback((sender, menuItem) =>
            {
                ViewPager.SetCurrentItem(menuItem.ItemId, true);
            }));

            var menuPopupHelper = new MenuPopupHelper(Context, menuBuilder);

            menuPopupHelper.SetAnchorView(JumpToButton);
            menuPopupHelper.SetForceShowIcon(true);
            menuPopupHelper.Show();
        }
コード例 #5
0
        private void SetupRecyclerView()
        {
            var recyclerView = FindViewById <MvxAdvancedRecyclerView>(Resource.Id.recyclerView);

            var mvxExpandableItemAdapter = recyclerView.AdvancedRecyclerViewAdapter as MvxExpandableItemAdapter;

            mvxExpandableItemAdapter.ChildItemBound += (args) =>
            {
                var playPauseView = args.ViewHolder.ItemView.FindViewById <PlayPauseView>(Resource.Id.play_pause_view);
                playPauseView.SetOnClickListener(new ActionClickListenerWrapper(x =>
                {
                    ViewModel.ItemTapped.Execute(args.DataContext);
                }));

                var overflowMenuView = args.ViewHolder.ItemView.FindViewById(Resource.Id.overflow_item);
                overflowMenuView.SetOnClickListener(new ActionClickListenerWrapper(x =>
                {
                    var overflowMenu = new PopupMenu(this, overflowMenuView);
                    overflowMenu.MenuInflater.Inflate(Resource.Menu.audio_item_menu, overflowMenu.Menu);

                    MenuPopupHelper helper = new MenuPopupHelper(this, (MenuBuilder)overflowMenu.Menu);
                    helper.SetAnchorView(overflowMenuView);
                    helper.SetForceShowIcon(true);
                    helper.Show();

                    overflowMenu.MenuItemClick += (sender, menuArgs) =>
                    {
                        overflowMenu.Dismiss();
                    };
                }));
            };

            mvxExpandableItemAdapter.ChildSwipeItemPinnedStateController.ForLeftSwipe().Pinned += (item) =>
            {
                ViewModel.PinToDelete.Execute(item);
            };
        }
コード例 #6
0
        public UnfollowerViewHolder(
            View item,
            IUnfollowerItemClickListener listener)
            : base(item)
        {
            _card        = item.FindViewById <MaterialCardView>(Resource.Id.item_unfollower_card);
            _tv_fullname = item.FindViewById <MaterialTextView>(Resource.Id.item_unfollower_fullname);
            _tv_username = item.FindViewById <MaterialTextView>(Resource.Id.item_unfollower_username);

            _menu = new MenuBuilder(ItemView.Context);
            _menu.SetCallback(this);
            var inflater = new SupportMenuInflater(ItemView.Context);

            inflater.Inflate(Resource.Menu.popup_unfollower, _menu);

            _popup = new MenuPopupHelper(ItemView.Context, _menu);
            _popup.SetAnchorView(ItemView);
            _popup.SetForceShowIcon(true);

            _listener = listener;

            _card.Click     += Item_Click;
            _card.LongClick += Item_LongClick;
        }
コード例 #7
0
        private void HandlePopupMenu(View view, FeedItemViewModel viewModel)
        {
            var menuBuilder = new MenuBuilder(Activity);

            menuBuilder.Add(0, 0, 0, AppResources.Item_Feed_AddIgnore).SetIcon(Resource.Drawable.icon_stop);

            if (!viewModel.IsWatched)
            {
                menuBuilder.Add(0, 1, 0, AppResources.Item_Feed_AddWatched).SetIcon(Resource.Drawable.icon_eye);
            }
            else
            {
                menuBuilder.Add(0, 2, 0, AppResources.Item_Feed_RemoveWatched).SetIcon(Resource.Drawable.icon_eye_off);
            }

            menuBuilder.SetCallback(new MenuCallback((sender, menuItem) =>
            {
                if (menuItem.ItemId == 0)
                {
                    viewModel.IgnoreItemCommand.Execute(null);
                }
                else if (menuItem.ItemId == 1)
                {
                    viewModel.WatchItemCommand.Execute(null);
                }
                else if (menuItem.ItemId == 2)
                {
                    viewModel.UnwatchItemCommand.Execute(null);
                }
            }));
            var menuPopupHelper = new MenuPopupHelper(Context, menuBuilder);

            menuPopupHelper.SetAnchorView(view);
            menuPopupHelper.SetForceShowIcon(true);
            menuPopupHelper.Show();
        }