Ejemplo n.º 1
0
        private async void ForumTopicPageActionButtonOnClick()
        {
            var str = await TextInputDialogBuilder.BuildForumPostTextInputDialog(Context, TextInputDialogBuilder.ForumPostTextInputContext.Reply, "");

            if (!string.IsNullOrEmpty(str))
            {
                ViewModel.ReplyMessage = str;
                ViewModel.CreateReplyCommand.Execute(null);
            }
        }
Ejemplo n.º 2
0
        private async void ProfilePageGeneralTabActionButtonOnClick()
        {
            var str = await TextInputDialogBuilder.BuildInputTextDialog(Context, "Find user", "username...", "Go");

            if (!string.IsNullOrEmpty(str))
            {
                ViewModel.NavigateProfileCommand.Execute(new MalUser {
                    Name = str
                });
            }
        }
Ejemplo n.º 3
0
        protected override void InitBindings()
        {
            ForumBoardPageIcon.Typeface = FontManager.GetTypeface(Activity, FontManager.TypefacePath);

            Bindings.Add(
                this.SetBinding(() => ViewModel.LoadingTopics,
                                () => ForumBoardPageLoadingSpinner.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(
                this.SetBinding(() => ViewModel.Title,
                                () => ForumBoardPageTitle.Text));

            Bindings.Add(this.SetBinding(() => ViewModel.Icon).WhenSourceChanges(() =>
            {
                ForumBoardPageIcon.SetText(DummyFontAwesomeToRealFontAwesomeConverter.Convert(ViewModel.Icon));
            }));

            Bindings.Add(
                this.SetBinding(() => ViewModel.SearchButtonVisibility,
                                () => ForumBoardPageSearchButton.Visibility)
                .ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(
                this.SetBinding(() => ViewModel.NewTopicButtonVisibility,
                                () => ForumBoardPageActionButton.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            ForumBoardPageActionButton.Click += (sender, args) => ViewModel.CreateNewTopicCommand.Execute(null);


            Bindings.Add(this.SetBinding(() => ViewModel.Topics).WhenSourceChanges(() =>
            {
                ForumBoardPagePostsList.Adapter = ViewModel.Topics.GetAdapter(GetTopicTemplateDelegate);
            }));

            Bindings.Add(
                this.SetBinding(() => ViewModel.EmptyNoticeVisibility,
                                () => ForumBoardPageEmptyNotice.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            ForumBoardPageSearchButton.Click += async(sender, args) =>
            {
                var str = await TextInputDialogBuilder.BuildInputTextDialog(Context, "Search", "keyword...", "Go");

                if (!string.IsNullOrEmpty(str))
                {
                    ViewModel.SearchQuery = str;
                    ViewModel.SearchCommand.Execute(null);
                }
            };

            ForumBoardPageGotoPageButton.SetOnClickListener(new OnClickListener(OnGotoPageButtonClick));

            Bindings.Add(this.SetBinding(() => ViewModel.AvailablePages).WhenSourceChanges(UpdatePageSelection));
        }
Ejemplo n.º 4
0
        private async void SetListSource()
        {
            var src = await TextInputDialogBuilder.BuildInputTextDialog(Activity, "List source", "username...", "Go!", true);

            if (string.IsNullOrWhiteSpace(src))
            {
                return;
            }
            if (src.Length > 2)
            {
                ViewModel.ListSource = src;
                await ViewModel.FetchData();
            }
            else
            {
                ResourceLocator.SnackbarProvider.ShowText("Invalid username");
            }
        }
Ejemplo n.º 5
0
        protected override void RootContainerInit()
        {
            var jsInterface = new DataJavascriptInterface(Context);

            ForumTopicPageItemWebView.Settings.JavaScriptEnabled = true;
            _client = new ListenableWebClient();
            _client.NavigationInterceptOpportunity = NavigationInterceptOpportunity;
            ForumTopicPageItemWebView.SetWebViewClient(_client);
            ForumTopicPageItemWebView.AddJavascriptInterface(jsInterface, "android");
            ForumTopicPageItemWebView.Tag = new WebViewTag(jsInterface).Wrap();
            ForumTopicPageItemWebView.VerticalScrollBarEnabled        = false;
            ForumTopicPageItemWebView.ScrollbarFadingEnabled          = true;
            ForumTopicPageItemWebView.HorizontalScrollBarEnabled      = false;
            ForumTopicPageItemWebView.ScrollBarDefaultDelayBeforeFade = 0;
            ForumTopicPageItemWebView.SetBackgroundColor(Color.Transparent);
            _dataJavascriptInterface = jsInterface;

            _dataJavascriptInterface.NewResponse += DataJavascriptInterfaceOnNewResponse;

            ForumTopicPageItemEditButton.SetOnClickListener(new OnClickListener(async view =>
            {
                await ViewModel.StartEdit();
                var str = await TextInputDialogBuilder.BuildForumPostTextInputDialog(Context, TextInputDialogBuilder.ForumPostTextInputContext.Edit, ViewModel.BBcodeContent);
                if (!string.IsNullOrEmpty(str))
                {
                    ViewModel.BBcodeContent = str;
                    ViewModel.SubmitEditCommand.Execute(null);
                }
            }));

            ForumTopicPageItemQuoteButton.SetOnClickListener(new OnClickListener(async view =>
            {
                var semaphore = new SemaphoreSlim(0);
                var vm        = ViewModelLocator.ForumsTopic;
                var deleg     = new PropertyChangedEventHandler((sender, args) =>
                {
                    if (args.PropertyName == nameof(vm.ReplyMessage))
                    {
                        semaphore.Release();
                    }
                });
                vm.ReplyMessage     = string.Empty;
                vm.PropertyChanged += deleg;
                ViewModel.QuoteCommand.Execute(null);
                await semaphore.WaitAsync();
                vm.PropertyChanged -= deleg;
                var str             = await TextInputDialogBuilder.BuildForumPostTextInputDialog(Context, TextInputDialogBuilder.ForumPostTextInputContext.Reply, vm.ReplyMessage);
                if (!string.IsNullOrEmpty(str))
                {
                    vm.ReplyMessage = str;
                    vm.CreateReplyCommand.Execute(null);
                }
            }));

            ForumTopicPageItemDeleteButton.SetOnClickListener(new OnClickListener(view =>
            {
                ViewModel.DeleteCommand.Execute(null);
            }));

            ForumTopicPageItemSendMessageButton.SetOnClickListener(new OnClickListener(view =>
            {
                ViewModelLocator.ForumsTopic.NavigateMessagingCommand.Execute(ViewModel.Data.Poster.MalUser);
            }));

            ForumTopicPageItemSeeOtherPostsButton.SetOnClickListener(new OnClickListener(view =>
            {
                ViewModel.GoToPostersOtherPosts.Execute(null);
            }));

            var listener = new OnClickListener(view => ViewModelLocator.ForumsTopic.NavigateProfileCommand.Execute(ViewModel.Data.Poster.MalUser));

            ForumTopicPageItemPostAuthor.SetOnClickListener(listener);
            ForumTopicPageItemAuthorImage.SetOnClickListener(listener);
        }