summaryrefslogtreecommitdiff
path: root/Juick/ViewModels/AppViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewModels/AppViewModel.cs')
-rw-r--r--Juick/ViewModels/AppViewModel.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/Juick/ViewModels/AppViewModel.cs b/Juick/ViewModels/AppViewModel.cs
index ab00cb0..e3a58bb 100644
--- a/Juick/ViewModels/AppViewModel.cs
+++ b/Juick/ViewModels/AppViewModel.cs
@@ -2,8 +2,10 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using System.Net.NetworkInformation;
using Juick.Classes;
using JuickApi;
+using Microsoft.Phone.Net.NetworkInformation;
using RestSharp;
using Microsoft.Phone.Notification;
using System.Diagnostics;
@@ -13,13 +15,21 @@ namespace Juick.ViewModels
{
public class AppViewModel : ViewModelBase
{
+ static readonly string IsNetworkAvailablePropertyName = ExpressionHelper.GetPropertyName<AppViewModel>(x => x.NetworkUnavailable);
readonly HttpNotificationChannel pushChannel;
// The name of our push channel.
string channelName = "JuickChannel";
+ public void UpdateNetworkStatus()
+ {
+ NetworkUnavailable = !DeviceNetworkInformation.IsNetworkAvailable;
+ }
+
public AppViewModel()
{
+ UpdateNetworkStatus();
+ NetworkChange.NetworkAddressChanged += (sender, args) => UpdateNetworkStatus();
pushChannel = HttpNotificationChannel.Find(channelName);
// If the channel was not found, then create a new connection to the push service.
@@ -120,6 +130,16 @@ namespace Juick.ViewModels
}
}
}
+ private bool _isNetworkUnavailable;
+ public bool NetworkUnavailable
+ {
+ get { return _isNetworkUnavailable; }
+ set
+ {
+ _isNetworkUnavailable = value;
+ NotifyPropertyChanged(IsNetworkAvailablePropertyName);
+ }
+ }
private AccountManager _acc;