Пример #1
0
        void OnConnectivityChanged(object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e)
        {
            IsConnected = e.IsConnected;

            if (!e.IsConnected)
            {
                // Cancel All Running Task
                var items = runningTasks.ToList();
                foreach (var item in items)
                {
                    item.Value.Cancel();
                    runningTasks.Remove(item.Key);
                }
            }
        }
Пример #2
0
 private void OnChanged(object sender, ConnectivityChangedEventArgs e)
 {
     if (e.IsConnected.ToString().Equals("False"))
     {
         if (CrossConnectivity.Current.ConnectionTypes.Contains(ConnectionType.WiFi))
         {
             // WE LOST AN CONNECTION BUT WIFI IS STILL ON
             connectionDetailsLbl.Text = "WE LOST AN CONNECTION BUT WIFI IS STILL ON";
         }
     }
     else
     {
         if (CrossConnectivity.Current.ConnectionTypes.Contains(ConnectionType.WiFi))
         {
             // WIFI WAS TURN ON AND WE HAVE A CONNECTION
             connectionDetailsLbl.Text = "WIFI WAS TURN ON AND WE HAVE A CONNECTION";
         }
         else
         {
             // WE HAVE A CONNECTION BUT NOT WIFI
             connectionDetailsLbl.Text = "WE HAVE A CONNECTION BUT NOT WIFI";
         }
     }
 }
Пример #3
0
 protected async void ConnectivityChanged (object sender, ConnectivityChangedEventArgs e)
 {
     //save current state and then set it
     var connected = Settings.Current.IsConnected;
     Settings.Current.IsConnected = e.IsConnected;
     if (connected && !e.IsConnected)
     {
         //we went offline, should alert the user and also update ui (done via settings)
         var task = Application.Current?.MainPage?.DisplayAlert("Offline", "Uh Oh, It looks like you have gone offline. Please check your internet connection to get the latest data and enable syncing data.", "OK");
         if (task != null)
             await task;
     }
 }
 private void HandleConnectivityChanged(object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e)
 {
     Type currentPage = this.MainPage.GetType();
     // if (e.IsConnected && currentPage != typeof(MainPage)) this.MainPage = new MainPage();
 }
Пример #5
0
 protected virtual void OnConnectionChange(object sender, ConnectivityChangedEventArgs e)
 {
     bool connected = CrossConnectivity.Current.IsConnected;
     switchView(connected);
 }
 /// <summary>
 /// When connectivity changes
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnConnectivityChanged(ConnectivityChangedEventArgs e) =>
     ConnectivityChanged?.Invoke(this, e);
 internal protected virtual void OnConnectionChange(object sender, ConnectivityChangedEventArgs e)
 {
     progress.IsVisible = true;
     updateNetworkInfo();
     progress.IsVisible = false;
 }
Пример #8
0
 /// <summary>
 /// When connectivity changes
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnConnectivityChanged(ConnectivityChangedEventArgs e) =>
 ConnectivityChanged?.Invoke(this, e);
Пример #9
0
 private void OnConnectivityChanged(object sender, ConnectivityChangedEventArgs connectivityChangedEventArgs)
 {
     isConnected = connectivityChangedEventArgs.IsConnected;
 }