mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
show loading indicator if syncing an no items
This commit is contained in:
parent
e753acbc3f
commit
9bbddd6aeb
4 changed files with 22 additions and 11 deletions
|
@ -29,9 +29,9 @@ namespace Bit.App.Controls
|
||||||
{
|
{
|
||||||
if(_syncIndicator)
|
if(_syncIndicator)
|
||||||
{
|
{
|
||||||
MessagingCenter.Subscribe<ISyncService, bool>(_syncService, "SyncCompleted",
|
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted",
|
||||||
(sender, success) => Device.BeginInvokeOnMainThread(() => IsBusy = _syncService.SyncInProgress));
|
(sender, success) => Device.BeginInvokeOnMainThread(() => IsBusy = _syncService.SyncInProgress));
|
||||||
MessagingCenter.Subscribe<ISyncService>(_syncService, "SyncStarted",
|
MessagingCenter.Subscribe<ISyncService>(Application.Current, "SyncStarted",
|
||||||
(sender) => Device.BeginInvokeOnMainThread(() => IsBusy = _syncService.SyncInProgress));
|
(sender) => Device.BeginInvokeOnMainThread(() => IsBusy = _syncService.SyncInProgress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ namespace Bit.App.Controls
|
||||||
{
|
{
|
||||||
if(_syncIndicator)
|
if(_syncIndicator)
|
||||||
{
|
{
|
||||||
MessagingCenter.Unsubscribe<ISyncService, bool>(_syncService, "SyncCompleted");
|
MessagingCenter.Unsubscribe<Application, bool>(Application.Current, "SyncCompleted");
|
||||||
MessagingCenter.Unsubscribe<ISyncService>(_syncService, "SyncStarted");
|
MessagingCenter.Unsubscribe<Application>(Application.Current, "SyncStarted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_syncIndicator)
|
if(_syncIndicator)
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace Bit.App.Pages
|
||||||
public Cipher[] Ciphers { get; set; } = new Cipher[] { };
|
public Cipher[] Ciphers { get; set; } = new Cipher[] { };
|
||||||
public ListView ListView { get; set; }
|
public ListView ListView { get; set; }
|
||||||
public SearchBar Search { get; set; }
|
public SearchBar Search { get; set; }
|
||||||
|
public ActivityIndicator LoadingIndicator { get; set; }
|
||||||
public StackLayout NoDataStackLayout { get; set; }
|
public StackLayout NoDataStackLayout { get; set; }
|
||||||
public StackLayout ResultsStackLayout { get; set; }
|
public StackLayout ResultsStackLayout { get; set; }
|
||||||
private AddCipherToolBarItem AddCipherItem { get; set; }
|
private AddCipherToolBarItem AddCipherItem { get; set; }
|
||||||
|
@ -156,12 +157,14 @@ namespace Bit.App.Pages
|
||||||
Title = AppResources.SearchVault;
|
Title = AppResources.SearchVault;
|
||||||
}
|
}
|
||||||
|
|
||||||
Content = new ActivityIndicator
|
LoadingIndicator = new ActivityIndicator
|
||||||
{
|
{
|
||||||
IsRunning = true,
|
IsRunning = true,
|
||||||
VerticalOptions = LayoutOptions.CenterAndExpand,
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
||||||
HorizontalOptions = LayoutOptions.Center
|
HorizontalOptions = LayoutOptions.Center
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Content = LoadingIndicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
|
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
|
||||||
|
@ -249,7 +252,7 @@ namespace Bit.App.Pages
|
||||||
protected override void OnAppearing()
|
protected override void OnAppearing()
|
||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
MessagingCenter.Subscribe<ISyncService, bool>(_syncService, "SyncCompleted", (sender, success) =>
|
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
||||||
{
|
{
|
||||||
if(success)
|
if(success)
|
||||||
{
|
{
|
||||||
|
@ -273,7 +276,7 @@ namespace Bit.App.Pages
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
{
|
{
|
||||||
base.OnDisappearing();
|
base.OnDisappearing();
|
||||||
MessagingCenter.Unsubscribe<ISyncService, bool>(_syncService, "SyncCompleted");
|
MessagingCenter.Unsubscribe<Application, bool>(Application.Current, "SyncCompleted");
|
||||||
|
|
||||||
AddCipherItem?.Dispose();
|
AddCipherItem?.Dispose();
|
||||||
ListView.ItemSelected -= CipherSelected;
|
ListView.ItemSelected -= CipherSelected;
|
||||||
|
@ -345,6 +348,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
Content = ResultsStackLayout;
|
Content = ResultsStackLayout;
|
||||||
}
|
}
|
||||||
|
else if(_syncService.SyncInProgress)
|
||||||
|
{
|
||||||
|
Content = LoadingIndicator;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Content = NoDataStackLayout;
|
Content = NoDataStackLayout;
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace Bit.App.Pages
|
||||||
protected override void OnAppearing()
|
protected override void OnAppearing()
|
||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
MessagingCenter.Subscribe<ISyncService, bool>(_syncService, "SyncCompleted", (sender, success) =>
|
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
||||||
{
|
{
|
||||||
if(success)
|
if(success)
|
||||||
{
|
{
|
||||||
|
@ -168,7 +168,7 @@ namespace Bit.App.Pages
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
{
|
{
|
||||||
base.OnDisappearing();
|
base.OnDisappearing();
|
||||||
MessagingCenter.Unsubscribe<ISyncService, bool>(_syncService, "SyncCompleted");
|
MessagingCenter.Unsubscribe<Application, bool>(Application.Current, "SyncCompleted");
|
||||||
|
|
||||||
ListView.ItemSelected -= GroupingSelected;
|
ListView.ItemSelected -= GroupingSelected;
|
||||||
AddCipherItem?.Dispose();
|
AddCipherItem?.Dispose();
|
||||||
|
@ -229,6 +229,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
Content = ListView;
|
Content = ListView;
|
||||||
}
|
}
|
||||||
|
else if(_syncService.SyncInProgress)
|
||||||
|
{
|
||||||
|
Content = LoadingIndicator;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Content = NoDataStackLayout;
|
Content = NoDataStackLayout;
|
||||||
|
|
|
@ -554,7 +554,7 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncInProgress = true;
|
SyncInProgress = true;
|
||||||
MessagingCenter.Send(this, "SyncStarted");
|
MessagingCenter.Send(Application.Current, "SyncStarted");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SyncCompleted(bool successfully)
|
private void SyncCompleted(bool successfully)
|
||||||
|
@ -565,7 +565,7 @@ namespace Bit.App.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncInProgress = false;
|
SyncInProgress = false;
|
||||||
MessagingCenter.Send(this, "SyncCompleted", successfully);
|
MessagingCenter.Send(Application.Current, "SyncCompleted", successfully);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CheckSuccess<T>(ApiResult<T> result, bool logout = false)
|
private bool CheckSuccess<T>(ApiResult<T> result, bool logout = false)
|
||||||
|
|
Loading…
Reference in a new issue