Exemple #1
0
        public IEnumerator GetProductImage(string sku, ImageDownloadCallback callback)
        {
            bool toEnd = false;

            yield return(null);

            foreach (Category cat in catList)
            {
                foreach (CategoryProduct cp in cat.Products)
                {
                    if (cp.sku == sku)
                    {
                        WWW www = new WWW(Application.streamingAssetsPath + "/Products/" + cat.name + "/" + cp.sku + ".png");
                        yield return(www);

                        callback(www.bytes);
                        toEnd = true;
                        break;
                    }
                }
                if (toEnd)
                {
                    break;
                }
            }
        }
Exemple #2
0
        public IEnumerator GetCategoryImage(long categoryId, ImageDownloadCallback callback)
        {
            yield return(null);

            foreach (Category cat in catList)
            {
                if (cat.id == categoryId)
                {
                    Debug.Log("path: " + Application.streamingAssetsPath + "/Products/" + cat.name + ".png");
                    WWW www = new WWW("file:///" + Application.streamingAssetsPath + "/Products/" + cat.name + ".png");

                    yield return(www);

                    callback(www.bytes);
                    break;
                }
            }
        }
        public IEnumerator GetProductImage(string sku, ImageDownloadCallback callback)
        {
            byte[] bytes;
            string path = DataUtility.GetProductIconPath() + sku;

            if (useCache && File.Exists(path))
            {
                bytes = File.ReadAllBytes(path);
            }
            else
            {
                WWW cases = new WWW(baseUrl + "/magento/products_img/" + EncodeUriComponent(sku) + ".png");
                yield return(cases);

                bytes = cases.bytes;
                File.WriteAllBytes(path, bytes);
            }
            callback(bytes);
        }
        public IEnumerator GetCategoryImage(long categoryId, ImageDownloadCallback callback)
        {
            byte[] bytes;
            string path = DataUtility.GetCategoryPath() + categoryId;

            if (useCache && File.Exists(path))
            {
                bytes = File.ReadAllBytes(path);
            }
            else
            {
                //icon is the file not the folder!
                WWW cases = new WWW(baseUrl + "/magento/categories/" + categoryId + "/icon.png");
                yield return(cases);

                bytes = cases.bytes;
                File.WriteAllBytes(path, bytes);
            }
            callback(bytes);
        }
Exemple #5
0
        public IEnumerator GetSubCategoryImage(long subCategoryId, string subCategoryName, ImageDownloadCallback callback)
        {
            bool toEnd = false;

            yield return(null);

            foreach (Category cat in catList)
            {
                foreach (SubCategory sc in cat.SubCategorys)
                {
                    if (sc.sub_id == subCategoryId)
                    {
                        WWW www = new WWW(Application.streamingAssetsPath + "/Products/" + cat.name + "/" + sc.sub_name + ".png");
                        yield return(www);

                        callback(www.bytes);
                        toEnd = true;
                        break;
                    }
                }
                if (toEnd)
                {
                    break;
                }
            }
        }
        //test !!!!need to rewrite in the future
        public IEnumerator GetSubCategoryImage(long subCategoryId, string subCategoryName, ImageDownloadCallback callback)
        {
            long categoryId = subCategoryId / 100;

            byte[] bytes;
            string path = DataUtility.GetSubCategoryPath() + subCategoryName + ".png";

            if (useCache && File.Exists(path))
            {
                bytes = File.ReadAllBytes(path);
            }
            else
            {
                WWW cases = new WWW(baseUrl + "/magento/categories/" + categoryId
                                    + "/" + subCategoryName + "/" + subCategoryName + ".png");
                yield return(cases);

                bytes = cases.bytes;
                File.WriteAllBytes(path, bytes);
            }
            callback(bytes);
        }