Permalink
Browse files

Better List item loading & better randomize manga list

  • Loading branch information...
1 parent ccb19eb commit 2c7d7199d62106fe22c427ba34c973f9f0f612e4 @a-fung committed Oct 20, 2012
Showing with 21 additions and 6 deletions.
  1. +10 −3 source/scriptsharp/Module/MangasModule.cs
  2. +11 −3 source/scriptsharp/Widget/MangaListItem.cs
@@ -189,10 +189,17 @@ private void MangaListRequestSuccess(MangaListResponse response)
};
break;
case -1:
- compare = delegate(MangaListItemJson a, MangaListItemJson b)
+ List<MangaListItemJson> list1 = (List<MangaListItemJson>)(object)items;
+ List<MangaListItemJson> list2 = new List<MangaListItemJson>();
+ int index;
+ while (list1.Count > 0)
{
- return Math.Round(Math.Random() * 2 - 1);
- };
+ index = Math.Floor(Math.Random() * list1.Count);
+ list2.Add(list1[index]);
+ list1.RemoveAt(index);
+ }
+
+ items = (MangaListItemJson[])(object)list2;
break;
default:
break;
@@ -111,14 +111,18 @@ private void TryLoadFromCache()
}
}
- public void Load()
+ public bool Load()
{
if (attachedObject.Is(":visible"))
{
coverRequest = new MangaListItemCoverRequest();
coverRequest.id = data.id;
Request.Send(coverRequest, CoverRequestSuccess);
+
+ return true;
}
+
+ return false;
}
[AlternateSignature]
@@ -377,9 +381,13 @@ private static void LoadNextItem()
return;
}
- loadQueue.Dequeue().Load();
+ MangaListItem item;
+ while ((item = loadQueue.Dequeue()) != null && !item.Load())
+ {
+ }
+
LoadNextItem();
- },
+ },
1000);
}
}

0 comments on commit 2c7d719

Please sign in to comment.