Archived
1
0

Fixes. Preparing for submission

This commit is contained in:
Michael Gordeev
2019-02-02 15:14:35 +03:00
parent c30a08f47a
commit 550192d540
51 changed files with 262 additions and 253 deletions
+12 -2
View File
@@ -1,6 +1,7 @@
using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using Microsoft.AppCenter.Analytics;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -16,7 +17,7 @@ namespace FoxTube.Background
public sealed class BackgroundProcessor : IBackgroundTask
{
private DateTime lastCheck = DateTime.Now;
private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
private readonly ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
private YouTubeService Service => new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
@@ -29,6 +30,7 @@ namespace FoxTube.Background
try
{
def = taskInstance.GetDeferral();
taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled);
if (settings.Values["lastCheck"] == null)
{
@@ -45,7 +47,6 @@ namespace FoxTube.Background
if (notificationsSettings[1])
await CheckAccount();
}
catch { }
finally
{
settings.Values["lastCheck"] = DateTime.Now.ToString();
@@ -53,6 +54,15 @@ namespace FoxTube.Background
}
}
private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
Analytics.TrackEvent("Background task caneled", new Dictionary<string, string>()
{
{ "Reason", reason.ToString() }
});
settings.Values["lastCheck"] = DateTime.Now.ToString();
}
async Task CheckAccount()
{
try