示例#1
0
 /// <summary>
 /// 显示弹窗
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 private void Show(MaterialDialog.Builder builder)
 {
     if (Looper.MainLooper == Looper.MyLooper())
     {
         builder.Show();
     }
     else
     {
         AppUtils.RunOnUI(() =>
         {
             builder.Show();
         });
     }
 }
示例#2
0
        protected override void ShowDialog(Bundle state)
        {
            if (GetEntries() == null || GetEntryValues() == null)
            {
                throw new IllegalStateException("ListPreference requires an entries array and an entryValues array.");
            }

            int preselect = FindIndexOfValue(Value);

            MaterialDialog.Builder builder = (new MaterialDialog.Builder(context)).SetTitle(DialogTitle).SetContent(DialogMessage).SetIcon(DialogIcon).SetNegativeText(NegativeButtonText).SetItems(GetEntries()).SetAutoDismiss(true).SetItemsCallbackSingleChoice(preselect, new ListCallbackSingleChoiceAnonymousInnerClassHelper(this));             // immediately close the dialog after selection

            View contentView = OnCreateDialogView();

            if (contentView != null)
            {
                OnBindDialogView(contentView);
                builder.SetCustomView(contentView, false);
            }
            else
            {
                builder.SetContent(DialogMessage);
            }

            mDialog = builder.Show();
        }
        public override void OnBackPressed()
        {
            Stack <Fragment> stack = stacks[(int)App.STATE.CurrentLibrary];

            if (stack.Count > 0)
            {
                if (stack.Count == 1)
                {
                    drawer.SetDrawerLockMode(DrawerLayout.LockModeLockedClosed, nav);
                }
                base.OnBackPressed();
            }
            else
            {
                MaterialDialog         dialog = null;
                MaterialDialog.Builder popup  = new MaterialDialog.Builder(this);
                popup.SetTitle("Exit Application?");
                popup.SetPositiveText("Yes", (o, e) =>
                {
                    base.OnBackPressed();
                });
                popup.SetNegativeText("No");

                dialog = popup.Show();
            }
        }
示例#4
0
        public void ShowFontSizeDialog()
        {
            SeekBar seek = new SeekBar(Activity);

            seek.Max              = 10;
            seek.Progress         = App.STATE.SeekBarTextSize;
            seek.ProgressChanged += (o, e) =>
            {
                int size = App.FUNCTIONS.GetWebViewTextSize(e.Progress);

                SetWebViewTextSize(size);

                // Set font size globally
                App.STATE.SeekBarTextSize = e.Progress;

                // Save font size to preferences
                var prefs = PreferenceManager.GetDefaultSharedPreferences(Activity);
                prefs.Edit().PutInt("WebViewBaseFontSize", e.Progress).Commit();
            };

            MaterialDialog dialog = null;

            MaterialDialog.Builder popup = new MaterialDialog.Builder(Activity);
            popup.SetCustomView(seek, false);
            popup.SetTitle("Text Size");
            popup.SetPositiveText("X");

            dialog = popup.Show();
        }
示例#5
0
        protected override void ShowDialog(Bundle state)
        {
            IList <int> indices = new List <int>();

            foreach (string s in Values)
            {
                int index = FindIndexOfValue(s);
                if (index >= 0)
                {
                    indices.Add(FindIndexOfValue(s));
                }
            }
            MaterialDialog.Builder builder = (new MaterialDialog.Builder(context)).SetTitle(DialogTitle).SetContent(DialogMessage).SetIcon(DialogIcon).SetNegativeText(NegativeButtonText).SetPositiveText(PositiveButtonText).SetItems(GetEntries()).SetItemsCallbackMultiChoice(indices.ToArray(), new ListCallbackMultiChoiceAnonymousInnerClassHelper(this)).SetDismissListener(this);

            View contentView = OnCreateDialogView();

            if (contentView != null)
            {
                OnBindDialogView(contentView);
                builder.SetCustomView(contentView, false);
            }
            else
            {
                builder.SetContent(DialogMessage);
            }

            mDialog = builder.Show();
        }
示例#6
0
        //Report Copyright
        private void ReportCopyRightLayoutOnClick(object sender, EventArgs e)
        {
            try
            {
                if (UserDetails.IsLogin)
                {
                    if (Methods.CheckConnectivity())
                    {
                        MaterialDialog dialog = new MaterialDialog.Builder(Controller.ActivityContext).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light)
                                                .Title(Resource.String.Lbl_ReportCopyRight)
                                                .CustomView(Resource.Layout.ReportCopyRightLayout, true)
                                                .PositiveText(Resource.String.Lbl_Submit).OnPositive((materialDialog, action) =>
                        {
                            try
                            {
                                if (TxtMessage != null && (CheckBox2 != null && (CheckBox1 != null && (CheckBox1.Checked && CheckBox2.Checked && !string.IsNullOrEmpty(TxtMessage.Text) && !string.IsNullOrWhiteSpace(TxtMessage.Text)))))
                                {
                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Video.ReportCopyRightVideos_Http(Controller.VideoData.Id, TxtMessage.Text)
                                    });
                                    Toast.MakeText(Controller.ActivityContext, Controller.ActivityContext.GetText(Resource.String.Lbl_received_your_report), ToastLength.Short).Show();
                                }
                                else
                                {
                                    Toast.MakeText(Controller.ActivityContext, Controller.ActivityContext.GetText(Resource.String.Lbl_Please_check_your_details), ToastLength.Short).Show();
                                }
                            }
                            catch (Exception exception)
                            {
                                Console.WriteLine(exception);
                            }
                        })
                                                .NegativeText(Resource.String.Lbl_Close).OnNegative(this)
                                                .Build();

                        TxtMessage = dialog.CustomView.FindViewById <EditText>(Resource.Id.MessageEditText);
                        CheckBox1  = dialog.CustomView.FindViewById <CheckBox>(Resource.Id.CheckBoxReportCopyRight1);
                        CheckBox2  = dialog.CustomView.FindViewById <CheckBox>(Resource.Id.CheckBoxReportCopyRight2);

                        dialog.Show();
                        Dismiss();
                    }
                    else
                    {
                        Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    }
                }
                else
                {
                    PopupDialogController dialog = new PopupDialogController(Activity, Controller.VideoData, "Login");
                    dialog.ShowNormalDialog(Context.GetText(Resource.String.Lbl_Warning), Context.GetText(Resource.String.Lbl_Please_sign_in_Report), Context.GetText(Resource.String.Lbl_Yes), Context.GetText(Resource.String.Lbl_No));
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
示例#7
0
        //////////////////////////////////////////////////////////////////////////
        // DIALOG Section
        //////////////////////////////////////////////////////////////////////////
        public void ShowPresentationDialog(Context context, string title, string content, bool external = false)
        {
            LayoutInflater inflater            = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
            View           view                = inflater.Inflate(Resource.Layout.DialogWebView, null);
            WebView        presentationWebView = view.FindViewById <WebView>(Resource.Id.dialogWebView);

            StorehouseWebViewClient client = new StorehouseWebViewClient(external);

            presentationWebView.SetWebViewClient(client);
            presentationWebView.Settings.JavaScriptEnabled   = true;
            presentationWebView.Settings.BuiltInZoomControls = true;
            presentationWebView.VerticalScrollBarEnabled     = false;
            presentationWebView.Settings.DefaultFontSize     = GetWebViewTextSize(App.STATE.SeekBarTextSize);

            if (content.StartsWith("http"))
            {
                presentationWebView.LoadUrl(content);
            }
            else
            {
                presentationWebView.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null);
            }

            MaterialDialog dialog = null;

            MaterialDialog.Builder popup = new MaterialDialog.Builder(context);
            popup.SetCustomView(view, false);
            popup.SetNegativeText("X", (o, args) =>
            {
                // Close dialog
            });

            App.STATE.Activity.RunOnUiThread(() =>
            {
                dialog = popup.Show();

                // Set dialog width to width of screen
                WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams();
                layoutParams.CopyFrom(dialog.Window.Attributes);
                layoutParams.Width       = WindowManagerLayoutParams.MatchParent;
                dialog.Window.Attributes = layoutParams;
            });
        }
示例#8
0
        protected override void OnViewModelSet()
        {
            base.OnViewModelSet();
            SetContentView(Resource.Layout.Main);

            var dialog = new MaterialDialog.Builder(this).SetContent("正在加载更多").SetCancelable(false).SetProgress(true, 0).Build();

            Messenger.Subscribe <LoadMoreMessager>(x =>
            {
                if (x.IsClose)
                {
                    dialog.Dismiss();
                }
                else
                {
                    dialog.Show();
                }
            });
        }
示例#9
0
        private void DisplayArticles()
        {
            MaterialDialog dialog = null;

            MaterialDialog.Builder progress = new MaterialDialog.Builder(Activity);
            progress.SetContent("Loading articles");
            progress.SetCancelable(false);
            progress.SetProgress(true, 0);

            ThreadPool.QueueUserWorkItem((o) =>
            {
                Activity.RunOnUiThread(() => dialog = progress.Show());

                if (primaryArticles.Count <= 0 || secondaryArticles.Count <= 0)
                {
                    LoadArticlesFromStorehouses();
                }

                List <string> content = new List <string>();

                content.Add(GetArticle("primary"));
                content.Add(GetArticle("secondary"));

                LoadWebViews(content);

                Activity.RunOnUiThread(() => dialog.Dismiss());
            });

            //Task.Factory.StartNew<List<string>>(() =>
            //{
            //    List<string> content = new List<string>();

            //    content.Add(GetArticle("primary"));
            //    content.Add(GetArticle("secondary"));

            //    return content;
            //}).ContinueWith(antecendent => LoadWebViews(antecendent.Result));

            ThreadPool.QueueUserWorkItem((o) => App.STATE.SelectedArticle = SelectedArticle);
            ThreadPool.QueueUserWorkItem((o) => App.STATE.SaveUserPreferences());
        }
示例#10
0
        private void AddComputerButtonOnClick(object sender, EventArgs eventArgs)
        {
            var dialogBuilder = new MaterialDialog.Builder(this)
                                .Title(Resource.String.app_addcomputer_title)
                                .CustomView(Resource.Layout.dialog_addcomputer, true)
                                .PositiveText(Resource.String.app_addcomputer_connect)
                                .NegativeText(Resource.String.app_addcomputer_cancel)
                                .OnPositive((dialog, w) =>
            {
                IpAddresses.Add(new ComputerModel(
                                    dialog.CustomView.FindViewById <EditText>(Resource.Id.ipAddress).Text,
                                    dialog.CustomView.FindViewById <EditText>(Resource.Id.password).Text));
                BlobCache.UserAccount.InsertObject("ipaddresses", IpAddresses);
            }).Build();

            var positiveAction = dialogBuilder.GetActionButton(DialogAction.Positive);
            var ipControl      = dialogBuilder.CustomView.FindViewById <EditText>(Resource.Id.ipAddress);
            var token          = new CancellationTokenSource();

            positiveAction.Enabled = false;

            ipControl.TextChanged += (o, args) =>
            {
                token.Cancel();
                token = new CancellationTokenSource();
                if (ValidateIPv4(ipControl.Text) && IpAddresses.All(i => i.Ip != ipControl.Text))
                {
                    Task.Factory.StartNew(
                        async() => positiveAction.Enabled = await Scanner.CheckHostForVlc(ipControl.Text),
                        token.Token);
                }
                else
                {
                    positiveAction.Enabled = false;
                }
            };

            dialogBuilder.Show();
        }
示例#11
0
        public void ShowCharacterLearningDialog(Context context, LearningCharacter character, WebView webview)
        {
            SQLiteConnection database = new SQLiteConnection(App.LearningCharactersPath);

            database.CreateTable <LearningCharacter>();

            var  table  = database.Table <LearningCharacter>();
            bool exists = table.Any(x => x.Chinese.Equals(character.Chinese) && x.Pinyin.Equals(character.Pinyin));

            string buttonTitle = (exists) ? "REMOVE" : "ADD";

            MaterialDialog.Builder popup = new MaterialDialog.Builder(context);
            popup.SetTitle(character.Chinese + " " + character.Pinyin);
            popup.SetContent(character.English);
            popup.SetPositiveText(buttonTitle, (o, e) =>
            {
                if (!exists)
                {
                    database.Insert(character);
                }
                if (exists)
                {
                    var query = (from c in table
                                 where (c.Chinese.ToLower().Equals(character.Chinese.ToLower()) && c.Pinyin.ToLower().Equals(character.Pinyin.ToLower()))
                                 select c).ToList().FirstOrDefault();

                    database.Delete(query);
                }
                string js = "javascript:ToggleEnglish();";
                webview.LoadUrl(js);
            });

            App.STATE.Activity.RunOnUiThread(() =>
            {
                popup.Show();
            });
        }
示例#12
0
        public void ShowCustomView(object sender, EventArgs e)
        {
            MaterialDialog dialog = new MaterialDialog.Builder(this)
                                    .Title(Resource.String.googleWifi)
                                    .CustomView(Resource.Layout.dialog_customview, true)
                                    .PositiveText(Resource.String.connect)
                                    .NegativeText(Android.Resource.String.Cancel)
                                    .OnPositive((dialog1, which) => ShowToast("Password: " + _passwordInput.Text))
                                    .Build();

            _positiveAction = dialog.GetActionButton(DialogAction.Positive);

            _passwordInput              = dialog.CustomView.FindViewById <EditText>(Resource.Id.password);
            _passwordInput.TextChanged += (s, ev) =>
            {
                _positiveAction.Enabled = String.Concat(ev.Text.Select(c => c.ToString())).Trim().Length > 0;
            };

            CheckBox checkbox = dialog.CustomView.FindViewById <CheckBox>(Resource.Id.showPassword);

            checkbox.CheckedChange += (s, ev) =>
            {
                _passwordInput.InputType            = (!ev.IsChecked) ? InputTypes.TextVariationPassword : InputTypes.ClassText;
                _passwordInput.TransformationMethod = (!ev.IsChecked) ? PasswordTransformationMethod.Instance : null;
            };

            int widgetColor = ThemeSingleton.Get().WidgetColor;

            MDTintHelper.SetTint(checkbox,
                                 widgetColor == 0 ? ContextCompat.GetColor(this, Resource.Color.accent) : widgetColor);

            MDTintHelper.SetTint(_passwordInput,
                                 widgetColor == 0 ? ContextCompat.GetColor(this, Resource.Color.accent) : widgetColor);

            dialog.Show();
            _positiveAction.Enabled = false;
        }
示例#13
0
        public void ShowChapterPrompt()
        {
            string title = gridViewTitle.Text;

            LayoutInflater       inflater = (LayoutInflater)Activity.GetSystemService(Context.LayoutInflaterService);
            View                 view     = inflater.Inflate(Resource.Layout.DialogChapterSelect, null);
            HeaderFooterGridView grid     = view.FindViewById <HeaderFooterGridView>(Resource.Id.chapterSelectGridView);

            grid.SetSelector(Android.Resource.Color.Transparent);
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                grid.ChoiceMode = ChoiceMode.Single;
            }

            List <ISpanned> articles;

            if (library == Library.Bible)
            {
                // Chapter numbers only
                articles         = primaryChapters.Select(a => Html.FromHtml(a.ToString().Split(new[] { ' ' }).Last())).ToList();
                grid.StretchMode = StretchMode.NoStretch;
                grid.NumColumns  = -1;
            }
            else if (library == Library.Insight)
            {
                // Article titles
                articles         = primaryChapters;
                grid.StretchMode = StretchMode.StretchColumnWidth;
                grid.NumColumns  = 2;
            }
            else
            {
                // Article titles
                articles         = primaryChapters;
                grid.StretchMode = StretchMode.StretchColumnWidth;
                grid.NumColumns  = 1;
            }

            // If one article, do nothing
            if (articles.Count == 1)
            {
                return;
            }

            MaterialDialog dialog = null;

            grid.Adapter    = new ArticleButtonAdapter(Activity, articles.ToArray());
            grid.ItemClick += SelectChapter;
            grid.ItemClick += delegate
            {
                dialog.Dismiss();
            };

            int index = GetNavigationIndex();

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                grid.SetItemChecked(index, true);
            }
            grid.SetSelection(index);

            MaterialDialog.Builder popup = new MaterialDialog.Builder(Activity);
            popup.SetCustomView(view, false);
            popup.SetTitle(title.Replace("\n", "<br/>").Split('<')[0]);
            popup.SetNegativeText("X");

            dialog = popup.Show();
        }
        public void BuildStorehouseWorker()
        {
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += (object sender, DoWorkEventArgs e) =>
            {
                MaterialDialog.Builder progress = new MaterialDialog.Builder(this);
                progress.SetTitle("Finalizing Storehouse");
                progress.SetContent("Please be patient");
                progress.SetCancelable(false);
                progress.SetProgress(true, 3);

                MaterialDialog dialog = null;

                RunOnUiThread(() =>
                {
                    dialog = progress.Show();
                });

                RunOnUiThread(() =>
                {
                    dialog.SetContent("Building English library");
                });
                App.FUNCTIONS.ExtractDatabase("english.db", this, MAIN_EXPANSION_FILE_VERSION);
                RunOnUiThread(() =>
                {
                    dialog.SetContent("Building Chinese library");
                });
                App.FUNCTIONS.ExtractDatabase("chinese.db", this, MAIN_EXPANSION_FILE_VERSION);
                RunOnUiThread(() =>
                {
                    dialog.SetContent("Building Pinyin library");
                });
                App.FUNCTIONS.ExtractDatabase("pinyin.db", this, MAIN_EXPANSION_FILE_VERSION);

                List <Library> libraries = new List <Library>();
                libraries.Add(Library.Bible);
                libraries.Add(Library.Insight);
                libraries.Add(Library.DailyText);
                libraries.Add(Library.Publications);

                App.STATE.Libraries      = libraries;
                App.STATE.CurrentLibrary = libraries.First();

                App.STATE.SeekBarTextSize = Resources.GetInteger(Resource.Integer.webview_base_font_size);

                // English
                App.STATE.PrimaryLanguage = App.FUNCTIONS.GetAvailableLanguages(this)[0];
                // Chinese
                App.STATE.SecondaryLanguage = App.FUNCTIONS.GetAvailableLanguages(this)[1];
                // Pinyin
                App.STATE.PinyinLanguage = App.FUNCTIONS.GetAvailableLanguages(this)[2];
                // Set current language first to English
                App.STATE.Language = App.STATE.PrimaryLanguage.EnglishName;

                App.STATE.SaveUserPreferences();
                preferences.Edit().PutInt("MainExpansionFileVersion", MAIN_EXPANSION_FILE_VERSION).Commit();

                RunOnUiThread(() =>
                {
                    Toast.MakeText(this, "Set up complete. Have fun!", ToastLength.Long).Show();
                });

                dialog.Dismiss();

                StartApplication();
            };

            worker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
            {
                Console.WriteLine("WORKER COMPLETE!");
            };
        }
示例#15
0
        private void OpenCashFreeDialog()
        {
            try
            {
                var dialog = new MaterialDialog.Builder(this).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light)
                             .Title(GetText(Resource.String.Lbl_CashFree))
                             .CustomView(Resource.Layout.CashFreePaymentLayout, true)
                             .PositiveText(GetText(Resource.String.Lbl_PayNow)).OnPositive(async(materialDialog, action) =>
                {
                    try
                    {
                        if (string.IsNullOrEmpty(TxtName.Text) || string.IsNullOrWhiteSpace(TxtName.Text))
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_name), ToastLength.Short)?.Show();
                            return;
                        }

                        var check = Methods.FunString.IsEmailValid(TxtEmail.Text.Replace(" ", ""));
                        if (!check)
                        {
                            Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_VerificationFailed), GetText(Resource.String.Lbl_IsEmailValid), GetText(Resource.String.Lbl_Ok));
                            return;
                        }

                        if (string.IsNullOrEmpty(TxtPhone.Text) || string.IsNullOrWhiteSpace(TxtPhone.Text))
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_your_data), ToastLength.Short)?.Show();
                            return;
                        }

                        Toast.MakeText(this, GetText(Resource.String.Lbl_Please_wait), ToastLength.Short)?.Show();

                        await CashFree(TxtName.Text, TxtEmail.Text, TxtPhone.Text);
                    }
                    catch (Exception e)
                    {
                        Methods.DisplayReportResultTrack(e);
                    }
                })
                             .NegativeText(GetText(Resource.String.Lbl_Close)).OnNegative(new WoWonderTools.MyMaterialDialog())
                             .Build();

                var iconName = dialog.CustomView.FindViewById <TextView>(Resource.Id.IconName);
                TxtName = dialog.CustomView.FindViewById <EditText>(Resource.Id.NameEditText);

                var iconEmail = dialog.CustomView.FindViewById <TextView>(Resource.Id.IconEmail);
                TxtEmail = dialog.CustomView.FindViewById <EditText>(Resource.Id.EmailEditText);

                var iconPhone = dialog.CustomView.FindViewById <TextView>(Resource.Id.IconPhone);
                TxtPhone = dialog.CustomView.FindViewById <EditText>(Resource.Id.PhoneEditText);

                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, iconName, FontAwesomeIcon.User);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, iconEmail, FontAwesomeIcon.PaperPlane);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, iconPhone, FontAwesomeIcon.Mobile);

                Methods.SetColorEditText(TxtName, AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                Methods.SetColorEditText(TxtEmail, AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                Methods.SetColorEditText(TxtPhone, AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                var local = ListUtils.MyProfileList?.FirstOrDefault();
                if (local != null)
                {
                    TxtName.Text  = WoWonderTools.GetNameFinal(local);
                    TxtEmail.Text = local.Email;
                    TxtPhone.Text = local.PhoneNumber;
                }

                dialog.Show();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
示例#16
0
        private void ShowChapterPrompt(string storehouse, WOLPublication pub, NavStruct article)
        {
            LayoutInflater       inflater = (LayoutInflater)Activity.GetSystemService(Context.LayoutInflaterService);
            View                 view     = inflater.Inflate(Resource.Layout.DialogChapterSelect, null);
            HeaderFooterGridView gridview = view.FindViewById <HeaderFooterGridView>(Resource.Id.chapterSelectGridView);

            gridview.SetSelector(Android.Resource.Color.Transparent);

            List <WOLArticle> articles;
            List <ISpanned>   titles;

            if (LibraryMode == Library.Bible)
            {
                gridview.NumColumns  = -1;
                gridview.StretchMode = StretchMode.NoStretch;

                string bookNumber = article.Book.ToString() + ".";

                articles = JwStore.QueryArticleChapterTitles(PublicationType.Bible, storehouse)
                           .Where(a => a.ArticleNumber.StartsWith(bookNumber)).ToList();

                titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.ToString().Split(new[] { ' ' }).Last())).ToList();
                if (titles.Count == 1)
                {
                    LoadArticle(article);

                    return;
                }
            }
            else if (LibraryMode == Library.Insight)
            {
                gridview.NumColumns  = 2;
                gridview.StretchMode = StretchMode.StretchColumnWidth;

                articles = JwStore.QueryArticleChapterTitles(PublicationType.Insight, storehouse)
                           .Where(i => i.ArticleGroup.Equals(pub.Group))
                           .ToList();

                titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>").Split('<')[0] + "<br/><i>" + a.ArticleLocation + "</i>")).ToList();
            }
            else
            {
                gridview.NumColumns  = 1;
                gridview.StretchMode = StretchMode.StretchColumnWidth;

                articles = JwStore.QueryArticleChapterTitles(pub.Code, storehouse)
                           .ToList();

                titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>").Split('<')[0] + "<br/><i>" + a.ArticleLocation + "</i>")).ToList();
                if (titles.Count == 1)
                {
                    LoadArticle(article);

                    return;
                }
            }

            MaterialDialog dialog = null;

            gridview.Adapter    = new ArticleButtonAdapter(Activity, titles.ToArray());
            gridview.ItemClick += (s, args) =>
            {
                dialog.Dismiss();

                article = NavStruct.Parse(articles[args.Position].ArticleNumber);
                LoadArticle(article);
            };

            MaterialDialog.Builder popup = new MaterialDialog.Builder(Activity);
            popup.SetCustomView(view, false);
            popup.SetTitle(pub.Name.Replace("\n", "<br/>").Split('<')[0]);
            popup.SetNegativeText("X");

            dialog = popup.Show();
        }
            public void OnSuccess(Java.Lang.Object p0)
            {
                try
                {
                    if (!(p0 is AppUpdateInfo info))
                    {
                        return;
                    }

                    Log.Debug("AVAILABLE VERSION CODE", $"{info.AvailableVersionCode()}");

                    PackageInfo packageInfo = MainActivity?.PackageManager?.GetPackageInfo(MainActivity.PackageName, 0);
                    string      versionName = packageInfo?.VersionName;

                    var availability = info.UpdateAvailability();
                    switch (availability)
                    {
                    case UpdateAvailability.UpdateAvailable:
                    case UpdateAvailability.DeveloperTriggeredUpdateInProgress:
                    {
                        var dialog = new MaterialDialog.Builder(MainActivity).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light)
                                     .Title(MainActivity.GetText(Resource.String.Lbl_ThereIsNewUpdate)).TitleColorRes(Resource.Color.primary)
                                     .CustomView(Resource.Layout.DialogCheckUpdateApp, true)
                                     .PositiveText(MainActivity.GetText(Resource.String.Lbl_Update)).OnPositive((materialDialog, action) =>
                            {
                                try
                                {
                                    switch (availability)
                                    {
                                    case UpdateAvailability.UpdateAvailable or UpdateAvailability.DeveloperTriggeredUpdateInProgress when info.IsUpdateTypeAllowed(AppUpdateType.Immediate):
                                        // Start an update
                                        AppUpdateManager.StartUpdateFlowForResult(info, AppUpdateType.Immediate, MainActivity, UpdateRequest);

                                        //#if DEBUG
                                        //if (AppUpdateManager is FakeAppUpdateManager fakeAppUpdate && fakeAppUpdate.IsImmediateFlowVisible)
                                        //{
                                        //    fakeAppUpdate.UserAcceptsUpdate();
                                        //    fakeAppUpdate.DownloadStarts();
                                        //    fakeAppUpdate.DownloadCompletes();
                                        //    LaunchRestartDialog(AppUpdateManager);
                                        //}
                                        //#endif
                                        break;

                                    case UpdateAvailability.UpdateNotAvailable:
                                    case UpdateAvailability.Unknown:
                                        Log.Debug("UPDATE NOT AVAILABLE", $"{info.AvailableVersionCode()}");
                                        // You can start your activityonresult method when update is not available when using immediate update
                                        MainActivity.StartActivityForResult(Intent, 400);         // You can use any random result code
                                        break;
                                    }
                                }
                                catch (Exception e)
                                {
                                    Methods.DisplayReportResultTrack(e);
                                }
                            })
                                     .NegativeText(MainActivity.GetText(Resource.String.Lbl_Close)).OnNegative(new WoWonderTools.MyMaterialDialog())
                                     .Build();

                        var textAppName = dialog.CustomView.FindViewById <TextView>(Resource.Id.text_app_name);
                        textAppName.Text = AppSettings.ApplicationName;

                        var txtNewVersion = dialog.CustomView.FindViewById <TextView>(Resource.Id.tv_new_version);
                        txtNewVersion.Text = MainActivity.GetText(Resource.String.Lbl_DiscoverNewVersion) + " V" + info.AvailableVersionCode();
                        var txtVersion = dialog.CustomView.FindViewById <TextView>(Resource.Id.tv_version);
                        txtVersion.Text = MainActivity.GetText(Resource.String.Lbl_Current) + " V" + versionName;
                        dialog.Show();
                        break;
                    }
                    }
                }
                catch (Exception e)
                {
                    Methods.DisplayReportResultTrack(e);
                }
            }