Exemple #1
0
        public void GetSentContactRequests()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return;
            }

            SetEmptyContentTemplate(true);

            this.SentContactRequests.Clear();
            MContactRequestList outgoingContactRequestsList = MegaSdk.getOutgoingContactRequests();

            for (int i = 0; i < outgoingContactRequestsList.size(); i++)
            {
                // To avoid null values
                if (outgoingContactRequestsList.get(i) == null)
                {
                    continue;
                }

                ContactRequest contactRequest = new ContactRequest(outgoingContactRequestsList.get(i));
                this.SentContactRequests.Add(contactRequest);

                if (!String.IsNullOrWhiteSpace(contactRequest.Email))
                {
                    MegaSdk.getUserAvatar(MegaSdk.getContact(contactRequest.Email), contactRequest.AvatarPath,
                                          new GetContactAvatarRequestListener(contactRequest));
                }
            }

            SetEmptyContentTemplate(false);
        }
Exemple #2
0
        public void GetReceivedContactRequests()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return;
            }

            SetEmptyContentTemplate(true);

            this.ReceivedContactRequests.Clear();
            MContactRequestList incomingContactRequestsList = MegaSdk.getIncomingContactRequests();

            for (int i = 0; i < incomingContactRequestsList.size(); i++)
            {
                // To avoid null values
                if (incomingContactRequestsList.get(i) == null)
                {
                    continue;
                }

                ContactRequest contactRequest = new ContactRequest(incomingContactRequestsList.get(i));
                this.ReceivedContactRequests.Add(contactRequest);

                MegaSdk.getUserAvatar(MegaSdk.getContact(contactRequest.Email), contactRequest.AvatarPath,
                                      new GetContactAvatarRequestListener(contactRequest));
            }

            SetEmptyContentTemplate(false);
        }
Exemple #3
0
        public void onContactRequestsUpdate(MegaSDK api, MContactRequestList requests)
        {
            // Exit methods when contact request list is incorrect
            if (requests == null || requests.size() < 1)
            {
                return;
            }

            try
            {
                bool isIncomingContactRequestUpdate = false;
                bool isOutgoingContactRequestUpdate = false;

                // Retrieve the listsize for performance reasons and store local
                int listSize = requests.size();

                for (int i = 0; i < listSize; i++)
                {
                    // Get the specific contact request that has an update.
                    // If null exit the method and process no notification.
                    MContactRequest megaContactRequest = requests.get(i);
                    if (megaContactRequest == null)
                    {
                        return;
                    }

                    if (megaContactRequest.isOutgoing())
                    {
                        isOutgoingContactRequestUpdate = true;
                    }
                    else
                    {
                        isIncomingContactRequestUpdate = true;
                    }
                }

                if (isIncomingContactRequestUpdate)
                {
                    OnIncomingContactRequestUpdated();
                }
                if (isOutgoingContactRequestUpdate)
                {
                    OnOutgoingContactRequestUpdated();
                }
            }
            catch (Exception) { /* Dummy catch, suppress possible exception */ }
        }