protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.snake_layout); Button b1 = (Button)FindViewById (Resource.Id.button1); b1.SetX (200); b1.SetY (530); b1.SetHeight (60); b1.SetWidth (60); b1.Text = "Arriba"; b1.Click += delegate { snake_view.keypress(Keycode.DpadUp); }; Button b2 = (Button)FindViewById(Resource.Id.button2); b2.SetX(200); b2.SetY(610); b2.SetHeight (60); b2.SetWidth (60); b2.Text = "Abajo"; b2.Click += delegate { snake_view.keypress(Keycode.DpadDown); }; Button b3 = (Button)FindViewById(Resource.Id.button3); b3.SetX(100); b3.SetY(610); b3.Text = "Izq."; b3.SetHeight (60); b3.SetWidth (60); b3.Click += delegate { snake_view.keypress(Keycode.DpadLeft); }; Button b4 = (Button)FindViewById(Resource.Id.button4); b4.SetX(300); b4.SetY(610); b4.Text = "Der."; b4.SetHeight (60); b4.SetWidth (60); b4.Click += delegate { snake_view.keypress(Keycode.DpadRight); }; snake_view = (GameView)FindViewById(Resource.Id.snake); snake_view.SetTextView((TextView)FindViewById(Resource.Id.text)); if (savedInstanceState == null) { snake_view.SetMode (GameMode.Ready); } else { Bundle map = savedInstanceState.GetBundle (ICICLE_KEY); if (map != null) snake_view.RestoreState (map); else snake_view.SetMode (GameMode.Paused); } }
// Called when Activity is first created. Turns off the title bar, sets up // the content views, and fires up the SnakeView. protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.snake_layout); snake_view = FindViewById <SnakeView> (Resource.Id.snake); snake_view.SetTextView(FindViewById <TextView> (Resource.Id.text)); if (savedInstanceState == null) { // We were just launched -- set up a new game snake_view.SetMode(GameMode.Ready); } else { // We are being restored Bundle map = savedInstanceState.GetBundle(ICICLE_KEY); if (map != null) { snake_view.RestoreState(map); } else { snake_view.SetMode(GameMode.Paused); } } }
public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); MRequestFocus = delegate { mList.FocusableViewAvailable(mList); }; mHandler = new MyPreferenceFragmentHandler(this); if (mHavePrefs) { BindPreferences(); } mInitDone = true; if (savedInstanceState != null) { Bundle container = savedInstanceState.GetBundle(PREFERENCES_TAG); if (container != null) { PreferenceScreen preferenceScreen = PreferenceScreen; if (preferenceScreen != null) { preferenceScreen.RestoreHierarchyState(container); } } } }
protected override void OnCreate(Bundle savedInstanceState) { Log.Debug(TAG, "OnCreate: "); base.OnCreate(savedInstanceState); HuaweiMapOptions huaweiMapOptions = new HuaweiMapOptions(); huaweiMapOptions.InvokeCompassEnabled(true); huaweiMapOptions.InvokeZoomControlsEnabled(true); huaweiMapOptions.InvokeScrollGesturesEnabled(true); huaweiMapOptions.InvokeZoomGesturesEnabled(true); mMapView = new MapView(this, huaweiMapOptions); Bundle mapViewBundle = null; if (savedInstanceState != null) { mapViewBundle = savedInstanceState.GetBundle(MAPVIEW_BUNDLE_KEY); } // please replace "Your API key" with api_key field value in // agconnect-services.json if the field is null. MapsInitializer.SetApiKey(Constants.API_KEY); mMapView.OnCreate(mapViewBundle); mMapView.GetMapAsync(this); SetContentView(mMapView); }
/// <summary> /// Restore current states from savedInstanceState. /// </summary> /// <param name="savedInstanceState">Saved instance state.</param> /// <param name="key">Key.</param> public void RestoreStatesFromKey(Bundle savedInstanceState, string key) { if (savedInstanceState != null && savedInstanceState.ContainsKey(key)) { Arguments = savedInstanceState.GetBundle(key); } }
void RestoreQuizState(Bundle savedInstanceState) { if (null == savedInstanceState) { return; } EventHandler <View.LayoutChangeEventArgs> handler = null; handler += (sender, e) => { quizView.LayoutChange -= handler; var currentChild = quizView.GetChildAt(0); var viewGroup = currentChild as ViewGroup; if (viewGroup == null) { return; } var potentialQuizView = viewGroup.GetChildAt(0); var absQuizView = potentialQuizView as AbsQuizView; if (absQuizView != null) { absQuizView.UserInput = savedInstanceState.GetBundle(KeyUserInput); } }; quizView.LayoutChange += handler; }
/** * Only if you need to restore open/close state when the orientation is changed. * Call this method in {@link android.app.Activity#onRestoreInstanceState(Bundle)} */ public void restoreStates(Bundle inState) { if (inState == null) { return; } if (inState.ContainsKey(BUNDLE_MAP_KEY)) { ConcurrentDictionary <string, int> restoredMap = new ConcurrentDictionary <string, int>(); Bundle statesBundle = inState.GetBundle(BUNDLE_MAP_KEY); ICollection <String> keySet = statesBundle.KeySet(); if (keySet != null) { foreach (var key in keySet) { restoredMap.put(key, statesBundle.GetInt(key)); } } mapStates = restoredMap; } }
public static FCMNotification ToFCMNotification(this Bundle bundle) { return(new FCMNotification( bundle.GetString(BundleKeyBody), bundle.GetString(BundleKeyTitle), bundle.GetString(BundleKeyImageUrl), bundle.GetBundle(BundleKeyData).ToDictionary())); }
/// <summary> /// Example of updating WASP-PoE /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonPoE_Click(object sender, RoutedEventArgs e) { Progress.Background = Brushes.Yellow; Progress.Value = 0; var progress = new Progress <ProgrammingProgress>(TesterProgrammingProgress); label.Content = "Programming..."; _waspUT.UpdateFirmware(Bundle.GetBundle("WASP-PoE 2.4.10-Firmware-R2.zip"), progress, new CompletionCallback(ProgrammingComplete), AccessMethod.Ethernet); }
public static void Preview(GamesInProgress.Info info, Bundle bundle) { info.Depth = bundle.GetInt(DEPTH); if (info.Depth == -1) { info.Depth = bundle.GetInt("maxDepth"); // FIXME } Hero.Preview(info, bundle.GetBundle(HERO)); }
internal static IBundle GetViewModelStateBundle([CanBeNull] this Bundle bundle) { var stateBundle = bundle?.GetBundle(ViewModelStateKey); if (stateBundle != null) { return(new NativeBundle(stateBundle)); } return(default);
public override void OnReceive(Context context, Intent intent) { if (context.GetType() != typeof(MainActivity) || intent.Extras == null) { return; } if (context is IHmsPushEvent hmsPushEvent)//If IHmsPushEvent has implemented on Activity { Bundle bundle = intent.Extras; if (bundle.ContainsKey(Method)) { string method = intent.Extras.GetString(Method); if (method == ((Action <string, Bundle>)hmsPushEvent.OnNewToken).Method.Name) { hmsPushEvent.OnNewToken(bundle.GetString(Token), bundle.GetBundle(Bundle)); } else if (method == ((Action <RemoteMessage>)hmsPushEvent.OnMessageReceived).Method.Name) { hmsPushEvent.OnMessageReceived(bundle.Get(Message) as RemoteMessage); } else if (method == ((Action <string>)hmsPushEvent.OnMessageSent).Method.Name) { hmsPushEvent.OnMessageSent(bundle.GetString(MsgId)); } else if (method == ((Action <string, int, string>)hmsPushEvent.OnSendError).Method.Name) { hmsPushEvent.OnSendError( bundle.GetString(MsgId), bundle.GetBundle(Exception).GetInt(ErrorCode), bundle.GetBundle(Exception).GetString(ErrorMessage)); } else if (method == ((Action <string, int, string>)hmsPushEvent.OnMessageDelivered).Method.Name) { hmsPushEvent.OnMessageDelivered( bundle.GetString(MsgId), bundle.GetBundle(Exception).GetInt(ErrorCode), bundle.GetBundle(Exception).GetString(ErrorMessage)); } else if (method == ((Action <int, string, Bundle>)hmsPushEvent.OnTokenError).Method.Name) { hmsPushEvent.OnTokenError( bundle.GetBundle(Exception).GetInt(ErrorCode), bundle.GetBundle(Exception).GetString(ErrorMessage), bundle.GetBundle(Bundle)); } else if (method == ((Action)hmsPushEvent.OnDeletedMessages).Method.Name) { hmsPushEvent.OnDeletedMessages(); } } } }
internal static IBundle?GetState(this Bundle bundle, string key) { IBundle?state = null; var stateNativeBundle = bundle.GetBundle(key); if (stateNativeBundle != null) { state = new AndroidBundle(stateNativeBundle); } return(state); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); //we initialise the app key for our data store //var a = Android.Content.Res.AssetManager.GetObject(); ApiAssets = new Dictionary <string, string>(); //we read the api key file var inputStream = Assets.Open(Constants.API_KEYFILE); var jsonObject = System.Json.JsonValue.Load(inputStream); ApiAssets[Constants.ASSET_NAME_APPNAME] = jsonObject.decryptAndGetApiSetting(Constants.ASSET_NAME_APPNAME); ApiAssets[Constants.ASSET_PROJECT_ID] = jsonObject.decryptAndGetApiSetting(Constants.ASSET_PROJECT_ID); ApiAssets[Constants.ASSET_NAME_SVC_ACCTEMAIL] = jsonObject.decryptAndGetApiSetting(Constants.ASSET_NAME_SVC_ACCTEMAIL); ApiAssets[Constants.ASSET_DATASTORE_APPKEY] = jsonObject.decryptAndGetApiSetting(Constants.ASSET_DATASTORE_APPKEY); ApiAssets[Constants.ASSET_P12KEYFILE] = jsonObject.decryptAndGetApiSetting(Constants.ASSET_P12KEYFILE); ProjectId = ApiAssets[Constants.ASSET_PROJECT_ID]; //ASSET_DATASTORE_APPKEY DataStoreApplicationKey = ApiAssets[Constants.ASSET_DATASTORE_APPKEY]; if (BigBundle == null) { BigBundle = new Bundle(); } if (bundle != null && bundle.ContainsKey(ALL_VALUES)) { BigBundle.PutAll(bundle.GetBundle(ALL_VALUES)); var resultsView = FindViewById <TextView>(Resource.Id.textAllValues); resultsView.Text = BigBundle.ToString(); } // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.SaveData); button.Click += buttonClicked; var button2 = FindViewById <Button>(Resource.Id.fetchData); button2.Click += getWebResource; //var showLoginButton = FindViewById<Button>(Resource.Id.showLoginForm); //showLoginButton.Click += LoginButton_Click; //var loginFormButton = FindViewById<Button>(Resource.Id.buttonLoginIn); //loginFormButton.Click += doLoginIn_Click; }
public void InitMap(Bundle savedInstanceState) { Bundle mapViewBundle = null; if (savedInstanceState != null) { mapViewBundle = savedInstanceState.GetBundle("MapViewBundleKey"); } mapView = FindViewById <MapView>(Resource.Id.googleMap); mapView.OnCreate(mapViewBundle); mapView.GetMapAsync(this); }
public override void OnSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) { base.OnSaveInstanceState(outState, outPersistentState); Bundle mapViewBundle = outState.GetBundle("MapViewBundleKey"); if (mapViewBundle == null) { mapViewBundle = new Bundle(); outState.PutBundle("MapViewBundleKey", mapViewBundle); } mapView.OnSaveInstanceState(mapViewBundle); }
///<inheritdoc/> public bool Extract(string key, Bundle bundle, ref IQuestViewModel entity) { if (bundle != null && !string.IsNullOrWhiteSpace(key) && entity != null) { Bundle viewModelBundle = bundle.GetBundle(key); if (viewModelBundle != null) { FillViewModelWithBundle(viewModelBundle, entity); return(true); } } return(false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); MapsInitializer.Initialize(this); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); AGConnectServicesConfig config = AGConnectServicesConfig.FromContext(ApplicationContext); config.OverlayWith(new HmsLazyInputStream(this)); Com.Huawei.Agconnect.AGConnectInstance.Initialize(this); checkPermission(new string[] { Android.Manifest.Permission.WriteExternalStorage, Android.Manifest.Permission.ReadExternalStorage, Android.Manifest.Permission.AccessCoarseLocation, Android.Manifest.Permission.AccessFineLocation, Android.Manifest.Permission.Internet }, 100); //get mapview instance mMapView = FragmentManager.FindFragmentById <MapFragment>(Resource.Id.mapview); btnMarkersDemo = FindViewById <Button>(Resource.Id.btnMarkersDemo); btnPolylineDemo = FindViewById <Button>(Resource.Id.btnPolylineDemo); btnPolygonDemo = FindViewById <Button>(Resource.Id.btnPolygonDemo); btnCircleDemo = FindViewById <Button>(Resource.Id.btnCircleDemo); btnOverlayDemo = FindViewById <Button>(Resource.Id.btnOverlayDemo); btntype = FindViewById <Button>(Resource.Id.btntype); btntype.Click += OnClick; btnMarkersDemo.Click += btnMarkersDemo_Click; btnPolylineDemo.Click += btnPolylineDemo_Click; btnPolygonDemo.Click += btnPolygonDemo_Click; btnCircleDemo.Click += btnCircleDemo_Click; btnOverlayDemo.Click += btnOverlayDemo_Click; context = this; viewModel = new MainViewModel(); Bundle mapViewBundle = null; if (savedInstanceState != null) { mapViewBundle = savedInstanceState.GetBundle(MAPVIEW_BUNDLE_KEY); } mMapView.OnCreate(mapViewBundle); //get map instance RunOnUiThread(() => mMapView.GetMapAsync(this)); }
private static void RestoreViewModelsFromBundle(IMvxJsonConverter serializer, Bundle savedInstanceState) { IMvxSavedStateConverter savedStateConverter; IMvxMultipleViewModelCache viewModelCache; IMvxViewModelLoader viewModelLoader; if (!Mvx.TryResolve(out savedStateConverter)) { Mvx.Trace("Could not resolve IMvxSavedStateConverter, won't be able to convert saved state"); return; } if (!Mvx.TryResolve(out viewModelCache)) { Mvx.Trace("Could not resolve IMvxMultipleViewModelCache, won't be able to convert saved state"); return; } if (!Mvx.TryResolve(out viewModelLoader)) { Mvx.Trace("Could not resolve IMvxViewModelLoader, won't be able to load ViewModel for caching"); return; } // Harder ressurection, just in case we were killed to death. var json = savedInstanceState.GetString(SavedFragmentTypesKey); if (string.IsNullOrEmpty(json)) { return; } var savedState = serializer.DeserializeObject <Dictionary <string, Type> >(json); foreach (var item in savedState) { var bundle = savedInstanceState.GetBundle(item.Key); if (bundle.IsEmpty) { continue; } var mvxBundle = savedStateConverter.Read(bundle); var request = MvxViewModelRequest.GetDefaultRequest(item.Value); // repopulate the ViewModel with the SavedState and cache it. var vm = viewModelLoader.LoadViewModel(request, mvxBundle); viewModelCache.Cache(vm, item.Key); } }
///<inehritdoc/> public bool Extract(string key, Bundle bundle, ref IList <ClarifiedError <int> > entity) { if (string.IsNullOrWhiteSpace(key) || bundle == null || entity == null) { return(false); } Bundle innerBundle = bundle.GetBundle(key); if (innerBundle == null) { return(false); } return(InnerExtractValues(innerBundle, entity)); }
public static void RestoreFromBundle(Bundle bundle) { var node = bundle.GetBundle(NODE); if (node.IsNull || (!(Spawned = node.GetBoolean(SPAWNED)))) { return; } Alternative = node.GetBoolean(ALTERNATIVE); Given = node.GetBoolean(GIVEN); IsCompleted = node.GetBoolean(COMPLETED); reward = (Ring)node.Get(REWARD); }
public override void OnReceive(Context context, Intent intent) { Bundle bundle = intent.Extras; IHMSTokenEvent hmsTokenEvent = HMSInstanceId.Instance; IHMSPushEvent hmsPushEvent = HMSPushEvent.Instance; if (bundle.ContainsKey(Method)) { string method = intent.Extras.GetString(Method); if (method == ((Action <string, Bundle>)hmsTokenEvent.HMSOnNewToken).Method.Name) { hmsTokenEvent.HMSOnNewToken(bundle.GetString(Token), bundle.GetBundle(Bundle)); } else if (method == ((Action <RemoteMessage>)hmsPushEvent.HMSOnMessageReceived).Method.Name) { hmsPushEvent.HMSOnMessageReceived(bundle.Get(Message) as RemoteMessage); } else if (method == ((Action <string>)hmsPushEvent.HMSOnMessageSent).Method.Name) { hmsPushEvent.HMSOnMessageSent(bundle.GetString(MsgId)); } else if (method == ((Action <string, int, string>)hmsPushEvent.HMSOnSendError).Method.Name) { hmsPushEvent.HMSOnSendError( bundle.GetString(MsgId), bundle.GetBundle(Exception).GetInt(ErrorCode), bundle.GetBundle(Exception).GetString(ErrorMessage)); } else if (method == ((Action <string, int, string>)hmsPushEvent.HMSOnMessageDelivered).Method.Name) { hmsPushEvent.HMSOnMessageDelivered( bundle.GetString(MsgId), bundle.GetBundle(Exception).GetInt(ErrorCode), bundle.GetBundle(Exception).GetString(ErrorMessage)); } else if (method == ((Action <int, string, Bundle>)hmsTokenEvent.HMSOnTokenError).Method.Name) { hmsTokenEvent.HMSOnTokenError( bundle.GetBundle(Exception).GetInt(ErrorCode), bundle.GetBundle(Exception).GetString(ErrorMessage), bundle.GetBundle(Bundle)); } } }
public static void RestoreFromBundle(Bundle bundle) { var node = bundle.GetBundle(Node); if (!node.IsNull && (_spawned = node.GetBoolean(Spawned))) { alternative = node.GetBoolean(Alternative); given = node.GetBoolean(Given); completed = node.GetBoolean(Completed); reforged = node.GetBoolean(Reforged); } else { Reset(); } }
public static void RestoreFromBundle(Bundle bundle) { var node = bundle.GetBundle(Node); if (!node.IsNull && (Spawned = node.GetBoolean(SPAWNED))) { Alternative = node.GetBoolean(ALTERNATIVE); IsGiven = node.GetBoolean(GIVEN); Wand1 = (Wand)node.Get(WAND1); Wand2 = (Wand)node.Get(WAND2); } else { Reset(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_mapview_demo); mMapView = (MapView)FindViewById(Resource.Id.mapView); Bundle mapViewBundle = null; if (savedInstanceState != null) { mapViewBundle = savedInstanceState.GetBundle(MAPVIEW_BUNDLE_KEY); } // please replace "Your API key" with api_key field value in // agconnect-services.json if the field is null. MapsInitializer.SetApiKey(Constants.API_KEY); mMapView.OnCreate(mapViewBundle); mMapView.GetMapAsync(this); }
/// <summary> /// Extracts view model result from the bundle. /// </summary> /// <typeparam name="TResult">The type of the view model result.</typeparam> /// <param name="bundle">The bundle from which to extract view model result.</param> /// <returns>View model result instance if the bundle contains result; otherwise, <c>null</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="bundle"/> is <c>null</c>.</exception> public static TResult?GetResult <TResult>(this Bundle bundle) where TResult : Result { if (bundle == null) { throw new ArgumentNullException(nameof(bundle)); } TResult?result = null; var resultNativeBundle = bundle.GetBundle(ResultKey); if (resultNativeBundle != null) { result = (TResult)FormatterServices.GetUninitializedObject(typeof(TResult)); result.ImportBundle(new AndroidBundle(resultNativeBundle)); } return(result); }
/// <summary> /// Extracts view model parameters from the bundle. /// </summary> /// <typeparam name="TParameters">The type of the view model parameters.</typeparam> /// <param name="bundle">The bundle from which to extract view model parameters.</param> /// <returns>View model parameters instance if the bundle contains parameters; otherwise, <c>null</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="bundle"/> is <c>null</c>.</exception> public static TParameters?GetParameters <TParameters>(this Bundle bundle) where TParameters : Parameters { if (bundle == null) { throw new ArgumentNullException(nameof(bundle)); } TParameters?parameters = null; var parametersNativeBundle = bundle.GetBundle(ParametersKey); if (parametersNativeBundle != null) { parameters = (TParameters)FormatterServices.GetUninitializedObject(typeof(TParameters)); parameters.ImportBundle(new AndroidBundle(parametersNativeBundle)); } return(parameters); }
/// <summary> /// Tells the fragment that its activity has completed its own Activity.onCreate(). /// </summary> /// <param name="savedInstanceState"></param> public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); if (savedInstanceState != null) { //Load pre-saved wizard context.. Coming in from a orientation change perhaps WizardFlow.LoadFlow(savedInstanceState); StateManager.ContextBundle = savedInstanceState.GetBundle(STATE_WIZARD_CONTEXT); StateManager.LoadStepContext(this); } else { StateManager.ContextBundle = new Bundle(); //Initialize wizard context //Persist hosting activity/fragment fields to wizard context enabling easy data transfer between wizard host and the steps StateManager.PersistStepContext(this); } Wizard = new Wizard(WizardFlow, StateManager, ChildFragmentManager); Wizard.StepChanged += OnWizardStepChanged; Wizard.WizardComplete += OnWizardComplete; }
/// <summary> /// Updates radio 4 to the selected type /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonRadio_Click(object sender, RoutedEventArgs e) { //Make sure the radio exists if (_waspUT.Radio4Type == RadioTypes.NotPopulated) { return; } Progress.Background = Brushes.Yellow; Progress.Value = 0; var progress = new Progress <ProgrammingProgress>(TesterProgrammingProgress); RadioFirmwareLoader rfl = new RadioFirmwareLoader(_waspUT); Bundle bundle = Bundle.GetBundle(_poeBundle); RadioFirmware bleFirmware = bundle.RadioFirmwares.FirstOrDefault(x => x.FirmwareType == FirmwareTypes.BLE_ACTIVE_SCAN); RadioFirmware antFirmware = bundle.RadioFirmwares.FirstOrDefault(x => x.FirmwareType == FirmwareTypes.ANT); RadioFirmware bcnFirmware = bundle.RadioFirmwares.FirstOrDefault(x => x.FirmwareType == FirmwareTypes.BEACON); RadioFirmware programmingFirmware = null; if (radioButtonAnt.IsChecked == true) { programmingFirmware = antFirmware; } else if (radioButtonBle.IsChecked == true) { programmingFirmware = bleFirmware; } else { programmingFirmware = bcnFirmware; } if (programmingFirmware == null) { MessageBox.Show("No firmware of that type in Bundle"); return; } rfl.Program(1, programmingFirmware, progress, new CompletionCallback(ProgrammingComplete)); }
// Called when Activity is first created. Turns off the title bar, sets up // the content views, and fires up the SnakeView. protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.snake_layout); snake_view = FindViewById<SnakeView> (Resource.Id.snake); snake_view.SetTextView (FindViewById<TextView> (Resource.Id.text)); if (savedInstanceState == null) { // We were just launched -- set up a new game snake_view.SetMode (GameMode.Ready); } else { // We are being restored Bundle map = savedInstanceState.GetBundle (ICICLE_KEY); if (map != null) snake_view.RestoreState (map); else snake_view.SetMode (GameMode.Paused); } }
protected void OnCreate(Bundle bundle) { if (bundle != null) { _state = bundle.GetBundle(nameof(State)); } if (_id == Guid.Empty) { _id = Guid.NewGuid(); } var oldId = bundle?.GetString(IdKey); if (string.IsNullOrEmpty(oldId)) { return; } var cacheDataContext = GetFromCache(Guid.Parse(oldId)); var vmTypeName = bundle.GetString(ViewModelTypeNameKey); if (vmTypeName == null) { return; } bundle.Remove(ViewModelTypeNameKey); var vmType = Type.GetType(vmTypeName, false); if (vmType != null && (cacheDataContext == null || !cacheDataContext.GetType().Equals(vmType))) { if (!bundle.ContainsKey(IgnoreStateKey)) { cacheDataContext = RestoreViewModel(vmType, bundle); } } if (!ReferenceEquals(DataContext, cacheDataContext)) { RestoreContext(Target, cacheDataContext); } }
/// <summary> /// Tells the fragment that its context has completed its own Activity.onCreate(). /// </summary> /// <param name="savedInstanceState"></param> public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); if (savedInstanceState != null) //Load pre-saved wizard context.. Coming in from a orientation change perhaps { WizardFlow.LoadFlow(savedInstanceState); StateManager.ContextBundle = savedInstanceState.GetBundle(STATE_WIZARD_CONTEXT); StateManager.LoadStepContext(this); } else { StateManager.ContextBundle = new Bundle(); //Initialize wizard context //Persist hosting context/fragment fields to wizard context enabling easy data transfer between wizard host and the steps StateManager.PersistStepContext(this); } Wizard = new Wizard(WizardFlow, StateManager, ChildFragmentManager); Wizard.StepChanged += OnWizardStepChanged; Wizard.WizardComplete += OnWizardComplete; }
public static void RestoreFromBundle(Bundle bundle) { var node = bundle.GetBundle(NODE); if (!node.IsNull && (spawned = node.GetBoolean(SPAWNED))) { alternative = node.GetBoolean(ALTERNATIVE); if (!alternative) { left2kill = node.GetInt(LEFT2KILL); } given = node.GetBoolean(GIVEN); depth = node.GetInt(DEPTH); processed = node.GetBoolean(PROCESSED); weapon = (Weapon)node.Get(WEAPON); armor = (Armor)node.Get(ARMOR); } else { reset(); } }
public override void OnActivityCreated (Bundle savedInstanceState) { base.OnActivityCreated (savedInstanceState); MRequestFocus = delegate { mList.FocusableViewAvailable (mList); }; mHandler = new MyPreferenceFragmentHandler (this); if (mHavePrefs) { BindPreferences (); } mInitDone = true; if (savedInstanceState != null) { Bundle container = savedInstanceState.GetBundle (PREFERENCES_TAG); if (container != null) { PreferenceScreen preferenceScreen = PreferenceScreen; if (preferenceScreen != null) { preferenceScreen.RestoreHierarchyState (container); } } } }
private static void RestoreViewModelsFromBundle(IMvxJsonConverter serializer, Bundle savedInstanceState) { IMvxSavedStateConverter savedStateConverter; IMvxMultipleViewModelCache viewModelCache; IMvxViewModelLoader viewModelLoader; if (!Mvx.TryResolve(out savedStateConverter)) { Mvx.Trace("Could not resolve IMvxSavedStateConverter, won't be able to convert saved state"); return; } if (!Mvx.TryResolve(out viewModelCache)) { Mvx.Trace("Could not resolve IMvxMultipleViewModelCache, won't be able to convert saved state"); return; } if (!Mvx.TryResolve(out viewModelLoader)) { Mvx.Trace("Could not resolve IMvxViewModelLoader, won't be able to load ViewModel for caching"); return; } // Harder ressurection, just in case we were killed to death. var json = savedInstanceState.GetString(SavedFragmentTypesKey); if (string.IsNullOrEmpty(json)) return; var savedState = serializer.DeserializeObject<Dictionary<string, Type>>(json); foreach (var item in savedState) { var bundle = savedInstanceState.GetBundle(item.Key); if (bundle.IsEmpty) continue; var mvxBundle = savedStateConverter.Read(bundle); var request = MvxViewModelRequest.GetDefaultRequest(item.Value); // repopulate the ViewModel with the SavedState and cache it. var vm = viewModelLoader.LoadViewModel(request, mvxBundle); viewModelCache.Cache(vm, item.Key); } }
void RestoreQuizState(Bundle savedInstanceState) { if (null == savedInstanceState) { return; } EventHandler<View.LayoutChangeEventArgs> handler = null; handler += (sender, e) => { quizView.LayoutChange -= handler; var currentChild = quizView.GetChildAt(0); var viewGroup = currentChild as ViewGroup; if (viewGroup != null) { var potentialQuizView = viewGroup.GetChildAt(0); var absQuizView = potentialQuizView as AbsQuizView; if (absQuizView != null) { absQuizView.UserInput = savedInstanceState.GetBundle(KeyUserInput); } } }; quizView.LayoutChange += handler; }