mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
run on main thread fixes
This commit is contained in:
parent
f394eddc01
commit
44fe5af4fb
1 changed files with 18 additions and 14 deletions
|
@ -174,26 +174,30 @@ namespace Bit.iOS.Autofill
|
||||||
public override void TextChanged(UISearchBar searchBar, string searchText)
|
public override void TextChanged(UISearchBar searchBar, string searchText)
|
||||||
{
|
{
|
||||||
var cts = new CancellationTokenSource();
|
var cts = new CancellationTokenSource();
|
||||||
Task.Run(async () =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrWhiteSpace(searchText))
|
NSRunLoop.Main.BeginInvokeOnMainThread(async () =>
|
||||||
{
|
{
|
||||||
await Task.Delay(300);
|
if (!string.IsNullOrWhiteSpace(searchText))
|
||||||
if(searchText != searchBar.Text)
|
|
||||||
{
|
{
|
||||||
return;
|
await Task.Delay(300);
|
||||||
|
if (searchText != searchBar.Text)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_filterResultsCancellationTokenSource?.Cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
try
|
||||||
{
|
{
|
||||||
_filterResultsCancellationTokenSource?.Cancel();
|
((TableSource)_controller.TableView.Source).FilterResults(searchText, cts.Token);
|
||||||
|
_controller.TableView.ReloadData();
|
||||||
}
|
}
|
||||||
}
|
catch (OperationCanceledException) { }
|
||||||
try
|
_filterResultsCancellationTokenSource = cts;
|
||||||
{
|
});
|
||||||
((TableSource)_controller.TableView.Source).FilterResults(searchText, cts.Token);
|
|
||||||
_controller.TableView.ReloadData();
|
|
||||||
}
|
|
||||||
catch(OperationCanceledException) { }
|
|
||||||
}, cts.Token);
|
}, cts.Token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue