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

Commit

Permalink
Merge pull request #17 from Paradoxon101/master
Browse files Browse the repository at this point in the history
Fixed #7
  • Loading branch information
ST-Apps authored Jul 31, 2016
2 parents a3802e8 + 76dee94 commit 5832a00
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions PokemonGo-UWP/ViewModels/GameManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Windows.Devices.Geolocation;
using Windows.Devices.Sensors;
using Windows.Foundation.Metadata;
using Windows.Phone.Devices.Notification;
using Windows.System.Threading;
using Windows.UI.Popups;
Expand Down Expand Up @@ -42,6 +43,11 @@ public GameManagerViewModel()
_clientSettings = new Settings();
_client = new Client(_clientSettings);
_inventory = new Inventory(_client);

if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice"))
{
_vibrationDevice = VibrationDevice.GetDefault();
}
}

#endregion
Expand Down Expand Up @@ -93,7 +99,7 @@ public override async Task OnNavigatingFromAsync(NavigatingEventArgs args)
/// <summary>
/// We use it to notify that we found at least one catchable Pokemon in our area
/// </summary>
private readonly VibrationDevice _vibrationDevice = VibrationDevice.GetDefault();
private readonly VibrationDevice _vibrationDevice;

/// <summary>
/// True if the phone can vibrate (e.g. the app is not in background)
Expand Down Expand Up @@ -456,7 +462,8 @@ private async void UpdateMapData(bool updateOnlyPokemonData = true)
var catchableTmp = new List<MapPokemon>(mapObjects.MapCells.SelectMany(i => i.CatchablePokemons));
Logger.Write($"Found {catchableTmp.Count} catchable pokemons");
if (CanVibrate && catchableTmp.Count != CatchablePokemons.Count)
_vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(500));
if(this._vibrationDevice != null)
_vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(500));
await Dispatcher.DispatchAsync(() =>
{
CatchablePokemons.Clear();
Expand Down

0 comments on commit 5832a00

Please sign in to comment.