Exemplo n.º 1
0
    /*
     * 加载图片
     */
    private void LoadImage()
    {
        string imageUrl = this.model.imageUrl;

        if (string.IsNullOrEmpty(imageUrl))
        {
            LogUtils.LogError(this.gameObject.name + " image url is null!");
            return;
        }
        if (imageUrl.StartsWith("poster"))
        {
            LogUtils.Log(this.model.title + " load image from <poster>");
            image.texture = Resources.Load(imageUrl) as Texture;
        }
        else if (imageUrl.StartsWith("sdcard"))
        {
            LogUtils.Log(this.model.title + " load image from <sdcard>");
            new LocalImageLoader(imageUrl, true, OnLocalTextureCallback).StartLoad();
        }
        else
        {
            string imageLocalPath = LauncherUtils.GetImageCachePath() + GetImageUrl().GetHashCode();
            if (!File.Exists(imageLocalPath))
            {
                LogUtils.Log(this.model.title + " load image from <network>");
                ImageUtils.Instance.LoadTexture(GetImageUrl());
            }
            else
            {
                LogUtils.Log(this.model.title + " load image from <cache>");
                new LocalImageLoader(imageLocalPath, true, OnLocalTextureCallback).StartLoad();
            }
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        LogUtils.Log("===================================== VRLauncher Unity Start =====================================");
        //设置语言
        string language = OtherUtils.Instance.GetLanguage();
        string country  = OtherUtils.Instance.GetCountry();

        LogUtils.Log(language + "<===>" + country);
        if (country == "TW")
        {
            Localization.language = language + "-" + country;
        }
        else
        {
            Localization.language = language;
        }
        //设置图片缓存路径
        LauncherUtils.SetImageCachePath(Application.persistentDataPath + "/ImageCache/");
        //初始化数据库
        //DBUtils.Instance.Init ();
        //初始化场景
        //ScreenManager.Instance.InitScreen();
        //bind sdk service
        if (Application.platform == RuntimePlatform.Android)
        {
            StartCoroutine(StartBind());
        }
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        ImageUtils.onTextureCallback += OnTextureCallback;
        GetComponent <Button> ().onClick.AddListener(delegate() {
            LauncherUtils.DoSomething(this.model);
        });

        initData();
    }
Exemplo n.º 4
0
    private void SaveToLocal(string imageUrl, HTTPResponse response)
    {
        string imagePath = LauncherUtils.GetImageCachePath() + imageUrl.GetHashCode();

        if (!File.Exists(imagePath))
        {
            ThreadStart threadStart = new ThreadStart(delegate(){
                if (!Directory.Exists(LauncherUtils.GetImageCachePath()))
                {
                    Directory.CreateDirectory(LauncherUtils.GetImageCachePath());
                }
                Texture2D image = response.DataAsTexture2D;
                byte[] pngData  = image.EncodeToPNG();
                File.WriteAllBytes(imagePath, pngData);
            });
            new Thread(threadStart).Start();
        }
    }
Exemplo n.º 5
0
 /*
  * 未读信息
  */
 public void UpdateBadge(string info)
 {
     Debug.Log("UpdateBadge------->" + info);
     if (!string.IsNullOrEmpty(info) && info.Contains("/"))
     {
         string[] infos = info.Split('/');
         if (infos != null && infos.Length != 3)
         {
             return;
         }
         string packageName = infos [0];
         if (packageName.Equals(Constant.SYSTEM_UPDATE_PACKAGE_NAME))
         {
             //显示系统升级Dialog
             Dialog.Show(Localization.Get("Update_Title"), Localization.Get("Dialog_Ok"), Localization.Get("Dialog_Cancel"), () => {
                 LauncherUtils.OpenSystemUpdate();
             }, () => {});
         }
     }
 }