//to display the toppers List public async Task refreshSession() { Console.WriteLine("SESSION COUNT 12 : " + session_names.Count); List <String> temp_session_names = new List <string>(); List <int> temp_active_session_position = new List <int>(); var index = 0; try { string message = " Loading..."; displayProgressDialog(message); var firebase = new FirebaseClient(FirebaseURL); var items = await firebase.Child("Session").OnceAsync <Session>(); foreach (var item in items) { temp_session_names.Add(item.Object.Session_Name); if (!active_session_position.Contains(index)) { var sessionItems = await firebase.Child(item.Object.Session_Name).Child("Score").OnceAsync <SessionResponse>(); if (sessionItems.Count > 0) { temp_active_session_position.Add(index); } } index++; } session_names = temp_session_names; active_session_position = temp_active_session_position; listView = FindViewById <SwipeableListView>(Resource.Id.listView); customAdapter = new CustomAdapter(this, session_names, active_session_position);//,sessionsRating); listView.Adapter = customAdapter; Console.WriteLine("SESSION COUNT 123123 : " + session_names.Count); if (alertDialog.IsShowing) { alertDialog.Dismiss(); } } catch (Exception) { if (alertDialog.IsShowing) { alertDialog.Dismiss(); } string message = "Please Check your Internet Connection And Try Again."; displayProgressDialog(message); } }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); //Set your main view here SetContentView(Resource.Layout.MainLayout); IsConnectedToNetwork = CrossConnectivity.Current.IsConnected; //check the initial state of connection Console.WriteLine("SESSION COUNT : " + session_names.Count); if (session_names.Count == 0) { if (IsConnectedToNetwork == false) { string message = "Please Check your Internet Connection And Try Again."; displayProgressDialog(message); } else { await refreshSession(); } } else { if (Intent.GetStringExtra("FromAddActivtiy") != "" && IsConnectedToNetwork) { session_names.Add(Intent.GetStringExtra("FromAddActivtiy")); listView = FindViewById <SwipeableListView>(Resource.Id.listView); myCustomAdapter = new CustomAdapter(this, session_names, active_session_position);//,sessionsRating); listView.Adapter = myCustomAdapter; } else { listView.Adapter = null; } } //to check whether the device is connected to network CrossConnectivity.Current.ConnectivityChanged += async delegate { if (CrossConnectivity.Current.IsConnected != true) { string message = "Please Check your Internet Connection And Try Again."; displayProgressDialog(message); IsConnectedToNetwork = false; } if (CrossConnectivity.Current.IsConnected == true) { if (alertDialog.IsShowing) { alertDialog.Dismiss(); } await refreshSession(); IsConnectedToNetwork = true; } }; }