public void OnLocationChanged(Android.Locations.Location location) { if (location.Provider != ActiveProvider) { if (ActiveProvider != null && Manager.IsProviderEnabled(ActiveProvider)) { var lapsed = ToTime(location.Time) - ToTime(LatestLocation.Time); if (Manager.GetProvider(location.Provider).Accuracy > Manager.GetProvider(ActiveProvider).Accuracy && lapsed < ReportIntervals.Add(ReportIntervals)) { location.Dispose(); return; } } ActiveProvider = location.Provider; } Interlocked.Exchange(ref LatestLocation, location)?.Dispose(); var position = location.ToGeoPosition(); PositionChanged.RaiseOn(Zebble.Thread.Pool, position); }
public void OnProviderDisabled(string provider) { if (provider == LocationManager.PassiveProvider) { return; } lock (ActiveProviders) { if (ActiveProviders.Remove(provider) && ActiveProviders.None()) { PositionError.RaiseOn(Zebble.Thread.Pool, new Exception(UNAVAILABLE_ERROR)); } } }
async Task DoPlay(string file) { await Stop(OnError.Ignore); Ended = new TaskCompletionSource <bool>(); if (file.IsUrl()) { await PlayStream(file); } else { await PlayFile(file); } await Completed.RaiseOn(Thread.Pool); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var bundle = savedInstanceState ?? Intent.Extras; RequestId = bundle.GetInt("id"); Action = bundle.GetString("action"); AllowMultiple = bundle.GetBoolean(Intent.ExtraAllowMultiple); PurgeCameraRoll = bundle.GetBoolean("purge-camera-roll"); Type = bundle.GetString("type"); FrontCamera = bundle.GetBoolean("front"); if (Type == "video/*") { IsVideo = true; } using (var intent = new Intent(Action)) { try { if (Action == Intent.ActionPick) { intent.SetType(Type); intent.PutExtra(Intent.ExtraAllowMultiple, AllowMultiple); } else { if (IsVideo) { MaxSeconds = bundle.GetInt(MediaStore.ExtraDurationLimit, 0); if (MaxSeconds != 0) { intent.PutExtra(MediaStore.ExtraDurationLimit, MaxSeconds); } VideoQuality = (VideoQuality)bundle.GetInt(MediaStore.ExtraVideoQuality, (int)VideoQuality.High); intent.PutExtra(MediaStore.ExtraVideoQuality, VideoQuality == VideoQuality.Low ? 0 : 1); } if (FrontCamera) { intent.PutExtra("android.intent.extras.CAMERA_FACING", 1); } var file = new Java.IO.File(PrepareTempStorageFile().FullName); Uri path; var packageName = UIRuntime.CurrentActivity.PackageName; if (Build.VERSION.SdkInt >= BuildVersionCodes.N) { path = FileProvider.GetUriForFile(Application.Context, $"{packageName}.fileprovider", file); } else { path = Uri.FromFile(file); } intent.PutExtra(MediaStore.ExtraOutput, path); FileUrlPath = path; FileAbsolotePath = file.AbsolutePath; } // if (intent.ResolveActivity(PackageManager) != null) // Removed due to Android 11 changes. // https://cketti.de/2020/09/03/avoid-intent-resolveactivity/ // https://stackoverflow.com/questions/62535856/intent-resolveactivity-returns-null-in-api-30 StartActivityForResult(intent, RequestId, savedInstanceState); } catch (Exception ex) { Log.For(this).Error(ex); Picked.RaiseOn(Thread.Pool, new MediaPickedEventArgs(RequestId, ex)); Finish(); } } }
public void Rotate() => RotateRequested.RaiseOn(Thread.UI);