コード例 #1
0
        public void ShowOptions(string title, string[] options, Action <object> action = null, string cancelText = "")
        {
            AlertDialog dialog = null;

            AlertDialog.Builder builder = Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1
                ? new AlertDialog.Builder(Instance, Resource.Style.AppCompatDialogStyle)
                : new AlertDialog.Builder(Instance);

            RunOnUiThread(() =>
            {
                if (!IsFinishing)
                {
                    dialog = builder.SetTitle(title)
                             .SetItems(options, (sender, e) =>
                    {
                        action?.Invoke(options[e.Which]);
                    })
                             .SetNegativeButton(cancelText, (s, e) =>
                    {
                        dialog?.Dismiss();
                    })
                             .Show();
                }
            });
        }
コード例 #2
0
        public static void Stop()
        {
            _recordingDialog?.Dismiss();
            _recordingDialog = null;

            // stop recording
            try
            {
                _mic.Stop();
            }
            catch (Exception e)
            {
                Device.Log.Warn(e);
            }

            // prepare object for GC by calling dispose
            _mic.Release();
            _mic.Dispose();
            _mic = null;

            if (_callback != null)
            {
                DroidFactory.Navigate(new Link(_callback, new Dictionary <string, string>
                {
                    { CallbackParam, _callbackId },
                }));
            }
        }
コード例 #3
0
        public void Filter(string[] categories, int selected, Func <int, int> callback)
        {
            AlertDialog ad = null;
            var         currentSelection = selected - 1;

            var top = Mvx.Resolve <IMvxAndroidCurrentTopActivity>();
            var act = top.Activity;

            var adb = new AlertDialog.Builder(act, _alertDialogThemeId);

            adb.SetCancelable(true);
            adb.SetTitle(Resource.String.activity_filter_title);

            if (categories.Length == 0)
            {
                adb.SetMessage(Resource.String.activity_filter_empty);
            }
            else
            {
                adb.SetSingleChoiceItems(categories, currentSelection,
                                         (sender, args) =>
                {
                    callback(args.Which + 1);
                    ad?.Dismiss();
                });
                //adb.SetPositiveButton("Выбрать",
                //    (sender, args) => callback(currentSelection));
            }
            adb.SetNegativeButton("Назад",
                                  (sender, args) => { });
            ad = adb.Show();
        }
コード例 #4
0
 /// <summary>
 /// Dispose the specified disposing.
 /// </summary>
 /// <returns>The dispose.</returns>
 /// <param name="disposing">If set to <c>true</c> disposing.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         // Dialog.Dispose() does not close an open dialog view so explicitly dismiss it before disposing
         _dialog?.Dismiss();
         _dialog?.Dispose();
         _dialog = null;
         _listView?.Dispose();
         _listView = null;
         _adapter?.Dispose();
         _adapter = null;
         _context = null;
         if (_notifyCollection != null)
         {
             _notifyCollection.CollectionChanged -= ItemsSourceCollectionChanged;
             _notifyCollection = null;
         }
         if (_selectedCollection != null)
         {
             _selectedCollection.CollectionChanged -= SelectedItems_CollectionChanged;
             _selectedCollection = null;
         }
         _indicatorView?.RemoveFromParent();
         _indicatorView?.SetImageDrawable(null);
         _indicatorView?.SetImageBitmap(null);
         _indicatorView?.Dispose();
         _indicatorView = null;
     }
     base.Dispose(disposing);
 }
コード例 #5
0
ファイル: MainActivity.cs プロジェクト: Clancey/SimpleSample
 void SetupApp()
 {
     App.Initialize();
     App.AlertFunction = (title, message) => {
         Toast.MakeText(this, $"{title} - {message}", ToastLength.Long).Show();
     };
     App.Invoker       = this.RunOnUiThread;
     App.OnShowSpinner = (text) => {
         if (spinnerDialog != null)
         {
             spinnerDialog.Dismiss();
         }
         spinnerDialog = new ProgressDialog.Builder(this).SetMessage(text).SetCancelable(false).Show();
     };
     App.OnDismissSpinner = () => {
         spinnerDialog?.Dismiss();
         spinnerDialog = null;
     };
 }
コード例 #6
0
        private void SelectWeek()
        {
            var builder = new AlertDialog.Builder(this);

            AlertDialog dialog = null;

            dialog = builder.SetTitle(Resource.String.WeekSelection)
                     .SetSingleChoiceItems(
                this.ViewModel.Weeks.Select(t => t.ToString()).ToArray(),
                this.ViewModel.Weeks.IndexOf(this.ViewModel.CurrentWeek),
                (sender, args) =>
            {
                this.ViewModel.CurrentWeek = this.ViewModel.Weeks[args.Which];

                dialog?.Dismiss();
            })
                     .Create();
            dialog.Show();
        }
コード例 #7
0
        public void SetupEverything()
        {
            if (IsSetup)
            {
                return;
            }
            IsSetup = true;

            Xamarin.Insights.Initialize(ApiConstants.InsightsApiKey, this);
            var appInfo = this.ApplicationInfo;

            App.Context        = this;
            App.Invoker        = RunOnUiThread;
            App.DoPushFragment = (f) =>
            {
                Navigate(f);
            };
            App.OnShowSpinner = (text) => {
                if (spinnerDialog != null)
                {
                    spinnerDialog.Dismiss();
                }
                spinnerDialog = new ProgressDialog.Builder(this).SetMessage(text).SetCancelable(false).Show();
            };
            App.OnDismissSpinner = () => {
                spinnerDialog?.Dismiss();
                spinnerDialog = null;
            };

            //Downloader.Init ();
            //Settings.Init (this);
            //var metrics = new DisplayMetrics();
            //WindowManager.DefaultDisplay.GetMetrics(metrics);

            CheckApi();
        }
コード例 #8
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.NotificationSettingsLayout);

            client = new MobileServiceClient(Backend_Endpoint);
            CurrentPlatform.Init();
            await InitLocalStoreAsync();

            tab = client.GetSyncTable <Currencies>();

            ISharedPreferences pref = Application.Context.GetSharedPreferences("ListPref", FileCreationMode.Private);
            var listJsonString      = pref.GetString("list", string.Empty);

            listNames  = new List <string>();
            listValues = new List <string>();
            listOver   = new List <bool>();

            if (listJsonString != string.Empty)
            {
                var list = JsonConvert.DeserializeObject <List <ListForSharedPref> >(listJsonString);

                for (var i = 0; i < list.Count; i++)
                {
                    listNames.Add(list[i].Name);
                    listValues.Add(RemoveComas(list[i].Value));
                    listOver.Add(list[i].OverOrUnder);
                }
            }
            else
            {
                listNames  = PrepareData.selectedCurrencies_Names;
                listValues = PrepareData.selectedCurrencies_Values;
                listOver   = PrepareData.selectedCurrencies_Over;
                //domyslnie slidery na false
            }

            //textboxy od góry do do³u, zeby nie mieszac
            tb1 = FindViewById <EditText>(Resource.Id.textBox1);
            tb2 = FindViewById <EditText>(Resource.Id.textBox2);
            tb3 = FindViewById <EditText>(Resource.Id.textBox3);
            tb4 = FindViewById <EditText>(Resource.Id.textBox4);
            tb5 = FindViewById <EditText>(Resource.Id.textBox5);

            tv1 = FindViewById <TextView>(Resource.Id.curr1);
            tv2 = FindViewById <TextView>(Resource.Id.curr2);
            tv3 = FindViewById <TextView>(Resource.Id.curr3);
            tv4 = FindViewById <TextView>(Resource.Id.curr4);
            tv5 = FindViewById <TextView>(Resource.Id.curr5);

            sw1 = FindViewById <Switch>(Resource.Id.sw1);
            sw2 = FindViewById <Switch>(Resource.Id.sw2);
            sw3 = FindViewById <Switch>(Resource.Id.sw3);
            sw4 = FindViewById <Switch>(Resource.Id.sw4);
            sw5 = FindViewById <Switch>(Resource.Id.sw5);

            switches = new List <Switch> {
                sw1, sw2, sw3, sw4, sw5
            };

            btn_ok = FindViewById <Button>(Resource.Id.btn_okNotSettings);

            mLay = FindViewById <LinearLayout>(Resource.Id.mLayout);
            rLayInsideScrollView = FindViewById <RelativeLayout>(Resource.Id.rLay_insideScrollview);

            mLay.Click += HideKb;
            rLayInsideScrollView.Click += HideKb;
            sw1.Click += HideKb;
            sw2.Click += HideKb;
            sw3.Click += HideKb;
            sw4.Click += HideKb;
            sw5.Click += HideKb;

            btn_ok.Click += Btn_ok_Click;

            edit_Boxes = new List <EditText>()
            {
                tb1, tb2, tb3, tb4, tb5
            };
            text_Views = new List <TextView>()
            {
                tv1, tv2, tv3, tv4, tv5
            };

            var listUserValuesJson = pref.GetString("userValues", string.Empty);
            var listUserValues     = new List <string>();

            for (var i = 0; i < listNames.Count; i++)
            {
                listUserValues.Add(string.Empty);
            }

            if (listUserValuesJson != string.Empty)
            {
                listUserValues = JsonConvert.DeserializeObject <List <string> >(listUserValuesJson);
            }

            if (listNames.Count != 0 && listValues.Count != 0 && listOver.Count != 0)
            {
                for (var i = 0; i < listNames.Count; i++)
                {
                    text_Views[i].Text       = listNames[i];
                    text_Views[i].Visibility = ViewStates.Visible;
                    edit_Boxes[i].Text       = (listUserValues[i] != string.Empty)? listUserValues[i] : listValues[i];
                    edit_Boxes[i].Visibility = ViewStates.Visible;
                    switches[i].Checked      = listOver[i];
                    switches[i].Visibility   = ViewStates.Visible;
                }
            }
            else
            {
                AlertDialog.Builder dlg   = new AlertDialog.Builder(this);
                AlertDialog         alert = dlg.Create();
                alert.SetTitle("Brak walut");
                var intent = new Intent(this, typeof(MainActivity));
                alert.SetButton("Ok", delegate
                {
                    alert.Dismiss();
                    this.StartActivity(intent);
                });
                alert.SetMessage("W menu walut, wybierz najpierw waluty, które chcesz œledziæ");
                alert.Show();
            }
        }
コード例 #9
0
ファイル: Dialog.cs プロジェクト: yongburenshu004/Verify
        private static void ShowGroup()
        {
            if (appInfo.data.group_style == 0 || appInfo.data.group_style == 1)
            {
                RelativeLayout relativeLayout = new RelativeLayout(Base);
                view = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_group_style_right.xml"), relativeLayout);
                auth = new AlertDialog.Builder(Base, 4)
                       .SetView(relativeLayout)
                       .SetCancelable(false)
                       .Show();
                auth.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent);
                CardView cardView = (CardView)view.FindViewWithTag("view");
                cardView.Radius               = 45;
                cardView.Elevation            = 1;
                cardView.PreventCornerOverlap = false;
                GradientDrawable gd1 = new GradientDrawable();
                gd1.SetCornerRadius(45);
                gd1.SetColor(appInfo.data.group_style == 0 ? Color.White : Color.Black);
                cardView.Background = gd1;
                ImageView v = (ImageView)view.FindViewWithTag("image");
                HttpApi.LoadImage2("http://q2.qlogo.cn/headimg_dl?dst_uin=" + appInfo.data.qq_key + "&spec=100", v);
                if (appInfo.data.group_style == 1)
                {
                    ((TextView)view.FindViewWithTag("title")).SetTextColor(Color.White);
                    ((TextView)view.FindViewWithTag("msg")).SetTextColor(Color.White);
                    ((Button)view.FindViewWithTag("start")).SetTextColor(Color.White);
                    ((Button)view.FindViewWithTag("qq")).SetTextColor(Color.White);
                    ((Button)view.FindViewWithTag("more")).SetTextColor(Color.White);
                    ((Button)view.FindViewWithTag("group")).SetTextColor(Color.White);
                }
                ((TextView)view.FindViewWithTag("title")).SetText(appInfo.data.title, BufferType.Normal);
                ((TextView)view.FindViewWithTag("msg")).SetText(appInfo.data.notice, BufferType.Normal);
                if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count)
                {
                    ((Button)view.FindViewWithTag("start")).SetText("进入软件", BufferType.Normal);
                }
                view.FindViewWithTag("start").Click += (delegate
                {
                    if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count)
                    {
                        if (auth != null)
                        {
                            auth.Dismiss();
                        }
                        HookView.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        Intent intent = new Intent("android.intent.action.SEND");
                        intent.SetType("text/plain");
                        intent.PutExtra(Intent.ExtraSubject, "分享");
                        intent.PutExtra(Intent.ExtraText, appInfo.data.share_msg);
                        intent.SetFlags(ActivityFlags.NewTask);
                        intent.SetComponent(new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity"));
                        Base.StartActivity(intent);
                        new Handler().PostDelayed(() =>
                        {
                            edit.PutInt("Share_Count", share.GetInt("Share_Count", 0) + 1);
                            edit.Apply();
                            Toast.MakeText(Base, "你已分享 " + share.GetInt("Share_Count", 0) + " / " + appInfo.data.share_count + "次", ToastLength.Long).Show();
                        }, 7000);
                    }
                });
                view.FindViewWithTag("group").Click += (delegate
                {
                    Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + appInfo.data.group_key + "&card_type=group&source=qrcode"));
                    Base.StartActivity(browserIntent);
                });
                view.FindViewWithTag("qq").Click += (delegate
                {
                    Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqwpa://im/chat?chat_type=wpa&uin=" + appInfo.data.qq_key));
                    Base.StartActivity(browserIntent);
                });
                view.FindViewWithTag("more").Click += (delegate
                {
                    Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.more_url));
                    Base.StartActivity(browserIntent);
                });
            }
            else if (appInfo.data.group_style == 2)
            {
                RelativeLayout relativeLayout = new RelativeLayout(Base);
                view = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_group.xml"), relativeLayout);
                ((TextView)view.FindViewWithTag("Title")).SetText(appInfo.data.title, BufferType.Normal);
                ((TextView)view.FindViewWithTag("Tips")).SetText(appInfo.data.notice, BufferType.Normal);
                TextView Count = (TextView)view.FindViewWithTag("Count");
                Count.SetText("你已分享 " + share.GetInt("Share_Count", 0) + " / " + appInfo.data.share_count + "次", BufferType.Normal);
                GradientDrawable gd1 = new GradientDrawable();
                gd1.SetCornerRadius(100);
                gd1.SetColor(Color.ParseColor("#FF237686"));
                view.FindViewWithTag("Start1").Background = gd1;

                GradientDrawable gd = new GradientDrawable();
                gd.SetCornerRadius(50);
                gd.SetStroke(3, Color.White);
                view.FindViewWithTag("bottom").Background = gd;

                TextView Group = (TextView)view.FindViewWithTag("Group");
                TextView QQ    = (TextView)view.FindViewWithTag("QQ");
                TextView More  = (TextView)view.FindViewWithTag("More");
                if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count)
                {
                    ((TextView)view.FindViewWithTag("Start")).SetText("进入软件", BufferType.Normal);
                }
                view.FindViewWithTag("Start").Click += (delegate
                {
                    if (share.GetInt("Share_Count", 0) >= appInfo.data.share_count)
                    {
                        if (auth != null)
                        {
                            auth.Dismiss();
                        }
                        HookView.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        Intent intent = new Intent("android.intent.action.SEND");
                        intent.SetType("text/plain");
                        intent.PutExtra(Intent.ExtraSubject, "分享");
                        intent.PutExtra(Intent.ExtraText, appInfo.data.share_msg);
                        intent.SetFlags(ActivityFlags.NewTask);
                        intent.SetComponent(new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity"));
                        Base.StartActivity(intent);
                        new Handler().PostDelayed(() =>
                        {
                            edit.PutInt("Share_Count", share.GetInt("Share_Count", 0) + 1);
                            edit.Apply();
                            Count.SetText("你已分享 " + share.GetInt("Share_Count", 0) + " / " + appInfo.data.share_count + "次", BufferType.Normal);
                        }, 7000);
                    }
                });
                Group.Click += (delegate
                {
                    Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + appInfo.data.group_key + "&card_type=group&source=qrcode"));
                    Base.StartActivity(browserIntent);
                });
                QQ.Click += (delegate
                {
                    Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse("mqqwpa://im/chat?chat_type=wpa&uin=" + appInfo.data.qq_key));
                    Base.StartActivity(browserIntent);
                });
                More.Click += (delegate
                {
                    Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.more_url));
                    Base.StartActivity(browserIntent);
                });
                Group.SetOnTouchListener(new Touch());
                QQ.SetOnTouchListener(new Touch());
                More.SetOnTouchListener(new Touch());
                RoundImageView v = (RoundImageView)view.FindViewWithTag("img");
                HttpApi.LoadImage("http://q2.qlogo.cn/headimg_dl?dst_uin=" + appInfo.data.qq_key + "&spec=100", v);
                auth = new AlertDialog.Builder(Base, 4)
                       .SetView(relativeLayout)
                       .SetCancelable(false)
                       .Show();
                auth.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent);
                auth.Window.SetLayout(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            }
        }
コード例 #10
0
        public virtual void OnFilePrompt(GeckoSession session, string title, int type, string[] mimeTypes, GeckoSession.PromptDelegateClassFileCallback callback)
        {
            var currentActivity = BlazorWebViewService.GetCurrentActivity();

            AlertDialog _futureDialog = null; //Workaround dismiss method not available on AlertDialog.Builder before Show();

            bool shouldDismiss = true;

            var dialogBuilder = new Android.App.AlertDialog.Builder(_renderer.Context);
            BlazorFileDialogDismissListener onDismissEvent = new BlazorFileDialogDismissListener();

            onDismissEvent.SetDismissHandler(() =>
            {
                if (shouldDismiss)
                {
                    callback.Dismiss();
                }

                dialogBuilder.Dispose();
            });

            dialogBuilder.SetOnDismissListener(onDismissEvent);

            GetContentCompatibleIntents(type, out List <IntentMetadata> intentList, out List <ResolveInfo> activitiesInfo);
            dialogBuilder.SetAdapter(BuilderAdapter(currentActivity, activitiesInfo),
                                     (sender, e) =>
            {
                //On Intent click

                shouldDismiss = false;
                IntentMetadata selectedIntent = intentList.ElementAt(e.Which);

                //Check for Android permissions for intents
                RequestPermissionHelper.CheckForPermission(selectedIntent.RequiredPermissions, () =>
                {
                    //On Intent permission availables

                    //We must manage multiple file selection too

                    //TODO: Even by adding this intent
                    //this seem to not working yet. Not sure if possible through launching external intents
                    if (type == FilePromptType.MULTIPLE)
                    {
                        selectedIntent.Intent.PutExtra(Intent.ExtraAllowMultiple, true);
                    }

                    currentActivity.StartActivityForResult(selectedIntent.Intent, 1, (int requestCode, Result resultCode, Intent data) =>
                    {
                        if (resultCode != Result.Ok)
                        {
                            //Do nothing as the user is still now on the Intent dialog box chooser

                            //As on Permission not granted, see comment below =>
                            //We should reset this value to true if denied, as the user may don't click on Cancel but use a back button instead
                            //As the back button will call the Dialog dismiss internally, we should emulate the cancel behavior (see SetNeutralButton code)
                            shouldDismiss = true;
                        }
                        else
                        {
                            try
                            {
                                callback.Confirm(currentActivity, GetFileForBrowser(data.Data));
                            }
                            catch (System.Exception e)
                            {
                                ConsoleHelper.WriteException(e);
                                callback.Dismiss();
                            }

                            _futureDialog.Dismiss();
                        }
                    });
                }, () =>
                {
                    //On Intent permission unavailable

                    //We should reset this value to true if denied, as the user may don't click on Cancel but use a back button instead
                    //As the back button will call the Dialog dismiss internally, we should emulate the cancel behavior (see SetNeutralButton code)
                    shouldDismiss = true;
                });
            });


            dialogBuilder.SetNeutralButton(currentActivity.Resources.GetString(Android.Resource.String.Cancel),
                                           (sender, e) =>
            {
                shouldDismiss = true;
                _futureDialog.Dismiss();
            });
            shouldDismiss = true;
            _futureDialog = dialogBuilder.Show();
        }
コード例 #11
0
 public void Dismiss()
 {
     _dialog?.Dismiss();
     _dialog = null;
 }
コード例 #12
0
 /// <summary>
 /// Dismisses the text input dialog
 /// </summary>
 public void DismissInputDialog()
 {
     inputDialog?.Dismiss();
     inputDialog = null;
 }
コード例 #13
0
        private bool Alert(Color backgroundcolor, Color fontColor, string title, string content, bool isGetInput, string positiveButton, string negativeButton, string neutralButton, Action <string> callback, InputConfig config)
        {
            bool alercon = false;

            if (ModernAlertsHelper.currentActivity == null)
            {
                throw new Exception("Call ModernAlertHelper.GetInstance().Init(this) in your MainActivity");
            }
            try
            {
                AlertDialog alertdialog = null;
                ModernAlertsHelper.currentActivity.RunOnUiThread(() =>
                {
                    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ModernAlertsHelper.currentActivity);

                    LayoutInflater inflater = ModernAlertsHelper.currentActivity.LayoutInflater;
                    var alertLayout         = inflater.Inflate(Resource.Layout.customized_alertdialog, null);
                    dialogBuilder.SetView(alertLayout);
                    var header      = alertLayout.FindViewById <TextView>(Resource.Id.header);
                    LinearLayout bv = (LinearLayout)alertLayout.FindViewById(Resource.Id.body_view);
                    var lineheader  = alertLayout.FindViewById(Resource.Id.lineheader);
                    lineheader.SetBackgroundColor(fontColor.ToAndroid());
                    var linebody = alertLayout.FindViewById(Resource.Id.linebody);
                    linebody.SetBackgroundColor(fontColor.ToAndroid());
                    var root        = alertLayout.FindViewById <LinearLayout>(Resource.Id.root);
                    var body        = alertLayout.FindViewById <TextView>(Resource.Id.body);
                    var buttons     = alertLayout.FindViewById <LinearLayout>(Resource.Id.buttons);
                    var button1     = alertLayout.FindViewById <Android.Widget.Button>(Resource.Id.positinvebutton);
                    var getinput_et = alertLayout.FindViewById <Android.Widget.EditText>(Resource.Id.getinput_et);

                    getinput_et.SetHintTextColor(Color.Gray.ToAndroid());

                    header.Text = title;
                    if (string.IsNullOrEmpty(content))
                    {
                        bv.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        body.Text = content;
                    }
                    header.SetTextColor(fontColor.ToAndroid());
                    body.SetTextColor(fontColor.ToAndroid());
                    buttons.SetBackgroundColor(backgroundcolor.ToAndroid());
                    root.SetBackgroundColor(backgroundcolor.ToAndroid());
                    button1.Visibility = ViewStates.Visible;
                    button1.Text       = positiveButton;
                    button1.SetTextColor(fontColor.ToAndroid());
                    button1.Click += ((si, e) =>
                    {
                        if (isGetInput)
                        {
                            if (!string.IsNullOrEmpty(getinput_et.Text))
                            {
                                callback(getinput_et.Text);
                                alertdialog.Dismiss();
                            }
                        }
                        else
                        {
                            callback(positiveButton);
                            alertdialog.Dismiss();
                        }
                    });
                    if (isGetInput)
                    {
                        if (config != null && config.MinLength != 0)
                        {
                            //button1.Background.Alpha = 100;
                            button1.Enabled          = false;
                            getinput_et.TextChanged += (w, me) =>
                            {
                                if (getinput_et.Text.Trim().Length >= config.MinLength)
                                {
                                    button1.Enabled = true;
                                    //button1.Background.Alpha = 0;
                                    button1.SetTextColor(fontColor.ToAndroid());
                                }
                                else
                                {
                                    //button1.Background.Alpha = 50;
                                    button1.SetTextColor(Color.Gray.ToAndroid());
                                    button1.Enabled = false;
                                }
                            };
                        }
                    }

                    if (isGetInput)
                    {
                        var getinputll = alertLayout.FindViewById <LinearLayout>(Resource.Id.get_input_view);

                        if (config != null)
                        {
                            getinput_et.SetBackgroundColor(config.BackgroundColor.ToAndroid());
                            getinput_et.SetTextColor(config.FontColor.ToAndroid());
                            getinput_et.Hint = config.placeholder;
                            if (config.keyboard == Keyboard.Telephone)
                            {
                                getinput_et.InputType = InputTypes.ClassPhone;
                            }
                            else if (config.keyboard == Keyboard.Numeric)
                            {
                                getinput_et.InputType = InputTypes.ClassNumber;
                            }
                            else if (config.keyboard == Keyboard.Text)
                            {
                                if (config.isMultipleLine)
                                {
                                    setMultiLine(getinput_et);
                                }
                                else
                                {
                                    getinput_et.InputType = InputTypes.ClassText;
                                }
                            }
                            else if (config.keyboard == Keyboard.Email)
                            {
                                getinput_et.InputType = InputTypes.TextVariationEmailAddress;
                            }
                            if (config.MaxLength != 0)
                            {
                                getinput_et.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(config.MaxLength) });
                            }
                        }
                        getinputll.Visibility = ViewStates.Visible;
                        if (string.IsNullOrEmpty(content))
                        {
                            LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
                            ll.SetMargins(0, 30, 0, 0);
                            getinputll.LayoutParameters = ll;
                        }
                    }
                    if (negativeButton != null)
                    {
                        var button2        = alertLayout.FindViewById <Android.Widget.Button>(Resource.Id.negativebutton);
                        button2.Visibility = ViewStates.Visible;
                        button2.Text       = negativeButton;
                        button2.SetTextColor(fontColor.ToAndroid());
                        button2.Click += ((si, e) =>
                        {
                            callback(negativeButton);
                            alertdialog.Dismiss();
                        });

                        var second_separator_line = alertLayout.FindViewById(Resource.Id.second_separator_line);
                        second_separator_line.SetBackgroundColor(fontColor.ToAndroid());
                        second_separator_line.Visibility = ViewStates.Visible;
                    }
                    if (neutralButton != null)
                    {
                        var button3        = alertLayout.FindViewById <Android.Widget.Button>(Resource.Id.neutralbutton);
                        button3.Visibility = ViewStates.Visible;
                        button3.Text       = neutralButton;
                        button3.SetTextColor(fontColor.ToAndroid());
                        button3.Click += ((si, e) =>
                        {
                            callback(neutralButton);
                            alertdialog.Dismiss();
                        });
                        var first_separator_line = alertLayout.FindViewById(Resource.Id.first_separator_line);
                        first_separator_line.SetBackgroundColor(fontColor.ToAndroid());
                        first_separator_line.Visibility = ViewStates.Visible;
                    }
                    alertdialog = dialogBuilder.Create();
                    if (isGetInput)
                    {
                        alertdialog.Window.SetSoftInputMode(SoftInput.StateAlwaysVisible);
                    }
                    alertdialog.Show();
                    if (config != null && !string.IsNullOrEmpty(config.DefaultValue))
                    {
                        getinput_et.Text = config.DefaultValue;
                        getinput_et.SetSelection(getinput_et.Text.Length);
                    }
                    ShowShadow(alertdialog);
                });
            }
            catch (Exception e)
            {
                throw e;
            }
            return(alercon);
        }
コード例 #14
0
        private async void Set_location_Click(object sender, EventArgs e)
        {
            Final_Position = googleMap.CameraPosition.Target;
            try
            {
                loader.Visibility    = Android.Views.ViewStates.Visible;
                set_location.Enabled = false;

                var Issue = JsonConvert.DeserializeObject <Pothole>(Intent.GetStringExtra("objtopass"));
                Issue.locationLatitude  = Final_Position.Latitude.ToString();
                Issue.locationLongitude = Final_Position.Longitude.ToString();
                Issue.Status            = "unverified";
                Issue.issueType         = "Pothole";
                Issue.isWorkingStarted  = 0;

                Issue.amount_collected = 0;
                Issue.estimated_cost   = 0;
                Issue.issueFlag        = new Control.IssueFlagDetector().DetectPotholeFlag(Issue);

                try
                {
                    mapFuncHelper = new MapFunctions.MapFunctionHelper(APIKEY, googleMap);
                    var LocationName = await mapFuncHelper.FindCordinateAddress(Final_Position);

                    if (LocationName == " ")
                    {
                        loader.Visibility    = Android.Views.ViewStates.Gone;
                        set_location.Enabled = true;
                        Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                        AlertDialog alert = dialog.Create();
                        alert.SetTitle("Zoom In");
                        alert.SetMessage("Please be more specific when selecting location, you can zoom in the map to point the exact location.");
                        alert.SetButton("OK", (c, ev) =>
                        {
                            alert.Dismiss();
                        });
                        alert.Show();
                    }
                    else
                    {
                        Issue.issueStatement = "Pothole " + Issue.waterLevel + " near " + LocationName;
                        Issue.location_name  = LocationName;
                        //
                        Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                        AlertDialog alert = dialog.Create();
                        //alert.SetContentView(Resource.Layout.createisue3);
                        alert.SetMessage("Please wait while your issue is being posted ...");
                        alert.Show();

                        _ = Control.IssueController.PostIssue <Model.Pothole>(Issue, this);
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
                }
            }



            catch (Exception)
            {
                Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                AlertDialog alert = dialog.Create();
                alert.SetTitle("Select Location");
                alert.SetMessage("Please select issue location by dragging pin on Issue Location");
                alert.SetButton("OK", (c, ev) =>
                {
                    alert.Dismiss();
                });
                alert.Show();
                set_location.Enabled = true;
                loader.Visibility    = Android.Views.ViewStates.Gone;
            }
        }
コード例 #15
0
 private void NoButton(object sender, DialogClickEventArgs e)
 {
     alert.Dismiss();
 }
        private void StopEditTransaction(object sender, EventArgs e)
        {
            // Create a dialog to prompt the user to commit or rollback
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);

            // Create the layout
            LinearLayout dialogLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            // Create a button to commit edits
            Button commitButton = new Button(this)
            {
                Text = "Commit"
            };

            // Handle the click event for the Commit button
            commitButton.Click += (s, args) =>
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, commit the transaction to store the edits (this will also end the transaction)
                    _localGeodatabase.CommitTransaction();
                    _messageTextBlock.Text = "Edits were committed to the local geodatabase.";
                }

                _stopEditDialog.Dismiss();
            };

            // Create a button to rollback edits
            Button rollbackButton = new Button(this)
            {
                Text = "Rollback"
            };

            // Handle the click event for the Rollback button
            rollbackButton.Click += (s, args) =>
            {
                // See if there is a transaction active for the geodatabase
                if (_localGeodatabase.IsInTransaction)
                {
                    // If there is, rollback the transaction to discard the edits (this will also end the transaction)
                    _localGeodatabase.RollbackTransaction();
                    _messageTextBlock.Text = "Edits were rolled back and not stored to the local geodatabase.";
                }

                _stopEditDialog.Dismiss();
            };

            // Create a button to cancel and return to the transaction
            Button cancelButton = new Button(this)
            {
                Text = "Cancel"
            };

            // Handle the click event for the Cancel button
            rollbackButton.Click += (s, args) => _stopEditDialog.Dismiss();

            // Add the controls to the dialog
            dialogLayout.AddView(cancelButton);
            dialogLayout.AddView(rollbackButton);
            dialogLayout.AddView(commitButton);
            dialogBuilder.SetView(dialogLayout);
            dialogBuilder.SetTitle("Stop Editing");

            // Show the dialog
            _stopEditDialog = dialogBuilder.Show();
        }
コード例 #17
0
        private async void TakeMapOfflineButton_Click(object sender, EventArgs e)
        {
            // Create a path for the output mobile map.
            string tempPath = $"{Path.GetTempPath()}";

            string[] outputFolders = Directory.GetDirectories(tempPath, "NapervilleWaterNetwork*");

            // Loop through the folder names and delete them.
            foreach (string dir in outputFolders)
            {
                try
                {
                    // Delete the folder.
                    Directory.Delete(dir, true);
                }
                catch (Exception)
                {
                    // Ignore exceptions (files might be locked, for example).
                }
            }

            // Create a new folder for the output mobile map.
            string packagePath = Path.Combine(tempPath, @"NapervilleWaterNetwork");
            int    num         = 1;

            while (Directory.Exists(packagePath))
            {
                packagePath = Path.Combine(tempPath, @"NapervilleWaterNetwork" + num.ToString());
                num++;
            }

            // Create the output directory.
            Directory.CreateDirectory(packagePath);

            try
            {
                // Show the progress dialog while the job is running.
                _alertDialog.Show();

                // Create an offline map task with the current (online) map.
                OfflineMapTask takeMapOfflineTask = await OfflineMapTask.CreateAsync(_mapView.Map);

                // Create the default parameters for the task, pass in the area of interest.
                GenerateOfflineMapParameters parameters = await takeMapOfflineTask.CreateDefaultGenerateOfflineMapParametersAsync(_areaOfInterest);

                // Create the job with the parameters and output location.
                _generateOfflineMapJob = takeMapOfflineTask.GenerateOfflineMap(parameters, packagePath);

                // Handle the progress changed event for the job.
                _generateOfflineMapJob.ProgressChanged += OfflineMapJob_ProgressChanged;

                // Await the job to generate geodatabases, export tile packages, and create the mobile map package.
                GenerateOfflineMapResult results = await _generateOfflineMapJob.GetResultAsync();

                // Check for job failure (writing the output was denied, e.g.).
                if (_generateOfflineMapJob.Status != JobStatus.Succeeded)
                {
                    // Report failure to the user.
                    ShowStatusMessage("Failed to take the map offline.");
                }

                // Check for errors with individual layers.
                if (results.LayerErrors.Any())
                {
                    // Build a string to show all layer errors.
                    System.Text.StringBuilder errorBuilder = new System.Text.StringBuilder();
                    foreach (KeyValuePair <Layer, Exception> layerError in results.LayerErrors)
                    {
                        errorBuilder.AppendLine(string.Format("{0} : {1}", layerError.Key.Id, layerError.Value.Message));
                    }

                    // Show layer errors.
                    ShowStatusMessage(errorBuilder.ToString());
                }

                // Display the offline map.
                _mapView.Map = results.OfflineMap;

                // Apply the original viewpoint for the offline map.
                _mapView.SetViewpoint(new Viewpoint(_areaOfInterest));

                // Enable map interaction so the user can explore the offline data.
                _mapView.InteractionOptions.IsEnabled = true;

                // Change the title and disable the "Take map offline" button.
                _takeMapOfflineButton.Text    = "Map is offline";
                _takeMapOfflineButton.Enabled = false;
            }
            catch (TaskCanceledException)
            {
                // Generate offline map task was canceled.
                ShowStatusMessage("Taking map offline was canceled");
            }
            catch (Exception ex)
            {
                // Exception while taking the map offline.
                ShowStatusMessage(ex.Message);
            }
            finally
            {
                // Hide the loading overlay when the job is done.
                _alertDialog.Dismiss();
            }
        }
コード例 #18
0
ファイル: NoxViewModel.cs プロジェクト: fs0c131y/BitfiSources
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                try
                {
                    convertView = LayoutInflater.From(context).Inflate(Resource.Layout.overview, parent, false);
                    //  convertView.FindViewById\\(Resource.Id.ovt1).Typeface = typeface;
                    //  convertView.FindViewById\\(Resource.Id.ovt1b).Typeface = typeface;
                    convertView.FindViewById \ \ (Resource.Id.ovt2).Typeface = typeface;
                    convertView.FindViewById \ \ (Resource.Id.ovt3).Typeface = typeface;
                    if (action == "overview" && filtered != null)
                    {
                        TextView tv1 = convertView.FindViewById \ \ (Resource.Id.ovt1);
                        tv1.Text = filtered[position].Currency;
                        convertView.FindViewById \ \ (Resource.Id.ovt2).Text        = filtered[position].Balance;
                        convertView.FindViewById \ \ (Resource.Id.ovt3).Text        = filtered[position].USD;
                        convertView.FindViewById \ \ (Resource.Id.ovt1b).Visibility = ViewStates.Gone;
                        convertView.FindViewById \ \ (Resource.Id.ovt2).Visibility  = ViewStates.Visible;
                        convertView.FindViewById \ \ (Resource.Id.ovt3).Visibility  = ViewStates.Visible;
                        if (position == 0)
                        {
                            //              convertView.FindViewById\\(Resource.Id.ovt1b).SetTextColor(new Color(Resource.Color.black_overlay));
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).Text = "[refresh]";
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).SetTypeface(Typeface.Monospace, TypefaceStyle.Italic);
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).SetTextSize(Android.Util.ComplexUnitType.Sp, 13);
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).Visibility = ViewStates.Visible;
                            convertView.FindViewById \ \ (Resource.Id.ovt3).Visibility  = ViewStates.Gone;
                            convertView.FindViewById \ \ (Resource.Id.ovt2).Visibility  = ViewStates.Gone;
                        }

                        convertView.FindViewById \ \ (Resource.Id.ovt1b).Click += delegate {
                            if (position == 0)
                            {
                                convertView.FindViewById \ \ (Resource.Id.ovt1b).Enabled = false;
                                convertView.FindViewById \ \ (Resource.Id.ovt1).Enabled  = false;
                                activity.Recreate();
                            }
                        };
                        convertView.FindViewById \ \ (Resource.Id.ovt1).Click += delegate {
                            if (position == 0)
                            {
                                convertView.FindViewById \ \ (Resource.Id.ovt1b).Enabled = false;
                                convertView.FindViewById \ \ (Resource.Id.ovt1).Enabled  = false;
                                activity.Recreate();
                            }
                        };
                    }
                    if (action == "accounts" && NWSfiltered != null)
                    {
                        TextView tv1 = convertView.FindViewById \ \ (Resource.Id.ovt1);
                        tv1.Visibility = ViewStates.Gone;
                        convertView.FindViewById \ \ (Resource.Id.ovt2).Text = NWSfiltered[position].BlkNet.ToUpper();
                        convertView.FindViewById \ \ (Resource.Id.ovt3).Text = NWSfiltered[position].BTCAddress;
                        convertView.FindViewById \ \ (Resource.Id.ovt2).SetTextSize(Android.Util.ComplexUnitType.Sp, 16);
                        convertView.FindViewById \ \ (Resource.Id.ovt3).SetTextSize(Android.Util.ComplexUnitType.Sp, 13);

                        if (position == 0)
                        {
                            //  convertView.FindViewById\\(Resource.Id.ovt1b).SetTextColor(new Color(Resource.Color.black_overlay));
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).Text = "[balances]";
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).SetTypeface(Typeface.Monospace, TypefaceStyle.Italic);
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).SetTextSize(Android.Util.ComplexUnitType.Sp, 12);
                            convertView.FindViewById \ \ (Resource.Id.ovt1b).Visibility = ViewStates.Visible;
                            convertView.FindViewById \ \ (Resource.Id.ovt3).Visibility  = ViewStates.Gone;
                            convertView.FindViewById \ \ (Resource.Id.ovt2).Visibility  = ViewStates.Gone;
                            tv1.Visibility = ViewStates.Visible;
                            tv1.Text       = NWSfiltered[position].ViewKey;
                        }
                        convertView.FindViewById \ \ (Resource.Id.ovt1b).Click += delegate {
                            if (position == 0)
                            {
                                action = "overview";
                                activity.Recreate();
                            }
                        };
                        convertView.FindViewById(Resource.Id.ovinf).Click += delegate {
                            if (position \ > \ 0)
                            {
                                ImageView image = new ImageView(context);
                                image.SetImageBitmap(ConvertQr(NWSfiltered[position].BTCAddress, NWSfiltered[position].BlkNet));
                                AlertDialog.Builder builder = new AlertDialog.Builder(context).SetTitle(NWSfiltered[position].BlkNet.ToUpper()).SetMessage(NWSfiltered[position].BTCAddress).SetCancelable(true).SetPositiveButton("CLOSE", (EventHandler \ \)null);
                                AlertDialog         alert   = builder.Create();
                                alert.SetView(image);
                                alert.Show();
                                var okBtn = alert.GetButton((int)DialogButtonType.Positive);
                                okBtn.Click += (asender, args) = \ > \
                                {
                                    alert.Dismiss();
                                };
                            }
                        };
                    }
                }
                catch (Exception)
                {
                }
                return(convertView);
            }
コード例 #19
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var context = TaskScheduler.FromCurrentSynchronizationContext();

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var send     = FindViewById <Button>(Resource.Id.Send);
            var host     = FindViewById <Button>(Resource.Id.Host);
            var connect  = FindViewById <Button>(Resource.Id.Connect);
            var listView = FindViewById <ListView>(Resource.Id.dataList);
            var text     = FindViewById <EditText>(Resource.Id.sendText);
            var adapter  = new MessageAdapter();

            listView.Adapter = adapter;

            host.Click += (sender, e) =>
            {
                _progress = ProgressSpinner.Show(this, null, null, true, false);

                _service.Host(new MultiplayerGame
                {
                    Name = Build.Manufacturer.Trim() + " " + Build.Model.Trim(),
                })
                .ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        ShowPopUp("Error", t.Exception.InnerExceptions.First().Message);
                    }
                    else
                    {
                        ShowPopUp("Success", "You have hosted a game.");
                    }
                }, context);
            };

            connect.Click += (sender, e) =>
            {
                _progress = ProgressSpinner.Show(this, null, null, true, false);
                _service.FindGames()
                .ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        ShowPopUp("Error", t.Exception.InnerExceptions.First().Message);
                        return;
                    }

                    AlertDialog dialog = null;
                    var games          = t.Result.Select(g => g.Name).ToArray();
                    var builder        = new AlertDialog.Builder(this);
                    builder.SetTitle("Select Connection");
                    builder.SetSingleChoiceItems(games, -1, (s, o) =>
                    {
                        var game = t.Result.ElementAtOrDefault(o.Which);
                        if (game != null)
                        {
                            _progress = ProgressSpinner.Show(this, null, null, true, false);
                            dialog.Dismiss();
                            _service.Join(game).ContinueWith(c =>
                            {
                                if (c.IsFaulted)
                                {
                                    ShowPopUp("Error", c.Exception.InnerExceptions.First().Message);
                                }
                                else
                                {
                                    ShowPopUp("Success", "You have connected to the game.");
                                }
                            }, context);
                        }
                    });
                    dialog = builder.Create();
                    dialog.Show();
                    _progress.Dismiss();
                }, context);
            };

            send.Click += (sender, e) =>
            {
                var message = new TestMessage
                {
                    Text       = text.Text,
                    ShouldEcho = true,
                    TimeStamp  = DateTime.Now
                };

                _service.Send("T", message).ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        ShowPopUp("Error", t.Exception.InnerExceptions.First().Message);
                        return;
                    }
                }, context);
            };

            _service.Received += (sender, e) =>
            {
                var message = e.Message as TestMessage;
                if (message.ShouldEcho)
                {
                    adapter.Logs.Add("RECEIVED: " + message.Text);
                    adapter.NotifyDataSetChanged();
                    message.ShouldEcho = false;
                    _service.Send("T", message);
                }

                else
                {
                    adapter.Logs.Add("Send: " + message.Text + " Latency: " + message.RoundTripMillis);
                }
            };
        }
コード例 #20
0
        private bool ShowActionSheet(Color backgroundcolor, Color fontColor, string title, string[] content, string negativeButton, Action <string> callback)
        {
            bool alercon = false;

            if (ModernAlertsHelper.currentActivity == null)
            {
                throw new Exception("Call ModernAlertHelper.GetInstance().Init(this) in your MainActivity");
            }
            try
            {
                AlertDialog alertdialog = null;
                ModernAlertsHelper.currentActivity.RunOnUiThread(() =>
                {
                    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ModernAlertsHelper.currentActivity);
                    LayoutInflater inflater           = ModernAlertsHelper.currentActivity.LayoutInflater;
                    var convertView = inflater.Inflate(Resource.Layout.customized_alertdialog, null);
                    dialogBuilder.SetView(convertView);
                    LinearLayout bv            = (LinearLayout)convertView.FindViewById(Resource.Id.body_view);
                    LinearLayout listview_root = (LinearLayout)convertView.FindViewById(Resource.Id.listview_root);
                    listview_root.Visibility   = ViewStates.Visible;
                    bv.Visibility = ViewStates.Gone;
                    Android.Widget.ListView lv         = (Android.Widget.ListView)convertView.FindViewById(Resource.Id.listiview);
                    AlertDialogListViewAdapter adapter = new AlertDialogListViewAdapter(ModernAlertsHelper.currentActivity, content, backgroundcolor.ToAndroid(), fontColor.ToAndroid());
                    lv.Adapter = adapter;
                    lv.SetDrawSelectorOnTop(true);
                    lv.Divider       = new ColorDrawable(Color.LightGray.ToAndroid());
                    lv.DividerHeight = 2;
                    var header       = convertView.FindViewById <TextView>(Resource.Id.header);
                    var root         = convertView.FindViewById <LinearLayout>(Resource.Id.root);
                    var lineheader   = convertView.FindViewById(Resource.Id.lineheader);
                    lineheader.SetBackgroundColor(fontColor.ToAndroid());
                    var linebody = convertView.FindViewById(Resource.Id.linebody);
                    linebody.SetBackgroundColor(fontColor.ToAndroid());
                    //var leftSpacer = convertView.FindViewById<LinearLayout>(Resource.Id.leftSpacer);
                    //leftSpacer.Visibility = ViewStates.Visible;
                    var buttons = convertView.FindViewById <LinearLayout>(Resource.Id.buttons);
                    var button1 = convertView.FindViewById <Android.Widget.Button>(Resource.Id.positinvebutton);
                    header.SetTextColor(fontColor.ToAndroid());
                    header.Text = title;
                    buttons.SetBackgroundColor(backgroundcolor.ToAndroid());
                    root.SetBackgroundColor(backgroundcolor.ToAndroid());
                    button1.Visibility = ViewStates.Visible;
                    button1.Text       = negativeButton;
                    button1.SetTextColor(fontColor.ToAndroid());
                    button1.Click += ((si, e) =>
                    {
                        callback(negativeButton);
                        alertdialog.Dismiss();
                    });
                    lv.ItemClick += ((sd, w) =>
                    {
                        callback(content[w.Position]);
                        alertdialog.Dismiss();
                    });
                    lv.ItemSelected += ((sd, w) =>
                    {
                        callback(content[w.Position]);
                        alertdialog.Dismiss();
                    });
                    alertdialog = dialogBuilder.Create();
                    alertdialog.Show();
                    ShowShadow(alertdialog);
                });
            }
            catch (Exception e)
            {
                throw e;
            }
            return(alercon);
        }
コード例 #21
0
 private static void PlatformCancel(int?result)
 {
     alert.Dismiss();
     tcs.SetResult(result);
 }
コード例 #22
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.LayoutAnadirUsuario);

            btnAnadirUsuario = FindViewById <ImageButton>(Resource.Id.btnAnadirUsu);
            btnBorrarUsuario = FindViewById <ImageButton>(Resource.Id.btnBorrarUsu);
            btnAtrasUsers    = FindViewById <ImageButton>(Resource.Id.btnAtrasUsers);
            listaUsuarios    = FindViewById <ListView>(Resource.Id.listaUsuarios);

            rol       = Intent.GetStringExtra("Rol");
            nombre    = Intent.GetStringExtra("Nombre");
            nick      = Intent.GetStringExtra("Usuario");
            telefono  = Intent.GetStringExtra("Telefono");
            profesion = Intent.GetStringExtra("Profesion");
            idUsuario = Intent.GetStringExtra("Id");

            //Rellena el grid de usuarios
            mItems = ConsultaUsuariosBaseDatosByRol(rol);
            var usuarioActual = new Usuario(Convert.ToInt32(idUsuario), nombre, profesion, telefono, nick);
            MyListViewAdapterUsuarios myAdapter = new MyListViewAdapterUsuarios(this, mItems, usuarioActual);

            listaUsuarios.Adapter = myAdapter;

            btnAnadirUsuario.Click += delegate
            {
                //Nos lleva a la pantalla de registro
                Intent intent = new Intent(this, typeof(ActivityRegistro));
                intent.PutExtra("Rol", rol.ToString());
                intent.PutExtra("Id", idUsuario);
                intent.PutExtra("Usuario", nick);
                intent.PutExtra("Telefono", telefono);
                intent.PutExtra("Profesion", profesion);
                intent.PutExtra("Nombre", nombre);
                StartActivity(intent);
                Finish();
            };

            btnAtrasUsers.Click += delegate
            {
                Intent intent = new Intent(this, typeof(ActivityTareas));
                intent.PutExtra("Id", idUsuario);
                intent.PutExtra("Usuario", nick);
                intent.PutExtra("Telefono", telefono);
                intent.PutExtra("Profesion", profesion);
                intent.PutExtra("Nombre", nombre);
                StartActivity(intent);
                Finish();
            };


            btnBorrarUsuario.Click += delegate
            {
                //borrar con modal
                var alert = new AlertDialog.Builder(this);
                alert.SetCancelable(true);

                View customView = LayoutInflater.Inflate(Resource.Layout.LayoutModalBorrarUsuarios, null);
                alert.SetView(customView);

                var spUsuarios = (Spinner)customView.FindViewById(Resource.Id.spUsuariosBorrar);

                //Establece los items que habrá dentro del "ComboBox", que en este caso es un "Spinner", seran los usuarios a los que este cargo ese rol con el que hemos entrado
                List <Usuario>            items     = ConsultaUsuariosBaseDatosByRol(rol);
                MyListViewAdapterUsuarios adaptador = new MyListViewAdapterUsuarios(this, items, null, true);
                spUsuarios.Adapter = adaptador;

                if (items.Count > 0) //si viene con usuarios
                {
                    var btnCerrarModalBorrar  = (Button)customView.FindViewById(Resource.Id.btnCerrarModalBorrarUsu);
                    var btnBorrarUsuarioModal = (Button)customView.FindViewById(Resource.Id.btnBorrarUsuario);

                    dialog = alert.Show();
                    dialog.Create();
                    dialog.Window.SetLayout(750, 500);

                    btnCerrarModalBorrar.Click += delegate
                    {
                        dialog.Dismiss();
                    };

                    btnBorrarUsuarioModal.Click += delegate
                    {
                        usuarioSeleccionado = spUsuarios.SelectedItem.Cast <Usuario>();
                        BorraUsuarioById(usuarioSeleccionado.Id);

                        Toast.MakeText(ApplicationContext, "Se ha borrado el usuario con nick " + usuarioSeleccionado.Nick + " y con nombre " + usuarioSeleccionado.NombreUsuario, ToastLength.Long).Show();
                        dialog.Dismiss();

                        //RECARGAMOS EL GRID/LIST PRINCIPAL
                        mItems = ConsultaUsuariosBaseDatosByRol(rol);
                        MyListViewAdapterUsuarios adapter = new MyListViewAdapterUsuarios(this, mItems, null);
                        listaUsuarios.Adapter = adapter;
                    };
                }
                else
                {
                    Toast.MakeText(ApplicationContext, "No hay usuarios para borrar.", ToastLength.Long).Show();
                }
            };
        }
コード例 #23
0
 /// <summary>
 /// Dismisses the text / icon dialog
 /// </summary>
 public void DismissDialog()
 {
     iconDialog?.Dismiss();
     iconDialog = null;
 }
コード例 #24
0
            public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
            {
                View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.ExerciseRow, parent, false);
                // View deleteView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.DeleteItem, null);
                //View editView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.EditExerciseDialog, null);
                ExerciseListViewHolder viewHolder = new ExerciseListViewHolder(itemView, OnClick);

                //click event for delete
                viewHolder.deleteButton.Click += (sender, e) =>
                {
                    var pos          = viewHolder.AdapterPosition;;
                    var exerciseName = exercises[pos].name;

                    //make popup menu for confirmation of deleting from database
                    View deleteView             = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.DeleteItem, null);
                    AlertDialog.Builder builder = new AlertDialog.Builder(parent.Context);
                    builder.SetView(deleteView);
                    AlertDialog alertDialog = builder.Create();

                    Button   deleteButton = deleteView.FindViewById <Button>(Resource.Id.btnDelete);
                    Button   cancelButton = deleteView.FindViewById <Button>(Resource.Id.btnCancel);
                    TextView txtTitle     = deleteView.FindViewById <TextView>(Resource.Id.titleDelete);
                    txtTitle.Text = "Remove exercise from playlist?";

                    deleteButton.Click += delegate
                    {
                        dataBase.removeExerciseFromPlaylist(playlistName, exerciseName);
                        Toast.MakeText(parent.Context, exerciseName + " removed", ToastLength.Short).Show();
                        exercises.RemoveAt(pos);
                        NotifyDataSetChanged();
                        alertDialog.Dismiss();
                    };
                    cancelButton.Click += delegate
                    {
                        //close window
                        alertDialog.Dismiss();
                    };
                    alertDialog.Show();
                };

                //click event for edit
                viewHolder.editButton.Click += (sender, e) =>
                {
                    var  pos          = viewHolder.AdapterPosition;;
                    var  exerciseName = exercises[pos].name;
                    View editView     = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.EditExerciseDialog, null);

                    AlertDialog.Builder builder = new AlertDialog.Builder(parent.Context);
                    builder.SetView(editView);
                    AlertDialog alertDialog = builder.Create();

                    Button   okButton      = editView.FindViewById <Button>(Resource.Id.btnCreate);
                    Button   cancelButton  = editView.FindViewById <Button>(Resource.Id.btnCancel);
                    EditText txtName       = editView.FindViewById <EditText>(Resource.Id.txtExerciseName);
                    EditText txtSets       = editView.FindViewById <EditText>(Resource.Id.txtSets);
                    EditText txtReps       = editView.FindViewById <EditText>(Resource.Id.txtReps);
                    EditText txtWeight     = editView.FindViewById <EditText>(Resource.Id.txtWeight);
                    EditText txtEquipment  = editView.FindViewById <EditText>(Resource.Id.txtEquipment);
                    EditText txtTargetArea = editView.FindViewById <EditText>(Resource.Id.txtTargetArea);

                    //Put current values of the exercise in the dialog so its easy to see
                    //what they are when the user is editing the exercise
                    //if they have a value of N/A leave them blank so the text hint shows
                    txtName.Text = exercises[pos].name;
                    if (exercises[pos].sets != "0")
                    {
                        txtSets.Text = exercises[pos].sets.ToString();
                    }
                    if (exercises[pos].reps != "0")
                    {
                        txtReps.Text = exercises[pos].reps.ToString();
                    }
                    if (exercises[pos].weight != "N/A")
                    {
                        txtWeight.Text = exercises[pos].weight;
                    }
                    if (exercises[pos].equipment != "N/A")
                    {
                        txtEquipment.Text = exercises[pos].equipment;
                    }
                    if (exercises[pos].targetArea != "N/A")
                    {
                        txtTargetArea.Text = exercises[pos].targetArea;
                    }

                    okButton.Click += delegate
                    {
                        //Need a valid name, the rest can be 0 or N/A
                        if (string.IsNullOrEmpty(txtName.Text))
                        {
                            Toast.MakeText(parent.Context, "Please enter a valid name.", ToastLength.Short).Show();
                        }
                        if (string.IsNullOrEmpty(txtSets.Text))
                        {
                            txtSets.Text = "0";
                        }
                        if (string.IsNullOrEmpty(txtReps.Text))
                        {
                            txtReps.Text = "0";
                        }
                        if (string.IsNullOrEmpty(txtWeight.Text))
                        {
                            txtWeight.Text = "N/A";
                        }
                        if (string.IsNullOrEmpty(txtEquipment.Text))
                        {
                            txtEquipment.Text = "N/A";
                        }
                        if (string.IsNullOrEmpty(txtTargetArea.Text))
                        {
                            txtTargetArea.Text = "N/A";
                        }



                        if (dataBase.updateExercise(exerciseName, txtName.Text, txtSets.Text, txtReps.Text, txtWeight.Text, txtTargetArea.Text, txtEquipment.Text))
                        {
                            Toast.MakeText(parent.Context, "Exercise updated.", ToastLength.Short).Show();

                            //update exercise in recyclerview list to add to the recyclerview list

                            exercises[pos].name       = txtName.Text;
                            exercises[pos].sets       = txtSets.Text;
                            exercises[pos].reps       = txtReps.Text;
                            exercises[pos].weight     = txtWeight.Text;
                            exercises[pos].targetArea = txtTargetArea.Text;
                            exercises[pos].equipment  = txtEquipment.Text;

                            NotifyDataSetChanged();
                            alertDialog.Dismiss();
                        }
                        else
                        {
                            Toast.MakeText(parent.Context, "Name is taken.", ToastLength.Short).Show();
                        }
                    };
                    cancelButton.Click += delegate
                    {
                        alertDialog.Dismiss();
                    };
                    alertDialog.Show();
                };

                //click event for search
                //this will open the youtube app for the user to search
                //for the exercise they clicked on
                viewHolder.searchButton.Click += (sender, e) =>
                {
                    var     pos     = viewHolder.AdapterPosition;
                    var     name    = exercises[pos].name;
                    Context context = parent.Context;

                    //start new intent that will open the youtube app
                    //and display search results for specific exercise
                    Intent intent = new Intent(Intent.ActionSearch);
                    intent.SetPackage("com.google.android.youtube");
                    intent.PutExtra("query", name + " how to");
                    intent.SetFlags(ActivityFlags.NewTask);
                    context.StartActivity(intent);
                };
                return(viewHolder);
            }
コード例 #25
0
 /// <summary>
 /// Dismisses the searchable list dialog
 /// </summary>
 public void DismissSearchListDialog()
 {
     searchList?.Dismiss();
     searchList = null;
 }
コード例 #26
0
        private void CheckTollRoad()
        {
            if (!inTollRoad && !isExiting) //Toll Yolda Değilken Ve Çıkmıyor İken
            {                              //Toll Yola Girip Girmediğimizi Burdan Anlıyoruz
                foreach (Area tollAreaItem in tollAreaList.Where(x => x.isBooth))
                {
                    double dist = CommonMethods.GetDistance(tollAreaItem.areaLatitude, tollAreaItem.areaLongitude, currentLocation.Latitude, currentLocation.Longitude);
                    if (dist < avgApproximity && tollAreaItem.isBooth)
                    {
                        tollAreaExitList = dbOperations.GetAreaPassListWithDisctance(tollAreaItem.areaID).ReturnObject.OrderBy(x => x.distance).ToList();

                        if (tollAreaExitList.Count != 0)
                        {
                            NotificationList   = new List <ExitNotification>();
                            notificationLayout = FindViewById <LinearLayout>(Resource.Id.notificationLayout);
                            notificationLayout.RemoveAllViews();
                            dialog.Dismiss();
                            foreach (var exitItem in tollAreaExitList)
                            {
                                //bu liste giris sonrasi cikan kutulari yaratiyor
                                if (exitItem.isBooth)
                                {
                                    //eger exitItem gise ise listeye ekle
                                    notificationLayout.AddView(RoadNotification(exitItem.areaID));
                                }
                            }

                            //yola girildi olarak kayit atiliyor
                            inTollRoad        = true;
                            tollAreaEnter     = tollAreaItem;
                            tollAreaEnterTime = DateTime.Now;

                            break;
                        }
                    }
                }
            }
            else //Toll yola girdikten sonra
            {
                //Yolun İçindeyken ve cikis halinde degilken
                if (!isExiting)
                {
                    //her exit icin
                    foreach (var tollAreaItem in tollAreaExitList.ToList())
                    {
                        double           dist          = CommonMethods.GetDistance(tollAreaItem.areaLatitude, tollAreaItem.areaLongitude, currentLocation.Latitude, currentLocation.Longitude);
                        ExitNotification currentNotify = NotificationList.Where(x => x.areaID == tollAreaItem.areaID).FirstOrDefault();
                        notificationLayout = FindViewById <LinearLayout>(Resource.Id.notificationLayout);
                        if (tollAreaItem.isBooth)
                        {
                            LinearLayout Container = (LinearLayout)FindViewById(currentNotify.ContainerID);
                            if (Container != null)
                            {
                                TextView LeftText   = (TextView)FindViewById(currentNotify.LeftID);
                                TextView CenterText = (TextView)FindViewById(currentNotify.CenterID);
                                TextView RightText  = (TextView)FindViewById(currentNotify.RightID);
                                TextView UpperRight = (TextView)FindViewById(currentNotify.RightUpperID);
                                TimeSpan TimeLeft   = CommonMethods.GetMinutesLeft(tollAreaItem.distance, carMaxSpeed, tollAreaEnterTime);
                                Container.Visibility = ViewStates.Visible;

                                if (TimeLeft == TimeSpan.Zero)
                                {
                                    Container.SetBackgroundColor(Color.Argb(200, 39, 174, 96));
                                }

                                //kutularin icindeki verileri guncelle
                                LeftText.Text   = tollAreaItem.areaName;
                                CenterText.Text = CommonMethods.GetExitTime(tollAreaItem.distance, carMaxSpeed, tollAreaEnterTime).ToString("HH:mm");
                                RightText.Text  = TimeLeft != null && TimeLeft.Hours > 0 ? string.Format(timeDisplayFormatWithHour, TimeLeft.Hours, TimeLeft.Minutes, TimeLeft.Seconds) :
                                                  string.Format(timeDisplayFormat, TimeLeft.Minutes, TimeLeft.Seconds);

                                //eger cikisa gelinmis ise
                                if (dist < avgApproximity)
                                {
                                    //yaziyi degistir
                                    UpperRight.Text = "Çıkış Saati";

                                    //cikis saatini goster
                                    RightText.Text = DateTime.Now.ToString("HH:mm");

                                    //diger tum cikislari listeden cikar
                                    foreach (ExitNotification item2 in NotificationList)
                                    {
                                        if (item2.areaID != tollAreaItem.areaID)
                                        {
                                            LinearLayout delContainer = (LinearLayout)FindViewById(item2.ContainerID);
                                            notificationLayout.RemoveView(delContainer);
                                        }
                                    }

                                    //cikiliyor olarak kayit yap
                                    isExiting  = true;
                                    inTollRoad = false;

                                    //cikis popup mesaji olusturm

                                    #region Popup Mesaji

                                    PopupMessage(this, TimeLeft);
                                    break;

                                    #endregion Popup Mesaji
                                }
                            }
                        }
                        else //Yon tayini ile ilgili bolumler
                        {
                            //gatelerden birine girmisse
                            if (dist < avgApproximity)
                            {
                                //giris noktasindan yolun bitis istikametine dogru gidiyor
                                if (tollAreaItem.areaID > tollAreaEnter.areaID)
                                {
                                    foreach (AreaWithDistance item2 in tollAreaExitList.ToList())
                                    {
                                        if (item2.areaID < tollAreaItem.areaID)
                                        {
                                            if (item2.isBooth)
                                            {
                                                ExitNotification delnotify    = NotificationList.Where(x => x.areaID == item2.areaID).FirstOrDefault();
                                                LinearLayout     delContainer = (LinearLayout)FindViewById(delnotify.ContainerID);
                                                notificationLayout.RemoveView(delContainer);

                                                //AdMob çıkıyor
                                                ShowInterstitialAd();
                                            }
                                            tollAreaExitList.Remove(item2);
                                        }
                                    }
                                }
                                else //giris noktasindan yolun baslangic istikametine dogru gidiyor
                                {
                                    foreach (AreaWithDistance item2 in tollAreaExitList.ToList())
                                    {
                                        if (tollAreaItem.areaID < item2.areaID)
                                        {
                                            if (item2.isBooth)
                                            {
                                                ExitNotification delnotify    = NotificationList.Where(x => x.areaID == item2.areaID).FirstOrDefault();
                                                LinearLayout     delContainer = (LinearLayout)FindViewById(delnotify.ContainerID);
                                                notificationLayout.RemoveView(delContainer);

                                                //AdMob çıkıyor
                                                ShowInterstitialAd();
                                            }
                                            tollAreaExitList.Remove(item2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else //Yoldan Çıkıyorken
                {
                    Boolean stillExiting = false;
                    foreach (AreaWithDistance item in tollAreaExitList)
                    {
                        double dist = CommonMethods.GetDistance(item.areaLatitude, item.areaLongitude, currentLocation.Latitude, currentLocation.Longitude);
                        if (dist < avgExitApproximity)
                        {
                            stillExiting = true;
                        }
                    }

                    if (!stillExiting)
                    {
                        isExiting         = stillExiting;
                        inTollRoad        = false;
                        tollAreaEnter     = null;
                        tollAreaEnterTime = DateTime.MinValue;
                        tollAreaExitList  = null;
                        TollWaitingPopUpShow();
                    }
                }
            }
        }
コード例 #27
0
        private void AddBookmark()
        {
            // Create a dialog for entering the bookmark name
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);

            // Create the layout
            LinearLayout dialogLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            // Create a layout for the text entry
            LinearLayout nameTextLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Horizontal
            };

            nameTextLayout.SetPadding(10, 0, 10, 0);

            // EditText control for entering the bookmark name
            _bookmarkNameText = new EditText(this);

            // Layout parameters for making views fill available width
            LinearLayout.LayoutParams fillWidthParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ViewGroup.LayoutParams.WrapContent,
                1.0f
                );
            _bookmarkNameText.LayoutParameters = fillWidthParam;

            // Label for the text entry
            TextView nameLabel = new TextView(this)
            {
                Text = "Name:"
            };

            // Add the controls to the layout
            nameTextLayout.AddView(nameLabel);
            nameTextLayout.AddView(_bookmarkNameText);

            // Create a layout for the dialog buttons (OK and Cancel)
            LinearLayout buttonLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Horizontal
            };

            // Button to cancel the new bookmark
            Button cancelButton = new Button(this)
            {
                Text             = "Cancel",
                LayoutParameters = fillWidthParam
            };

            cancelButton.Click += (s, e) => _newBookmarkDialog.Dismiss();

            // Button to save the current viewpoint as a new bookmark
            Button okButton = new Button(this)
            {
                Text             = "OK",
                LayoutParameters = fillWidthParam
            };

            okButton.Click += CreateNewBookmark;

            // Add the buttons to the layout
            buttonLayout.AddView(cancelButton);
            buttonLayout.AddView(okButton);

            // Build the dialog with the text control and button layouts
            dialogLayout.AddView(nameTextLayout);
            dialogLayout.AddView(buttonLayout);

            // Set dialog content
            dialogBuilder.SetView(dialogLayout);
            dialogBuilder.SetTitle("New Bookmark");

            // Show the dialog
            _newBookmarkDialog = dialogBuilder.Show();
        }
コード例 #28
0
ファイル: Dialog.cs プロジェクト: yongburenshu004/Verify
            public void next(KfkPageData data)
            {
                Loading.Hide();
                RelativeLayout relativeLayout = new RelativeLayout(Base);
                View           view           = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_pay.xml"), relativeLayout);
                CardView       cardView       = (CardView)view.FindViewWithTag("cardview");

                cardView.Radius               = 45;
                cardView.Elevation            = 1;
                cardView.PreventCornerOverlap = false;
                Spinner Goods = (Spinner)view.FindViewWithTag("goods");

                Goods.Adapter = new GoodsAdapter(Base, data.data);
                Spinner     Products = (Spinner)view.FindViewWithTag("products");
                Button      button   = (Button)view.FindViewWithTag("Pay");
                AlertDialog pay      = new AlertDialog.Builder(Base, 4)
                                       .SetView(relativeLayout)
                                       .Create();

                pay.Show();
                pay.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent);
                Goods.ItemSelected += (v, i) =>
                {
                    Products.Adapter = new ProductAdapter(Base, data.data[i.Position].products);
                };
                button.Click += delegate
                {
                    List <string> item = new List <string>();
                    if (data.ZfbPay)
                    {
                        item.Add("支付宝支付");
                    }
                    if (data.WxPay)
                    {
                        item.Add("微信支付");
                    }
                    if (data.QQPay)
                    {
                        item.Add("QQ钱包支付");
                    }
                    AlertDialog PayType = null;
                    PayType = new AlertDialog.Builder(Base, 5).SetTitle("请选择支付方式")
                              .SetSingleChoiceItems(item.ToArray(), -1, (dialog, pos) =>
                    {
                        //创建订单
                        Loading.Show(Base);
                        int p = 0;
                        switch (item[pos.Which])
                        {
                        case "支付宝支付":
                            p = 1;
                            break;

                        case "微信支付":
                            p = 2;
                            break;

                        case "QQ钱包支付":
                            p = 3;
                            break;
                        }
                        HttpApi.Build_order(this, data.data[Goods.SelectedItemPosition].products[Products.SelectedItemPosition].product_id, p, data.buyer_token, appInfo.data.weburl);
                        PayType.Dismiss();
                    })
                              .Show();
                };
            }
コード例 #29
0
        void ShowPublish()
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            LayoutInflater liView = LayoutInflater;

            customView = liView.Inflate(Resource.Layout.PublishLayout, null, true);

            ImageView imgPerfil = customView.FindViewById <ImageView>(Resource.Id.imgPerfil);

            if (post.Usuario.Usuario_Fotografia_Perfil != null)
            {
                imgPerfil.SetImageBitmap(BitmapFactory.DecodeByteArray(post.Usuario.Usuario_Fotografia_Perfil, 0, post.Usuario.Usuario_Fotografia_Perfil.Length));
            }
            else
            {
                imgPerfil.SetImageResource(Resource.Mipmap.ic_profile_empty);
            }
            customView.FindViewById <TextView>(Resource.Id.lblNombre).Text = post.Usuario.Usuario_Nombre;
            customView.FindViewById <TextView>(Resource.Id.lblPuesto).Text = post.Usuario.Usuario_Puesto;

            customView.FindViewById <TextView>(Resource.Id.lblFecha).Text                = DateTime.Now.ToString("d");
            customView.FindViewById <ImageButton>(Resource.Id.imgPicture).Visibility     = ViewStates.Gone;
            customView.FindViewById <ImageButton>(Resource.Id.btnDeleteImage).Visibility = ViewStates.Gone;

            customView.FindViewById <ImageButton>(Resource.Id.imgPicture).Click += delegate
            {
                AndHUD.Shared.ShowImage(this, Drawable.CreateFromPath(_file.ToPath().ToString()));
            };

            customView.FindViewById <EditText>(Resource.Id.txtPublicacion).TextChanged += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(((EditText)sender).Text))
                {
                    customView.FindViewById <Button>(Resource.Id.btnPublishApply).Enabled = true;
                }
                else
                {
                    customView.FindViewById <Button>(Resource.Id.btnPublishApply).Enabled = false;
                }
            };

            customView.FindViewById <ImageButton>(Resource.Id.btnDeleteImage).Click += delegate
            {
                ImageButton imgPicture = customView.FindViewById <ImageButton>(Resource.Id.imgPicture);
                imgPicture.SetImageURI(null);
                imgPicture.Visibility = ViewStates.Gone;
                _file = null;
                customView.FindViewById <ImageButton>(Resource.Id.btnDeleteImage).Visibility = ViewStates.Gone;
            };

            customView.FindViewById <ImageButton>(Resource.Id.btnTakePicture).Click += delegate
            {
                CreateDirectoryForPictures();
                IsThereAnAppToTakePictures();
                Intent intent = new Intent(MediaStore.ActionImageCapture);
                _file = new File(_dir, String.Format("{0}.png", Guid.NewGuid()));
                intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file));
                StartActivityForResult(intent, TakePicture);
            };

            customView.FindViewById <ImageButton>(Resource.Id.btnAttachImage).Click += delegate
            {
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, "Select photo"), PickImageId);
            };
            customView.FindViewById <Button>(Resource.Id.btnPublishApply).Click += delegate
            {
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                bitmap?.Compress(Bitmap.CompressFormat.Png, 0, stream);
                byte[] bitmapData = stream?.ToArray();
                if (bitmapData.Length != 0 || customView.FindViewById <EditText>(Resource.Id.txtPublicacion).Text.Trim().Length != 0)
                {
                    if (DashboardController.CommentPost(post_id, localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), customView.FindViewById <EditText>(Resource.Id.txtPublicacion).Text, bitmapData))
                    {
                        customView.FindViewById <EditText>(Resource.Id.txtPublicacion).Text = "";
                        customView.FindViewById <EditText>(Resource.Id.txtPublicacion).ClearFocus();
                        comentarios = DashboardController.GetComentariosPost(post_id, localStorage.Get("Usuario_Id"), localStorage.Get("Usuario_Tipo"), page, sizePage);
                        FillComments();
                        svComentarios.ScrollY = svComentarios.Height;
                    }
                    else
                    {
                        Toast.MakeText(this, Resource.String.str_general_save_error, ToastLength.Short);
                    }
                }
                else
                {
                    Toast.MakeText(this, "Escribe o envía una imagen", ToastLength.Short).Show();
                }
                dialog.Dismiss();
            };

            builder.SetView(customView);
            builder.Create();
            dialog = builder.Show();
            dialog.Window.SetGravity(GravityFlags.Top | GravityFlags.Center);
        }
コード例 #30
0
        /// <summary>
        /// Show an alert which simply notifies the user with only 1 optional change in action.
        /// </summary>
        /// <param name="title">The title of the alert.</param>
        /// <param name="message">The message of the alert.</param>
        public void ShowInertAlert(string title = EMPTY_STRING, string message = EMPTY_STRING, EventHandler e = null, DialogButton button1 = null)
        {
            //Create the new alert
            AlertDialog alert = dialogBuilder.Create();

            //Set the title and message.
            alert.SetTitle(title);
            alert.SetMessage(message);

            //Setup the dismiss listener if not null
            if (e != null)
            {
                alert.SetOnDismissListener(new OnDismissListener(() =>
                {
                    //Invoke the event attached.
                    e.Invoke(this, EventArgs.Empty);
                }));

                //Setup the dismiss button.
                alert.SetButton(context.Resources.GetString(Resource.String.item_options_close), (s, e) => alert.Dismiss());

                //Setup the button.
                if (button1 != null)
                {
                    alert.SetButton2(button1.Title, button1.Action);
                }
            }
            else if (button1 != null)
            {
                alert.SetButton(button1.Title, button1.Action);
            }

            //Show the alert.
            alert.Show();
        }