Mhurd has submitted this change and it was merged.

Change subject: Stub 'imagesBySection' method on MWKImageList
......................................................................


Stub 'imagesBySection' method on MWKImageList

To be replaced by cooler stuff in a bit.

Change-Id: I22a13e879cac9b155aa85470fd76d531a5bef8ce
---
M MediaWikiKit/MediaWikiKit/MWKImageList.h
M MediaWikiKit/MediaWikiKit/MWKImageList.m
2 files changed, 31 insertions(+), 0 deletions(-)

Approvals:
  Mhurd: Verified; Looks good to me, approved



diff --git a/MediaWikiKit/MediaWikiKit/MWKImageList.h 
b/MediaWikiKit/MediaWikiKit/MWKImageList.h
index eb8109a..64ffb75 100644
--- a/MediaWikiKit/MediaWikiKit/MWKImageList.h
+++ b/MediaWikiKit/MediaWikiKit/MWKImageList.h
@@ -26,6 +26,7 @@
 -(NSString *)largestImageVariant:(NSString *)image;
 
 -(NSArray *)imageURLsForSectionId:(int)sectionId;
+-(NSArray *)imagesBySection; // returns array of arrays indexed from section 0 
until the last one that's been accesseded, may not be the last section
 
 @property (readwrite)NSString *thumbnailURL;
 @end
diff --git a/MediaWikiKit/MediaWikiKit/MWKImageList.m 
b/MediaWikiKit/MediaWikiKit/MWKImageList.m
index e1fcfff..192be77 100644
--- a/MediaWikiKit/MediaWikiKit/MWKImageList.m
+++ b/MediaWikiKit/MediaWikiKit/MWKImageList.m
@@ -83,6 +83,36 @@
     return [[self entriesBySection:sectionId] copy];
 }
 
+-(NSArray *)imagesBySection
+{
+    NSMutableArray *arr = [[NSMutableArray alloc] init];
+    NSArray *keys = [entriesBySection 
keysSortedByValueUsingComparator:^NSComparisonResult(NSString *key1, NSString 
*key2) {
+        int int1 = [key1 intValue];
+        int int2 = [key2 intValue];
+        if (int1 == int2 ) {
+            return NSOrderedSame;
+        } else if (int1 > int2) {
+            return NSOrderedDescending;
+        } else {
+            return NSOrderedAscending;
+        }
+    }];
+    int lastSection = -1;
+    for (NSString *key in keys) {
+        lastSection = [key intValue];
+    }
+    for (int i = 0; i <= lastSection; i++) {
+        NSString *key = [NSString stringWithFormat:@"%d", i];
+        NSMutableArray *subarr = [[NSMutableArray alloc] init];
+        for (NSString *url in entriesBySection[key]) {
+            [subarr addObject:url];
+        }
+        [arr addObject:subarr];
+    }
+    return [NSArray arrayWithArray:arr];
+}
+
+
 #pragma mark - data i/o
 
 -(instancetype)initWithTitle:(MWKTitle *)title

-- 
To view, visit https://gerrit.wikimedia.org/r/177933
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I22a13e879cac9b155aa85470fd76d531a5bef8ce
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to