示例#1
0
 private static void CleanupVideosDialog()
 {
     _videosDialogBindings.ForEach(binding => binding.Detach());
     _videosDialogBindings = new List <Binding>();
     _videosDialog?.Dismiss();
     _videosDialog = null;
 }
示例#2
0
        public static void BuildChangelogDialog(IChangeLogProvider changeLogProvider)
        {
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetGravity((int)(GravityFlags.Top));
            dialogBuilder.SetMargin(DimensionsHelper.DpToPx(40), DimensionsHelper.DpToPx(75), DimensionsHelper.DpToPx(2), 0);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.ChangelogDialog));
            dialogBuilder.SetContentBackgroundResource(Resource.Color.Transparent);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupChangelogDialog));
            _changelogDialog = dialogBuilder.Create();
            var dialogView = _changelogDialog.HolderView;

            dialogView.FindViewById <TextView>(Resource.Id.ChangelogDialogHeader).Text = changeLogProvider.DateWithVersion;
            dialogView.FindViewById(Resource.Id.ChangelogDialogCloseButton).SetOnClickListener(new OnClickListener(view => _changelogDialog.Dismiss()));
            dialogView.FindViewById <LinearLayout>(Resource.Id.ChangelogDialogChangesList).SetAdapter(changeLogProvider.Changelog.GetAdapter(
                                                                                                          (i, s, arg3) =>
            {
                var view = new TextView(MainActivity.CurrentContext);
                view.SetTextColor(new Color(ResourceExtension.BrushText));
                view.Text = $"• {s}";
                return(view);
            }));

            _changelogDialog.Show();
        }
示例#3
0
        public void ShowDialog(Context context, string link)
        {
            var animeLink = AnimeImageExtensions.GetImgUrl(link);

            if (animeLink == null || link == "https://myanimelist.cdn-dena.com/images/anime//0.jpg")
            {
                ResourceLocator.SnackbarProvider.ShowText("Failed obatining image.");
                return;
            }
            var dialogBuilder = DialogPlus.NewDialog(context);

            dialogBuilder.SetGravity((int)GravityFlags.Center);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeDetailsKeyImageDialog));
            dialogBuilder.SetContentBackgroundResource(global::Android.Resource.Color.Transparent);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));

            _dialog = dialogBuilder.Create();

            var dialogView = _dialog.HolderView;


            dialogView.FindViewById <ImageViewAsync>(Resource.Id.Image).Into(animeLink, null,
                                                                             async =>
            {
                var zoomable      = async as ZoomableImageView;
                zoomable.bmHeight = (async.Drawable as SelfDisposingBitmapDrawable).Bitmap.Height;
                zoomable.bmWidth  = (async.Drawable as SelfDisposingBitmapDrawable).Bitmap.Width;
            });
            dialogView.FindViewById(Resource.Id.SaveButton).SetOnClickListener(
                new OnClickListener(view => ViewModelLocator.AnimeDetails.SaveImageCommand.Execute(null)));

            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(() => _dialog.Dismiss()));
            _dialog.Show();
        }
        private void ShowNoHeaderDialog(IHolder holder, GravityFlags gravity, BaseAdapter adapter,
                                        OnClickListener clickListener, OnItemClickListener itemClickListener,
                                        OnDismissListener dismissListener, OnCancelListener cancelListener,
                                        bool expanded)
        {
            DialogPlus dialog = DialogPlus.NewDialog(this)
                                .SetContentHolder(holder)
                                .SetFooter(Resource.Layout.footer)
                                .SetCancelable(true)
                                .SetGravity((int)gravity)
                                .SetAdapter(adapter)
                                .SetOnClickListener(clickListener)
                                .SetOnItemClickListener(new OnItemClickListener()
            {
                ItemClick = (p0, p1, p2, p3) =>
                {
                    Toast.MakeText(this, "DialogPlus: " + " onItemClick() called with: " + "item = [" +
                                   p1 + "], position = [" + p3 + "]", ToastLength.Short).Show();
                }
            })
                                .SetOnDismissListener(dismissListener)
                                .SetOnCancelListener(cancelListener)
                                .SetExpanded(expanded)
                                .Create();

            dialog.Show();
        }
示例#5
0
        public void ShowDialog(Context context, ProfileData data, ProfilePageGeneralTabFragment parent)
        {
            var dialogBuilder = DialogPlus.NewDialog(context);

            dialogBuilder.SetGravity((int)GravityFlags.Center);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.FriendRequestDialog));
            dialogBuilder.SetContentBackgroundResource(global::Android.Resource.Color.Transparent);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));

            _dialog = dialogBuilder.Create();

            var dialogView = _dialog.HolderView;

            dialogView.FindViewById <ImageViewAsync>(Resource.Id.Image).Into(data.User.ImgUrl, new CircleTransformation());

            dialogView.FindViewById(Resource.Id.SubmitButton).SetOnClickListener(new OnClickListener(view =>
            {
                ViewModelLocator.ProfilePage.SendFriendRequestCommand.Execute(dialogView
                                                                              .FindViewById <EditText>(Resource.Id.TextBox).Text);
                _dialog.Dismiss();
                parent.ProfilePageGeneralTabSendRequestButton.Visibility = ViewStates.Gone;
            }));
            _dialog.Show();
        }
示例#6
0
 private static void CleanupTagsDialog()
 {
     ViewModelLocator.NavMgr.ResetOneTimeMainOverride();
     _tagsDialogBindings.ForEach(binding => binding.Detach());
     _tagsDialog?.Dismiss();
     _scoreDialog = null;
 }
        private void ShowCompleteDialog(IHolder holder, GravityFlags gravity, BaseAdapter adapter,
                                        IOnClickListener clickListener, OnItemClickListener itemClickListener,
                                        OnDismissListener dismissListener, OnCancelListener cancelListener,
                                        bool expanded)
        {
            DialogPlus dialog = DialogPlus.NewDialog(this)
                                .SetContentHolder(holder)
                                .SetHeader(Resource.Layout.header)
                                .SetFooter(Resource.Layout.footer)
                                .SetCancelable(true)
                                .SetGravity((int)gravity)
                                .SetAdapter(adapter)
                                .SetOnClickListener(clickListener)
                                .SetOnItemClickListener(new OnItemClickListener()
            {
                ItemClick = (p0, p1, p2, p3) =>
                {
                    Toast.MakeText(this, "DialogPlus: " + " onItemClick() called with: " + "item = [" +
                                   p1 + "], position = [" + p3 + "]", ToastLength.Short).Show();
                }
            })
                                .SetOnDismissListener(dismissListener)
                                .SetExpanded(expanded)
                                //.SetContentWidth(800)
                                .SetContentHeight(ViewGroup.LayoutParams.WrapContent)
                                .SetOnCancelListener(cancelListener)
                                .SetOverlayBackgroundResource(Android.Resource.Color.Transparent)
                                //.SetContentBackgroundResource(R.drawable.corner_background)
                                //.SetOutMostMargin(0, 100, 0, 0)
                                .Create();

            dialog.Show();
        }
示例#8
0
        public static void BuildStatusDialog(IAnimeData model, bool anime, Action <AnimeStatus> action = null)
        {
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetAdapter(new StatusDialogAdapter(MainActivity.CurrentContext,
                                                             !anime, model.IsRewatching, model.MyStatus));
            dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
            dialogBuilder.SetOnItemClickListener(new EnumDialogListener <AnimeStatus>
            {
                OnItemClickAction = (d, status) =>
                {
                    if (action == null)
                    {
                        model.MyStatus = status;
                    }
                    else
                    {
                        action.Invoke(status);
                    }
                    CleanupStatusDialog();
                }
            });
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupStatusDialog));
            _statusDialog = dialogBuilder.Create();
            _statusDialog.Show();
        }
示例#9
0
        public static void BuildScoreDialog(IAnimeData model, Action <float> action = null)
        {
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetAdapter(new ScoreDialogAdapter(MainActivity.CurrentContext,
                                                            AnimeItemViewModel.ScoreFlyoutChoices, model.MyScore));
            dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
            dialogBuilder.SetOnItemClickListener(new IntegerDialogListener()
            {
                OnItemClickAction = (d, score) =>
                {
                    if (action == null)
                    {
                        model.MyScore = score;
                    }
                    else
                    {
                        action.Invoke(score);
                    }
                    CleanupScoreDialog();
                }
            });
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupScoreDialog));
            _scoreDialog = dialogBuilder.Create();
            _scoreDialog.Show();
        }
示例#10
0
        public static void BuildTagDialog(AnimeDetailsPageViewModel viewModel)
        {
            _tagsDialogBindings = new List <Binding>();
            _tagsDialogContext  = viewModel;
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeTagsDialog));
            dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
            dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupTagsDialog));
            dialogBuilder.SetGravity((int)GravityFlags.Top);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupTagsDialog));
            _tagsDialog = dialogBuilder.Create();
            var view = _tagsDialog.HolderView;

            view.FindViewById <ListView>(Resource.Id.AnimeTagsDialogList).Adapter =
                viewModel.MyTags.GetAdapter(GetTagItem);
            var editBox = view.FindViewById <EditText>(Resource.Id.AnimeTagsDialogEditBox);

            _tagsDialogBindings.Add(new Binding <string, string>(
                                        viewModel,
                                        () => viewModel.NewTagInput,
                                        editBox,
                                        () => editBox.Text, BindingMode.TwoWay));

            view.FindViewById <ImageButton>(Resource.Id.AnimeTagsDialogAddTagButton).SetCommand("Click", viewModel.AddTagCommand);

            _tagsDialog.Show();
        }
示例#11
0
 private static void CleanupTagsDialog()
 {
     AndroidUtilities.HideKeyboard();
     _tagsDialogBindings?.ForEach(binding => binding.Detach());
     _tagsDialog?.Dismiss();
     _scoreDialog = null;
     MainActivity.CurrentContext.DialogToCollapseOnBack = null;
 }
 private static void CleanupVideosDialog()
 {
     ViewModelLocator.NavMgr.ResetOneTimeMainOverride();
     _videosDialogBindings.ForEach(binding => binding.Detach());
     _videosDialogBindings = new List <Binding>();
     _videosDialog?.Dismiss();
     _videosDialog = null;
 }
        public static async Task <string> BuildForumPostTextInputDialog(Context context, ForumPostTextInputContext displayContext, string content)
        {
            var dialogBuilder = DialogPlus.NewDialog(context);

            dialogBuilder.SetGravity((int)GravityFlags.Center);
            var margin = DimensionsHelper.DpToPx(10);

            dialogBuilder.SetMargin(margin, DimensionsHelper.DpToPx(30), margin, margin);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.ForumPostTextDialog));
            dialogBuilder.SetContentBackgroundResource(Resource.Color.Transparent);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(() => CleanupForumPostTextInputDialog(false)));
            _forumTextInputDialog = dialogBuilder.Create();
            var dialogView = _forumTextInputDialog.HolderView;

            var acceptButton = dialogView.FindViewById <Button>(Resource.Id.ForumPostTextDialogAcceptButton);

            switch (displayContext)
            {
            case ForumPostTextInputContext.Reply:
                dialogView.FindViewById <TextView>(Resource.Id.ForumPostTextDialogTitle).Text = "New Reply";
                acceptButton.SetCompoundDrawablesWithIntrinsicBounds(context.Resources.GetDrawable(Resource.Drawable.icon_send, context.Theme), null, null, null);
                acceptButton.Text = "Send";
                break;

            case ForumPostTextInputContext.Edit:
                dialogView.FindViewById <TextView>(Resource.Id.ForumPostTextDialogTitle).Text = "Edit Message";
                acceptButton.Text = "Edit";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(displayContext), displayContext, null);
            }
            acceptButton.SetOnClickListener(new OnClickListener(view => CleanupForumPostTextInputDialog(true)));

            var textEditor = new BBCodeEditor(context);

            textEditor.TextChanged += OnTextChanged;
            textEditor.Text         = content;

            dialogView.FindViewById <LinearLayout>(Resource.Id.ForumPostTextDialogInputSection).AddView(textEditor, 0);

            dialogView.FindViewById <WebView>(Resource.Id.ForumPostTextDialogPreview).SetBackgroundColor(Color.Transparent);

            _forumTextInputDialog.Show();

            await _semaphoreForumTextInput.WaitAsync();

            if (_success)
            {
                _success = false;
                return(textEditor.Text);
            }
            _success = false;
            return(null);
        }
示例#14
0
 private static void CleanupWatchedDialog()
 {
     ViewModelLocator.NavMgr.ResetOneTimeMainOverride();
     _watchedDialogBindings.ForEach(binding => binding.Detach());
     _watchedDialogBindings = new List <Binding>();
     _watchedDialog?.Dismiss();
     _watchedDialog        = null;
     _watchedDialogContext = null;
     _watchedDialogAction  = null;
 }
示例#15
0
        public static void BuildWatchedDialog(AnimeItemViewModel ViewModel, Action <AnimeItemViewModel, string> action = null, bool volumes = false)
        {
            _watchedDialogContext = ViewModel;
            _watchedDialogAction  = action;
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeItemWatchedDialog));
            dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
            dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupWatchedDialog));
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupWatchedDialog));
            _watchedDialog = dialogBuilder.Create();
            var view = _watchedDialog.HolderView;


            view.FindViewById <ImageButton>(Resource.Id.AnimeItemWatchedDialogAcceptButton)
            .SetCommand("Click", new RelayCommand(
                            () =>
            {
                if (!volumes)
                {
                    ViewModel.OnFlyoutEpsKeyDown.Execute(null);
                }
                else
                {
                    action.Invoke(_watchedDialogContext, _watchedDialog.HolderView.FindViewById <TextView>(
                                      Resource.Id.AnimeItemWatchedDialogTextInput).Text);
                }
                CleanupWatchedDialog();
            }));

            var grid = view.FindViewById <GridView>(Resource.Id.AnimeItemWatchedDialogEpisodesGridView);

            if (volumes)
            {
                grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, ViewModel.MyVolumes,
                                                        ViewModel.AllVolumes);
                view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text = "Read volumes";
            }
            else
            {
                var input = view.FindViewById <EditText>(Resource.Id.AnimeItemWatchedDialogTextInput);
                _watchedDialogBindings.Add(new Binding <string, string>(ViewModel, () => ViewModel.WatchedEpsInput, input,
                                                                        () => input.Text, BindingMode.TwoWay));
                grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, ViewModel.MyEpisodesFocused,
                                                        ViewModel.AllEpisodesFocused);
                view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text =
                    ViewModel.WatchedEpsLabel;
            }

            grid.ItemClick += GridOnItemClick;
            _watchedDialog.Show();
        }
        public static void BuildPromotionalVideoDialog(AnimeDetailsPageViewModel viewModel)
        {
            viewModel.LoadVideosCommand.Execute(null);
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetGravity((int)GravityFlags.Center);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeDetailsPageVideosDialog));
            dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupVideosDialog));
            _videosDialog = dialogBuilder.Create();
            var dialogView = _videosDialog.HolderView;

            var spinner = dialogView.FindViewById(Resource.Id.AnimeDetailsPageVideosDialogProgressBar);

            _videosDialogBindings = new List <Binding>
            {
                new Binding <bool, ViewStates>(
                    viewModel,
                    () => viewModel.LoadingVideosVisibility,
                    spinner,
                    () => spinner.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility)
            };

            dialogView.FindViewById <ListView>(Resource.Id.AnimeDetailsPageVideosDialogList).Adapter = viewModel
                                                                                                       .AvailableVideos.GetAdapter(
                (i, data, convertView) =>
            {
                var view = convertView;
                if (view == null)
                {
                    view =
                        MainActivity.CurrentContext.LayoutInflater.Inflate(
                            Resource.Layout.AnimeDetailsPageVideosDialogItem, null);
                    view.SetOnClickListener(new OnClickListener(VideoItemOnClick));
                }

                ImageService.Instance.LoadUrl(data.Thumb)
                .FadeAnimation(false)
                .Success(view.FindViewById(Resource.Id.AnimeDetailsPageVideosDialogItemImage).AnimateFadeIn)
                .Into(view.FindViewById <ImageViewAsync>(Resource.Id.AnimeDetailsPageVideosDialogItemImage));

                view.FindViewById <TextView>(Resource.Id.AnimeDetailsPageVideosDialogItemText).Text = data.Name;

                view.Tag = data.Wrap();

                return(view);
            });

            _videosDialog.Show();
        }
 private static void CleanupForumPostTextInputDialog(bool success)
 {
     if (_forumTextInputDialog == null)
     {
         return;
     }
     AndroidUtilities.HideKeyboard();
     _success = success;
     _semaphoreForumTextInput.Release();
     _forumTextInputDialog.Dismiss();
     _forumTextInputDialog.Dispose();
     _forumTextInputDialog = null;
 }
 private static void CleanupTextInputDialog(bool success)
 {
     if (_textInputDialog == null)
     {
         return;
     }
     _success = success;
     AndroidUtilities.HideKeyboard();
     ViewModelLocator.NavMgr.ResetOneTimeOverride();
     _semaphoreTextInput.Release();
     _textInputDialog.Dismiss();
     _textInputDialog.Dispose();
     _textInputDialog = null;
 }
示例#19
0
 private static void CleanupWatchedDialog()
 {
     if (_watchedDialog != null)
     {
         AndroidUtilities.HideKeyboard();
         _watchedDialog.Dismiss();
     }
     _watchedDialogBindings.ForEach(binding => binding.Detach());
     _watchedDialogBindings = new List <Binding>();
     _watchedDialog         = null;
     _watchedDialogContext  = null;
     _watchedDialogAction   = null;
     MainActivity.CurrentContext.DialogToCollapseOnBack = null;
 }
        public static void BuildWatchedDialog(AnimeItemViewModel ViewModel,Action<AnimeItemViewModel, string> action = null,bool volumes = false)
        {
            _watchedDialogContext = ViewModel;
            _watchedDialogAction = action;
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeItemWatchedDialog));
            dialogBuilder.SetContentBackgroundResource(Resource.Color.BrushFlyoutBackground);
            dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupWatchedDialog));
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupWatchedDialog));
            _watchedDialog = dialogBuilder.Create();
            var view = _watchedDialog.HolderView;


            view.FindViewById<ImageButton>(Resource.Id.AnimeItemWatchedDialogAcceptButton)
                .SetCommand("Click", new RelayCommand(
                    () =>
                    {
                        if (!volumes)
                            ViewModel.OnFlyoutEpsKeyDown.Execute(null);
                        else
                            action.Invoke(_watchedDialogContext, _watchedDialog.HolderView.FindViewById<TextView>(
                                Resource.Id.AnimeItemWatchedDialogTextInput).Text);
                        CleanupWatchedDialog();
                    }));

            var grid = view.FindViewById<GridView>(Resource.Id.AnimeItemWatchedDialogEpisodesGridView);
            if (volumes)
            {

                grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, ViewModel.MyVolumes,
                    ViewModel.AllVolumes);
                view.FindViewById<TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text = "Read volumes";
            }
            else
            {
                var input = view.FindViewById<EditText>(Resource.Id.AnimeItemWatchedDialogTextInput);
                _watchedDialogBindings.Add(new Binding<string, string>(ViewModel, () => ViewModel.WatchedEpsInput, input,
                    () => input.Text, BindingMode.TwoWay));
                grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, ViewModel.MyEpisodesFocused,
                    ViewModel.AllEpisodesFocused);
                view.FindViewById<TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text =
                    ViewModel.WatchedEpsLabel;
            }

            grid.ItemClick += GridOnItemClick;
            _watchedDialog.Show();
        }
示例#21
0
        public static void BuildTagDialog(AnimeDetailsPageViewModel viewModel)
        {
            _tagsDialogBindings = new List <Binding>();
            _tagsDialogContext  = viewModel;
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeTagsDialog));
            dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupTagsDialog));
            dialogBuilder.SetOnBackPressListener(new OnBackPressListener(CleanupTagsDialog));
            dialogBuilder.SetGravity((int)GravityFlags.Top);
            _tagsDialog = dialogBuilder.Create();
            var view = _tagsDialog.HolderView;

            var list = view.FindViewById <ListView>(Resource.Id.AnimeTagsDialogList);

            list.EmptyView = view.FindViewById(Resource.Id.AnimeTagsDialogEmptyNotice);
            list.Adapter   = viewModel.MyTags.GetAdapter(GetTagItem);
            var editBox = view.FindViewById <AutoCompleteTextView>(Resource.Id.AnimeTagsDialogEditBox);

            editBox.Threshold = 1;
            editBox.Adapter   = new ArrayAdapter <string>(MainActivity.CurrentContext, global::Android.Resource.Layout.SelectDialogItem, ViewModelLocator.GeneralMain.SearchHints);
            //editBox.SetOnEditorActionListener(new OnEditorActionListener(action =>
            //{
            //    if(action == ImeAction.Done)
            //        viewModel.AddTagCommand.Execute(null);
            //}));
            editBox.AddTextChangedListener(new OnTextEnterListener(() =>
            {
                viewModel.AddTagCommand.Execute(null);
            }));

            _tagsDialogBindings.Add(new Binding <string, string>(
                                        viewModel,
                                        () => viewModel.NewTagInput,
                                        editBox,
                                        () => editBox.Text, BindingMode.TwoWay));

            view.FindViewById <ImageButton>(Resource.Id.AnimeTagsDialogAddTagButton).SetOnClickListener(new OnClickListener(
                                                                                                            v =>
            {
                viewModel.AddTagCommand.Execute(null);
            }));

            _tagsDialog.Show();
            MainActivity.CurrentContext.DialogToCollapseOnBack = _tagsDialog;
        }
        public static async Task <string> BuildInputTextDialog(Context context, string title, string hint, string accept,
                                                               bool afterFlyout = false)
        {
            var dialogBuilder = DialogPlus.NewDialog(context);

            dialogBuilder.SetGravity((int)(GravityFlags.Center));
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.TextInputDialog));
            dialogBuilder.SetContentBackgroundResource(Resource.Color.Transparent);
            dialogBuilder.SetOnDismissListener(new DialogDismissedListener(() => CleanupTextInputDialog(false)));
            if (afterFlyout)
            {
                (ViewModelLocator.NavMgr as NavMgr).EnqueueOneTimeOverride(
                    new RelayCommand(() => CleanupTextInputDialog(false)));
            }
            else
            {
                ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(
                    new RelayCommand(() => CleanupTextInputDialog(false)));
            }

            _textInputDialog = dialogBuilder.Create();
            var dialogView = _textInputDialog.HolderView;

            dialogView.FindViewById <TextView>(Resource.Id.TextInputDialogTitle).Text = title;
            var textBox = dialogView.FindViewById <EditText>(Resource.Id.TextInputDialogTextBox);

            textBox.Hint = hint;
            textBox.AddTextChangedListener(new OnTextEnterListener(() => CleanupTextInputDialog(true)));

            dialogView.FindViewById <Button>(Resource.Id.TextInputDialogAcceptButton).Text = accept;
            dialogView.FindViewById(Resource.Id.TextInputDialogAcceptButton)
            .SetOnClickListener(new OnClickListener(view => CleanupTextInputDialog(true)));
            _textInputDialog.Show();

            await _semaphoreTextInput.WaitAsync();


            if (_success)
            {
                _success = false;
                return(textBox.Text.Trim());
            }
            _success = false;
            return(null);
        }
示例#23
0
        public void ShowDialog(Context context, View rootView, string html)
        {
            var dialogBuilder = DialogPlus.NewDialog(context);

            dialogBuilder.SetGravity((int)GravityFlags.Center);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.ProfileDescriptionDialog));
            dialogBuilder.SetContentBackgroundResource(global::Android.Resource.Color.Transparent);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));

            dialogBuilder.SetMargin(0, 0, 0, 0);
            _dialog = dialogBuilder.Create();

            var dialogView = _dialog.HolderView;

            dialogView.LayoutParameters.Height = rootView.Height - DimensionsHelper.DpToPx(16 * 2);
            dialogView.SetMargins(0, 16, 0, 0);
            var webView = dialogView.FindViewById <WebView>(Resource.Id.WebView);
            var client  = new ListenableWebClient {
                NavigationInterceptOpportunity = NavigationInterceptOpportunity
            };

            webView.Settings.JavaScriptEnabled = true;
            webView.Settings.SetSupportZoom(true);
            webView.Settings.DisplayZoomControls = false;
            webView.SetWebViewClient(client);
            webView.Settings.BuiltInZoomControls = true;
            webView.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
            webView.SetBackgroundColor(new Color(ResourceExtension.BrushAnimeItemInnerBackground));

            webView.Post(() =>
            {
                var scale = (100 - 735 * 100 / (dialogView.Width == 0 ? 300 : dialogView.Width)) + 100;
                webView.SetInitialScale(scale);
                //WebView.SetPadding(DimensionsHelper.DpToPx(15),0,0,0);
            });

            webView.LoadDataWithBaseURL(null,
                                        ResourceLocator.CssManager.WrapWithCss(html, false, 800),
                                        "text/html; charset=utf-8", "UTF-8", null);
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(() => _dialog.Dismiss()));
            _dialog.Show();
        }
示例#24
0
        private static void CleanupGoPageDialog(DialogResult success)
        {
            if (_goPageDialog == null)
            {
                return;
            }
            AndroidUtilities.HideKeyboard();
            switch (success)
            {
            case DialogResult.Cancel:
                _result = null;
                break;

            case DialogResult.LastPage:
                _result = -2;
                break;

            case DialogResult.FirstPage:
                _result = -1;
                break;

            case DialogResult.InputPage:
                var text = _goPageDialog.HolderView.FindViewById <EditText>(Resource.Id.ForumGoToPageDialogTextBox)
                           .Text;
                if (int.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out int page))
                {
                    _result = page;
                }
                else
                {
                    _result = null;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(success), success, null);
            }

            GoPageSemaphore.Release();
            _goPageDialog.Dismiss();
            _goPageDialog.Dispose();
            _goPageDialog = null;
        }
示例#25
0
        public PinnedUsersDialog(IHandyDataStorageModule <MalUser> dataStorageModule)
        {
            _dataStorageModule  = dataStorageModule;
            _tagsDialogBindings = new List <Binding>();
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);

            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.PinnedUsersDialog));
            dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupDialog));
            dialogBuilder.SetOnBackPressListener(new OnBackPressListener(CleanupDialog));
            dialogBuilder.SetGravity((int)GravityFlags.Top);
            _tagsDialog = dialogBuilder.Create();
            var view = _tagsDialog.HolderView;

            var list = view.FindViewById <ListView>(Resource.Id.List);

            list.EmptyView = view.FindViewById(Resource.Id.EmptyNotice);
            list.Adapter   = dataStorageModule.StoredItems.GetAdapter(GetTagItem);

            _tagsDialog.Show();
            MainActivity.CurrentContext.DialogToCollapseOnBack = _tagsDialog;
        }
示例#26
0
        public override void OnBackPressed()
        {
            if (DialogToCollapseOnBack != null)
            {
                DialogToCollapseOnBack.Dismiss();
                DialogToCollapseOnBack = null;
                return;
            }

            if (!ViewModel.SearchToggleLock)
            {
                if (ViewModel.SearchToggleStatus)
                {
                    MainPageSearchView.SetQuery("", false);
                    MainPageSearchView.FindViewById(Resource.Id.search_close_btn).PerformClick();
                    return;
                }
            }

            ViewModelLocator.NavMgr.CurrentMainViewOnBackRequested();
        }
 public static void BuildStatusDialog(IAnimeData model,bool anime,Action<AnimeStatus> action = null)
 {
     var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);
     dialogBuilder.SetAdapter(new StatusDialogAdapter(MainActivity.CurrentContext,
         !anime, model.IsRewatching, model.MyStatus));
     dialogBuilder.SetContentBackgroundResource(Resource.Color.BrushFlyoutBackground);
     dialogBuilder.SetOnItemClickListener(new EnumDialogListener<AnimeStatus>
     {
         OnItemClickAction = (d, status) =>
         {
             if(action == null)
                 model.MyStatus = status;
             else
                 action.Invoke(status);
             CleanupStatusDialog();
         }
     });
     dialogBuilder.SetOnDismissListener(
         new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
     ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupStatusDialog));
     _statusDialog = dialogBuilder.Create();
     _statusDialog.Show();
 }
示例#28
0
        /// <summary>
        /// -1 for first page, -2 for last page , null for no choice , anything else equals page number
        /// </summary>
        public static async Task <int?> BuildGoPageDialog(Context context)
        {
            _result = null;
            var dialogBuilder = DialogPlus.NewDialog(context);

            dialogBuilder.SetGravity((int)GravityFlags.Center);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.ForumGoToPageDialog));
            dialogBuilder.SetContentBackgroundResource(Resource.Color.Transparent);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(() => CleanupGoPageDialog(DialogResult.Cancel)));
            _goPageDialog = dialogBuilder.Create();
            var dialogView = _goPageDialog.HolderView;

            dialogView.FindViewById(Resource.Id.ForumGoToPageDialogAcceptButton).SetOnClickListener(new OnClickListener(view => CleanupGoPageDialog(DialogResult.InputPage)));
            dialogView.FindViewById(Resource.Id.ForumGoToPageDialogFirstPageButton).SetOnClickListener(new OnClickListener(view => CleanupGoPageDialog(DialogResult.FirstPage)));
            dialogView.FindViewById(Resource.Id.ForumGoToPageDialogLastPageButton).SetOnClickListener(new OnClickListener(view => CleanupGoPageDialog(DialogResult.LastPage)));
            dialogView.FindViewById <EditText>(Resource.Id.ForumGoToPageDialogTextBox).SetOnEditorActionListener(new OnEditorActionListener(action => CleanupGoPageDialog(DialogResult.InputPage)));
            _goPageDialog.Show();

            await GoPageSemaphore.WaitAsync();

            return(_result);
        }
 public static void BuildScoreDialog(IAnimeData model,Action<float> action = null)
 {
     var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);
     dialogBuilder.SetAdapter(new ScoreDialogAdapter(MainActivity.CurrentContext,
         AnimeItemViewModel.ScoreFlyoutChoices,model.MyScore));
     dialogBuilder.SetContentBackgroundResource(Resource.Color.BrushFlyoutBackground);
     dialogBuilder.SetOnItemClickListener(new IntegerDialogListener()
     {
         OnItemClickAction = (d, score) =>
         {
             if(action == null)
                 model.MyScore = score;
             else
                 action.Invoke(score);
             CleanupScoreDialog();
         }
     });
     dialogBuilder.SetOnDismissListener(
         new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
     ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupScoreDialog));
     _scoreDialog = dialogBuilder.Create();
     _scoreDialog.Show();
 }
示例#30
0
 public void OnItemClick(DialogPlus p0, Java.Lang.Object p1, View p2, int p3)
 {
     OnItemClickAction.Invoke(p0,(float)p2.Tag);
 }
示例#31
0
        public static void BuildWatchedDialog(AnimeItemViewModel viewModel, Action <AnimeItemViewModel, string> action = null, bool volumes = false)
        {
            try
            {
                _watchedDialogContext = viewModel;
                _watchedDialogAction  = action;
                var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);
                dialogBuilder.SetGravity((int)GravityFlags.Top);
                dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeItemWatchedDialog));
                dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes);
                dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupWatchedDialog));
                dialogBuilder.SetContentBackgroundResource(ResourceExtension.AccentColourDarkRes);
                _watchedDialog = dialogBuilder.Create();
                var view = _watchedDialog.HolderView;


                view.FindViewById <ImageButton>(Resource.Id.AnimeItemWatchedDialogAcceptButton)
                .SetCommand("Click", new RelayCommand(
                                () =>
                {
                    if (action == null)
                    {
                        viewModel.OnFlyoutEpsKeyDown.Execute(null);
                    }
                    else
                    {
                        action.Invoke(_watchedDialogContext, _watchedDialog.HolderView.FindViewById <TextView>(
                                          Resource.Id.AnimeItemWatchedDialogTextInput).Text);
                    }
                    CleanupWatchedDialog();
                }));

                var grid = view.FindViewById <GridView>(Resource.Id.AnimeItemWatchedDialogEpisodesGridView);

                if (volumes)
                {
                    grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, viewModel.MyVolumes,
                                                            viewModel.AllVolumes, null);
                    view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text = "Read volumes";
                    grid.Post(() =>
                    {
                        try
                        {
                            grid.SetSelection(
                                GetRightMostIndex(
                                    (grid.Adapter as WatchedDialogAdapter).Items.IndexOf(viewModel.MyVolumes)));
                        }
                        catch (Exception)
                        {
                            //welp
                        }
                    });
                }
                else
                {
                    int?currentEp = null;
                    if (viewModel.Airing)
                    {
                        if (ResourceLocator.AiringInfoProvider.TryGetCurrentEpisode(viewModel.Id, out int ep))
                        {
                            currentEp = ep;
                        }
                    }
                    grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, viewModel.MyEpisodes,
                                                            viewModel.AllEpisodes, currentEp);
                    view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text =
                        viewModel.ParentAbstraction.RepresentsAnime ? "Watched episodes" : "Read chapters";
                    grid.Post(() =>
                    {
                        try
                        {
                            grid.SetSelection(
                                GetRightMostIndex(
                                    (grid.Adapter as WatchedDialogAdapter).Items.IndexOf(viewModel.MyEpisodes)));
                        }
                        catch (Exception)
                        {
                            //welp
                        }
                    });
                }



                if (grid.Adapter.Count > 16 && MainActivity.CurrentContext.Resources.Configuration.Orientation ==
                    Orientation.Portrait)
                {
                    grid.LayoutParameters.Height = DimensionsHelper.DpToPx(180);
                }

                if (action == null)
                {
                    var input = view.FindViewById <EditText>(Resource.Id.AnimeItemWatchedDialogTextInput);
                    _watchedDialogBindings.Add(new Binding <string, string>(viewModel, () => viewModel.WatchedEpsInput, input,
                                                                            () => input.Text, BindingMode.TwoWay));
                }


                grid.ItemClick += GridOnItemClick;
                _watchedDialog.Show();
                MainActivity.CurrentContext.DialogToCollapseOnBack = _watchedDialog;

                int GetRightMostIndex(int source)
                {
                    var rest = (source + 1) % grid.NumColumns;

                    source -= rest;
                    return(source - 1);
                }
            }
            catch (Exception e)
            {
                //TODO Get from hovckey
                ResourceLocator.SnackbarProvider.ShowText("An unknown error occurred, cause has been logged. I'll fix it in next update.");
                ResourceLocator.TelemetryProvider.LogEvent($"BuildWatchedDialog Crash: {e} , {viewModel.Title}, {action == null}, {volumes}, {e.Source}");
            }
        }
        public static void BuildTagDialog(AnimeDetailsPageViewModel viewModel)
        {
            _tagsDialogBindings = new List<Binding>();
            _tagsDialogContext = viewModel;
            var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext);
            dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeTagsDialog));
            dialogBuilder.SetContentBackgroundResource(Resource.Color.BrushFlyoutBackground);
            dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupTagsDialog));
            dialogBuilder.SetGravity((int) GravityFlags.Top);
            dialogBuilder.SetOnDismissListener(
                new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride()));
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupTagsDialog));
            _tagsDialog = dialogBuilder.Create();
            var view = _tagsDialog.HolderView;

            view.FindViewById<ListView>(Resource.Id.AnimeTagsDialogList).Adapter =
                viewModel.MyTags.GetAdapter(GetTagItem);
            var editBox = view.FindViewById<EditText>(Resource.Id.AnimeTagsDialogEditBox);

            _tagsDialogBindings.Add(new Binding<string, string>(
                viewModel,
                () => viewModel.NewTagInput,
                editBox,
                () => editBox.Text,BindingMode.TwoWay));

            view.FindViewById<ImageButton>(Resource.Id.AnimeTagsDialogAddTagButton).SetCommand("Click",viewModel.AddTagCommand);

            _tagsDialog.Show();
        }
 private static void CleanupTagsDialog()
 {
     ViewModelLocator.NavMgr.ResetOneTimeMainOverride();
     _tagsDialogBindings.ForEach(binding => binding.Detach());
     _tagsDialog?.Dismiss();
     _scoreDialog = null;
 }
示例#34
0
 private static void CleanupStatusDialog()
 {
     ViewModelLocator.NavMgr.ResetOneTimeMainOverride();
     _statusDialog?.Dismiss();
     _statusDialog = null;
 }
 private static void CleanupStatusDialog()
 {
     ViewModelLocator.NavMgr.ResetOneTimeMainOverride();
     _statusDialog?.Dismiss();
     _statusDialog = null;
 }
 public void OnDismiss(DialogPlus p0)
 {
     _onDismissAction.Invoke();
 }
 public void OnItemClick(DialogPlus p0, Java.Lang.Object p1, View p2, int p3)
 {
     OnItemClickAction.Invoke(p0, (float)p2.Tag);
 }
 private static void CleanupWatchedDialog()
 {
     ViewModelLocator.NavMgr.ResetOneTimeMainOverride();
     _watchedDialogBindings.ForEach(binding => binding.Detach());
     _watchedDialogBindings = new List<Binding>();
     _watchedDialog?.Dismiss();
     _watchedDialog = null;
     _watchedDialogContext = null;
     _watchedDialogAction = null;
 }
示例#39
0
 public void OnBackPressed(DialogPlus p0)
 {
     _action.Invoke();
 }