|
@@ -12,6 +12,7 @@ namespace GFGGame
|
|
|
private List<PoemPhotoData> _photoInfos;
|
|
|
private int _curIndex = 0;
|
|
|
private int _sourceType = 0;
|
|
|
+ private PoemPhotoData _curPhotoData;
|
|
|
|
|
|
public override void Dispose()
|
|
|
{
|
|
@@ -35,6 +36,7 @@ namespace GFGGame
|
|
|
|
|
|
_ui.m_list.SetVirtual();
|
|
|
_ui.m_list.itemRenderer = RenderListItem;
|
|
|
+ _ui.m_list.scrollPane.onScrollEnd.Add(OnListScrollEnd);
|
|
|
_ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
|
|
|
_ui.m_btnRight.onClick.Add(OnBtnRightClick);
|
|
|
_ui.m_btnLock.target.onClick.Add(OnBtnLockClick);
|
|
@@ -51,19 +53,10 @@ namespace GFGGame
|
|
|
{
|
|
|
base.OnShown();
|
|
|
_curIndex = (int)(this.viewData as object[])[0];
|
|
|
- _sourceType = (int)(this.viewData as object[])[1];
|
|
|
-
|
|
|
- if (_sourceType == (int)PictureSourceType.PersonalAlbum)
|
|
|
- {
|
|
|
- _photoInfos = PoemPhotoDataManager.Instance.PersonalPhotoInfos;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _photoInfos = PoemPhotoDataManager.Instance.WsqsPhotoInfos;
|
|
|
- }
|
|
|
+ _photoInfos = (this.viewData as object[])[1] as List<PoemPhotoData>;
|
|
|
|
|
|
_ui.m_list.numItems = _photoInfos.Count;
|
|
|
- if (_photoInfos.Count > 0) _ui.m_list.ScrollToView(_curIndex);
|
|
|
+ _ui.m_list.height = _ui.m_list.GetChildAt(0).height;
|
|
|
UpdateView();
|
|
|
}
|
|
|
|
|
@@ -88,8 +81,11 @@ namespace GFGGame
|
|
|
{
|
|
|
_ui.m_btnLeft.enabled = _curIndex > 0;
|
|
|
_ui.m_btnRight.enabled = _curIndex < _ui.m_list.numItems - 1;
|
|
|
-
|
|
|
_ui.m_txtTime.text = TimeUtil.FormattingTime1(_photoInfos[_curIndex].CreationTime);
|
|
|
+ _ui.m_btnLock.m_c1.selectedIndex = _photoInfos[_curIndex].LockingStatus ? 1 : 0;
|
|
|
+ _ui.m_btnUp.m_c1.selectedIndex = _photoInfos[_curIndex].ToppingStatus ? 1 : 0;
|
|
|
+
|
|
|
+ if (_photoInfos.Count > 0) _ui.m_list.ScrollToView(_curIndex);
|
|
|
|
|
|
if (_ui.m_btnLock.target.data == null)
|
|
|
{
|
|
@@ -101,15 +97,17 @@ namespace GFGGame
|
|
|
{
|
|
|
_ui.m_btnUp.target.onClick.Add(OnBtnUpClick);
|
|
|
}
|
|
|
- _ui.m_btnUp.target.data = _curIndex;
|
|
|
+ _curPhotoData = _photoInfos[_curIndex];
|
|
|
|
|
|
}
|
|
|
private void RenderListItem(int index, GObject obj)
|
|
|
{
|
|
|
UI_ListPhotoPreviewItem item = UI_ListPhotoPreviewItem.Proxy(obj);
|
|
|
-
|
|
|
+ GLoader loaIcon = item.m_comPhoto.m_loaPhoto;
|
|
|
item.m_comPhoto.m_loaPhoto.texture = PoemPhotoDataManager.Instance.BytesToTexture2D(_photoInfos[index].Bytes);
|
|
|
-
|
|
|
+ item.target.SetSize(item.target.width, item.target.initHeight * _ui.target.height / _ui.target.initHeight);
|
|
|
+ loaIcon.SetSize(loaIcon.width, loaIcon.texture.height * loaIcon.width / loaIcon.texture.width);
|
|
|
+ loaIcon.y = item.target.height / 2;
|
|
|
UI_ListPhotoPreviewItem.ProxyEnd();
|
|
|
}
|
|
|
|
|
@@ -117,6 +115,7 @@ namespace GFGGame
|
|
|
{
|
|
|
_curIndex--;
|
|
|
_curIndex = Mathf.Max(0, _curIndex);
|
|
|
+
|
|
|
UpdateView();
|
|
|
}
|
|
|
|
|
@@ -124,58 +123,81 @@ namespace GFGGame
|
|
|
{
|
|
|
_curIndex++;
|
|
|
_curIndex = Mathf.Min(_ui.m_list.numItems - 1, _curIndex);
|
|
|
+
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
+ private void OnListScrollEnd()
|
|
|
+ {
|
|
|
+ _curIndex = _ui.m_list.ChildIndexToItemIndex(0);
|
|
|
UpdateView();
|
|
|
}
|
|
|
-
|
|
|
private void OnBtnLockClick()
|
|
|
{
|
|
|
- PoemPhotoData photoData = _photoInfos[_curIndex];
|
|
|
- if (photoData.LockingStatus == false)
|
|
|
+ if (_curPhotoData.LockingStatus == false)
|
|
|
{
|
|
|
AlertUI.Show("是否确认锁定此照片?", "(锁住的照片无法被删除)")
|
|
|
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
|
|
|
+ .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
|
|
|
{
|
|
|
- PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, true, _sourceType).Coroutine();
|
|
|
+ bool result = await PoemPhotoSProxy.ReqChangeLockingState(_curPhotoData.PictureId, true, _sourceType);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ _photoInfos[_curIndex].LockingStatus = true;
|
|
|
+
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
AlertUI.Show("是否确认解锁此照片?", "(解锁后的照片可随意删除)")
|
|
|
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
|
|
|
+ .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
|
|
|
{
|
|
|
- PoemPhotoSProxy.ReqChangeLockingState(photoData.PictureId, false, _sourceType).Coroutine();
|
|
|
+ bool result = await PoemPhotoSProxy.ReqChangeLockingState(_curPhotoData.PictureId, false, _sourceType);
|
|
|
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ _photoInfos[_curIndex].LockingStatus = false;
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnBtnUpClick()
|
|
|
{
|
|
|
- PoemPhotoData photoData = _photoInfos[_curIndex];
|
|
|
- if (photoData.ToppingStatus == false)
|
|
|
+ if (_curPhotoData.ToppingStatus == false)
|
|
|
{
|
|
|
AlertUI.Show("是否确认置顶此照片?")
|
|
|
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
|
|
|
+ .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
|
|
|
{
|
|
|
- PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, true, _sourceType).Coroutine();
|
|
|
-
|
|
|
+ bool result = await PoemPhotoSProxy.ReqChangeToppingState(_curPhotoData.PictureId, true, _sourceType);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ _photoInfos[_curIndex].ToppingStatus = true;
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
AlertUI.Show("是否确认取消置顶此照片?")
|
|
|
- .SetLeftButton(true, "否").SetRightButton(true, "是", (object data) =>
|
|
|
+ .SetLeftButton(true, "否").SetRightButton(true, "是", async (object data) =>
|
|
|
{
|
|
|
- PoemPhotoSProxy.ReqChangeToppingState(photoData.PictureId, false, _sourceType).Coroutine();
|
|
|
+ bool result = await PoemPhotoSProxy.ReqChangeToppingState(_curPhotoData.PictureId, false, _sourceType);
|
|
|
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ _photoInfos[_curIndex].ToppingStatus = false;
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnBtnShareClick()
|
|
|
{
|
|
|
- ViewManager.Show<PoemPhotoShareView>(new object[] { _curIndex, _sourceType }, new object[] { typeof(PoemPhotoPreView).FullName, _curIndex });
|
|
|
+ ViewManager.Show<PoemPhotoShareView>(_curPhotoData, new object[] { typeof(PoemPhotoPreView).FullName, new object[] { _curIndex, _photoInfos } });
|
|
|
}
|
|
|
}
|
|
|
}
|