protected override void InitializeLastChance() { base.InitializeLastChance(); MvvmCross.Plugins.DownloadCache.PluginLoader.Instance.EnsureLoaded(); MvvmCross.Plugins.File.PluginLoader.Instance.EnsureLoaded(); MvvmCross.Plugins.Json.PluginLoader.Instance.EnsureLoaded(); var configuration = MvxDownloadCacheConfiguration.Default; configuration.MaxInMemoryBytes = 20971520; var fileDownloadCache = new MvxFileDownloadCache( configuration.CacheName, configuration.CacheFolderPath, configuration.MaxFiles, configuration.MaxFileAge); Mvx.RegisterSingleton <IMvxFileDownloadCache>(fileDownloadCache); //Mvx.RegisterSingleton<IMvxHttpFileDownloader>(new ARMvxHttpFileDownloader()); var presenter = Mvx.Resolve <IMvxAndroidViewPresenter>() as IMvxMultipleViewModelCache; Mvx.RegisterSingleton <MvvmCross.Droid.Views.IMvxMultipleViewModelCache>(presenter ?? new ARMultipleViewModelCache()); Mvx.CallbackWhenRegistered <IMvxValueCombinerRegistry>(service => { service.Fill(ValueConverterAssemblies); }); }
public override void Initialize() { (new API.App()).Initialize(); Mvx.LazyConstructAndRegisterSingleton <ISessionService, SessionService>(); Mvx.RegisterSingleton <IAuthConfigService>(() => new AuthConfigService()); Mvx.RegisterType(typeof(IPasswordNewVmService), typeof(PasswordNewVmService)); Mvx.RegisterType(typeof(IResetPasswordVmService), typeof(ResetPasswordVmService)); Mvx.RegisterType(typeof(IResetPasswordSmsVmService), typeof(ResetPasswordSmsVmService)); Mvx.RegisterType(typeof(ISignInVmService), typeof(SignInVmService)); Mvx.RegisterType(typeof(ISignUpVmService), typeof(SignUpVmService)); Mvx.RegisterType(typeof(IAuthVmService), typeof(AuthVmService)); Mvx.RegisterType(typeof(ISignUpItemFactoryService), typeof(SignUpItemFactoryService)); var vmLookupService = Mvx.Resolve <IViewModelLookupService>(); vmLookupService.Register <IAuthViewModel>(typeof(AuthViewModel)); vmLookupService.Register <ISignUpViewModel>(typeof(SignUpViewModel)); vmLookupService.Register <ISignInViewModel>(typeof(SignInViewModel)); vmLookupService.Register <IResetPasswordViewModel>(typeof(ResetPasswordViewModel)); vmLookupService.Register <IResetPasswordSmsViewModel>(typeof(ResetPasswordSmsViewModel)); vmLookupService.Register <IPasswordNewViewModel>(typeof(PasswordNewViewModel)); vmLookupService.Register <IThanksViewModel>(typeof(ThanksViewModel)); Mvx.RegisterType <IAuthNavigationVmService>(() => new AuthNavigationVmService()); if (!string.IsNullOrEmpty(AuthSettings.Token)) { Mvx.CallbackWhenRegistered <IMvxMessenger>(() => Mvx.Resolve <ISessionService>().StartByToken(AuthSettings.Token).ConfigureAwait(false)); } }
public override void OnTokenRefresh() { base.OnTokenRefresh(); FirebaseMessaging.Instance.SubscribeToTopic(GLOBAL_TOPIC_KEY); var token = FirebaseInstanceId.Instance.Token; Log.Verbose(PackageName, $"Push token refresh: {token}"); System.Diagnostics.Debug.WriteLine(message: $"Push token refresh: {token}", category: PackageName); Mvx.CallbackWhenRegistered <IPushNotificationsService>(async service => { try { Log.Verbose(PackageName, $"Sending push token"); System.Diagnostics.Debug.WriteLine(message: $"Sending push token", category: PackageName); AppSettings.PushToken = token; await service.RegisterDeviceForPushNotificatons(token); Log.Verbose(PackageName, $"Push token sent"); System.Diagnostics.Debug.WriteLine(message: $"Push token sent", category: PackageName); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(message: $"Exception when sending push token {ex.BuildAllMessagesAndStackTrace()}", category: PackageName); } }); }
public void Load() { Mvx.CallbackWhenRegistered <IMvxMainThreadDispatcher>(service => { if (CurrentActivity == null) { Mvx.Resolve <IMvxAndroidActivityLifetimeListener>().ActivityChanged += Handle_ActivityChanged; } else { service.RequestMainThreadAction(() => { var config = Mvx.Resolve <IAFConfigService>().Config; AppsFlyerLib.Instance.StartTracking(CurrentActivity.Application, config.DevKey); _trackerDelegate = new CustomAppsFlyerConversionDelegate(); AppsFlyerLib.Instance.RegisterConversionListener(Application.Context, _trackerDelegate); Mvx.RegisterSingleton <IAppsFlyerService>(() => new AppsFlyerService()); }); } }); }
protected override void InitStartPage() { Mvx.CallbackWhenRegistered <IMvxNavigationService>(async service => { await service.Navigate(ViewModel.DefaultViewModel, ((IMvxBundle) new BaseBundle(Base.Core.Models.Navigation.NavigationType.ClearAndPush)), null); }); }
public MarkedObservableService() { _listToken = Messenger.Subscribe <ProductMarkedQuantityChangedMessage>(OnMarkedChanged); _cardToken = Messenger.Subscribe <ProductCardMarkedMessage>(OnMarkedChanged); Mvx.CallbackWhenRegistered <IMarkedService>(() => OnMarkedChanged(null)); }
protected override void InitializePlatformServices() { base.InitializePlatformServices(); Mvx.LazyConstructAndRegisterSingleton <IDocumentRoot, DocumentRoot>(); Mvx.CallbackWhenRegistered <IMvxMainThreadAsyncDispatcher>(SetupFlurry); }
public void EnsureLoaded() { var manager = Mvx.Resolve <IMvxPluginManager>(); manager.EnsurePlatformAdaptionLoaded <PluginLoader>(); Mvx.CallbackWhenRegistered <IMvxValueConverterRegistry>(RegisterValueConverters); }
public BasketObservableService() { _token = Messenger.Subscribe <ProductAddToBasketMessage>(OnProductAddToBasket); _quantityToken = Messenger.Subscribe <ProductQuantityChangedMessage>(OnBasketChanged); _orderFinishedToken = Messenger.Subscribe <OrderCreationFinishedMessage>(OnBasketChanged); Mvx.CallbackWhenRegistered <IBasketService>(() => OnProductAddToBasket(null)); }
public Wifi() { Mvx.CallbackWhenRegistered <IMvxAndroidGlobals>(x => { _manager = x.ApplicationContext.GetSystemService(Context.WifiService) .JavaCast <WifiManager>(); }); }
protected virtual void RegisterBindingBuilderCallbacks() { Mvx.CallbackWhenRegistered <IMvxValueConverterRegistry>(FillValueConverters); Mvx.CallbackWhenRegistered <IMvxTargetBindingFactoryRegistry>(FillTargetFactories); Mvx.CallbackWhenRegistered <IMvxBindingNameRegistry>(FillBindingNames); Mvx.CallbackWhenRegistered <IMvxTypeCache <View> >(FillViewTypes); Mvx.CallbackWhenRegistered <IMvxAxmlNameViewTypeResolver>(FillAxmlViewTypeResolver); Mvx.CallbackWhenRegistered <IMvxNamespaceListViewTypeResolver>(FillNamespaceListViewTypeResolver); }
public DroidNetworkService() { NetworkConnectionBroadcastReceiver.OnChange = x => this.SetFromInfo(x, true); Mvx.CallbackWhenRegistered <IMvxAndroidGlobals>(x => { var manager = (ConnectivityManager)x.ApplicationContext.GetSystemService(Application.ConnectivityService); this.SetFromInfo(manager.ActiveNetworkInfo, false); }); }
public override void Initialize() { Mvx.CallbackWhenRegistered <IMvxMessenger>(() => Mvx.RegisterSingleton <IBasketObservableService>(new BasketObservableService())); Mvx.RegisterSingleton <IBasketConfigService>(() => new BasketConfigService()); Mvx.RegisterSingleton <IBasketItemVmService>(() => new BasketItemVmService()); Mvx.RegisterSingleton <IBasketVmService>(() => new BasketVmService()); Mvx.RegisterSingleton <IOrderVmService>(() => new OrderVmService()); Mvx.RegisterSingleton <IUserVmService>(() => new UserVmService()); Mvx.RegisterSingleton <IDeliveryVmService>(() => new DeliveryVmService()); Mvx.RegisterSingleton <IBasketNavigationVmService>(() => new BasketNavigationVmService()); Mvx.LazyConstructAndRegisterSingleton <IBasketProductCardVmService, BasketProductCardVmService>(); Mvx.LazyConstructAndRegisterSingleton <IProductQuantityVmService, ProductQuantityVmService>(); Mvx.LazyConstructAndRegisterSingleton <IProductDeleteVmService, ProductDeleteVmService>(); #region VMs registration var vmLookupService = Mvx.Resolve <IViewModelLookupService>(); vmLookupService.Register <IBasketViewModel, BasketViewModel>(); vmLookupService.Register <IDeliveryViewModel, DeliveryViewModel>(); vmLookupService.Register <IDeliveryOnPointVM, DeliveryOnPointVM>(); vmLookupService.Register <IDeliveryOnAddressVM, DeliveryOnAddressVM>(); vmLookupService.Register <IDeliveryPointOnMapVM, DeliveryPointOnMapVM>(); vmLookupService.Register <IDeliveryPointAdditionalInfoVM, DeliveryPointAdditionalInfoVM>(); vmLookupService.Register <IUserViewModel, UserViewModel>(); vmLookupService.Register <IPaymentViewModel, PaymentViewModel>(); vmLookupService.Register <IBasketProductCardViewModel, BasketProductCardViewModel>(); vmLookupService.Register <IBasketCatalogItemVM, BasketCatalogItemVM>(); vmLookupService.Register <IBasketCartIndicatorViewModel, BasketCartIndicatorViewModel>(); vmLookupService.Register <IThanksViewModel, ThanksViewModel>(); vmLookupService.Register <IOrderFieldAutocompleteVM, OrderFieldAutocompleteVM>(); var orderType = Mvx.Resolve <IBasketConfigService>().Config.OrderViewType; switch (orderType) { case Enums.OrderViewType.Full: vmLookupService.Register <IOrderViewModel, FullOrderViewModel>(); break; case Enums.OrderViewType.Partial: vmLookupService.Register <IOrderViewModel, UserViewModel>(); break; } #endregion #region RouterSubscriber registration var routerService = Mvx.Resolve <IRouterService>(); routerService.Register <IBasketViewModel>(new BasketRouterSubscriber()); #endregion }
public void EnsureLoaded() { if (_loaded) { return; } Mvx.CallbackWhenRegistered <IMvxSourceBindingFactoryExtensionHost>(OnHostRegistered); _loaded = true; }
public NotificationsSubscriber() { Mvx.CallbackWhenRegistered <IMvxMessenger>(() => { _screenToken = Messenger.Subscribe <ScreenAnalyticsMessage>(HandleScreenNotification); _eventToken = Messenger.Subscribe <EventAnalyticsMessage>(HandleEventNotification); _orderToken = Messenger.Subscribe <OrderAnalyticsMessage>(HandleOrderNotification); _exceptionToken = Messenger.Subscribe <ExceptionAnalyticsMessage>(HandleExceptionNotification); }); }
public override void InitializePrimary() { base.InitializePrimary(); UserDialogs.Init(() => Mvx.Resolve <IMvxAndroidCurrentTopActivity>().Activity); Mvx.CallbackWhenRegistered <IMvxLanguageBindingParser>(parser => { var parserIntance = (MvxLanguageBindingParser)parser; parserIntance.DefaultTextSourceName = "LocalizedTextSource"; parserIntance.DefaultBindingMode = MvxBindingMode.OneWay; }); }
public Connectivity() { ConnectivityChangeBroadcastReceiver.OnChange = info => NetworkChanged(info); Mvx.CallbackWhenRegistered <IMvxAndroidGlobals>(x => { var manager = x.ApplicationContext.GetSystemService(Context.ConnectivityService) .JavaCast <ConnectivityManager>(); NetworkChanged(manager.ActiveNetworkInfo, false); }); }
private void InitializeServices() { Mvx.LazyConstructAndRegisterSingleton <ICryptoService, PBKDF2>(); Mvx.RegisterSingleton <ILocationTracker>(InitializeLocationTracker); Mvx.RegisterSingleton <IResourceLocator>(InitializeResources); Mvx.RegisterSingleton <IUserDialogs>(UserDialogs.Instance); Mvx.RegisterSingleton <ISettings>(CrossSettings.Current); Mvx.RegisterType <IRouteRecorder, RouteRecorder>(); Mvx.CallbackWhenRegistered <IMvxMainThreadAsyncDispatcher>(InitializeText); }
public void Load() { Mvx.RegisterSingleton <IFiltersThemeConfigService>(() => new FiltersThemeConfigService()); var viewLookupService = Mvx.Resolve <IViewLookupService>(); viewLookupService.Register <ISortViewModel, SortViewController>(); viewLookupService.Register <IFiltersViewModel, FiltersViewController>(); viewLookupService.Register <IFilterSelectionViewModel, SelectionViewController>(); Mvx.CallbackWhenRegistered <IMvxTargetBindingFactoryRegistry>((registry) => registry.RegisterCustomBindingFactory <UITextField>("FiltersDateBinding", view => new FiltersDateBinding(view))); }
/// <summary> /// Ensures the platform specific version is loaded /// </summary> public void EnsureLoaded() { Mvx.CallbackWhenRegistered <IMvxFileStore>( () => Mvx.CallbackWhenRegistered <IMvxUserInteraction>(() => { Mvx.ConstructAndRegisterSingleton <IFeedbackDataService, FeedbackDataService>(); var manager = Mvx.Resolve <IMvxPluginManager>(); manager.EnsurePlatformAdaptionLoaded <PluginLoader>(); ((MvxFeedbackDialog)Mvx.GetSingleton <IMvxFeedbackDialog>()).SetConfiguration(_configuration); })); }
private static async Task <ILocalization> LocalizationProvider() { if (Mvx.CanResolve <ILocalization>()) { return(Mvx.Resolve <ILocalization>()); } var tcs = new TaskCompletionSource <ILocalization>(); Mvx.CallbackWhenRegistered <ILocalization>(service => tcs.TrySetResult(service)); return(await tcs.Task); }
public override void ChangePresentation(MvxPresentationHint hint) { if (hint is NavigateToDefaultViewModelHint) { Mvx.CallbackWhenRegistered <IMvxNavigationService>(async service => { await service.Navigate(Mvx.Resolve <IMenuVmService>().DefaultViewModelType(), ((IMvxBundle) new BaseBundle(NavigationType.ClearAndPush)), null); }); return; } base.ChangePresentation(hint); }
public BaseVmService() { if (AppSettings.ApiKey.IsNullOrEmtpy()) { throw new ArgumentNullException(nameof(AppSettings.ApiKey)); } CachedObjects = new Dictionary <string, IEnumerable>(); Mvx.CallbackWhenRegistered <IMvxMessenger>(service => { _languageToken = service.Subscribe <LanguageChangedMessage>(OnLanguageChanged); }); }
private void HandleAppNotification(AppAnalyticsMessage msg) { try { if (MobileCenter == null) { Mvx.CallbackWhenRegistered <IMobileCenter>(() => MobileCenter.TrackApp(msg.State, msg.Data)); } else { MobileCenter.TrackApp(msg.State, msg.Data); } } catch {} }
protected override void BindControls() { NavigationController.NavigationBarHidden = true; var set = this.CreateBindingSet <MenuViewController, MenuViewModel>(); BindTableView(_menuTableView, set); set.Apply(); Mvx.CallbackWhenRegistered <IMvxNavigationService>(async service => { await service.Navigate(ViewModel.DefaultViewModel, ((IMvxBundle) new BaseBundle(NavigationType.ClearAndPush)), null); }); }
private void HandleScreenNotification(ScreenAnalyticsMessage msg) { try { if (MobileCenter == null) { Mvx.CallbackWhenRegistered <IMobileCenter>(() => MobileCenter.TrackScreen(msg.ScreenName, msg.ScreenState, msg.Data)); } else { MobileCenter.TrackScreen(msg.ScreenName, msg.ScreenState, msg.Data); } } catch {} }
private void HandleEventNotification(EventAnalyticsMessage msg) { try { if (MobileCenter == null) { Mvx.CallbackWhenRegistered <IMobileCenter>(() => MobileCenter.TrackEvent(msg.Category, msg.Action, msg.Label, msg.Data)); } else { MobileCenter.TrackEvent(msg.Category, msg.Action, msg.Label, msg.Data); } } catch {} }
private void HandleExceptionNotification(ExceptionAnalyticsMessage msg) { try { if (MobileCenter == null) { Mvx.CallbackWhenRegistered <IMobileCenter>(() => MobileCenter.TrackException(msg.Message, msg.StackTrace, msg.Data)); } else { MobileCenter.TrackException(msg.Message, msg.StackTrace, msg.Data); } } catch {} }
protected virtual void NavigateToDeeplinkFromPush(IViewModelLookupService vmLS, string deeplink) { deeplink.ParseDeeplink(out var urlScheme, out var routing, out var urlParameters); if (vmLS.IsRegisteredDeeplink(urlScheme)) { Log.Verbose(PackageName, $"Deeplink was registered"); System.Diagnostics.Debug.WriteLine(message: $"Deeplink was registered", category: PackageName); Mvx.CallbackWhenRegistered <IPushNotificationsService>(service => { service.NavigateTo(deeplink: deeplink); }); } }
protected virtual void NavigateToDeeplinkFromPush(NSDictionary userInfo, string deeplink) { var vmLS = Mvx.Resolve <IViewModelLookupService>(); if (vmLS.IsRegisteredDeeplink(deeplink)) { Mvx.CallbackWhenRegistered <IPushNotificationsService>(service => service.NavigateTo(deeplink)); } else if (!Initialized) { OnInitialized = () => { vmLS.CallbackWhenDeeplinkRegistered(deeplink, type => { InvokeOnMainThread(() => Mvx.CallbackWhenRegistered <IPushNotificationsService>(service => service.NavigateTo(deeplink))); }); }; } }