Skip to content

Commit

Permalink
* Fixin Application not responsive problems
Browse files Browse the repository at this point in the history
  • Loading branch information
wench committed Aug 5, 2019
1 parent f225649 commit 9078ed5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<BundleAssemblies>false</BundleAssemblies>
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi>
<AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64;arm64-v8a</AndroidSupportedAbis>
<Debugger>Native</Debugger>
<AotAssemblies>false</AotAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions Ao3TrackReader/Ao3TrackReader.Version/GitRevision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Ao3TrackReader.Version
{
static partial class Version
{
public const string GitRevision = "75228bb6f4dfbfa4a6189ce2142cff74c48dcea6";
public const string GitTag = "";
public const string GitRevision = "f225649009f63bf162c02ece20ce58b82841e766";
public const string GitTag = "v1.1.3.1";
}
}
2 changes: 1 addition & 1 deletion Ao3TrackReader/Ao3TrackReader.Version/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static partial class Version
public const int Build = 3;
public const int Revision = 1;

public const string String = "1.1.3.1";
public const string String = "1.1.3.2";
public const int Integer = Major * 100000000 + Minor * 100000 + Build * 100 + Revision;

public static string Full => $"{Major}.{Minor}.{Build}.{Revision}";
Expand Down
44 changes: 25 additions & 19 deletions Ao3TrackReader/Ao3TrackReader/Controls/ReadingListView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ void RestoreReadingList()

using (var tasklimit = new SemaphoreSlim(MaxRefreshTasks))
{
if (items.Count == 0)
await wvp.DoOnMainThreadAsync(() =>ListView.ItemsSource = readingListBacking);
if (items.Count == 0)
{
tasks.Enqueue(AddAsyncImpl("http://archiveofourown.org/", DateTime.UtcNow.ToUnixTime()));
}
Expand All @@ -131,18 +132,19 @@ void RestoreReadingList()
Favourite = item.Favourite
};

await wvp.DoOnMainThreadAsync(() =>
{
viewmodel.PropertyChanged += Viewmodel_PropertyChanged;
readingListBacking.Add(viewmodel);
});

await tasklimit.WaitAsync();
tasks.Enqueue(wvp.DoOnMainThreadAsync(async () =>
tasks.Enqueue(Task.Run(async () =>
{
await viewmodel.SetBaseDataAsync(model,false);
RefreshAsync(viewmodel);
await Task.Yield();
await viewmodel.SetBaseDataAsync(model, false);
if (!readingListBacking.Contains(viewmodel)){
await wvp.DoOnMainThreadAsync(() =>
{
viewmodel.PropertyChanged += Viewmodel_PropertyChanged;
readingListBacking.Add(viewmodel);
});
}

await RefreshAsync(viewmodel);
await Task.Delay(RefreshDelay);
tasklimit.Release();
}));
Expand All @@ -154,13 +156,11 @@ await wvp.DoOnMainThreadAsync(() =>
#pragma warning restore 4014
}
}
await Task.WhenAll(tasks);
tasks.Clear();
}

await wvp.DoOnMainThreadAsync(() =>
{
ListView.ItemsSource = readingListBacking;

restored.SetResult(true);
SyncIndicator.Content = new ActivityIndicator() { IsVisible = IsOnScreen, IsRunning = IsOnScreen, IsEnabled = IsOnScreen };
App.Database.GetVariableEvents("LogFontSizeUI").Updated += LogFontSizeUI_Updated;
Expand All @@ -176,7 +176,13 @@ await wvp.DoOnMainThreadAsync(() =>
await tcsNetworkAvailable.Task;
}

await SyncToServerAsync(false, true);
#pragma warning disable 4014
while (tasks.Count > 0 && tasks.Peek().IsCompleted)
tasks.Dequeue();
#pragma warning restore 4014
await Task.WhenAll(tasks);

await SyncToServerAsync(false, true);

}
finally
Expand Down Expand Up @@ -366,7 +372,7 @@ private void OnRefresh(object sender, EventArgs e)
try
{
await SyncToServerAsync(false, true);
/*

using (var tasklimit = new SemaphoreSlim(MaxRefreshTasks))
{
List<Task> tasks = new List<Task>();
Expand All @@ -384,7 +390,7 @@ private void OnRefresh(object sender, EventArgs e)
}

await Task.WhenAll(tasks);
}*/
}
}
finally
{
Expand Down Expand Up @@ -772,8 +778,8 @@ await wvp.DoOnMainThreadAsync(async () =>
{
await viewmodel.SetBaseDataAsync(model, true);
viewmodel.Loaded = true;
// readingListBacking.Remove(viewmodel);
//readingListBacking.Add(viewmodel);
readingListBacking.Remove(viewmodel);
readingListBacking.Add(viewmodel);
});

await WriteViewModelToDbAsync(viewmodel, new ReadingList(model, 0, viewmodel.Unread));
Expand Down
17 changes: 16 additions & 1 deletion Ao3TrackReader/Ao3TrackReader/GroupList2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ public T Find(Predicate<T> pred)
}
return default(T);
}
public bool Contains(T obj)
{
foreach (var g in this)
{
if (g.Contains(obj)) return true;
}
return false;
}
public T FindInAll(Predicate<T> pred)
{
foreach (var e in allItems.Keys)
Expand Down Expand Up @@ -445,7 +453,14 @@ public bool Remove(T item)
return RemoveFromGroup(item);
}
}

public bool Contains(T obj)
{
foreach (var g in this)
{
if (g.Contains(obj)) return true;
}
return false;
}
public T Find(Predicate<T> pred)
{
lock (locker)
Expand Down

0 comments on commit 9078ed5

Please sign in to comment.