PoemPhotoDataManager.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using ET;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class PoemPhotoDataManager : SingletonBase<PoemPhotoDataManager>
  9. {
  10. /// <summary>
  11. /// 个人相册
  12. /// </summary>
  13. /// <typeparam name="PoemPhotoData"></typeparam>
  14. /// <returns></returns>
  15. public List<PoemPhotoData> PersonalPhotoInfos = new List<PoemPhotoData>();
  16. /// <summary>
  17. /// 万水千山相册
  18. /// </summary>
  19. /// <typeparam name="PoemPhotoData"></typeparam>
  20. /// <returns></returns>
  21. public List<PoemPhotoData> WsqsPhotoInfos = new List<PoemPhotoData>();
  22. public void Clear()
  23. {
  24. PersonalPhotoInfos.Clear();
  25. WsqsPhotoInfos.Clear();
  26. }
  27. public void Add(PoemPhotoData photoData, int sourceType)
  28. {
  29. List<PoemPhotoData> poemPhotoDatas = null;
  30. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  31. {
  32. // PersonalPhotoInfos.Add(photoData);
  33. // PersonalPhotoInfos = SortInfos(PersonalPhotoInfos);
  34. poemPhotoDatas = PersonalPhotoInfos;
  35. }
  36. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  37. {
  38. // WsqsPhotoInfos.Add(photoData);
  39. // WsqsPhotoInfos = SortInfos(WsqsPhotoInfos);
  40. poemPhotoDatas = WsqsPhotoInfos;
  41. }
  42. poemPhotoDatas.Add(photoData);
  43. poemPhotoDatas = SortInfos(poemPhotoDatas);
  44. }
  45. public void Remove(List<long> pictureIds, int sourceType)
  46. {
  47. List<PoemPhotoData> poemPhotoDatas = null;
  48. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  49. {
  50. poemPhotoDatas = PersonalPhotoInfos;
  51. }
  52. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  53. {
  54. poemPhotoDatas = WsqsPhotoInfos;
  55. }
  56. for (int i = 0; i < pictureIds.Count; i++)
  57. {
  58. for (int j = 0; j < poemPhotoDatas.Count; j++)
  59. {
  60. if (pictureIds[i] == poemPhotoDatas[j].PictureId)
  61. {
  62. poemPhotoDatas.RemoveAt(j);
  63. break;
  64. }
  65. }
  66. }
  67. poemPhotoDatas = SortInfos(poemPhotoDatas);
  68. }
  69. public void ChangeLockingState(long pictureId, bool state, int sourceType)
  70. {
  71. List<PoemPhotoData> poemPhotoDatas = null;
  72. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  73. {
  74. poemPhotoDatas = PersonalPhotoInfos;
  75. }
  76. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  77. {
  78. poemPhotoDatas = WsqsPhotoInfos;
  79. }
  80. for (int i = 0; i < poemPhotoDatas.Count; i++)
  81. {
  82. if (poemPhotoDatas[i].PictureId == pictureId)
  83. {
  84. poemPhotoDatas[i].LockingStatus = state;
  85. break;
  86. }
  87. }
  88. poemPhotoDatas = SortInfos(poemPhotoDatas);
  89. }
  90. public void ChangeToppingState(long pictureId, bool state, int sourceType)
  91. {
  92. List<PoemPhotoData> poemPhotoDatas = null;
  93. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  94. {
  95. poemPhotoDatas = PersonalPhotoInfos;
  96. }
  97. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  98. {
  99. poemPhotoDatas = WsqsPhotoInfos;
  100. }
  101. for (int i = 0; i < poemPhotoDatas.Count; i++)
  102. {
  103. if (poemPhotoDatas[i].PictureId == pictureId)
  104. {
  105. poemPhotoDatas[i].ToppingStatus = state;
  106. break;
  107. }
  108. }
  109. poemPhotoDatas = SortInfos(poemPhotoDatas);
  110. }
  111. private List<PoemPhotoData> SortInfos(List<PoemPhotoData> photoInfos)
  112. {
  113. photoInfos.Sort((PoemPhotoData a, PoemPhotoData b) =>
  114. {
  115. if (a.ToppingStatus) return 1;
  116. if (b.ToppingStatus) return -1;
  117. if (a.CreationTime < b.CreationTime) return 1;
  118. if (a.CreationTime > b.CreationTime) return -1;
  119. return 0;
  120. });
  121. return photoInfos;
  122. }
  123. }
  124. }