public override void ActionSheet(ActionSheetConfig config)
        {
            var dlg = new AlertDialog
                .Builder(this.GetTopActivity())
                .SetCancelable(false)
                .SetTitle(config.Title);

            if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null)) {
                var adapter = new ActionSheetListAdapter(this.GetTopActivity(), Android.Resource.Layout.SelectDialogItem, Android.Resource.Id.Text1, config);
                dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke());
            }
            else {
                var array = config
                    .Options
                    .Select(x => x.Text)
                    .ToArray();

                dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke());
            }

            if (config.Destructive != null)
                dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke());

            if (config.Cancel != null)
                dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke());

            Utils.RequestMainThread(() => dlg.ShowExt());
        }
Beispiel #2
0
        public override void ActionSheet(ActionSheetConfig config)
        {
            var dlg = new AlertDialog
                      .Builder(this.GetTopActivity())
                      .SetCancelable(false)
                      .SetTitle(config.Title);

            if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null))
            {
                var adapter = new ActionSheetListAdapter(this.GetTopActivity(), Android.Resource.Layout.SelectDialogItem, Android.Resource.Id.Text1, config);
                dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke());
            }
            else
            {
                var array = config
                            .Options
                            .Select(x => x.Text)
                            .ToArray();

                dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke());
            }

            if (config.Destructive != null)
            {
                dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke());
            }

            if (config.Cancel != null)
            {
                dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke());
            }

            Utils.RequestMainThread(() => dlg.ShowExt());
        }
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var loc = ServiceLocator.Current.GetInstance <ILocalizedStringProvider>();

            var builder = new AlertDialog.Builder(Activity);

            builder.SetTitle(loc.GetLocalizedString(Localized.Sessions_Label));
            builder.SetAdapter(App.Locator.CourseViewModel.Course.Sessions.GetAdapter(GetSessionTemplate), this);

            return(builder.Create());
        }
Beispiel #4
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var loc = ServiceLocator.Current.GetInstance <ILocalizedStringProvider>();

            var builder = new AlertDialog.Builder(Activity);

            builder.SetTitle(loc.GetLocalizedString(Localized.ChangeLanguage_Label));
            builder.SetAdapter(new LanguageAdapter(Activity), this);

            return(builder.Create());
        }
        public Dialog Build(AppCompatActivity activity, ActionSheetConfig config)
        {
            var dialog = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0)
                         .SetTitle(config.Title);

            if (config.Cancel != null)
            {
                dialog.SetNeutralButton(config.Cancel.Text, (s, a) =>
                {
                    config.Cancel.Action?.Invoke();
                });
            }

            if (config.Destructive != null)
            {
                dialog.SetNegativeButton(config.Destructive.Text, (s, a) =>
                {
                    config.Destructive.Action?.Invoke();
                });
            }

            if (config.Items != null && config.Items.Count > 0)
            {
                if (config.Items.Any(t => t.ItemIcon != null))
                {
                    var adapter = new ActionSheetListAdapter(activity, global::Android.Resource.Layout.SelectDialogItem, global::Android.Resource.Id.Text1, config);

                    dialog.SetAdapter(adapter, (s, a) =>
                    {
                        config.Items[a.Which].Action?.Invoke();
                    });
                }
                else
                {
                    var array = config.Items.Select(t => t.Text).ToArray();

                    dialog.SetItems(array, (s, a) =>
                    {
                        config.Items[a.Which].Action?.Invoke();
                    });
                }
            }

            return(dialog.Create());
        }
        public Dialog Build(AppCompatActivity activity, ActionSheetConfig config)
        {
            var dlg = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0)
                      .SetTitle(config.Title);

            //.SetCustomTitle(new TextView(activity) {
            //    Text = config.Title,
            //    TextSize = 18.0f
            //});

            if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null))
            {
                var adapter = new ActionSheetListAdapter(activity, Android.Resource.Layout.SelectDialogItem,
                                                         Android.Resource.Id.Text1, config);
                dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke());
            }
            else
            {
                var array = config
                            .Options
                            .Select(x => x.Text)
                            .ToArray();

                dlg.SetSingleChoiceItems(array, config.SelectedIndex, (s, args) =>
                {
                    config.Options[args.Which].Action?.Invoke();
                    (s as AppCompatAlertDialog).Dismiss();
                });
            }

            if (config.Destructive != null)
            {
                dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke());
            }

            if (!string.IsNullOrEmpty(config.Cancel?.Text))
            {
                dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke());
            }

            return(dlg.Create());
        }
Beispiel #7
0
        public static AppCompatAlertDialog.Builder Build(AppCompatActivity activity, ActionSheetConfig config)
        {
            var dlg = new AppCompatAlertDialog
                      .Builder(activity)
                      .SetCancelable(false)
                      .SetTitle(config.Title);

            //.SetCustomTitle(new TextView(activity) {
            //    Text = config.Title,
            //    TextSize = 18.0f
            //});

            if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null))
            {
                var adapter = new ActionSheetListAdapter(activity, Android.Resource.Layout.SelectDialogItem,
                                                         Android.Resource.Id.Text1, config);
                dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke());
            }
            else
            {
                var array = config
                            .Options
                            .Select(x => x.Text)
                            .ToArray();

                dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke());
            }

            if (config.Destructive != null)
            {
                dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke());
            }

            if (config.Cancel != null)
            {
                dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke());
            }

            return(dlg);
        }
Beispiel #8
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            SupportActionBar.DisplayOptions = (int)ActionBarDisplayOptions.ShowCustom;
            SupportActionBar.SetCustomView(Resource.Layout.ActionBar_Moses);
            _sos        = SupportActionBar.CustomView.FindViewById <RelativeLayout>(Resource.Id.sos);
            _myLocation = SupportActionBar.CustomView.FindViewById <RelativeLayout>(Resource.Id.where_i);
            _layers     = SupportActionBar.CustomView.FindViewById <RelativeLayout>(Resource.Id.layers);

            _sos.Click += delegate(object sender, EventArgs args)
            {
                Toast.MakeText(this, "Help me!!!!", ToastLength.Long).Show();
            };
            _layers.Click += delegate(object sender, EventArgs args)
            {
                AlertDialog.Builder builderSingle = new AlertDialog.Builder(this);
                builderSingle.SetTitle("Type");

                ArrayAdapterWithIcon arrayAdapter = new ArrayAdapterWithIcon(
                    this,
                    Android.Resource.Layout.select_dialog_singlechoice_material);
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.tse_tse
                });
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.grass
                });
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.water
                });
                arrayAdapter.Add(new ListItem()
                {
                    ImageResourceId = Resource.Drawable.fire
                });
                builderSingle.SetNegativeButton("Cancel", NegativeHandler);
                builderSingle.SetAdapter(arrayAdapter, this);
                builderSingle.Show();
            };
            _myLocation.Click += delegate(object sender, EventArgs args)
            {
                _mapController.SetCenter(_centreOfMap);
            };
            //StyleInterpreter interpreter = null;
            try
            {
                bool isTile = true;
                //List<OsmGeo> osm = null;
                if (isTile)
                {
                    _mapView = FindViewById <MapView>(Resource.Id.mapview);
                    _mapView.SetTileSource(TileSourceFactory.DefaultTileSource);
                    _mapView.SetBuiltInZoomControls(true);
                    //_mapView.SetUseDataConnection(false);

                    _provider = new CustomLocationProvider(this);
                    _provider.StartLocationProvider(new MyLocationNewOverlay(this, _mapView));

                    //List<OverlayItem> overlayItemArray = new List<OverlayItem>();
                    //OverlayItem olItem = new OverlayItem("Here", "SampleDescription", new GeoPoint(34.878039, -10.650));
                    //overlayItemArray.Add(olItem);
                    //olItem.SetMarker(Resources.GetDrawable(Resource.Drawable.cloud));
                    //overlayItemArray.Add(new OverlayItem("Hi", "You're here", new GeoPoint(34.888039, -10.660)));


                    DefaultResourceProxyImpl defaultResourceProxyImpl = new DefaultResourceProxyImpl(this);
                    //ItemizedIconOverlay myItemizedIconOverlay = new ItemizedIconOverlay(overlayItemArray, null, defaultResourceProxyImpl);
                    //_mapView.Overlays.Add(myItemizedIconOverlay);

                    //PathOverlay myPath = new PathOverlay(Color.Red, this);
                    //myPath.AddPoint(new GeoPoint(34.878039, -10.650));
                    //myPath.AddPoint(new GeoPoint(34.888039, -10.660));
                    //_mapView.Overlays.Add(myPath);

                    _mapController = _mapView.Controller;
                    _mapController.SetZoom(6);

                    _mapController.SetCenter(_centreOfMap);

                    _geoService = new CouchDbGeoObjectsService();

                    //var firstPoint = ((GeoJSON.Net.Geometry.Point) points.Features[0].Geometry);
                    var firstPoint = new OsmSharp.Geo.Geometries.Point(new OsmSharp.Math.Geo.GeoCoordinate(33, -10));
                    //double x = ((GeographicPosition) firstPoint.Coordinates).Latitude;
                    //double y = ((GeographicPosition)firstPoint.Coordinates).Longitude;
                    //List<OverlayItem> overlayItemArray = new List<OverlayItem>();
                    //OverlayItem olItem = new OverlayItem("Here", "SampleDescription", new GeoPoint(x, y));
                    //overlayItemArray.Add(olItem);
                    //olItem.SetMarker(Resources.GetDrawable(Resource.Drawable.cloud));

                    //ItemizedIconOverlay newPoints = new ItemizedIconOverlay(overlayItemArray, null, defaultResourceProxyImpl);
                    //_mapView.Overlays.Add(newPoints);
                }
                else
                {
                    /*List<OsmGeo> osm = await _service.DownloadArea(34.878039, -10.465, 36, -9.077);
                     * if (osm != null)
                     * {
                     * Native.Initialize();
                     *
                     * // initialize map.
                     * var map = new Map();
                     * interpreter = new MapCSSInterpreter(css);
                     *
                     * IDataSourceReadOnly source = new MemoryDataSource(osm.ToArray());
                     * var layer = map.AddLayerOsm(source, interpreter);
                     *
                     * _mapView = new MapView(this, new MapViewSurface(this));
                     * _mapView.Map = map;
                     * _mapView.MapMaxZoomLevel = 17; // limit min/max zoom because MBTiles sample only contains a small portion of a map.
                     * _mapView.MapMinZoomLevel = 1;
                     * _mapView.MapTilt = 0;
                     * _mapView.MapCenter = new GeoCoordinate(-9.2, 36);
                     * _mapView.MapZoom = 2;
                     * _mapView.MapAllowTilt = false;
                     *
                     * //OsmSharp.Data.SQLite.SQLiteConnectionBase sqLiteConnection = new SQLiteConnection("osmMap");
                     *
                     * frame.AddView(_mapView);
                     * var textLabel = FindViewById<TextView>(Resource.Id.text_label);
                     * textLabel.Text = "Изображение подгрузилось";
                     * Toast.MakeText(this, "Read success", ToastLength.Long).Show();
                     * }
                     * else
                     * {
                     * Toast.MakeText(this, "OSM is null", ToastLength.Long).Show();
                     * }*/
                }
            }
            catch (Exception exception)
            {
                Toast.MakeText(this, exception.Message, ToastLength.Long).Show();
                SetContentView(Resource.Layout.Main);
            }
        }