/// <summary>
    /// Gets the hash set.
    /// </summary>
    /// <returns>
    /// The hash set.
    /// </returns>
    /// <param name='method'>
    /// Method.
    /// </param>
    protected HashSet <string> GetHashSet(HashSetMethod method)
    {
#if UNITY_ANDROID
        AndroidJNI.PushLocalFrame(10);
        //never return null
        HashSet <string> returnSet = new HashSet <string>();

        //get the string set
        AndroidJavaObject stringSet = javaObject.Call <AndroidJavaObject>(method.ToString());

        if (stringSet == null)
        {
            return(returnSet);
        }

        //get iterator from string set
        AndroidJavaObject iterator = stringSet.Call <AndroidJavaObject>("iterator");

        if (iterator == null)
        {
            return(returnSet);
        }

        //iterate until it has been... iterated...
        while (iterator.Call <bool>("hasNext"))
        {
            string key = iterator.Call <string>("next");
            returnSet.Add(key);
        }
        AndroidJNI.PopLocalFrame(System.IntPtr.Zero);

        return(returnSet);
#elif UNITY_IOS
        // Get the HashSet from the Objective C library as a JSON formated string.
        string hashSetAsJSON = getHashSetAsJSON(method);
        if (null == hashSetAsJSON)
        {
            return(null);
        }
        // Convert the string to an array list.
        ArrayList jsonAsArrayList = hashSetAsJSON.arrayListFromJson();
        // Convert the array list to a hashset.
        HashSet <string> returnSet = new HashSet <string>();
        foreach (string jsonObject in jsonAsArrayList)
        {
            returnSet.Add(jsonObject);
        }
        return(returnSet);
#else
        return(default(HashSet <String>));
#endif
    }
Example #2
0
    /// <summary>
    /// Gets the hash set.
    /// </summary>
    /// <returns>
    /// The hash set.
    /// </returns>
    /// <param name='method'>
    /// Method.
    /// </param>
    protected HashSet <string> GetHashSet(HashSetMethod method)
    {
#if UNITY_ANDROID
        AndroidJNI.PushLocalFrame(10);
        //never return null
        HashSet <string> returnSet = new HashSet <string>();

        //get the string set
        AndroidJavaObject stringSet = javaObject.Call <AndroidJavaObject>(method.ToString());

        if (stringSet == null)
        {
            return(returnSet);
        }

        //get iterator from string set
        AndroidJavaObject iterator = stringSet.Call <AndroidJavaObject>("iterator");

        if (iterator == null)
        {
            return(returnSet);
        }

        //iterate until it has been... iterated...
        while (iterator.Call <bool>("hasNext"))
        {
            string key = iterator.Call <string>("next");
            returnSet.Add(key);
        }
        AndroidJNI.PopLocalFrame(System.IntPtr.Zero);

        return(returnSet);
#else
        return(default(HashSet <String>));
#endif
    }
    /// <summary>
    /// Gets the hash set from the iOS library as JSON formatted string.
    /// </summary>
    /// <returns>
    /// The hash set as JSON formatted string.
    /// </returns>
    /// <param name='method'>
    /// The method to call.
    /// </param>
    string getHashSetAsJSON(HashSetMethod method)
    {
        // Having a method per hash set retrieval matches
        // the iOS SDK, and the Android half of the plugin's behavior.
        switch (method)
        {
        case HashSetMethod.getDeveloperStringKeys:
            return(_AmazonGCWSGetDeveloperStringKeysAsJSON());

        case HashSetMethod.getAccumulatingNumberKeys:
            return(_AmazonGCWSGetAccumulatingNumberKeysAsJSON());

        case HashSetMethod.getHighestNumberKeys:
            return(_AmazonGCWSGetHighestNumberKeysAsJSON());

        case HashSetMethod.getHighNumberListKeys:
            return(_AmazonGCWSGetHighNumberListKeysAsJSON());

        case HashSetMethod.getLatestNumberKeys:
            return(_AmazonGCWSGetLatestNumberKeysAsJSON());

        case HashSetMethod.getLatestNumberListKeys:
            return(_AmazonGCWSGetLatestNumberListKeysAsJSON());

        case HashSetMethod.getLatestStringKeys:
            return(_AmazonGCWSGetLatestStringKeysAsJSON());

        case HashSetMethod.getLatestStringListKeys:
            return(_AmazonGCWSGetLatestStringListKeysAsJSON());

        case HashSetMethod.getLowestNumberKeys:
            return(_AmazonGCWSGetLowestNumberKeysAsJSON());

        case HashSetMethod.getLowNumberListKeys:
            return(_AmazonGCWSGetLowNumberListKeysAsJSON());

        case HashSetMethod.getMapKeys:
            return(_AmazonGCWSGetMapKeysAsJSON());

        case HashSetMethod.getStringSetKeys:
            return(_AmazonGCWSGetStringSetKeysAsJSON());

        default:
            AGSClient.LogGameCircleError(string.Format("Unhandled hash set method {0}", method.ToString()));
            return(null);
        }
    }