示例#1
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();
        }
示例#2
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();
        }
示例#3
0
        protected override void ShowDialog(Bundle state)
        {
            MaterialDialog.Builder builder = new MaterialDialog.Builder(context)
                                             .SetTitle(DialogTitle)
                                             .SetContent(DialogMessage)
                                             .SetIcon(DialogIcon)
                                             .SetDismissListener(this)
                                             .SetCallback(new ButtonCallback
            {
                Neutral = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Neutral);
                },
                Negative = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Negative);
                },
                Positive = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Positive);
                }
            })
                                             .SetPositiveText(PositiveButtonText)
                                             .SetNegativeText(NegativeButtonText)
                                             .SetAutoDismiss(true);

            View contentView = OnCreateDialogView();

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

            try
            {
                PreferenceManager        pm     = PreferenceManager;
                Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod(
                    "registerOnActivityDestroyListener",
                    Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = builder.Build();
            if (state != null)
            {
                mDialog.OnRestoreInstanceState(state);
            }
            mDialog.Show();
        }
        protected override void ShowDialog(Bundle state)
        {
            MaterialDialog.Builder builder = new MaterialDialog.Builder(context)
                .SetTitle(DialogTitle)
                .SetContent(DialogMessage)
                .SetIcon(DialogIcon)
                .SetDismissListener(this)
                .SetCallback(new ButtonCallback
                {
                    Neutral = (x) =>
                    {
                        OnClick(x,(int)DialogButtonType.Neutral);
                    },
                    Negative = (x) =>
                    {
                        OnClick(x, (int)DialogButtonType.Negative);
                    },
                    Positive = (x) =>
                    {
                        OnClick(x, (int)DialogButtonType.Positive);
                    }
                })
                .SetPositiveText(PositiveButtonText)
                .SetNegativeText(NegativeButtonText)
                .SetAutoDismiss(true);

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

            try
            {
                PreferenceManager pm = PreferenceManager;
                Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod(
                        "registerOnActivityDestroyListener",
                        Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = builder.Build();
            if (state != null)
                mDialog.OnRestoreInstanceState(state);
            mDialog.Show();
        }
示例#5
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());
        }
示例#6
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();
            });
        }
 public virtual Builder SetMessage(int messageId)
 {
     builder.SetContent(messageId);
     return(this);
 }
示例#8
0
        protected override void ShowDialog(Bundle state)
        {
            List <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)
                                             .SetCallback(new ButtonCallback()
            {
                Neutral = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Neutral);
                },
                Negative = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Negative);
                },
                Positive = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Positive);
                }
            })
                                             .SetItems(GetEntries())
                                             .SetItemsCallbackMultiChoice(indices.ToArray(), new ListCallbackMultiChoice
            {
                Selection = (dialog, which, text) =>
                {
                    OnClick(null, (int)DialogButtonType.Positive);
                    dialog.Dismiss();
                    ISet <String> values = new HashSet <String>();
                    foreach (int i in which)
                    {
                        values.Add(GetEntryValues()[i]);
                    }
                    if (CallChangeListener((Java.Lang.Object)values))
                    {
                        Values = values;
                    }
                    return(true);
                }
            }).SetDismissListener(this);

            View contentView = OnCreateDialogView();

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

            try
            {
                PreferenceManager pm     = PreferenceManager;
                Method            method = pm.Class.GetDeclaredMethod(
                    "registerOnActivityDestroyListener",
                    Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = builder.Build();
            if (state != null)
            {
                mDialog.OnRestoreInstanceState(state);
            }
            mDialog.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!");
            };
        }
        protected override void ShowDialog(Bundle state)
        {
            if (GetEntries() == null || GetEntryValues() == null)
            {
                throw new InvalidOperationException(
                        "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)
                    .SetDismissListener(this)
                    .SetCallback(new ButtonCallback()
                    {
                        Neutral = (x) =>
                        {
                            OnClick(x, (int)DialogButtonType.Neutral);
                        },
                        Negative = (x) =>
                        {
                            OnClick(x, (int)DialogButtonType.Negative);
                        },
                        Positive = (x) =>
                        {
                            OnClick(x, (int)DialogButtonType.Positive);
                        }
                    })
                    .SetNegativeText(NegativeButtonText)
                    .SetItems(GetEntries())
                    .SetAutoDismiss(true)
                    .SetItemsCallbackSingleChoice(preselect, new ListCallbackSingleChoice
                    {
                        Selection = (dialog, itemView, which, text) =>
                        {
                            OnClick(null, (int)DialogButtonType.Positive);
                            if (which >= 0 && GetEntryValues() != null)
                            {
                                try
                                {
                                    Field clickedIndex = this.Class.GetDeclaredField("mClickedDialogEntryIndex");
                                    clickedIndex.Accessible = true;
                                    clickedIndex.Set(this, which);
                                }
                                catch (Exception e)
                                {
                                    throw e;
                                }
                            }
                            return true;
                        }
                    });

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

            try
            {
                PreferenceManager pm = PreferenceManager;
                Method method = pm.Class.GetDeclaredMethod(
                        "registerOnActivityDestroyListener",
                        Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = builder.Build();
            if (state != null)
                mDialog.OnRestoreInstanceState(state);
            mDialog.Show();
        }
        protected override void ShowDialog(Bundle state)
        {
            List<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)
                    .SetCallback(new ButtonCallback()
                    {
                        Neutral = (x) =>
                        {
                            OnClick(x, (int)DialogButtonType.Neutral);
                        },
                        Negative = (x) =>
                        {
                            OnClick(x, (int)DialogButtonType.Negative);
                        },
                        Positive = (x) =>
                        {
                            OnClick(x, (int)DialogButtonType.Positive);
                        }
                    })
                    .SetItems(GetEntries())
                    .SetItemsCallbackMultiChoice(indices.ToArray(), new ListCallbackMultiChoice
                    {
                        Selection = (dialog, which, text) =>
                        {
                            OnClick(null, (int)DialogButtonType.Positive);
                            dialog.Dismiss();
                            ISet<String> values = new HashSet<String>();
                            foreach (int i in which)
                            {
                                values.Add(GetEntryValues()[i]);
                            }
                            if (CallChangeListener((Java.Lang.Object)values))
                                Values = values;
                            return true;
                        }
                    }).SetDismissListener(this);

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

            try
            {
                PreferenceManager pm = PreferenceManager;
                Method method = pm.Class.GetDeclaredMethod(
                        "registerOnActivityDestroyListener",
                        Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = builder.Build();
            if (state != null)
                mDialog.OnRestoreInstanceState(state);
            mDialog.Show();
        }
示例#12
0
        protected override void ShowDialog(Bundle state)
        {
            if (GetEntries() == null || GetEntryValues() == null)
            {
                throw new InvalidOperationException(
                          "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)
                                             .SetDismissListener(this)
                                             .SetCallback(new ButtonCallback()
            {
                Neutral = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Neutral);
                },
                Negative = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Negative);
                },
                Positive = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Positive);
                }
            })
                                             .SetNegativeText(NegativeButtonText)
                                             .SetItems(GetEntries())
                                             .SetAutoDismiss(true)
                                             .SetItemsCallbackSingleChoice(preselect, new ListCallbackSingleChoice
            {
                Selection = (dialog, itemView, which, text) =>
                {
                    OnClick(null, (int)DialogButtonType.Positive);
                    if (which >= 0 && GetEntryValues() != null)
                    {
                        try
                        {
                            Field clickedIndex      = this.Class.GetDeclaredField("mClickedDialogEntryIndex");
                            clickedIndex.Accessible = true;
                            clickedIndex.Set(this, which);
                        }
                        catch (Exception e)
                        {
                            throw e;
                        }
                    }
                    return(true);
                }
            });

            View contentView = OnCreateDialogView();

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

            try
            {
                PreferenceManager pm     = PreferenceManager;
                Method            method = pm.Class.GetDeclaredMethod(
                    "registerOnActivityDestroyListener",
                    Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = builder.Build();
            if (state != null)
            {
                mDialog.OnRestoreInstanceState(state);
            }
            mDialog.Show();
        }