Skip to content
This repository was archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
Fixed #229
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-Apps committed Aug 4, 2016
1 parent a3f8d5f commit c80313b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Binary file modified .vs/Pokemon Go Universal/v14/.suo
Binary file not shown.
33 changes: 19 additions & 14 deletions PokemonGo-UWP/Utils/GameClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,27 +266,32 @@ public static async Task InitializeDataUpdate()
};
_mapUpdateTimer.Tick += async (s, e) =>
{
if (!UpdateDataMutex.WaitOne(0)) return;
if (_skipNextUpdate)
{
_skipNextUpdate = false;
}
else
{
Logger.Write("Updating map");
await UpdateMapObjects();
}

UpdateDataMutex.ReleaseMutex();
};
Logger.Write("Updating map");
await UpdateMapObjects();
};
// Update before starting timer
Busy.SetBusy(true, Resources.Translation.GetString("GettingUserData"));
await UpdateMapObjects();
await UpdateInventory();
_mapUpdateTimer.Start();
Busy.SetBusy(false);
}

/// <summary>
/// Toggles the update timer based on the isEnabled value
/// </summary>
/// <param name="isEnabled"></param>
public static void ToggleUpdateTimer(bool isEnabled = true)
{
if (isEnabled)
{
_mapUpdateTimer.Start();
}
else
{
_mapUpdateTimer.Stop();
}
}

/// <summary>
/// Updates catcheable and nearby Pokemons + Pokestops.
/// We're using a single method so that we don't need two separate calls to the server, making things faster.
Expand Down
4 changes: 4 additions & 0 deletions PokemonGo-UWP/ViewModels/GameMapPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ await Dispatcher.DispatchAsync(async () =>
}
});
}
// Restarts map timer
GameClient.ToggleUpdateTimer();
if (suspensionState.Any())
{
// Recovering the state
Expand Down Expand Up @@ -111,6 +113,8 @@ public override async Task OnNavigatedFromAsync(IDictionary<string, object> susp
public override async Task OnNavigatingFromAsync(NavigatingEventArgs args)
{
args.Cancel = false;
// Stops map timer
GameClient.ToggleUpdateTimer(false);
GameClient.MapPokemonUpdated -= GameClientOnMapPokemonUpdated;
await Task.CompletedTask;
}
Expand Down

0 comments on commit c80313b

Please sign in to comment.