示例#1
0
        /// <summary>
        /// Fetches all contacts matching the query, if any.
        /// </summary>
        /// <param name="query">The query string to use for searching.</param>
        public void LoadContactsFromAPI(string query = "")
        {
            #if PLATFORM_LUMIN
            if (!MLContacts.IsStarted)
            {
                return;
            }

            loadedContacts.Clear();

            MLResult            result;
            MLContacts.ListPage fillPage = null;

            if (string.IsNullOrEmpty(query))
            {
                fillPage = MLContacts.CreateListPage(MLContacts.DefaultFetchLimit, out result, RefreshListPageReady, HandlePageFailed);
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: MLContactsBehavior failed to create the contacts list page, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }
            else
            {
                // Change second parameter to limit searching by name, email address, or phone number only.
                fillPage = MLContacts.CreateSearchPage(query, MLContacts.SearchField.All, MLContacts.DefaultFetchLimit, out result, RefreshListPageReady, HandlePageFailed);
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: MLContactsBehavior failed to create the contacts search page, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }

            // Begin fetching contacts.
            result = fillPage.NextPage();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed to request the next page of contacts, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
            #endif
        }
示例#2
0
        /// <summary>
        /// Fetches all contacts matching the query, if any.
        /// </summary>
        /// <param name="query">Search Query</param>
        private void LoadContactsFromAPI(string query = "")
        {
            _loadedContacts.Clear();
            _needToReloadContacts = false;

            MLResult           result;
            MLContactsListPage fillPage = null;

            if (string.IsNullOrEmpty(query))
            {
                fillPage = MLContacts.CreateListPage(MLContacts.DEFAULT_FETCH_LIMIT, out result, RefreshListPageReady, HandlePageFailed);
                if (!result.IsOk)
                {
                    Log(string.Format("<color=red>Cannot load contacts. Reason: {0}</color>", result));
                    Debug.LogErrorFormat("Error: ContactsExample failed to create the contacts list page, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }
            else
            {
                // change second parameter to limit searching by name, email address, or phone number only
                fillPage = MLContacts.CreateSearchPage(query, MLContactsSearchField.All, MLContacts.DEFAULT_FETCH_LIMIT, out result, RefreshListPageReady, HandlePageFailed);
                if (!result.IsOk)
                {
                    Log(string.Format("<color=red>Cannot search contacts. Reason: {0}</color>", result));
                    Debug.LogErrorFormat("Error: ContactsExample failed to create the contacts search page, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }
            }

            // begin fetching contacts
            result = fillPage.NextPage();
            if (!result.IsOk)
            {
                Log(string.Format("<color=red>Cannot load contacts. Reason: {0}</color>", result));
                Debug.LogErrorFormat("Error: ContactsExample failed to request the next page of contacts, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }
        }