protected override void OnRestoreInstanceState(Android.OS.IParcelable state) { if (state is Bundle) { Bundle bundle = (Bundle)state; SetProgress(bundle.GetFloat("progress")); SetMarkerProgress(bundle.GetFloat("marker_progress")); int progressColor = bundle.GetInt("progress_color"); if (progressColor != _progressColor) { _progressColor = progressColor; UpdateProgressColor(); } int progressBackgroundColor = bundle.GetInt("progress_background_color"); if (progressBackgroundColor != _progressBackgroundColor) { _progressBackgroundColor = progressBackgroundColor; UpdateBackgroundColor(); } _isThumbEnabled = bundle.GetBoolean("thumb_visible"); _isMarkerEnabled = bundle.GetBoolean("marker_visible"); base.OnRestoreInstanceState((IParcelable)bundle.GetParcelable("saved_state")); return; } base.OnRestoreInstanceState(state); }
protected override void OnRestoreInstanceState(IParcelable state) { Bundle bundle = (Bundle)state; IParcelable superState = (IParcelable)bundle.GetParcelable("superState"); base.OnRestoreInstanceState(superState); mNeedleInitialized = bundle.GetBoolean("needleInitialized"); mNeedleVelocity = bundle.GetFloat("needleVelocity"); mNeedleAcceleration = bundle.GetFloat("needleAcceleration"); mNeedleLastMoved = bundle.GetLong("needleLastMoved"); mCurrentValue = bundle.GetFloat("currentValue"); mTargetValue = bundle.GetFloat("targetValue"); }
internal static object GetValue(this Bundle args, string key, Type type) { if (type == typeof(string)) { return(args.GetString(key)); } else if (type == typeof(int)) { return(args.GetInt(key)); } else if (type == typeof(bool)) { return(args.GetBoolean(key)); } else if (type == typeof(double)) { return(args.GetDouble(key)); } else if (type == typeof(float)) { return(args.GetFloat(key)); } else if (type == typeof(short)) { return(args.GetShort(key)); } else if (type == typeof(DateTime)) { return(new DateTime(args.GetLong(key))); } else if (type == typeof(char)) { return(args.GetChar(key)); } else if (typeof(Parcelable).IsAssignableFrom(type)) { return(args.GetParcelable(key)); } else if (type is Java.IO.ISerializable) { return(args.GetSerializable(key)); } else if (type.IsValueType == false) //Runtime serialization for reference type.. use json.net serialization { var value = args.GetString(key); if (string.IsNullOrWhiteSpace(value)) { return(null); } return(Newtonsoft.Json.JsonConvert.DeserializeObject(value, type)); } else { //TODO: Add support for arrays throw new ArgumentException(string.Format("Unsuported type. Cannot pass value to variable {0} of step {1}. Variable type is unsuported.", key, type.FullName)); } }
public float GetFloat(float defaultValue = default, string?key = null) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(key)); } return(_bundle.GetFloat(key, defaultValue)); }
/// <inheritdoc /> public float GetFloat(float defaultValue = default, [CallerMemberName] string?key = null) { if (key == null) { throw new ArgumentNullException(nameof(key)); } return(_bundle.GetFloat(key, defaultValue)); }
protected override void OnRestoreInstanceState(IParcelable state) { Bundle savedState = (Bundle)state; IParcelable superState = (IParcelable)savedState.GetParcelable(STATE_PARENT); base.OnRestoreInstanceState(superState); setColor(Color.HSVToColor(savedState.GetFloatArray(STATE_COLOR))); if (savedState.ContainsKey(STATE_SATURATION)) { setSaturation(savedState.GetFloat(STATE_SATURATION)); } else { setValue(savedState.GetFloat(STATE_VALUE)); } }
protected override void OnRestoreInstanceState(IParcelable state) { if (state is Bundle) { Bundle bundle = (Bundle)state; normalizedScale = bundle.GetFloat("saveScale"); m = bundle.GetFloatArray("matrix"); prevMatrix.SetValues(m); prevMatchViewHeight = bundle.GetFloat("matchViewHeight"); prevMatchViewWidth = bundle.GetFloat("matchViewWidth"); prevViewHeight = bundle.GetInt("viewHeight"); prevViewWidth = bundle.GetInt("viewWidth"); imageRenderedAtLeastOnce = bundle.GetBoolean("imageRendered"); base.OnRestoreInstanceState((IParcelable)bundle.GetParcelable("instanceState")); return; } base.OnRestoreInstanceState(state); }
protected override void OnRestoreInstanceState(IParcelable state) { Bundle savedState = (Bundle)state; IParcelable superState = (IParcelable)savedState.GetParcelable(STATE_PARENT); base.OnRestoreInstanceState(superState); setColor(Color.HSVToColor(savedState.GetFloatArray(STATE_COLOR))); setValue(savedState.GetFloat(STATE_VALUE)); }
public static void RestoreFromBundle(Bundle bundle) { GoldCollected = bundle.GetInt(GOLD); DeepestFloor = bundle.GetInt(DEEPEST); EnemiesSlain = bundle.GetInt(SLAIN); FoodEaten = bundle.GetInt(FOOD); PotionsCooked = bundle.GetInt(ALCHEMY); PiranhasKilled = bundle.GetInt(PIRANHAS); NightHunt = bundle.GetInt(NIGHT); AnkhsUsed = bundle.GetInt(ANKHS); Duration = bundle.GetFloat(DURATION); AmuletObtained = bundle.GetBoolean(AMULET); }
public static WifiLocation ToWifiLocation(this Bundle model) { var wifiLocation = new WifiLocation(); wifiLocation.Accuracy = model.GetFloat(nameof(wifiLocation.Accuracy)); wifiLocation.DisplayName = model.GetString(nameof(wifiLocation.DisplayName)); wifiLocation.Enabled = model.GetBoolean(nameof(wifiLocation.Enabled)); wifiLocation.Lat = model.GetDouble(nameof(wifiLocation.Lat)); wifiLocation.Lon = model.GetDouble(nameof(wifiLocation.Lon)); wifiLocation.SSID = model.GetString(nameof(wifiLocation.SSID)); return(wifiLocation); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Sensors); trackButton = FindViewById <Button> (Resource.Id.trackButton); stepCount = FindViewById <TextView> (Resource.Id.stepCount); // create a sensor manager to schedule batches of sensor data senMgr = (SensorManager)GetSystemService(SensorService); // update state from orientation change if (bundle != null) { count = bundle.GetFloat("step_count", 0); if (bundle.GetBoolean("visible", false)) { visible = true; stepCount.Text = count.ToString(); } Log.Debug(GetType().FullName, "Recovered instance state"); } // This button gets the user's step count since the last time the device was rebooted trackButton.Click += (o, e) => { // get the step counter sensor via the SensorManager counter = senMgr.GetDefaultSensor(SensorType.StepCounter); // button's been clicked, so counter visibility gets set to true visible = true; // This sensor is only available on Nexus 5 and Moto X at time of writing // The following line will check if the sensor is available explicitly: bool counterAvailabe = PackageManager.HasSystemFeature(PackageManager.FeatureSensorStepCounter); Log.Info("SensorManager", "Counter available"); if (counterAvailabe && counter != null) { // Set sensor delay to normal, the default rate for batching sensor data senMgr.RegisterListener(this, counter, SensorDelay.Normal); Toast.MakeText(this, "Count sensor started", ToastLength.Long).Show(); } else { Toast.MakeText(this, "Count sensor unavailable", ToastLength.Long).Show(); } }; }
public override void HandleMessage(Message msg) { base.HandleMessage(msg); if (mActivity == null || mActivity.IsFinishing) { return; } if (msg.What == LiveSkeletonAnalyseActivity.UpdateView) { Bundle bundle = msg.Data; float result = bundle.GetFloat("similarity"); mActivity.similarityTxt.Visibility = ViewStates.Visible; mActivity.similarityTxt.Text = ("similarity:" + (int)(result * 100) + "%"); } }
protected override void OnRestoreInstanceState(IParcelable state) { Bundle savedState = (Bundle)state; IParcelable superState = (IParcelable)savedState.GetParcelable(STATE_PARENT); base.OnRestoreInstanceState(superState); mAngle = savedState.GetFloat(STATE_ANGLE); setOldCenterColor(savedState.GetInt(STATE_OLD_COLOR)); mShowCenterOldColor = savedState.GetBoolean(STATE_SHOW_OLD_COLOR); int currentColor = calculateColor(mAngle); mPointerColor.Color = new Color(currentColor); setNewCenterColor(currentColor); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Sensors); trackButton = FindViewById<Button> (Resource.Id.trackButton); stepCount = FindViewById<TextView> (Resource.Id.stepCount); // create a sensor manager to schedule batches of sensor data senMgr = (SensorManager) GetSystemService (SensorService); // update state from orientation change if (bundle != null) { count = bundle.GetFloat ("step_count", 0); if (bundle.GetBoolean ("visible", false)) { visible = true; stepCount.Text = count.ToString (); } Log.Debug(GetType().FullName, "Recovered instance state"); } // This button gets the user's step count since the last time the device was rebooted trackButton.Click += (o, e) => { // get the step counter sensor via the SensorManager counter = senMgr.GetDefaultSensor (SensorType.StepCounter); // button's been clicked, so counter visibility gets set to true visible = true; // This sensor is only available on Nexus 5 and Moto X at time of writing // The following line will check if the sensor is available explicitly: bool counterAvailabe = PackageManager.HasSystemFeature(PackageManager.FeatureSensorStepCounter); Log.Info("SensorManager", "Counter available"); if (counterAvailabe && counter != null) { // Set sensor delay to normal, the default rate for batching sensor data senMgr.RegisterListener(this, counter, SensorDelay.Normal); Toast.MakeText(this,"Count sensor started",ToastLength.Long).Show(); } else { Toast.MakeText(this, "Count sensor unavailable", ToastLength.Long).Show(); } }; }
public override void RestoreFromBundle(Bundle bundle) { base.RestoreFromBundle(bundle); left = bundle.GetFloat(Left); }
protected override void OnCreate(Bundle savedInstanceState) { powerManager = (PowerManager)GetSystemService(Context.PowerService); wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "MyWakeLock"); wakeLock.Acquire(); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Pedometer); chrono = FindViewById<Chronometer>(Resource.Id.chronometer1); sensorManager = (SensorManager)GetSystemService(Context.SensorService); stepsTextView = FindViewById<TextView>(Resource.Id.pedometer); caloriesTextView = FindViewById<TextView>(Resource.Id.calories); speedTextView = FindViewById<TextView>(Resource.Id.speed); distanceTextView = FindViewById<TextView>(Resource.Id.distance); timeTextView = FindViewById<TextView>(Resource.Id.time); if (savedInstanceState != null) { steps = savedInstanceState.GetInt("steps", 0); calories = savedInstanceState.GetFloat("calories", 0.0f); speed = savedInstanceState.GetFloat("speed", 0.0f); distance = savedInstanceState.GetFloat("distance", 0.0f); chrono.Base = savedInstanceState.GetLong("time", SystemClock.ElapsedRealtime()); run = savedInstanceState.GetBoolean("run", false); } chrono.Format = "00:0%s"; chrono.OnChronometerTickListener = this; int h = 480; mYOffset = h * 0.5f; mScale[0] = -(h * 0.5f * (1.0f / (SensorManager.StandardGravity * 2))); mScale[1] = -(h * 0.5f * (1.0f / (SensorManager.MagneticFieldEarthMax))); if (run) { refreshTextViews(); sensorsListenerRegister(); chrono.Start(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); labyrinth = LabyrinthGenerator.GenerateLabyrinth(labyrinthName, this); SetContentView(Resource.Layout.Main); GridLayout layout = FindViewById <GridLayout>(Resource.Id.gridLayout1); LabyrinthViewGenerator.Generate(labyrinth, layout, this); heroImage = FindViewById <ImageView>(Resource.Id.imageView1); if (bundle != null) { time = bundle.GetInt("time"); iterator = bundle.GetInt("iterator"); heroImage.TranslationX = bundle.GetFloat("HeroPositionX"); var surfaceOrientation = WindowManager.DefaultDisplay.Rotation; if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) { heroImage.TranslationX += 350; } else { heroImage.TranslationX -= 350; } heroImage.TranslationY = bundle.GetFloat("HeroPositionY"); } else { var surfaceOrientation = WindowManager.DefaultDisplay.Rotation; if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) { heroImage.TranslationX = -460 + labyrinth.Start.XCoord * 150; } else { heroImage.TranslationX = -810 + labyrinth.Start.XCoord * 150; } heroImage.TranslationY = labyrinth.Start.YCoord * 150 + 40; } Hero hero = new Hero(labyrinth.Finish); hero.MoveToNextRoom(labyrinth.Start); List <Coordinates> journey = hero.journey; ValueAnimator animator = ValueAnimator.OfInt(0, 10); animator.SetDuration(1000 * journey.Count); animator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) => { float shift = 15; if (iterator == journey.Count - 1) { return; } if (journey[iterator].X < journey[iterator + 1].X) { heroImage.TranslationX += shift; } if (journey[iterator].X > journey[iterator + 1].X) { heroImage.TranslationX -= shift; } if (journey[iterator].Y < journey[iterator + 1].Y) { heroImage.TranslationY += shift; } if (journey[iterator].Y > journey[iterator + 1].Y) { heroImage.TranslationY -= shift; } if (time++ > 8) { iterator++; time = 0; } }; animator.Start(); }
protected override void OnRestoreInstanceState(Bundle savedInstanceState) { base.OnRestoreInstanceState(savedInstanceState); _badge.BackgroundColor = new Color(savedInstanceState.GetInt("color")); _badge.CornerRadius = savedInstanceState.GetFloat("cornerRadius"); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Console.WriteLine("OnCreate Called"); Window.RequestFeature(WindowFeatures.NoTitle); AppCenter.Start("7ac229ee-9940-46b8-becc-d2611c48b2ad", typeof(Analytics), typeof(Crashes), typeof(Push), typeof(Distribute)); Push.SetSenderId(firebaseSenderId); Push.PushNotificationReceived += PushNotificationRecieved; currState = LastCustomNonConfigurationInstance as SaveState; SetContentView(Resource.Layout.Main); if (currState == null) { await ServiceLayer.SharedInstance.InitalizeSettings(); for (int i = 1; i <= NumPokes; i++) { try { pokeResourceMap[i] = (int)typeof(Resource.Mipmap).GetField($"p{i.ToString("d3")}").GetValue(null); } catch (Exception e) { Console.WriteLine($"poke {i} not found"); } } Console.WriteLine("No saved state"); } else { pokeResourceMap = currState.ResourceMap; Console.WriteLine("saved state recalled"); } lastUpdate = DateTime.UtcNow; if (savedInstanceState != null && savedInstanceState.ContainsKey("centerLat") && currState == null) { var cLat = savedInstanceState.GetDouble("centerLat"); var cLon = savedInstanceState.GetDouble("centerLon"); var zoom = savedInstanceState.GetFloat("centerZoom"); var update = savedInstanceState.GetLong("lastUpdate"); lastUpdate = Utility.FromUnixTime(update); currState = new SaveState() { CurrentCenter = new LatLng(cLat, cLon), CurrentZoom = zoom }; } _mapFragment = FragmentManager.FindFragmentByTag("map") as MapFragment; progress = FindViewById(Resource.Id.progressBar) as ProgressBar; if (_mapFragment == null) { CameraPosition startCam; if (currState == null) { startCam = new CameraPosition(mDefaultLocation, defaultZoom, 0.0f, 0.0f); //CameraUpdateFactory.NewLatLngZoom(mDefaultLocation, defaultZoom); } else { startCam = new CameraPosition(currState.CurrentCenter, currState.CurrentZoom, 0.0f, 0.0f); } GoogleMapOptions mapOptions = new GoogleMapOptions() .InvokeMapType(GoogleMap.MapTypeNormal) .InvokeZoomControlsEnabled(false) .InvokeCompassEnabled(true) .InvokeRotateGesturesEnabled(false) .InvokeCamera(startCam); Android.App.FragmentTransaction fragTx = FragmentManager.BeginTransaction(); _mapFragment = MapFragment.NewInstance(mapOptions); fragTx.Add(Resource.Id.map, _mapFragment, "map"); fragTx.Commit(); } loginHolder = FindViewById(Resource.Id.loginHolder) as CardView; username = FindViewById(Resource.Id.username) as EditText; if (settings.LoggedIn) { loginHolder.Visibility = ViewStates.Gone; _mapFragment.GetMapAsync(this); var imm = GetSystemService(Context.InputMethodService) as InputMethodManager; imm.HideSoftInputFromWindow(username.WindowToken, 0); if (currState == null) { await LoadData(); } else if (lastUpdate < DateTime.UtcNow.AddSeconds(-20)) { RefreshMapData(null); } } else { loginHolder.Visibility = ViewStates.Visible; password = FindViewById(Resource.Id.password) as EditText; username.RequestFocus(); _mapFragment.GetMapAsync(this); } var loginButton = FindViewById(Resource.Id.signInButton) as Button; loginButton.Click += LoginButton_Click; var settingButton = FindViewById(Resource.Id.settingsButton); settingButton.Click += SettingButton_Click; var layerButton = FindViewById(Resource.Id.layerssButton); layerButton.Click += LayerButton_Click; settingsHolder = FindViewById(Resource.Id.settingsHolder) as CardView; var settingsDone = settingsHolder.FindViewById(Resource.Id.settingsDoneButton); settingsDone.Click += SettingsDone_Click; var settingsInfo = settingsHolder.FindViewById(Resource.Id.settingsInfoButton); settingsInfo.Click += SettingsInfo_Click; var hideButton = FindViewById(Resource.Id.hideButton) as Button; var notifyButton = FindViewById(Resource.Id.notifyButton) as Button; hideButton.Click += HideButton_Click; notifyButton.Click += NotifyButton_Click1; progress.Indeterminate = true; settingsListview = FindViewById(Resource.Id.settingsListView) as ListView; settingsListview.Adapter = new SettingsAdaptor(this, pokeResourceMap); App.Current.LocationServiceConnected += (object sender, ServiceConnectedEventArgs e) => { Log.Debug("MainActivity", "ServiceConnected Event Raised"); }; App.StartLocationService(); }
public override void RestoreFromBundle(Bundle bundle) { base.RestoreFromBundle(bundle); _level = bundle.GetFloat(Level); }
public virtual void RestoreFromBundle(Bundle bundle) { _time = bundle.GetFloat(TIME); }