예제 #1
0
        //Run this method, if expired makes data null
        private void CheckExpiryRagData(List <RagJson> ragObj, ListView ragListView)
        {
            if (MCOLTabbedDash.dataExpired)
            {
                ragObj = null;
                ragListView.Visibility = ViewStates.Gone;

                //ShowAlert("Sorry, the data has expired. Please log back in.", false);

                //Introduce new DialogFragment
                Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
                dialog_LogIn loginPrompt = new dialog_LogIn();
                loginPrompt.Cancelable = false;
                loginPrompt.Show(transaction, "dialog fragment");
            }
        }
        public void CheckIfDataIsExpired()
        {
            int DataExpiredNotificationId = 1001;

            //Quick API call to test if data has expired, if 401 then expired
            McolStatsFragment stats = new McolStatsFragment();

            stats.GetMcolStatsJson();

            //If expired
            if (dataExpired)
            {
                //Alert dialog below
                //ShowAlert("Sorry, the data has expired. Please log back in.", false);

                //Introduce new DialogFragment
                Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
                dialog_LogIn loginPrompt = new dialog_LogIn();
                loginPrompt.Cancelable = false;
                loginPrompt.Show(transaction, "dialog fragment");

                //Notification to say data has expired
                // Construct a back stack for cross-task navigation:
                Android.Support.V4.App.TaskStackBuilder stackBuilder = Android.Support.V4.App.TaskStackBuilder.Create(this);

                // Build the notification:
                NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                     .SetAutoCancel(true)                                      // Dismiss from the notif. area when clicked
                                                     .SetContentTitle("Data has expired.")                     // Set its title
                                                     .SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
                                                     .SetSmallIcon(Resource.Drawable.Icon)                     //  this icon
                                                     .SetContentText("Data has expired, please log back in."); // The message to display.

                // Finally, publish the notification:
                NotificationManager notificationManager =
                    (NotificationManager)GetSystemService(Context.NotificationService);
                notificationManager.Notify(DataExpiredNotificationId, builder.Build());
            }
        }