Пример #1
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;
        }
Пример #2
0
        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;
        }
Пример #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 Button_Click(object sender, EventArgs e)
        {
            var          v           = sender as View;
            PopupMenu    popup       = new PopupMenu(this, v);
            MenuBuilder  menuBuilder = new MenuBuilder(this);
            MenuInflater inflater    = new MenuInflater(this);

            inflater.Inflate(Resource.Menu.PopupMenu, menuBuilder);
            MenuPopupHelper menuPopupHelper = new MenuPopupHelper(this, menuBuilder, v);

            popup.MenuItemClick += Popup_MenuItemClick;
            menuPopupHelper.SetForceShowIcon(true);

            menuPopupHelper.Show();
            menuBuilder.SetCallback(this);
        }
Пример #5
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();
        }
        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);
            };
        }
        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;
        }
Пример #8
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();
        }
        public void OnItemLongClick(int position)
        {
            if (position == 0 && workingPath.Length != 1)
            {
                return;
            }

            var item  = items[workingPath.Length == 1 ? position : (position - 1)];
            var view  = layoutManager.FindViewByPosition(position);
            var popup = new PopupMenu(Context, view);

            popup.MenuInflater.Inflate(Resource.Menu.file_actions, popup.Menu);

            if (item.IsDirectory)
            {
                popup.Menu.FindItem(Resource.Id.action_download).SetVisible(false);
            }
            if (item.IsReadOnly)
            {
                popup.Menu.FindItem(Resource.Id.action_rename).SetVisible(false);
                popup.Menu.FindItem(Resource.Id.action_move).SetVisible(false);
                popup.Menu.FindItem(Resource.Id.action_delete).SetVisible(false);
            }
            if (item.Attributes.HasFlag(FileAttributes.Device))
            {
                popup.Menu.FindItem(Resource.Id.action_rename).SetVisible(false);
                popup.Menu.FindItem(Resource.Id.action_move).SetVisible(false);
            }

            popup.MenuItemClick += (o, e) => {
                switch (e.Item.ItemId)
                {
                case Resource.Id.action_download:
                {
                    opSource = item;
                    this.StartActivityForResult(typeof(ChooseFolderActivity), CallbackDownload);
                    return;
                }

                case Resource.Id.action_move:
                {
                    opSource = item;
                    var intent        = new Intent(Context, typeof(ChooseDestinationActivity));
                    var deviceRoot    = workingPath.Substring(1);
                    var nextSeparator = deviceRoot.IndexOf(Path.AltDirectorySeparatorChar);
                    if (nextSeparator == -1)
                    {
                        deviceRoot = "/" + deviceRoot;
                    }
                    else
                    {
                        deviceRoot = "/" + deviceRoot.Substring(0, nextSeparator);
                    }
                    intent.PutExtra(ChooseDestinationActivity.ExtraRootPath, deviceRoot);
                    StartActivityForResult(intent, CallbackMove);
                    return;
                }

                case Resource.Id.action_rename:
                {
                    Activity.ShowEditorAlert(GetString(Resource.String.new_file_name), item.Name, item.Name, GetString(Resource.String.action_save), text => {
                            if (string.IsNullOrWhiteSpace(text))
                            {
                                Activity.ShowAlert(GetString(Resource.String.bad_file_name), null);
                                return;
                            }

                            if (text == item.Name)
                            {
                                return;
                            }

#pragma warning disable 0618
                            var progress = new Android.App.ProgressDialog(Context);
                            progress.SetCancelable(false);
                            progress.SetMessage(GetString(Resource.String.renaming));
                            progress.Show();
#pragma warning restore 0618
                            Task.Run(async() => {
                                try
                                {
                                    var path = Path.Combine(workingPath, item.Name);
                                    await fileSystem.RenameAsync(path, text).ConfigureAwait(false);

                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        RefreshDirectory(this, EventArgs.Empty);
                                    });
                                }
                                catch (HttpRequestException exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                                    });
                                }
                                catch (Exception exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_rename_file), exception.GetType().Name);
                                    });
                                }
                            });
                        }, GetString(Resource.String.action_cancel), null);
                    return;
                }

                case Resource.Id.action_delete:
                {
                    Activity.ShowAlert(GetString(Resource.String.delete_permanently),
                                       GetString(Resource.String.delete_all_contents, item.Name),
                                       GetString(Resource.String.action_cancel), null, GetString(Resource.String.action_delete), () => {
#pragma warning disable 0618
                            var progress = new Android.App.ProgressDialog(Context);
                            progress.SetCancelable(false);
                            progress.SetMessage(GetString(Resource.String.deleting));
                            progress.Show();
#pragma warning restore 0618

                            Task.Run(async() => {
                                try
                                {
                                    var path = Path.Combine(workingPath, item.Name);
                                    if (item.IsDirectory)
                                    {
                                        path += Path.AltDirectorySeparatorChar;
                                    }
                                    await fileSystem.DeleteAsync(path).ConfigureAwait(false);

                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        RefreshDirectory(this, EventArgs.Empty);
                                    });
                                }
                                catch (HttpRequestException exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                                    });
                                }
                                catch (Exception exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_delete_file), exception.GetType().Name);
                                    });
                                }
                            });
                        });
                    return;
                }
                }
            };

            if (popup.Menu.Size() != 0)
            {
                var helper = new MenuPopupHelper(Context, (MenuBuilder)popup.Menu, view);
                helper.SetForceShowIcon(true);
                helper.Show();
            }
        }