public virtual void DoInitialize(AssetDetailConfig detailConfig, OnInitFinished initCallback, params SystemObject[] values) { State = LoaderState.Initializing; assetDetailConfig = detailConfig; initializedCallback = initCallback; }
/// <summary> /// 设置当前加载器为懒加载待触发状态 /// </summary> public void SetLazyTrigger() { lock (this) { this.state = LoaderState.LazyTrigger; } }
protected override async void OnLoad() { ItemsCount = await _viewProvider.GetItemsCount(); OnPropertyChanged(nameof(ItemsCount)); LoaderState.ToIdle(); }
// Update is called once per frame void Update() { switch (currentLoaderState) { case LoaderState.PreLoading: DontDestroyOnLoad(transform.gameObject); Application.LoadLevel(loadingScene.ToString()); currentLoaderState = LoaderState.Loading; break; case LoaderState.Loading: if (!Application.isLoadingLevel) { currentLoaderState = LoaderState.Done; } break; case LoaderState.Done: currentScene = loadingScene; DispatchMessage("OnLoadingDone", null); currentLoaderState = LoaderState.None; Destroy(this.gameObject); break; } }
void SetState(LoaderState newState) { if (this.state != newState) { this.state = newState; } }
private void StartLoading() { currentLoaderState = LoaderState.PreLoading; float fxVolume = PlayerPrefs.GetFloat(GameSettings.FX_SAVE_NAME, GameSettings.DEFAULT_FX_VOLUME); SoundUtils.SetSoundVolume(SoundType.FX, fxVolume); }
void Handle_OpenReadCompleted(object sender, TestableOpenReadCompletedEventArgs e) { // Check for errors. Error = CheckForError(e); if (Error != null) { State = LoaderState.LoadError; OnLoadFailed(); } // Pass execution to the callback, and alert listeners. if (State != LoaderState.LoadError) state = LoaderState.Loaded; // Update the load state prior to executing the callback... OnLoadCallback(e); if (State != LoaderState.LoadError) OnPropertyChanged(PropLoaderState); // ...but wait for the callback to be executed before firing the property changed event. // Calculate the load time. LoadTime = DateTime.UtcNow.Subtract(loadStartedAt); // Finish up. OnLoaded(); if (loadCallback != null) { loadCallback.Invoke(); loadCallback = null; } }
/// <summary> /// See [XRLoader.Start](xref:UnityEngine.XR.Management.XRLoader.Start) /// </summary> /// <returns>True if started, false otherwise.</returns> public override bool Start() { if (currentLoaderState == LoaderState.Started) { return(true); } if (!validLoaderStartStates.Contains(currentLoaderState)) { return(false); } currentLoaderState = LoaderState.StartAttempted; #if TEST_SUPPORT if (ShouldExitEarly()) { return(false); } #endif if (!StartInternal()) { Stop(); return(false); } currentLoaderState = LoaderState.Started; return(true); }
/// <summary> /// See [XRLoader.Stop](xref:UnityEngine.XR.Management.XRLoader.Stop) /// </summary> /// <returns>True if stopped, false otherwise.</returns> public override bool Stop() { if (currentLoaderState == LoaderState.Stopped) { return(true); } if (!validLoaderStopStates.Contains(currentLoaderState)) { return(false); } currentLoaderState = LoaderState.StopAttempted; #if TEST_SUPPORT if (ShouldExitEarly()) { return(false); } #endif Internal_RequestExitSession(); StopInternal(); currentLoaderState = LoaderState.Stopped; return(true); }
private void NavigateToOnFinishedInternal(string message, LoaderState state) { Description = message; Logger.Add(string.Format("{0:D3} | {1}", LoaderId, message)); State = state; _notifyFinishedTimer.Start(); }
protected override void Process(MaybeLoaderDto dtoIn, LoaderState <List <MaybeEntity> > loadState, MaybeEntity dtoOutDefaultMapped) { // dto should be validated and mapped to target entity by default // any custom mapping/translation logic should be implemented here // add to valid state loadState.Valid.Add(dtoOutDefaultMapped); }
public virtual void Init(string path, object param, UnityAction <Loader, float> actionProgress, UnityAction <Loader, object> actionLoaded, bool async = true) { m_State = LoaderState.None; m_Path = path; m_Param = param; m_Async = async; m_ActionProgress = actionProgress; m_ActionLoaded = actionLoaded; }
protected void OnLoadCompleted(object data) { m_State = LoaderState.Finish; if (null != m_ActionLoaded) { m_ActionLoaded(this, data); } OnLoadProgress(1.0f); Reset(); }
protected async override void OnLoad() { var progress = new Progress <ImageDto>(dto => { if (LoaderState.IsBusy) { LoaderState.ToIdle(); } Images.Add(new ImageViewModel(dto)); }); await _viewProvider.GetImagesAsync(progress); }
private async void Save() { LoaderState.ToBusy(); var dto = new ImageGalleryDto { CollectionItemId = _collectionItemId, Images = Images.Where(x => !x.IsSelected).Select(x => x.InnerObject).ToList() }; await _dataProvider.SaveImageGalleryAsync(dto); LoaderState.ToIdle(); Navigations.CloseCurrentView(); }
private async void AddImage() { var dialogResult = Dialog.OpenImageFileDialog(); if (!dialogResult.Result) { return; } LoaderState.ToBusy(); await _dataProvider.BuildAsync(dialogResult.Value, _collectionItemId, _progress); LoaderState.ToIdle(); }
private async void Delete() { if (!Dialog.AskForDelete()) { return; } LoaderState.ToBusy(); var selectedImages = Images.Where(x => x.IsSelected); await _viewProvider.Delete(selectedImages.Select(x => x.InnerObject)); Images.RemoveAll(selectedImages.ToArray()); LoaderState.ToIdle(); }
/// <summary> /// 开始加载 /// </summary> /// <param name="catchMemory">是否需要保存在内存,如果不需要,在抛出完成事件后会析构下载的资源</param> public void Load() { if (State == LoaderState.idle || State == LoaderState.error) { State = LoaderState.loading; onLoadStart.Dispatch(this); onLoadStart.Clear(); CoroutineCall.Call(this.LoadingSequence); } else if (State == LoaderState.complete) { this.LoadComplete(); } }
protected async override void OnLoad() { var collectionItem = _dataProvider.GetCollectionItem(_collectionItemId); Code = collectionItem.Code; Title = collectionItem.Title; Locality = collectionItem.Locality; await _dataProvider.GetThumbnailsOfAsync(_collectionItemId, _progress); _memento = new GalleryMemento(Images); OnPropertyChanged(nameof(Code)); OnPropertyChanged(nameof(Title)); OnPropertyChanged(nameof(Locality)); LoaderState.ToIdle(); }
/// <summary> /// 加载完成时 /// </summary> protected void LoadComplete() { State = LoaderState.complete; if (debug) { DebugConsole.Info("Loader", "加载完成", this.url, CurrentDataSource.ToString()); } OnLoadCompleteHandler(); onLoadComplete.Dispatch(this); onLoadComplete.Clear(); if (CurrentDataSource.source != DownLoadAgent.DataSourceType.Cache) { SaveToLocal(); } }
private async void SaveToFile() { var dialogResult = Dialog.OpenDirectorySelector(); if (!dialogResult.Result) { return; } LoaderState.ToBusy(); var selectedImages = Images.Where(x => x.IsSelected).Select(x => x.InnerObject); await _viewProvider.SaveToFile(selectedImages, dialogResult.Value); DeSelectAll(); LoaderState.ToIdle(); Dialog.Say("Saving images completed successfully!"); }
private async Task LoadData(string sortBy) { LoaderState.ToBusy(); SortOnCode = sortBy == "Code"; SortOnGenus = sortBy == "Genus"; OnPropertyChanged(nameof(SortOnCode)); OnPropertyChanged(nameof(SortOnGenus)); var items = await _viewProvider.GetCollectionItemsAsync(sortBy); CollectionItems.Clear(); foreach (var item in items) { CollectionItems.Add(new CollectionItemViewModel(item)); } LoaderState.ToIdle(); }
/// <summary> /// 加载出错时 /// </summary> protected void LoadError(String ErrorString = "") { State = LoaderState.error; if (String.IsNullOrEmpty(ErrorString)) { DebugConsole.Warning("Loader", "加载", this.url, www != null ? www.error : "www=null"); } else { DebugConsole.Warning("Loader", "加载", this.url, ErrorString); } onLoadError.Dispatch(this); onLoadError.Clear(); OnLoadErrorHandler(); }
internal DeviceLoaderSynchronizer( DevAddr devAddr, LoRaDeviceAPIServiceBase loRaDeviceAPIService, ILoRaDeviceFactory deviceFactory, NetworkServerConfiguration configuration, LoRaDeviceCache deviceCache, HashSet <ILoRaDeviceInitializer> initializers, ILogger <DeviceLoaderSynchronizer> logger) { this.loRaDeviceAPIService = loRaDeviceAPIService; this.deviceFactory = deviceFactory; this.configuration = configuration; this.devAddr = devAddr; this.loraDeviceCache = deviceCache; this.initializers = initializers; this.logger = logger; this.state = LoaderState.QueryingDevices; this.queueLock = new object(); this.queuedRequests = new List <LoRaRequest>(); }
internal DeviceLoaderSynchronizer( string devAddr, LoRaDeviceAPIServiceBase loRaDeviceAPIService, ILoRaDeviceFactory deviceFactory, DevEUIToLoRaDeviceDictionary destinationDictionary, HashSet <ILoRaDeviceInitializer> initializers, NetworkServerConfiguration configuration, Action <Task, DeviceLoaderSynchronizer> continuationAction, Action <LoRaDevice> registerDeviceAction) { this.loRaDeviceAPIService = loRaDeviceAPIService; this.deviceFactory = deviceFactory; this.devAddr = devAddr; this.existingDevices = destinationDictionary; this.initializers = initializers; this.configuration = configuration; this.registerDeviceAction = registerDeviceAction; this.state = LoaderState.QueryingDevices; this.loadingDevicesFailed = false; this.queueLock = new object(); this.queuedRequests = new List <LoRaRequest>(); this.loading = Task.Run(() => this.Load().ContinueWith((t) => continuationAction(t, this), TaskContinuationOptions.ExecuteSynchronously)); }
void Update() { switch (currentLoaderState) { case LoaderState.PreLoading: DontDestroyOnLoad(transform.gameObject); Application.LoadLevelAdditive(loadingScene.ToString()); currentLoaderState = LoaderState.Loading; break; case LoaderState.Loading: if (!Application.isLoadingLevel) { currentLoaderState = LoaderState.Done; } break; case LoaderState.Done: currentScene = loadingScene; OnLoadingDone(); currentLoaderState = LoaderState.None; break; } }
protected async override void OnLoad() { PrintItems = Bag.Of <LabelPrintViewModel>() .FilterBy((vm, text) => vm.Name.Has(text) || vm.Species.Has(text)) .Build(); var info = await _viewProvider.LoadInfoAsync(); CollectionItems = Bag.Of <CollectionItemViewModel>() .FilterBy((vm, text) => vm.Name.Has(text) || vm.Code == text) .WithConvertor((CollectionItemDto dto) => new CollectionItemViewModel(dto)) .WithId(x => x.InnerObject.Id) .WithSource(info.CollectionItems) .Build(); Taxa = Bag.Of <TaxonViewModel>() .FilterBy((vm, text) => vm.Name.Has(text)) .WithConvertor((TaxonDto dto) => new TaxonViewModel(dto)) .WithSource(info.Taxa) .WithId(x => x.InnerObject.Id) .Build(); OnPropertyChanged(nameof(PrintItems)); OnPropertyChanged(nameof(CollectionItems)); OnPropertyChanged(nameof(Taxa)); LoaderState.ToIdle(); }
/// <summary>Loads data for a graph either from cache or starts a download thread</summary> /// <param name="root">Name of root node</param> /// <param name="depth">Depth of this graph for resursion counting</param> private void LoadSubGraph(string root, int depth) { WebGraph.Data.IWebGraphSource source = comboBoxPlugins.SelectedItem as WebGraph.Data.IWebGraphSource; WebGraph.Data.WebCache cache = new WebGraph.Data.WebCache(); Graph.Tag = source.ToString(); LoaderState state = new LoaderState(); state.Depth = depth; state.Source = source; state.Root = root; state.Url = source.GetContentUrl(state.Root); state.Result = cache.Load(state.Url); if (state.Result != null) // cache hit { System.Diagnostics.Debug.WriteLine(string.Format("Using cached item {0}.", state.Url)); state.Cached = true; OnWebDataLoaded(state); // just go one } else // cache miss { buttonGo.IsEnabled = false; // no new graphs until this one is ready statusText.Text = "Lade " + state.Url; // this one gets expensive, so do ít async ThreadPool.QueueUserWorkItem(new WaitCallback(OnWebDataLoad), state); } }
/// <summary> /// See [XRLoader.DeInitialize](xref:UnityEngine.XR.Management.XRLoader.Stop) /// </summary> /// <returns>True if deinitialized, false otherwise.</returns> public override bool Deinitialize() { if (currentLoaderState == LoaderState.Uninitialized) { return(true); } if (!validLoaderDeinitStates.Contains(currentLoaderState)) { return(false); } currentLoaderState = LoaderState.DeinitializeAttempted; try { #if TEST_SUPPORT if (ShouldExitEarly()) { return(false); } // The test hook above will leave the loader in a half initialized state. To work // around this we reset the instance pointer if it is missing. if (Instance == null) { Instance = this; } #endif Application.onBeforeRender -= ProcessOpenXRMessageLoop; ProcessOpenXRMessageLoop(); // Drain any remaining events. OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemDestroy); DestroySubsystem <XRInputSubsystem>(); DestroySubsystem <XRDisplaySubsystem>(); DiagnosticReport.DumpReport("System Shutdown"); Internal_DestroySession(); ProcessOpenXRMessageLoop(); Internal_UnloadOpenXRLibrary(); currentLoaderState = LoaderState.Uninitialized; if (unhandledExceptionHandler != null) { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException -= unhandledExceptionHandler; unhandledExceptionHandler = null; } return(base.Deinitialize()); } finally { // Ensure we always clear the instance reference even if some part of Deinitialize threw an exception Instance = null; } }
private bool InitializeInternal() { Instance = this; currentLoaderState = LoaderState.InitializeAttempted; #if TEST_SUPPORT if (ShouldExitEarly()) { return(false); } #endif #if UNITY_EDITOR if (!DisableValidationChecksOnEnteringPlaymode) { if (OpenXRProjectValidation.LogPlaymodeValidationIssues()) { return(false); } } #endif OpenXRFeature.Initialize(); if (!LoadOpenXRSymbols()) { Debug.LogError("Failed to load openxr runtime loader."); return(false); } // Sort the features array by priority in descending order (highest priority first) OpenXRSettings.Instance.features = OpenXRSettings.Instance.features .Where(f => f != null) .OrderByDescending(f => f.priority) .ThenBy(f => f.nameUi) .ToArray(); OpenXRFeature.HookGetInstanceProcAddr(); if (!Internal_InitializeSession()) { return(false); } SetApplicationInfo(); RequestOpenXRFeatures(); RegisterOpenXRCallbacks(); if (null != OpenXRSettings.Instance) { OpenXRSettings.Instance.ApplySettings(); } if (!CreateSubsystems()) { return(false); } if (OpenXRFeature.requiredFeatureFailed) { return(false); } OpenXRAnalytics.SendInitializeEvent(true); OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemCreate); OpenXRInput.Initialize(); DebugLogEnabledSpecExtensions(); Application.onBeforeRender += ProcessOpenXRMessageLoop; currentLoaderState = LoaderState.Initialized; return(true); }
public virtual void Load() { m_State = LoaderState.Loading; OnLoadProgress(0.0f); }
// commit to the underling data store protected override void Commit(LoaderState <List <MaybeEntity> > loadState) { _provider.Add(loadState.Valid); }