예제 #1
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            if (_syncService.SyncInProgress)
            {
                IsBusy = true;
            }

            _broadcasterService.Subscribe(nameof(ViewPage), async(message) =>
            {
                try
                {
                    if (message.Command == "syncStarted")
                    {
                        Device.BeginInvokeOnMainThread(() => IsBusy = true);
                    }
                    else if (message.Command == "syncCompleted")
                    {
                        await Task.Delay(500);
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            IsBusy = false;
                            if (message.Data is Dictionary <string, object> data && data.ContainsKey("successfully"))
                            {
                                var success = data["successfully"] as bool?;
                                if (success.GetValueOrDefault())
                                {
                                    var task = _vm.LoadAsync(() => AdjustToolbar());
                                }
                            }
                        });
                    }
                    else if (message.Command == "selectSaveFileResult")
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            var data = message.Data as Tuple <string, string>;
                            if (data == null)
                            {
                                return;
                            }
                            _vm.SaveFileSelected(data.Item1, data.Item2);
                        });
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.LogEvenIfCantBeResolved(ex);
                }
            });
            await LoadOnAppearedAsync(_scrollView, true, async() =>
            {
                var success = await _vm.LoadAsync(() => AdjustToolbar());
                if (!success)
                {
                    await Navigation.PopModalAsync();
                }
            }, _mainContent);
        }
예제 #2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            _broadcasterService.Subscribe(nameof(ViewPage), (message) =>
            {
                if (message.Command == "syncCompleted")
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        var data = message.Data as Dictionary <string, object>;
                        if (data.ContainsKey("successfully"))
                        {
                            var success = data["successfully"] as bool?;
                            if (success.HasValue && success.Value)
                            {
                                var task = _vm.LoadAsync();
                            }
                        }
                    });
                }
            });
            await LoadOnAppearedAsync(_scrollView, true, async() =>
            {
                var success = await _vm.LoadAsync();
                if (!success)
                {
                    await Navigation.PopModalAsync();
                }
            }, _mainContent);

            if (Device.RuntimePlatform == Device.Android)
            {
                if (_vm.Cipher.OrganizationId == null)
                {
                    if (ToolbarItems.Contains(_collectionsItem))
                    {
                        ToolbarItems.Remove(_collectionsItem);
                    }
                    if (!ToolbarItems.Contains(_shareItem))
                    {
                        ToolbarItems.Insert(1, _shareItem);
                    }
                }
                else
                {
                    if (ToolbarItems.Contains(_shareItem))
                    {
                        ToolbarItems.Remove(_shareItem);
                    }
                    if (!ToolbarItems.Contains(_collectionsItem))
                    {
                        ToolbarItems.Insert(1, _collectionsItem);
                    }
                }
            }
        }
예제 #3
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            if (_syncService.SyncInProgress)
            {
                IsBusy = true;
            }

            _broadcasterService.Subscribe(nameof(ViewPage), async(message) =>
            {
                if (message.Command == "syncStarted")
                {
                    Device.BeginInvokeOnMainThread(() => IsBusy = true);
                }
                else if (message.Command == "syncCompleted")
                {
                    await Task.Delay(500);
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        IsBusy = false;
                        if (message.Data is Dictionary <string, object> data && data.ContainsKey("successfully"))
                        {
                            var success = data["successfully"] as bool?;
                            if (success.GetValueOrDefault())
                            {
                                var task = _vm.LoadAsync(() => AdjustToolbar());
                            }
                        }
                    });
                }
            });
            await LoadOnAppearedAsync(_scrollView, true, async() =>
            {
                var success = await _vm.LoadAsync(() => AdjustToolbar());
                if (!success)
                {
                    await Navigation.PopModalAsync();
                }
            }, _mainContent);
        }