| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.IO;
 
- using System.Threading.Tasks;
 
- using ET;
 
- using FairyGUI;
 
- using UI.DressUp;
 
- using UnityEngine;
 
- using UnityEngine.Android;
 
- namespace GFGGame
 
- {
 
-     public class PhotographSaveView : BaseView
 
-     {
 
-         private UI_PhotographSaveUI _ui;
 
-         private Texture2D tex;
 
-         private byte[] bytes;
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_PhotographUI.PACKAGE_NAME;
 
-             _ui = UI_PhotographSaveUI.Create();
 
-             viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             isReturnView = true;
 
-             _ui.m_btnClose.onClick.Add(this.Hide);
 
-             _ui.m_btnSave.onClick.Add(this.OnClickBtnSave);
 
-             _ui.m_btnSavePhoto.onClick.Add(this.OnClickBtnSavePhoto);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             tex = this.viewData as Texture2D;
 
-             bytes = tex.EncodeToJPG();//将纹理数据,转化成一个jpg图片
 
-             _ui.m_imgRes.texture = new NTexture(tex);
 
-             float width = _ui.m_imgBorder.width;
 
-             float height = width * tex.height / tex.width;
 
-             _ui.m_imgRes.SetSize(width, height);
 
-             _ui.m_imgBorder.SetSize(width, height + 12);
 
-             Timers.inst.AddUpdate(CheckGuide);
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             _ui.m_btnSave.selected = false;
 
-             _ui.m_btnSave.enabled = true;
 
-             _ui.m_btnSavePhoto.selected = false;
 
-             _ui.m_btnSavePhoto.enabled = true;
 
-             Timers.inst.Remove(CheckGuide);
 
-         }
 
-         public override void Dispose()
 
-         {
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         private void OnClickBtnSave()
 
-         {
 
-             //检查用户是否已授予对需要授权的设备资源或信息的访问权。
 
-             if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
 
-             {
 
-                 if (LocalCache.GetBool(GameConst.WRITE_EXTERNAL_STORAGE_FORBIDDEN, false))
 
-                 {
 
-                     AlertSystem.Show("保存至本地需要使用存储权限,您已经禁止!请前往手机系统设置开启应用存储权限。")
 
-                             .SetLeftButton(true, "知道了");
 
-                     return;
 
-                 }
 
-                 PromptController.Instance.ShowFloatTextPrompt("保存至本地需要使用存储权限,请同意!");
 
-                 //请求用户授权访问需要授权的设备资源或信息.
 
-                 PermissionCallbacks permissionCallbacks = new PermissionCallbacks();
 
-                 permissionCallbacks.PermissionGranted += (string a) =>
 
-                 {
 
-                     TrySavePicturoToLocal();
 
-                 };
 
-                 permissionCallbacks.PermissionDenied += (string a) =>
 
-                 {
 
-                     PromptController.Instance.ShowFloatTextPrompt("由于被禁止存储权限,保存失败!");
 
-                 };
 
-                 permissionCallbacks.PermissionDeniedAndDontAskAgain += (string a) =>
 
-                 {
 
-                     LocalCache.SetBool(GameConst.WRITE_EXTERNAL_STORAGE_FORBIDDEN, true);
 
-                     PromptController.Instance.ShowFloatTextPrompt("由于被禁止存储权限,保存失败!");
 
-                 };
 
-                 Permission.RequestUserPermission(Permission.ExternalStorageWrite, permissionCallbacks);
 
-             }
 
-             else
 
-             {
 
-                 LocalCache.SetBool(GameConst.WRITE_EXTERNAL_STORAGE_FORBIDDEN, false);
 
-                 TrySavePicturoToLocal();
 
-             }
 
-         }
 
-         private void TrySavePicturoToLocal()
 
-         {
 
-             if (Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
 
-             {
 
-                 string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
 
-                 PhotographUtil.Instance.SavePicturoToLocal(bytes, fileName);
 
-                 _ui.m_btnSave.enabled = false;
 
-             }
 
-         }
 
-         private async void OnClickBtnSavePhoto()
 
-         {
 
-             if (PoemPhotoDataManager.Instance.PersonalPhotoInfos.Count >= GlobalCfgArray.globalCfg.maxPhotoCount)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("照片数量已达上限");
 
-                 return;
 
-             }
 
-             object[] rsp = await PoemPhotoSProxy.ReqTempPictureUrl();
 
-             if (rsp == null) return;
 
-             bool pushResult = await PictureStorageHelper.PushToHWCloud(rsp[0].ToString(), bytes);
 
-             if (!pushResult) return;
 
-             long addResult = await PoemPhotoSProxy.ReqAddTophoto((long)rsp[1]);
 
-             if (addResult > 0)
 
-             {
 
-                 List<PoemPhotoData> list = PoemPhotoDataManager.Instance.PersonalPhotoInfos;
 
-                 for (int i = 0; i < list.Count; i++)
 
-                 {
 
-                     if (list[i].PictureId == addResult)
 
-                     {
 
-                         list[i].Bytes = bytes;
 
-                         list[i].Ntexture = new NTexture(tex);
 
-                         break;
 
-                     }
 
-                 }
 
-             }
 
-             _ui.m_btnSavePhoto.enabled = false;
 
-         }
 
-         private void CheckGuide(object param)
 
-         {
 
-             if (GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0)
 
-             {
 
-                 UpdateToCheckGuide(null);
 
-             }
 
-             else
 
-             {
 
-                 Timers.inst.Remove(CheckGuide);
 
-             }
 
-         }
 
-         protected override void UpdateToCheckGuide(object param)
 
-         {
 
-             if (!ViewManager.CheckIsTopView(this.viewCom)) return;
 
-             GuideController.TryGuide(_ui.m_btnSavePhoto, ConstGuideId.FREEDOM_DRESS, 9, "");
 
-             GuideController.TryGuide(_ui.m_btnClose, ConstGuideId.FREEDOM_DRESS, 10, "");
 
-             GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 10);
 
-         }
 
-         protected override void TryCompleteGuide()
 
-         {
 
-             base.TryCompleteGuide();
 
-             // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FREEDOM_DRESS);
 
-             GuideController.TryCompleteGuideIndex(ConstGuideId.FREEDOM_DRESS, 10);
 
-             GuideController.TryCompleteGuide(ConstGuideId.FREEDOM_DRESS, 10);
 
-         }
 
-     }
 
- }
 
 
  |