Exemplo n.º 1
1
        // Check touch position on button
        public bool OnTouch(View v, MotionEvent e)
        {
            switch (e.Action)
            {
                // Get the x and y position for a touch (always before move)
                case MotionEventActions.Down:
                    old_x = e.GetX ();
                    old_y = e.GetY ();
                    Console.WriteLine ("x = " + old_x + " y = " + old_y);
                    break;
                // Get the x and y position difference continously
                case MotionEventActions.Move:
                    // Get the difference between current position and old position
                    new_x = e.GetX () - old_x;
                    new_y = e.GetY () - old_y;
                    // Convert to int, to remove decimal numbers (apparently can't be send through the tcp listener)
                    int_x = Convert.ToInt32 (new_x);
                    int_y = Convert.ToInt32 (new_y);
                    // Convert to string, so it can be send
                    send_x = Convert.ToString (int_x);
                    send_y = Convert.ToString (int_y);

                    // Send x and y position over two messages
                    Connect (ipAddress, send_x);
                    Connect (ipAddress, send_y);

                    // Set old position to current position
                    old_x = e.GetX ();
                    old_y = e.GetY ();
                    break;
            }
            return true;
        }
Exemplo n.º 2
0
 void View.IOnClickListener.OnClick (View v)
 {
     StartActivity (new Intent (
         Intent.ActionView,
         Android.Net.Uri.Parse (Toggl.Phoebe.Build.GooglePlayUrl)
     ));
 }
 /** Called when the Clear button is clicked. */
 public void OnClearMap(View view)
 {
     if (!CheckReady()) {
         return;
     }
     mMap.Clear();
 }
Exemplo n.º 4
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ViewHolder holder = null;
            if (convertView == null) {
                LayoutInflater inflator = LayoutInflater.From (nn_context);
                convertView = inflator.Inflate (Resource.Layout.team_findpotencialmember_item, null);

                holder = new ViewHolder ();
                holder.contentview = (RelativeLayout)convertView;
                holder.button = (Button)convertView.FindViewById (Resource.Id.findpotencialmember_uninvite_button);
                holder.textviewtitle = (TextView)convertView.FindViewById (Resource.Id.findpotencialmember_membername_textview);
                convertView.Tag=holder;
            } else {
                holder= (ViewHolder) convertView.Tag;
            }

            holder.button.Tag = position;

            holder.textviewtitle.Text = nn_list [position].first_name+" "+nn_list [position].last_name;
            holder.button.Visibility = ViewStates.Visible;
            holder.button.Click -= OnInviteClick;
            holder.button.Click += OnInviteClick;
            holder.button.Text = "Invite";
            holder.button.SetTextColor (Color.White);
            holder.button.SetTypeface (Typeface.Default, TypefaceStyle.Bold);

            return convertView;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            _view = FindViewById<LinearLayout>(Resource.Id.parentLayout);
            _text = FindViewById<TextView>(Resource.Id.logTextView);

            UpdateDisplay(INITIAL_MESSAGE,Color.White);

            var beaconManager = new BeaconManager(this);

            indoorLocationController = new IndoorLocationController(beaconManager);
            indoorLocationController.BeaconFound += HandleBeaconFound;
            indoorLocationController.BeaconLost += HandleBeaconLost;

            var beacon1 = DummyBeaconCreator.CreateBeaconUrsin();
            var beacon2 = DummyBeaconCreator.CreateBeaconMarcel();
            indoorLocationController.AddBeaconsAndStart(new List<Beacon>{beacon1,beacon2});

            if (!IsBluetoothAvailable)
            {
                Toast.MakeText(this, "Please activate Bluetooth! iBeacons works only when Bluetooth available.",ToastLength.Long).Show();
            }
        }
 private TodoViewModel GetViewVm(View view)
 {
   if (view == null) { return null; }
   var key = Int32.Parse(view.Tag.ToString());
   var vm = _todoVms.Single(x => x.ViewKey == key);
   return vm;
 }
        protected override View GetBindableView(View convertView, object dataContext, int templateId)
        {
            IMvxLayoutListItemViewFactory layout;
            if (dataContext == null)
            {
                layout = _defaultItemLayout;
            }
            else
            {
                if (!_itemLayouts.TryGetValue(dataContext.GetType().Name, out layout))
                {
                    layout = _defaultItemLayout;
                }
            }

            var existing = convertView as IMvxLayoutListItemView;
            if (existing != null)
            {
                if (existing.UniqueName == layout.UniqueName)
                {
                    // reuse the convertView...
                    existing.DataContext = dataContext;
                    return convertView;
                }
            }

            // use a special engine thing
            var view = layout.BuildView(Context, BindingContext, dataContext);
            return view;
        }
		public override void OnViewCreated (View view, Bundle savedInstanceState)
		{
			mWebView = (WebView)view.FindViewById (Resource.Id.web_view);
			// Here, we use #mWebChromeClient with implementation for handling PermissionRequests.
			mWebView.SetWebChromeClient (mWebChromeClient);
			ConfigureWebSettings (mWebView.Settings);
		}
Exemplo n.º 9
0
        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            var person = ((PeopleGroupsAdapter)ListAdapter).GetPerson (position);

            if (person != null)
                StartActivity (PersonActivity.CreateIntent (this, person));
        }
Exemplo n.º 10
0
        public override View GetView(Context context, View convertView, ViewGroup parent)
		{
            this.Click = delegate { SelectImage(); };

            Bitmap scaledBitmap = Bitmap.CreateScaledBitmap(_image, dimx, dimy, true);

            var view = convertView as RelativeLayout;
            if (view == null)
            {
                view = new RelativeLayout(context);
                _imageView = new ImageView(context);
            }
            else
            {
                _imageView = (ImageView)view.GetChildAt(0);
            }
            _imageView.SetImageBitmap(scaledBitmap);
            
            var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            parms.SetMargins(5, 2, 5, 2);
            parms.AddRule( LayoutRules.AlignParentLeft);
			if(_imageView.Parent != null && _imageView.Parent is ViewGroup)
				((ViewGroup)_imageView.Parent).RemoveView(_imageView);
			view.AddView(_imageView, parms);

            return view;
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            layout = FindViewById<LinearLayout>(Resource.Id.main);

            var intent = Intent;
            if (NeedPermissions(this))
            {
                RequestPermissions();
            }
            else if (intent != null)
            {
                intent.SetComponent(null);
                intent.SetPackage("com.google.android.GoogleCamera");
                intent.SetFlags(ActivityFlags.NewTask);
                StartActivity(intent);
                Finish();
            }
            else
                Finish();

            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
        public override void OnListItemClick(ListView p0, View p1, int position, long p3)
        {
            Fragment newContent = null;
            switch (position)
            {
                case 0:
                    newContent = new ColorFragment(Resource.Color.red);
                    break;
                case 1:
                    newContent = new ColorFragment(Resource.Color.green);
                    break;
                case 2:
                    newContent = new ColorFragment(Resource.Color.blue);
                    break;
                case 3:
                    newContent = new ColorFragment(Resource.Color.white);
                    break;
                case 4:
                    newContent = new ColorFragment(Resource.Color.black);
                    break;
            }

            if (newContent != null)
                SwitchFragment(newContent);
        }
		public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
			view = inflater.Inflate(Resource.Layout.TeamsFragment, container, false);
			if(listTeams.Count == 0) {
				//display text that there are currently no events and hide list with events
				view.FindViewById(Resource.Id.teamsFragmentListTeams).Visibility = ViewStates.Gone;
			} else {
				//display list with events and hide the text
				view.FindViewById(Resource.Id.teamsFragmentNoTeams).Visibility = ViewStates.Gone;

				listView = view.FindViewById<ListView>(Resource.Id.teamsFragmentListTeams);
				listView.Adapter = new ListTeamsAdapter(this, listTeams);
				listView.ItemClick += OnListItemClick;
			}

			if(DB_Communicator.getInstance().isAtLeast(VBUser.GetUserFromPreferences().getUserType(), UserType.Coremember)) {
				view.FindViewById<LinearLayout>(Resource.Id.teamsFragmentBtnAddLine).Visibility = ViewStates.Visible;
			} else {
				view.FindViewById<LinearLayout>(Resource.Id.teamsFragmentBtnAddLine).Visibility = ViewStates.Gone;
			}

			view.FindViewById<Button>(Resource.Id.teamsFragmentBtnAdd).Click += (object sender, EventArgs e) => {
				ViewController.getInstance().mainActivity.switchFragment(ViewController.TEAMS_FRAGMENT, 
					ViewController.ADD_TEAM_FRAGMENT, new AddTeamFragment());
			};

			return view;
		}
		public MyHealth_TakwimViewHolder (View itemView, Action<int> listener) : base(itemView)
		{
			tvTitle = itemView.FindViewById <TextView> (Resource.Id.tvCardHeader);
			mRViewList = itemView.FindViewById <RecyclerView> (Resource.Id.takwimRecyclerViewList);

			itemView.Click += (sender, e) => listener (base.Position);
		}
Exemplo n.º 15
0
		public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			View v = inflater.Inflate (Resource.Layout.WebViewDialog, container, false);

			txtTitle = v.FindViewById<TextView> (Resource.Id.txt_dialog_title);
			divider = v.FindViewById<View> (Resource.Id.title_divider);
			webView = v.FindViewById<WebView> (Resource.Id.dialog_web_view);

			if (title == null || title.Length < 1) {
				txtTitle.Visibility = divider.Visibility = ViewStates.Gone;
			} else {
				txtTitle.Text = title;
			}

			if (url != null && url.Length > 0) {
				webView.LoadUrl (url);
			}

			if (showOkay) {
				btnOk.Visibility = ViewStates.Visible;
				btnOk.Click += (object sender, EventArgs e) => {
					this.Dismiss ();
				};
			}

			return v;
		}
Exemplo n.º 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                _task = Rep.DatabaseHelper.Tasks.Enumerator.Current;
                var category = Rep.DatabaseHelper.Tasks.GetCategory(_task.CategoryId);
                SetContentView(Resource.Layout.ImageCard);
                _image = FindViewById<ImageView>(Resource.Id.imageCardView);
                var imageIdentifier = this.Resources.GetIdentifier(category.Image, "drawable", this.PackageName);
                _image.SetImageResource(imageIdentifier);

                var text = FindViewById<TextView>(Resource.Id.textCard);
                text.SetTypeface(Rep.FontManager.Get(Font.BankirRetro), TypefaceStyle.Normal);
                text.Text = _task.TaskName;

                _contentFrameLayout = FindViewById(Resource.Id.contentFrameLayout);

                _contentFrameLayout.Click += ContentFrameLayoutOnClick;

            }
            catch (Exception exception)
            {
                GaService.TrackAppException(this.Class,"OnCreate", exception, false);
                base.OnBackPressed();
            }
        }
        public virtual View CreateView(View parent, string name, Context context, IAttributeSet attrs)
        {
            // resolve the tag name to a type
            var viewType = ViewTypeResolver.Resolve(name);

            if (viewType == null)
            {
                //MvxBindingTrace.Trace(MvxTraceLevel.Error, "View type not found - {0}", name);
                return null;
            }

            try
            {
                var view = Activator.CreateInstance(viewType, context, attrs) as View;
                if (view == null)
                {
                    MvxBindingTrace.Trace(MvxTraceLevel.Error, "Unable to load view {0} from type {1}", name,
                                          viewType.FullName);
                }
                return view;
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception exception)
            {
                MvxBindingTrace.Trace(MvxTraceLevel.Error,
                                      "Exception during creation of {0} from type {1} - exception {2}", name,
                                      viewType.FullName, exception.ToLongString());
                return null;
            }
        }
Exemplo n.º 18
0
        public override void OnViewCreated (View view, Bundle savedInstanceState)
        {
            base.OnViewCreated (view, savedInstanceState);

            ListView.SetClipToPadding (false);
            ListAdapter = new SettingsAdapter ();
        }
Exemplo n.º 19
0
    public override View GetView(int position, View convertView, ViewGroup parent)
    {
      var isNewView = convertView == null;

      var view = convertView ?? _context.LayoutInflater.Inflate(
            Resource.Layout.TodoGrid,
            parent,
            false) as GridLayout;

      System.Diagnostics.Debug.Assert(view != null, "TodoItem view is null?!?");

      // View Controls
      var delete = view.FindViewById<Button>(Resource.Id.DeleteButton);
      var description = view.FindViewById<TextView>(Resource.Id.DescriptionText);
      var isDone = view.FindViewById<CheckBox>(Resource.Id.IsDoneCheckbox);

      // Copy item data to the controls
      var vm = _todoVms[position];
      var item = vm.Todo;
      view.Tag = vm.ViewKey.ToString(CultureInfo.InvariantCulture);
      description.Text = item.Description;
      isDone.Checked = item.IsDone;

      if (isNewView) {
        // add event handlers to new views only
        isDone.Click += (sender, e) => IsDoneClicked(view, isDone);
        description.TextChanged += (sender, e) => DescriptionChanged(view, description);
        delete.Click += (sender, e) => DeleteClicked(view);
      }
      return view;
    }
Exemplo n.º 20
0
 private void DeleteClicked(View view)
 {
     var vm = GetViewVm(view);
     _dataContext.DeleteTodo(vm.Todo);
     _todoVms.Remove(vm);
     NotifyDataSetChanged(); // trigger view reset so item disappears
 }
        public override void PerformAction(View view)
        {
            try
            {
                ContentValues eventValues = new ContentValues();

                eventValues.Put( CalendarContract.Events.InterfaceConsts.CalendarId,
                    _calId);
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Title,
                    "Test Event from M4A");
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Description,
                    "This is an event created from Xamarin.Android");
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart,
                    GetDateTimeMS(2011, 12, 15, 10, 0));
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend,
                    GetDateTimeMS(2011, 12, 15, 11, 0));

                var uri = ContentResolver.Insert(CalendarContract.Events.ContentUri,
                    eventValues);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.Android, Context);

            }
        }
Exemplo n.º 22
0
		protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context)
		{
			Performance.Start();
			var cell = (ViewCell)item;

			var container = convertView as ViewCellContainer;
			if (container != null)
			{
				container.Update(cell);
				Performance.Stop();
				return container;
			}

			BindableProperty unevenRows = null, rowHeight = null;
			if (ParentView is TableView)
			{
				unevenRows = TableView.HasUnevenRowsProperty;
				rowHeight = TableView.RowHeightProperty;
			}
			else if (ParentView is ListView)
			{
				unevenRows = ListView.HasUnevenRowsProperty;
				rowHeight = ListView.RowHeightProperty;
			}

			IVisualElementRenderer view = Platform.CreateRenderer(cell.View);
			Platform.SetRenderer(cell.View, view);
			cell.View.IsPlatformEnabled = true;
			var c = new ViewCellContainer(context, view, cell, ParentView, unevenRows, rowHeight);

			Performance.Stop();

			return c;
		}
Exemplo n.º 23
0
		public override View GetView (Context context, View convertView, ViewGroup parent)
		{
			var view = new RelativeLayout(context);
						
            var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                        ViewGroup.LayoutParams.WrapContent);

            view.SetMinimumHeight(150);
            parms.SetMargins(5, 3, 5, 0);
            parms.AddRule(LayoutRules.AlignParentLeft);

			_caption = new TextView (context);
			SetCaption (Caption);
            view.AddView(_caption, parms);
			
			if (!String.IsNullOrWhiteSpace (Indicator)) {
	            var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
	                                                         ViewGroup.LayoutParams.WrapContent);
	            tparms.SetMargins(5, 3, 5, 5);
	            tparms.AddRule(LayoutRules.CenterVertical);
				tparms.AddRule(LayoutRules.AlignParentRight);
	
	            _text = new TextView (context) {
					Text = Indicator,
					TextSize = 22f
				};
	            view.AddView(_text, tparms);
			}
			return view;
		}
Exemplo n.º 24
0
		public bool IsLoginFormValidate(EditText email, EditText password, ref View focus) {
			var icon = email.Context.Resources.GetDrawable(Android.Resource.Drawable.StatNotifyError);
			var emailText = email.Text;
			var passwordText = password.Text;
			if (emailText == null || emailText == String.Empty) {
				email.SetError(requiredFieldErrorMessage, icon);
				focus = email;
				return false;
			}
			Regex emailRegex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
			if (!emailRegex.IsMatch(emailText)) {
				email.SetError(incorrectEmailErrorMessage, icon);
				focus = email;
				return false;
			}
			else if (passwordText == null || passwordText == String.Empty) {
				password.SetError(requiredFieldErrorMessage, icon);
				focus = password;
				return false;
			}
			Regex passwordRegex = new Regex(@"\d+");
			if (passwordText.Length < 6 || (passwordText.Length > 6 && !passwordRegex.IsMatch(passwordText))) {
				password.SetError(incorrectPasswordErrorMessage, icon);
				focus = password;
				return false;
			}

			return true;
		}
Exemplo n.º 25
0
		public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) {
			View container = View.Inflate(parent.Context, Resource.Layout.list_item_child, null);
			TextView txtGroupName = (TextView)container.FindViewById(Resource.Id.txtExampleName);
			ExampleFragment child = (ExampleFragment)this.GetChild(groupPosition, childPosition);
			txtGroupName.Text = child.Title();
			return container;
		}
Exemplo n.º 26
0
		public override View GetView(Context context, View convertView, ViewGroup parent)
        {
			var view = convertView as RelativeLayout;
			
			if (view == null)
				view = new RelativeLayout(context);
						
            var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                        ViewGroup.LayoutParams.WrapContent);
            parms.SetMargins(5, 3, 5, 0);
            parms.AddRule((int) LayoutRules.AlignParentLeft);

            _caption = new TextView(context) {Text = Caption, TextSize = 16f};
            view.AddView(_caption, parms);

            if (!string.IsNullOrEmpty(Value))
            {
                var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                             ViewGroup.LayoutParams.WrapContent);
                tparms.SetMargins(5, 3, 5, 0);
                tparms.AddRule((int) LayoutRules.AlignParentRight);

                _text = new TextView(context) {Text = Value, TextSize = 16f};
                view.AddView(_text, tparms);
            }

            return view;
        }
Exemplo n.º 27
0
 public View CreateTabContent(string tag)
 {
     var v = new View(_context);
     v.SetMinimumHeight(0);
     v.SetMinimumWidth(0);
     return v;
 }
			public void OnClick(View view) {
				switch(this.source) {
				case ON_SAVE:
					this.onSave();
					break;
				}
			}
Exemplo n.º 29
0
        private void Initialize (Context ctx)
        {
            var dm = ctx.Resources.DisplayMetrics;
            var inflater = LayoutInflater.FromContext (ctx);

            overlayInset = (int)TypedValue.ApplyDimension (ComplexUnitType.Dip, 45, dm);

            backgroundView = new SliceView (ctx) {
                StartAngle = 0,
                EndAngle = 360,
                Color = emptyPieColor,
            };
            AddView (backgroundView);

            loadingOverlayView = inflater.Inflate (Resource.Layout.PieChartLoading, this, false);
            AddView (loadingOverlayView);

            emptyOverlayView = inflater.Inflate (Resource.Layout.PieChartEmpty, this, false);
            emptyOverlayView.Visibility = ViewStates.Gone;
            AddView (emptyOverlayView);

            statsOverlayView = inflater.Inflate (Resource.Layout.PieChartStats, this, false);
            statsOverlayView.Visibility = ViewStates.Gone;
            AddView (statsOverlayView);

            statsTimeTextView = statsOverlayView.FindViewById<TextView> (Resource.Id.TimeTextView);
            statsMoneyTextView = statsOverlayView.FindViewById<TextView> (Resource.Id.MoneyTextView);

            Click += delegate {
                // Deselect slices on click. The Clickable property is set to true only when a slice is selected.
                ActiveSlice = -1;
            };
            Clickable = false;
        }
Exemplo n.º 30
0
        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            var url = _adapter.GetMapUrl (position);
            var intent = new Intent (Intent.ActionView, Uri.Parse(url));

            StartActivity (intent);
        }
        public override Views.View GetView(int position, Views.View convertView, Views.ViewGroup parent)
        {
            if (convertView == null)
            {
                convertView = context.LayoutInflater.Inflate(layout, parent, false);
            }

            InitButton(
                convertView.FindViewById <Button>(Resource.Id.contactbutton),
                position,
                model.Dial);

            return(convertView);
        }
Exemplo n.º 32
0
 internal virtual void SendVisualElementInitialized(VisualElement element, AView nativeView)
 {
     element.SendViewInitialized(nativeView);
 }
Exemplo n.º 33
0
        protected override void Dispose(bool disposing)
        {
            if (CheckFlagsForDisposed())
            {
                return;
            }

            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                SetOnClickListener(null);
                SetOnTouchListener(null);

                EffectUtilities.UnregisterEffectControlProvider(this, Element);

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;
                }

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (_gestureManager != null)
                {
                    _gestureManager.Dispose();
                    _gestureManager = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                if (Element != null)
                {
                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }
Exemplo n.º 34
0
        protected override void Dispose(bool disposing)
        {
            if ((_flags & VisualElementRendererFlags.Disposed) != 0)
            {
                return;
            }
            _flags |= VisualElementRendererFlags.Disposed;

            if (disposing)
            {
                SetOnClickListener(null);
                SetOnTouchListener(null);

                if (Tracker != null)
                {
                    Tracker.Dispose();
                    Tracker = null;
                }

                if (_packager != null)
                {
                    _packager.Dispose();
                    _packager = null;
                }

                if (_scaleDetector != null && _scaleDetector.IsValueCreated)
                {
                    _scaleDetector.Value.Dispose();
                    _scaleDetector = null;
                }

                if (_gestureListener != null)
                {
                    _gestureListener.Dispose();
                    _gestureListener = null;
                }

                if (ManageNativeControlLifetime)
                {
                    int count = ChildCount;
                    for (var i = 0; i < count; i++)
                    {
                        AView child = GetChildAt(i);
                        child.Dispose();
                    }
                }

                RemoveAllViews();

                if (Element != null)
                {
                    Element.PropertyChanged -= _propertyChangeHandler;
                    UnsubscribeGestureRecognizers(Element);

                    if (Platform.GetRenderer(Element) == this)
                    {
                        Platform.SetRenderer(Element, null);
                    }

                    Element = null;
                }
            }

            base.Dispose(disposing);
        }
 public override void GetOutline(Android.Views.View view, Outline outline) => outline?.SetRoundRect(0, 0, view.Width, view.Height, _raio);
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            View view;

            if (position == 0)
            {
                view          = context.LayoutInflater.Inflate(Resource.Layout.SortingSettingsRow, parent, false);
                sortingSwitch = view.FindViewById <SwitchCompat>(Resource.Id.sortingSwitch);
                CheckSortingSwitchState();

                sortingSwitch.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e)
                {
                    if (e.IsChecked == true)
                    {
                        MainActivity.isSortedByDistance = true;
                        MainActivity.editor.PutBoolean("isSortedByDistance", MainActivity.isSortedByDistance);
                        MainActivity.editor.Apply();
                    }
                    else
                    {
                        MainActivity.isSortedByDistance = false;
                        MainActivity.editor.PutBoolean("isSortedByDistance", MainActivity.isSortedByDistance);
                        MainActivity.editor.Apply();
                    }
                };

                return(view);
            }
            else if (position == 1)
            {
                view           = context.LayoutInflater.Inflate(Resource.Layout.RadiusSettingsRow, parent, false);
                radiusSeekBar  = view.FindViewById <SeekBar>(Resource.Id.seekBarRadius);
                radiusTextView = view.FindViewById <TextView>(Resource.Id.textViewRadius);
                CheckRadiusBarValue();

                radiusSeekBar.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
                {
                    if (e.FromUser)
                    {
                        SeekBar seekbar = (SeekBar)sender;

                        if (seekbar.Progress == 0)
                        {
                            MainActivity.editor.PutInt("radius", 1);
                            MainActivity.editor.Apply();
                        }
                        else
                        {
                            MainActivity.editor.PutInt("radius", e.Progress);
                            MainActivity.editor.Apply();
                        }
                    }
                };

                return(view);
            }
            else if (position == 2)
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.NumberOfResultsSettingsRow, parent, false);
                numberOfResultsSeekBar = view.FindViewById <SeekBar>(Resource.Id.seekBarResults);
                CheckNumberOfResultsBarValue();

                numberOfResultsSeekBar.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
                {
                    if (e.FromUser)
                    {
                        MainActivity.editor.PutInt("numberOfResults", e.Progress + 10);
                        MainActivity.editor.Apply();
                    }
                };

                return(view);
            }
            else if (position == 3)
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.DistanceUnitsSettingsRow, parent, false);
                distanceUnitsSpinner         = view.FindViewById <Spinner>(Resource.Id.spinnerDistanceUnits);
                distanceUnitsSpinner.Adapter = SettingsActivity.spinnerAdapter;
                CheckDistanceUnits();

                distanceUnitsSpinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(SpinnerItemSelected);

                return(view);
            }
            else if (position == 4)
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.TemperatureSettingsRow, parent, false);
                temperatureUnitsSwitch = view.FindViewById <SwitchCompat>(Resource.Id.tempUnitsSwitch);
                CheckTemperatureUnitsSwitchState();

                temperatureUnitsSwitch.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e)
                {
                    if (e.IsChecked == true)
                    {
                        MainActivity.isCelcius = false;
                        MainActivity.editor.PutBoolean("isCelcius", MainActivity.isCelcius);
                        MainActivity.editor.Apply();
                        string currentTempString = "";
                        for (int i = 0; i < MainActivity.temperatureTextView.Text.Length - 2; i++)
                        {
                            currentTempString += MainActivity.temperatureTextView.Text[i];
                        }
                        double currentTempValue    = Convert.ToDouble(currentTempString);
                        double newTempValue        = currentTempValue * 1.8 + 32.0;
                        var    roundedNewTempValue = Math.Round(newTempValue, 0, MidpointRounding.AwayFromZero);
                        MainActivity.temperatureTextView.Text = roundedNewTempValue.ToString() + "°F";
                    }
                    else
                    {
                        MainActivity.isCelcius = true;
                        MainActivity.editor.PutBoolean("isCelcius", MainActivity.isCelcius);
                        MainActivity.editor.Apply();
                        string currentTempString = "";
                        for (int i = 0; i < MainActivity.temperatureTextView.Text.Length - 2; i++)
                        {
                            currentTempString += MainActivity.temperatureTextView.Text[i];
                        }
                        double currentTempValue    = Convert.ToDouble(currentTempString);
                        double newTempValue        = (currentTempValue - 32) * 5 / 9;
                        var    roundedNewTempValue = Math.Round(newTempValue, 0, MidpointRounding.AwayFromZero);
                        MainActivity.temperatureTextView.Text = roundedNewTempValue.ToString() + "°C";
                    }
                };

                return(view);
            }
            else
            {
                view = context.LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItem1, parent, false);
                return(view);
            }
        }
Exemplo n.º 37
0
 public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
 {
     //return base.OnCreateView(inflater, container, savedInstanceState);
     Android.Views.View view = inflater.Inflate(Resource.Layout.rigth_Fragment, container, false);
     return(view);
 }
Exemplo n.º 38
0
        bool CanScrollUp(Android.Views.View view)
        {
            if (this.RefreshView.IsPullToRefreshEnabled == false)
            {
                return(true);
            }

            var viewGroup = view as ViewGroup;

            if (viewGroup == null)
            {
                return(base.CanChildScrollUp());
            }

            var sdk = (int)global::Android.OS.Build.VERSION.SdkInt;

            if (sdk >= 16)
            {
                //is a scroll container such as listview, scroll view, gridview
                if (viewGroup.IsScrollContainer)
                {
                    var can = base.CanChildScrollUp();
                    return(can);
                }
            }

            //if you have something custom and you can't scroll up you might need to enable this
            //for instance on a custom recycler view where the code above isn't working!
            for (int i = 0; i < viewGroup.ChildCount; i++)
            {
                var child = viewGroup.GetChildAt(i);
                if (child is Android.Widget.AbsListView)
                {
                    var list = child as Android.Widget.AbsListView;
                    if (list != null)
                    {
                        if (list.FirstVisiblePosition == 0)
                        {
                            var subChild = list.GetChildAt(0);

                            return(subChild != null && subChild.Top != 0);
                        }

                        //if children are in list and we are scrolled a bit... sure you can scroll up
                        return(true);
                    }
                }
                else if (child is Android.Widget.ScrollView)
                {
                    var scrollview = child as Android.Widget.ScrollView;
                    return(scrollview.ScrollY <= 0.0);
                }
                else if (child is Android.Webkit.WebView)
                {
                    var webView = child as Android.Webkit.WebView;
                    return(webView.ScrollY > 0.0);
                }
                else if (child is Android.Support.V4.Widget.SwipeRefreshLayout)
                {
                    return(CanScrollUp(child as ViewGroup));
                }
                //else if something else like a recycler view?
            }

            return(false);
        }
Exemplo n.º 39
0
 ///<inheritdoc/>
 protected override AvailableQuestViewHolder CreateViewHolder(Android.Views.View view)
 {
     return(new AvailableQuestViewHolder(view));
 }
Exemplo n.º 40
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="child"></param>
        /// <param name="drawingTime"></param>
        /// <returns></returns>
        protected override bool DrawChild(Canvas canvas, Android.Views.View child, long drawingTime)
        {
            try
            {
                var radius = (float)Math.Min(Width, Height) / 2f;

                var borderThickness = ((CircleImage)Element).BorderThickness;

                float strokeWidth = 0f;

                if (borderThickness > 0)
                {
                    var logicalDensity = Xamarin.Forms.Forms.Context.Resources.DisplayMetrics.Density;
                    strokeWidth = (float)Math.Ceiling(borderThickness * logicalDensity + .5f);
                }

                radius -= strokeWidth / 2f;



                var path = new Path();
                path.AddCircle(Width / 2.0f, Height / 2.0f, radius, Path.Direction.Ccw);


                canvas.Save();
                canvas.ClipPath(path);



                var paint = new Paint
                {
                    AntiAlias = true
                };
                paint.SetStyle(Paint.Style.Fill);
                paint.Color = ((CircleImage)Element).FillColor.ToAndroid();
                canvas.DrawPath(path, paint);
                paint.Dispose();


                var result = base.DrawChild(canvas, child, drawingTime);

                path.Dispose();
                canvas.Restore();

                path = new Path();
                path.AddCircle(Width / 2f, Height / 2f, radius, Path.Direction.Ccw);


                if (strokeWidth > 0.0f)
                {
                    paint = new Paint
                    {
                        AntiAlias   = true,
                        StrokeWidth = strokeWidth
                    };
                    paint.SetStyle(Paint.Style.Stroke);
                    paint.Color = ((CircleImage)Element).BorderColor.ToAndroid();
                    canvas.DrawPath(path, paint);
                    paint.Dispose();
                }

                path.Dispose();
                return(result);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
            }

            return(base.DrawChild(canvas, child, drawingTime));
        }
Exemplo n.º 41
0
 //have to decide children size when OnLayoutChange.
 public void OnLayoutChange(Android.Views.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
 {
     _layout.Right  = v.Width;
     _layout.Bottom = v.Height;
 }
Exemplo n.º 42
0
 public Size MeasureElement(View element, Size availableSize) => MeasureChild(element, availableSize);
Exemplo n.º 43
0
 public void ArrangeElement(View element, Rect finalRect) => ArrangeChild(element, finalRect);
Exemplo n.º 44
0
 protected override void MeasureChild(View view, int widthSpec, int heightSpec) => view.Measure(widthSpec, heightSpec);
Exemplo n.º 45
0
 public override bool IsViewFromObject(AView.View view, Java.Lang.Object obj)
 {
     return(view == obj);
 }
Exemplo n.º 46
0
        public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var shellSection = ShellSection;

            if (shellSection == null)
            {
                return(null);
            }

            if (shellSection.CurrentItem == null)
            {
                throw new InvalidOperationException($"Content not found for active {shellSection}. Title: {shellSection.Title}. Route: {shellSection.Route}.");
            }

            var context         = Context;
            var root            = PlatformInterop.CreateShellCoordinatorLayout(context);
            var appbar          = PlatformInterop.CreateShellAppBar(context, Resource.Attribute.appBarLayoutStyle, root);
            int actionBarHeight = context.GetActionBarHeight();

            var shellToolbar = new Toolbar(shellSection);

            ShellToolbarTracker.ApplyToolbarChanges(_shellContext.Shell.Toolbar, shellToolbar);
            _toolbar = (AToolbar)shellToolbar.ToPlatform(_shellContext.Shell.FindMauiContext());
            appbar.AddView(_toolbar);
            _tablayout = PlatformInterop.CreateShellTabLayout(context, appbar, actionBarHeight);

            var pagerContext        = MauiContext.MakeScoped(layoutInflater: inflater, fragmentManager: ChildFragmentManager);
            var adapter             = new ShellFragmentStateAdapter(shellSection, ChildFragmentManager, pagerContext);
            var pageChangedCallback = new ViewPagerPageChanged(this);

            _viewPager = PlatformInterop.CreateShellViewPager(context, root, _tablayout, this, adapter, pageChangedCallback);

            Page currentPage  = null;
            int  currentIndex = -1;
            var  currentItem  = shellSection.CurrentItem;
            var  items        = SectionController.GetItems();

            while (currentIndex < 0 && items.Count > 0 && shellSection.CurrentItem != null)
            {
                currentItem = shellSection.CurrentItem;
                currentPage = ((IShellContentController)shellSection.CurrentItem).GetOrCreateContent();

                // current item hasn't changed
                if (currentItem == shellSection.CurrentItem)
                {
                    currentIndex = items.IndexOf(currentItem);
                }
            }

            _toolbarTracker = _shellContext.CreateTrackerForToolbar(_toolbar);
            _toolbarTracker.SetToolbar(shellToolbar);
            _toolbarTracker.Page = currentPage;

            _viewPager.CurrentItem = currentIndex;

            if (items.Count == 1)
            {
                UpdateTablayoutVisibility();
            }

            _tablayout.LayoutChange += OnTabLayoutChange;

            _tabLayoutAppearanceTracker = _shellContext.CreateTabLayoutAppearanceTracker(ShellSection);
            _toolbarAppearanceTracker   = _shellContext.CreateToolbarAppearanceTracker();

            HookEvents();

            return(_rootView = root);
        }
Exemplo n.º 47
0
 public void OnClick(Android.Views.View v)
 {
     mainActivity.OnBackPressed();
 }
Exemplo n.º 48
0
 void AView.IOnClickListener.OnClick(AView v)
 {
 }
Exemplo n.º 49
0
 void ViewTreeObserver.IOnGlobalLayoutListener.OnGlobalLayout()
 {
     _gridChild = ViewGroup.GetChildAt(0);
     _gridChild.SetOnTouchListener(this);
 }
Exemplo n.º 50
0
 public void OnClick(AView v)
 {
     Element?.PopAsync();
 }
Exemplo n.º 51
0
 public override void OnViewRemoved(Android.Views.View child)
 {
     base.OnViewRemoved(child);
     navView.NavigationItemSelected   -= NavView_NavigationItemSelected;
     Settings.Current.PropertyChanged -= SettingsPropertyChanged;
 }
Exemplo n.º 52
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            AToolbar bar = _toolbar;

            // make sure bar stays on top of everything
            bar.BringToFront();

            int barHeight = ActionBarHeight();

            if (Element.IsSet(BarHeightProperty))
            {
                barHeight = Element.OnThisPlatform().GetBarHeight();
            }

            if (barHeight != _lastActionBarHeight && _lastActionBarHeight > 0)
            {
                ResetToolbar();
                bar = _toolbar;
            }
            _lastActionBarHeight = barHeight;

            bar.Measure(MeasureSpecFactory.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(barHeight, MeasureSpecMode.Exactly));

            var barOffset       = ToolbarVisible ? barHeight : 0;
            int containerHeight = b - t - ContainerTopPadding - barOffset - ContainerBottomPadding;

            PageController.ContainerArea = new Rectangle(0, 0, Context.FromPixels(r - l), Context.FromPixels(containerHeight));

            // Potential for optimization here, the exact conditions by which you don't need to do this are complex
            // and the cost of doing when it's not needed is moderate to low since the layout will short circuit pretty fast
            Element.ForceLayout();

            base.OnLayout(changed, l, t, r, b);

            bool toolbarLayoutCompleted = false;

            for (var i = 0; i < ChildCount; i++)
            {
                AView child = GetChildAt(i);

                Page childPage = (child as PageContainer)?.Child?.Element as Page;

                if (childPage == null)
                {
                    return;
                }

                // We need to base the layout of both the child and the bar on the presence of the NavBar on the child Page itself.
                // If we layout the bar based on ToolbarVisible, we get a white bar flashing at the top of the screen.
                // If we layout the child based on ToolbarVisible, we get a white bar flashing at the bottom of the screen.
                bool childHasNavBar = NavigationPage.GetHasNavigationBar(childPage);

                if (childHasNavBar)
                {
                    bar.Layout(0, 0, r - l, barHeight);
                    child.Layout(0, barHeight + ContainerTopPadding, r, b - ContainerBottomPadding);
                }
                else
                {
                    bar.Layout(0, -1000, r, barHeight - 1000);
                    child.Layout(0, ContainerTopPadding, r, b - ContainerBottomPadding);
                }
                toolbarLayoutCompleted = true;
            }

            // Making the layout of the toolbar dependant on having a child Page could potentially mean that the toolbar is not laid out.
            // We'll do one more check to make sure it isn't missed.
            if (!toolbarLayoutCompleted)
            {
                if (ToolbarVisible)
                {
                    bar.Layout(0, 0, r - l, barHeight);
                }
                else
                {
                    bar.Layout(0, -1000, r, barHeight - 1000);
                }
            }
        }
Exemplo n.º 53
0
 void AView.IOnClickListener.OnClick(AView v)
 {
     _tapGestureHandler.OnSingleClick();
 }
Exemplo n.º 54
0
        public static void HideKeyboard(View pView)
        {
            InputMethodManager inputMethodManager = Current.GetSystemService(Context.InputMethodService) as InputMethodManager;

            inputMethodManager.HideSoftInputFromWindow(pView.WindowToken, HideSoftInputFlags.None);
        }
Exemplo n.º 55
0
 public static void UpdateVisibility(this AView platformView, IView view)
 {
     platformView.Visibility = view.Visibility.ToPlatformVisibility();
 }
Exemplo n.º 56
0
        public static Drawable GenerateBackgroundWithShadow(RoundedCornerView control, Android.Views.View child, Android.Graphics.Color backgroundColor,
                                                            Android.Graphics.Color shadowColor,
                                                            int elevation,
                                                            GravityFlags shadowGravity)
        {
            var radii = GetRadii(control);

            int DY;

            switch (shadowGravity)
            {
            case GravityFlags.Center:
                DY = 0;
                break;

            case GravityFlags.Top:
                DY = -1 * elevation / 3;
                break;

            default:
            case GravityFlags.Bottom:
                DY = elevation / 3;
                break;
            }

            var shapeDrawable = new ShapeDrawable();

            shapeDrawable.Paint.Color = backgroundColor;
            shapeDrawable.Paint.SetShadowLayer(elevation, 0, DY, shadowColor);

            child.SetLayerType(LayerType.Software, shapeDrawable.Paint);

            shapeDrawable.Shape = new RoundRectShape(radii, null, null);

            var drawable = new LayerDrawable(new Drawable[] { shapeDrawable });

            drawable.SetLayerInset(0, elevation, elevation, elevation, elevation);

            child.Background = drawable;
            return(drawable);
        }
Exemplo n.º 57
0
 public static void Unfocus(this AView platformView, IView view)
 {
     platformView.ClearFocus();
 }
 public override bool IsViewFromObject(A.View view, Java.Lang.Object @object)
 {
     return(view == @object);
 }
 public void OnDrawerSlide(AView drawerView, float slideOffset)
 {
 }
Exemplo n.º 60
0
 public static void UpdateIsEnabled(this AView platformView, IView view)
 {
     platformView.Enabled = view.IsEnabled;
 }