예제 #1
0
        //THis works like a charm :)
        private void StartTimeout(bool stop)
        {
            //This action is: 'Hide the notification, and set the timeoutStarted as finished(false)
            //because this action will be invoked only when the timeout has finished.

            //If the timeout has started, then cancel the action, and start again.

            if (stop)
            {
                maincontainer?.RemoveCallbacks(HideNotification); //Stop counting.
                return;
            }
            else
            {
                if (timeoutStarted == true)
                {
                    maincontainer?.RemoveCallbacks(HideNotification);
                    maincontainer?.PostDelayed(HideNotification, 7000);
                }
                //If not, simply wait 5 seconds then hide the notification, in that span of time, the timeout is
                //marked as Started(true)
                else
                {
                    timeoutStarted = true;
                    maincontainer?.PostDelayed(HideNotification, 7000);
                }
            }
        }
예제 #2
0
 private void StartTimeout(bool start)
 {
     if (start == false)
     {
         maincontainer?.RemoveCallbacks(HideMusicWidget); //Stop counting.
         return;
     }
     else
     {
         if (timeoutStarted == true)
         {
             maincontainer?.RemoveCallbacks(HideMusicWidget);
             maincontainer?.PostDelayed(HideMusicWidget, 7000);
         }
         //If not, simply wait 7 seconds then hide the notification, in that span of time, the timeout is
         //marked as Started(true)
         else
         {
             timeoutStarted = true;
             maincontainer?.PostDelayed(HideMusicWidget, 7000);
         }
     }
 }
예제 #3
0
        //THis works like a charm :)
        private void StartTimeout(bool stop)
        {
            //This action is: 'Hide the notification, and set the timeoutStarted as finished(false)
            //because this action will be invoked only when the timeout has finished.
            void hideNotification()
            {
                if (notification != null)
                {
                    notification.Visibility = ViewStates.Gone;
                }
                timeoutStarted = false;
            }

            //If the timeout has started, then cancel the action, and start again.

            if (stop)
            {
                notification?.RemoveCallbacks(hideNotification); //Stop counting.
                return;
            }
            else
            {
                if (timeoutStarted == true)
                {
                    notification?.RemoveCallbacks(hideNotification);
                    notification?.PostDelayed(hideNotification, 5000);
                }
                //If not, simply wait 5 seconds then hide the notification, in that span of time, the timeout is
                //marked as Started(true)
                else
                {
                    timeoutStarted = true;
                    notification?.PostDelayed(hideNotification, 5000);
                }
            }
        }