├── .github
└── ISSUE_TEMPLATE.md
├── .gitignore
├── BRMultilevelMeun.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── gitburning.xcuserdatad
│ │ └── WorkspaceSettings.xcsettings
└── xcuserdata
│ └── gitburning.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── BRMultilevelMeun.xcscheme
│ └── xcschememanagement.plist
├── BRMultilevelMeun
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── MultilevelMenu
│ ├── CellView
│ │ ├── CollectionHeader.h
│ │ ├── CollectionHeader.m
│ │ ├── CollectionHeader.xib
│ │ ├── MultilevelCollectionViewCell.h
│ │ ├── MultilevelCollectionViewCell.m
│ │ ├── MultilevelCollectionViewCell.xib
│ │ ├── MultilevelTableViewCell.h
│ │ ├── MultilevelTableViewCell.m
│ │ └── MultilevelTableViewCell.xib
│ ├── MultilevelMenu.h
│ └── MultilevelMenu.m
├── Vendor
│ └── SDWebImage
│ │ ├── NSData+ImageContentType.h
│ │ ├── NSData+ImageContentType.m
│ │ ├── SDImageCache.h
│ │ ├── SDImageCache.m
│ │ ├── SDWebImageCompat.h
│ │ ├── SDWebImageCompat.m
│ │ ├── SDWebImageDecoder.h
│ │ ├── SDWebImageDecoder.m
│ │ ├── SDWebImageDownloader.h
│ │ ├── SDWebImageDownloader.m
│ │ ├── SDWebImageDownloaderOperation.h
│ │ ├── SDWebImageDownloaderOperation.m
│ │ ├── SDWebImageManager.h
│ │ ├── SDWebImageManager.m
│ │ ├── SDWebImageOperation.h
│ │ ├── SDWebImagePrefetcher.h
│ │ ├── SDWebImagePrefetcher.m
│ │ ├── UIButton+WebCache.h
│ │ ├── UIButton+WebCache.m
│ │ ├── UIImage+GIF.h
│ │ ├── UIImage+GIF.m
│ │ ├── UIImage+MultiFormat.h
│ │ ├── UIImage+MultiFormat.m
│ │ ├── UIImageView+HighlightedWebCache.h
│ │ ├── UIImageView+HighlightedWebCache.m
│ │ ├── UIImageView+WebCache.h
│ │ ├── UIImageView+WebCache.m
│ │ ├── UIView+WebCacheOperation.h
│ │ └── UIView+WebCacheOperation.m
├── ViewController.h
├── ViewController.m
└── main.m
├── BRMultilevelMeunTests
├── BRMultilevelMeunTests.m
└── Info.plist
├── CONTRIBUTING.md
├── LICENSE
├── Menu.gif
├── README.md
└── tempShop.png
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | #Pods/
27 |
--------------------------------------------------------------------------------
/BRMultilevelMeun.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/BRMultilevelMeun.xcodeproj/project.xcworkspace/xcuserdata/gitburning.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/BRMultilevelMeun.xcodeproj/xcuserdata/gitburning.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/BRMultilevelMeun.xcodeproj/xcuserdata/gitburning.xcuserdatad/xcschemes/BRMultilevelMeun.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/BRMultilevelMeun.xcodeproj/xcuserdata/gitburning.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | BRMultilevelMeun.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 66BCC0B91AE03C160029F30F
16 |
17 | primary
18 |
19 |
20 | 66BCC0D21AE03C160029F30F
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // BRMultilevelMeun
4 | //
5 | // Created by gitBurning on 15/4/17.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // BRMultilevelMeun
4 | //
5 | // Created by gitBurning on 15/4/17.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/BRMultilevelMeun/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | zom.com.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/CollectionHeader.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionHeader.h
3 | // ft_procute
4 | //
5 | // Created by gitBurning on 15/3/18.
6 | // Copyright (c) 2015年 ft_iem. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollectionHeader : UICollectionReusableView
12 |
13 | @property (weak, nonatomic) IBOutlet UILabel *headerTitile;
14 | @end
15 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/CollectionHeader.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionHeader.m
3 | // ft_procute
4 | //
5 | // Created by gitBurning on 15/3/18.
6 | // Copyright (c) 2015年 ft_iem. All rights reserved.
7 | //
8 |
9 | #import "CollectionHeader.h"
10 |
11 | @implementation CollectionHeader
12 |
13 | - (void)awakeFromNib {
14 | // Initialization code
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/CollectionHeader.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/MultilevelCollectionViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // MultilevelCollectionViewCell.h
3 | // MultilevelMenu
4 | //
5 | // Created by gitBurning on 15/3/13.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MultilevelCollectionViewCell : UICollectionViewCell
12 |
13 | @property (weak, nonatomic) IBOutlet UIImageView *imageView;
14 | @property (weak, nonatomic) IBOutlet UILabel *titile;
15 | @end
16 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/MultilevelCollectionViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // MultilevelCollectionViewCell.m
3 | // MultilevelMenu
4 | //
5 | // Created by gitBurning on 15/3/13.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import "MultilevelCollectionViewCell.h"
10 |
11 | @implementation MultilevelCollectionViewCell
12 |
13 | - (void)awakeFromNib {
14 | // Initialization code
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/MultilevelCollectionViewCell.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/MultilevelTableViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // MultilevelTableViewCell.h
3 | // MultilevelMenu
4 | //
5 | // Created by gitBurning on 15/3/13.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MultilevelTableViewCell : UITableViewCell
12 |
13 | @property (weak, nonatomic) IBOutlet UILabel *titile;
14 |
15 | -(void)setZero;
16 | @end
17 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/MultilevelTableViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // MultilevelTableViewCell.m
3 | // MultilevelMenu
4 | //
5 | // Created by gitBurning on 15/3/13.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import "MultilevelTableViewCell.h"
10 |
11 | @implementation MultilevelTableViewCell
12 |
13 | - (void)awakeFromNib {
14 | // Initialization code
15 | }
16 |
17 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
18 | [super setSelected:selected animated:animated];
19 |
20 | // Configure the view for the selected state
21 | }
22 |
23 | -(void)setZero{
24 | if ([self respondsToSelector:@selector(setLayoutMargins:)]) {
25 | self.layoutMargins=UIEdgeInsetsZero;
26 | }
27 | if ([self respondsToSelector:@selector(setSeparatorInset:)]) {
28 | self.separatorInset=UIEdgeInsetsZero;
29 | }
30 |
31 | }
32 | @end
33 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/CellView/MultilevelTableViewCell.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/MultilevelMenu.h:
--------------------------------------------------------------------------------
1 | //
2 | // MultilevelMenu.h
3 | // MultilevelMenu
4 | //
5 | // Created by gitBurning on 15/3/13.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #define kLeftWidth 100
12 |
13 | @interface MultilevelMenu : UIView
14 |
15 | @property(strong,nonatomic,readonly) NSArray * allData;
16 |
17 |
18 | @property(copy,nonatomic,readonly) id block;
19 |
20 | /**
21 | * 是否 记录滑动位置
22 | */
23 | @property(assign,nonatomic) BOOL isRecordLastScroll;
24 | /**
25 | * 记录滑动位置 是否需要 动画
26 | */
27 | @property(assign,nonatomic) BOOL isRecordLastScrollAnimated;
28 |
29 | @property(assign,nonatomic,readonly) NSInteger selectIndex;
30 |
31 | /**
32 | * 为了 不修改原来的,因此增加了一个属性,选中指定 行数
33 | */
34 | @property(assign,nonatomic) NSInteger needToScorllerIndex;
35 | /**
36 | * 颜色属性配置
37 | */
38 |
39 | /**
40 | * 左边背景颜色
41 | */
42 | @property(strong,nonatomic) UIColor * leftBgColor;
43 | /**
44 | * 左边点中文字颜色
45 | */
46 | @property(strong,nonatomic) UIColor * leftSelectColor;
47 | /**
48 | * 左边点中背景颜色
49 | */
50 | @property(strong,nonatomic) UIColor * leftSelectBgColor;
51 |
52 | /**
53 | * 左边未点中文字颜色
54 | */
55 |
56 | @property(strong,nonatomic) UIColor * leftUnSelectColor;
57 | /**
58 | * 左边未点中背景颜色
59 | */
60 | @property(strong,nonatomic) UIColor * leftUnSelectBgColor;
61 | /**
62 | * tablew 的分割线
63 | */
64 | @property(strong,nonatomic) UIColor * leftSeparatorColor;
65 |
66 | -(instancetype)initWithFrame:(CGRect)frame WithData:(NSArray*)data withSelectIndex:(void(^)(NSInteger left,NSInteger right,id info))selectIndex;
67 |
68 | @end
69 |
70 |
71 | @interface rightMeun : NSObject
72 |
73 | /**
74 | * 菜单图片名
75 | */
76 | @property(copy,nonatomic) NSString * urlName;
77 | /**
78 | * 菜单名
79 | */
80 | @property(copy,nonatomic) NSString * meunName;
81 | /**
82 | * 菜单ID
83 | */
84 | @property(copy,nonatomic) NSString * ID;
85 |
86 | /**
87 | * 下一级菜单
88 | */
89 | @property(strong,nonatomic) NSArray * nextArray;
90 |
91 | /**
92 | * 菜单层数
93 | */
94 | @property(assign,nonatomic) NSInteger meunNumber;
95 |
96 | @property(assign,nonatomic) float offsetScorller;
97 |
98 | @end
--------------------------------------------------------------------------------
/BRMultilevelMeun/MultilevelMenu/MultilevelMenu.m:
--------------------------------------------------------------------------------
1 | //
2 | // MultilevelMenu.m
3 | // MultilevelMenu
4 | //
5 | // Created by gitBurning on 15/3/13.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import "MultilevelMenu.h"
10 | #import "MultilevelTableViewCell.h"
11 | #import "MultilevelCollectionViewCell.h"
12 | #import "UIImageView+WebCache.h"
13 |
14 | #define kCellRightLineTag 100
15 | #define kImageDefaultName @"tempShop"
16 | #define kMultilevelCollectionViewCell @"MultilevelCollectionViewCell"
17 | #define kMultilevelCollectionHeader @"CollectionHeader"//CollectionHeader
18 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width
19 |
20 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height
21 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
22 | @interface MultilevelMenu()
23 |
24 | @property(strong,nonatomic ) UITableView * leftTablew;
25 | @property(strong,nonatomic ) UICollectionView * rightCollection;
26 |
27 | @property(assign,nonatomic) BOOL isReturnLastOffset;
28 |
29 | @end
30 | @implementation MultilevelMenu
31 |
32 | /*
33 | // Only override drawRect: if you perform custom drawing.
34 | // An empty implementation adversely affects performance during animation.
35 | - (void)drawRect:(CGRect)rect {
36 | // Drawing code
37 | }
38 | */
39 | -(instancetype)initWithFrame:(CGRect)frame WithData:(NSArray *)data withSelectIndex:(void (^)(NSInteger, NSInteger, id))selectIndex
40 | {
41 | self=[super initWithFrame:frame];
42 | if (self) {
43 | if (data.count==0) {
44 | return nil;
45 | }
46 |
47 | _block=selectIndex;
48 | self.leftSelectColor=[UIColor blackColor];
49 | self.leftSelectBgColor=[UIColor whiteColor];
50 | self.leftBgColor=UIColorFromRGB(0xF3F4F6);
51 | self.leftSeparatorColor=UIColorFromRGB(0xE5E5E5);
52 | self.leftUnSelectBgColor=UIColorFromRGB(0xF3F4F6);
53 | self.leftUnSelectColor=[UIColor blackColor];
54 |
55 | _selectIndex=0;
56 | _allData=data;
57 |
58 |
59 | /**
60 | 左边的视图
61 | */
62 | self.leftTablew=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, kLeftWidth, frame.size.height)];
63 | self.leftTablew.dataSource=self;
64 | self.leftTablew.delegate=self;
65 |
66 | self.leftTablew.tableFooterView=[[UIView alloc] init];
67 | [self addSubview:self.leftTablew];
68 | self.leftTablew.backgroundColor=self.leftBgColor;
69 | if ([self.leftTablew respondsToSelector:@selector(setLayoutMargins:)]) {
70 | self.leftTablew.layoutMargins=UIEdgeInsetsZero;
71 | }
72 | if ([self.leftTablew respondsToSelector:@selector(setSeparatorInset:)]) {
73 | self.leftTablew.separatorInset=UIEdgeInsetsZero;
74 | }
75 | self.leftTablew.separatorColor=self.leftSeparatorColor;
76 |
77 |
78 | /**
79 | 右边的视图
80 | */
81 | UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
82 | flowLayout.minimumInteritemSpacing=0.f;//左右间隔
83 | flowLayout.minimumLineSpacing=0.f;
84 | float leftMargin =0;
85 | self.rightCollection=[[UICollectionView alloc] initWithFrame:CGRectMake(kLeftWidth+leftMargin,0,kScreenWidth-kLeftWidth-leftMargin*2,frame.size.height) collectionViewLayout:flowLayout];
86 |
87 | self.rightCollection.delegate=self;
88 | self.rightCollection.dataSource=self;
89 |
90 | UINib *nib=[UINib nibWithNibName:kMultilevelCollectionViewCell bundle:nil];
91 |
92 | [self.rightCollection registerNib: nib forCellWithReuseIdentifier:kMultilevelCollectionViewCell];
93 |
94 |
95 | UINib *header=[UINib nibWithNibName:kMultilevelCollectionHeader bundle:nil];
96 | [self.rightCollection registerNib:header forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kMultilevelCollectionHeader];
97 |
98 | [self addSubview:self.rightCollection];
99 |
100 |
101 | self.isReturnLastOffset=YES;
102 |
103 | self.rightCollection.backgroundColor=self.leftSelectBgColor;
104 |
105 | self.backgroundColor=self.leftSelectBgColor;
106 |
107 | }
108 | return self;
109 | }
110 |
111 | -(void)setNeedToScorllerIndex:(NSInteger)needToScorllerIndex{
112 |
113 | /**
114 | * 滑动到 指定行数
115 | */
116 | [self.leftTablew selectRowAtIndexPath:[NSIndexPath indexPathForRow:needToScorllerIndex inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
117 |
118 | _selectIndex=needToScorllerIndex;
119 |
120 | [self.rightCollection reloadData];
121 |
122 | _needToScorllerIndex=needToScorllerIndex;
123 | }
124 | -(void)setLeftBgColor:(UIColor *)leftBgColor{
125 | _leftBgColor=leftBgColor;
126 | self.leftTablew.backgroundColor=leftBgColor;
127 |
128 | }
129 | -(void)setLeftSelectBgColor:(UIColor *)leftSelectBgColor{
130 |
131 | _leftSelectBgColor=leftSelectBgColor;
132 | self.rightCollection.backgroundColor=leftSelectBgColor;
133 |
134 | self.backgroundColor=leftSelectBgColor;
135 | }
136 | -(void)setLeftSeparatorColor:(UIColor *)leftSeparatorColor{
137 | _leftSeparatorColor=leftSeparatorColor;
138 | self.leftTablew.separatorColor=leftSeparatorColor;
139 | }
140 | -(void)reloadData{
141 |
142 | [self.leftTablew reloadData];
143 | [self.rightCollection reloadData];
144 |
145 | }
146 | -(void)setLeftTablewCellSelected:(BOOL)selected withCell:(MultilevelTableViewCell*)cell
147 | {
148 | UILabel * line=(UILabel*)[cell viewWithTag:kCellRightLineTag];
149 | if (selected) {
150 |
151 | line.backgroundColor=cell.backgroundColor;
152 | cell.titile.textColor=self.leftSelectColor;
153 | cell.backgroundColor=self.leftSelectBgColor;
154 | }
155 | else{
156 | cell.titile.textColor=self.leftUnSelectColor;
157 | cell.backgroundColor=self.leftUnSelectBgColor;
158 | line.backgroundColor=_leftTablew.separatorColor;
159 | }
160 |
161 |
162 | }
163 |
164 | #pragma mark---左边的tablew 代理
165 | #pragma mark--deleagte
166 | -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
167 | return 1;
168 | }
169 |
170 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
171 |
172 | return self.allData.count;
173 |
174 | }
175 |
176 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
177 |
178 | static NSString * Identifier=@"MultilevelTableViewCell";
179 | MultilevelTableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:Identifier];
180 |
181 | cell.selectionStyle=UITableViewCellSelectionStyleNone;
182 |
183 |
184 | if (!cell) {
185 | cell=[[NSBundle mainBundle] loadNibNamed:@"MultilevelTableViewCell" owner:self options:nil][0];
186 |
187 | UILabel * label=[[UILabel alloc] initWithFrame:CGRectMake(kLeftWidth-0.5, 0, 0.5, 44)];
188 | label.backgroundColor=tableView.separatorColor;
189 | [cell addSubview:label];
190 | label.tag=kCellRightLineTag;
191 | }
192 |
193 |
194 | cell.selectionStyle=UITableViewCellSelectionStyleNone;
195 | rightMeun * title=self.allData[indexPath.row];
196 |
197 | cell.titile.text=title.meunName;
198 |
199 |
200 | if (indexPath.row==self.selectIndex) {
201 | NSLog(@"设置 点中");
202 | [self setLeftTablewCellSelected:YES withCell:cell];
203 | }
204 | else{
205 | [self setLeftTablewCellSelected:NO withCell:cell];
206 |
207 | NSLog(@"设置 不点中");
208 |
209 | }
210 |
211 |
212 |
213 | if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
214 | cell.layoutMargins=UIEdgeInsetsZero;
215 | }
216 | if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
217 | cell.separatorInset=UIEdgeInsetsZero;
218 | }
219 |
220 |
221 | return cell;
222 | }
223 |
224 |
225 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
226 | return 44;
227 | }
228 |
229 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
230 |
231 | MultilevelTableViewCell * cell=(MultilevelTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
232 |
233 | // MultilevelTableViewCell * BeforeCell=(MultilevelTableViewCell*)[tableView cellForRowAtIndexPath:[NSIndexPath indexPathWithIndex:_selectIndex]];
234 | //
235 | // [self setLeftTablewCellSelected:NO withCell:BeforeCell];
236 | _selectIndex=indexPath.row;
237 |
238 | [self setLeftTablewCellSelected:YES withCell:cell];
239 |
240 | rightMeun * title=self.allData[indexPath.row];
241 |
242 | [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
243 |
244 | self.isReturnLastOffset=NO;
245 |
246 |
247 | [self.rightCollection reloadData];
248 |
249 |
250 | if (self.isRecordLastScroll) {
251 | [self.rightCollection scrollRectToVisible:CGRectMake(0, title.offsetScorller, self.rightCollection.frame.size.width, self.rightCollection.frame.size.height) animated:self.isRecordLastScrollAnimated];
252 | }
253 | else{
254 |
255 | [self.rightCollection scrollRectToVisible:CGRectMake(0, 0, self.rightCollection.frame.size.width, self.rightCollection.frame.size.height) animated:self.isRecordLastScrollAnimated];
256 | }
257 |
258 |
259 | }
260 |
261 |
262 | -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
263 | MultilevelTableViewCell * cell=(MultilevelTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
264 | // cell.titile.textColor=self.leftUnSelectColor;
265 | // UILabel * line=(UILabel*)[cell viewWithTag:100];
266 | // line.backgroundColor=tableView.separatorColor;
267 |
268 | [self setLeftTablewCellSelected:NO withCell:cell];
269 |
270 | cell.backgroundColor=self.leftUnSelectBgColor;
271 | }
272 |
273 | #pragma mark---imageCollectionView--------------------------
274 |
275 | -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
276 |
277 |
278 | if (self.allData.count==0) {
279 | return 0;
280 | }
281 |
282 | rightMeun * title=self.allData[self.selectIndex];
283 | return title.nextArray.count;
284 |
285 |
286 | }
287 |
288 | -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
289 | rightMeun * title=self.allData[self.selectIndex];
290 | if (title.nextArray.count>0) {
291 |
292 | rightMeun *sub=title.nextArray[section];
293 |
294 | if (sub.nextArray.count==0)//没有下一级
295 | {
296 | return 1;
297 | }
298 | else
299 | return sub.nextArray.count;
300 |
301 | }
302 | else{
303 | return title.nextArray.count;
304 | }
305 | }
306 |
307 | -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
308 |
309 | rightMeun * title=self.allData[self.selectIndex];
310 | NSArray * list;
311 |
312 |
313 |
314 | rightMeun * meun;
315 |
316 | meun=title.nextArray[indexPath.section];
317 |
318 | if (meun.nextArray.count>0) {
319 | meun=title.nextArray[indexPath.section];
320 | list=meun.nextArray;
321 | meun=list[indexPath.row];
322 | }
323 |
324 |
325 | void (^select)(NSInteger left,NSInteger right,id info) = self.block;
326 |
327 | select(self.selectIndex,indexPath.row,meun);
328 |
329 | }
330 |
331 | -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
332 |
333 | MultilevelCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:kMultilevelCollectionViewCell forIndexPath:indexPath];
334 | rightMeun * title=self.allData[self.selectIndex];
335 | NSArray * list;
336 |
337 | rightMeun * meun;
338 |
339 | meun=title.nextArray[indexPath.section];
340 |
341 | if (meun.nextArray.count>0) {
342 | meun=title.nextArray[indexPath.section];
343 | list=meun.nextArray;
344 | meun=list[indexPath.row];
345 | }
346 |
347 | cell.titile.text=meun.meunName;
348 | cell.backgroundColor=[UIColor clearColor];
349 | cell.imageView.backgroundColor=UIColorFromRGB(0xF8FCF8);
350 | [cell.imageView sd_setImageWithURL:[NSURL URLWithString:meun.urlName] placeholderImage:[UIImage imageNamed:kImageDefaultName]];
351 | return cell;
352 | }
353 |
354 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
355 |
356 | NSString *reuseIdentifier;
357 | if ([kind isEqualToString: UICollectionElementKindSectionFooter ]){
358 | reuseIdentifier = @"footer";
359 | }else{
360 | reuseIdentifier = kMultilevelCollectionHeader;
361 | }
362 |
363 | rightMeun * title=self.allData[self.selectIndex];
364 |
365 | UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind :kind withReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
366 |
367 | UILabel *label = (UILabel *)[view viewWithTag:1];
368 | label.font=[UIFont systemFontOfSize:15];
369 | label.textColor=UIColorFromRGB(0x686868);
370 | if ([kind isEqualToString:UICollectionElementKindSectionHeader]){
371 |
372 | if (title.nextArray.count>0) {
373 |
374 |
375 | rightMeun * meun;
376 | meun=title.nextArray[indexPath.section];
377 |
378 | label.text=meun.meunName;
379 |
380 | }
381 | else{
382 | label.text=@"暂无";
383 | }
384 | }
385 | else if ([kind isEqualToString:UICollectionElementKindSectionFooter]){
386 | view.backgroundColor = [UIColor lightGrayColor];
387 | label.text = [NSString stringWithFormat:@"这是footer:%ld",(long)indexPath.section];
388 | }
389 | return view;
390 | }
391 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
392 |
393 | return CGSizeMake(60, 90);
394 | }
395 | -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
396 | return UIEdgeInsetsMake(0, 10, 0, 10);
397 | }
398 | -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
399 | CGSize size={kScreenWidth,44};
400 | return size;
401 | }
402 |
403 |
404 | #pragma mark---记录滑动的坐标
405 | -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
406 | {
407 | if ([scrollView isEqual:self.rightCollection]) {
408 |
409 |
410 | self.isReturnLastOffset=YES;
411 | }
412 | }
413 |
414 | -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
415 | {
416 | if ([scrollView isEqual:self.rightCollection]) {
417 |
418 | rightMeun * title=self.allData[self.selectIndex];
419 |
420 | title.offsetScorller=scrollView.contentOffset.y;
421 | self.isReturnLastOffset=NO;
422 |
423 | }
424 |
425 | }
426 |
427 | -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
428 | if ([scrollView isEqual:self.rightCollection]) {
429 |
430 | rightMeun * title=self.allData[self.selectIndex];
431 |
432 | title.offsetScorller=scrollView.contentOffset.y;
433 | self.isReturnLastOffset=NO;
434 |
435 | }
436 |
437 | }
438 |
439 | -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
440 |
441 | if ([scrollView isEqual:self.rightCollection] && self.isReturnLastOffset) {
442 | rightMeun * title=self.allData[self.selectIndex];
443 |
444 | title.offsetScorller=scrollView.contentOffset.y;
445 |
446 |
447 | }
448 | }
449 |
450 |
451 |
452 | #pragma mark--Tools
453 | -(void)performBlock:(void (^)())block afterDelay:(NSTimeInterval)delay{
454 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC));
455 | dispatch_after(popTime, dispatch_get_main_queue(), block);
456 | }
457 |
458 | @end
459 |
460 |
461 |
462 | @implementation rightMeun
463 |
464 |
465 |
466 | @end
467 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/NSData+ImageContentType.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Fabrice Aneche on 06/01/14.
3 | // Copyright (c) 2014 Dailymotion. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | @interface NSData (ImageContentType)
9 |
10 | /**
11 | * Compute the content type for an image data
12 | *
13 | * @param data the input data
14 | *
15 | * @return the content type as string (i.e. image/jpeg, image/gif)
16 | */
17 | + (NSString *)sd_contentTypeForImageData:(NSData *)data;
18 |
19 | @end
20 |
21 |
22 | @interface NSData (ImageContentTypeDeprecated)
23 |
24 | + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`");
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/NSData+ImageContentType.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Fabrice Aneche on 06/01/14.
3 | // Copyright (c) 2014 Dailymotion. All rights reserved.
4 | //
5 |
6 | #import "NSData+ImageContentType.h"
7 |
8 |
9 | @implementation NSData (ImageContentType)
10 |
11 | + (NSString *)sd_contentTypeForImageData:(NSData *)data {
12 | uint8_t c;
13 | [data getBytes:&c length:1];
14 | switch (c) {
15 | case 0xFF:
16 | return @"image/jpeg";
17 | case 0x89:
18 | return @"image/png";
19 | case 0x47:
20 | return @"image/gif";
21 | case 0x49:
22 | case 0x4D:
23 | return @"image/tiff";
24 | case 0x52:
25 | // R as RIFF for WEBP
26 | if ([data length] < 12) {
27 | return nil;
28 | }
29 |
30 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding];
31 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) {
32 | return @"image/webp";
33 | }
34 |
35 | return nil;
36 | }
37 | return nil;
38 | }
39 |
40 | @end
41 |
42 |
43 | @implementation NSData (ImageContentTypeDeprecated)
44 |
45 | + (NSString *)contentTypeForImageData:(NSData *)data {
46 | return [self sd_contentTypeForImageData:data];
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDImageCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageCompat.h"
11 |
12 | typedef NS_ENUM(NSInteger, SDImageCacheType) {
13 | /**
14 | * The image wasn't available the SDWebImage caches, but was downloaded from the web.
15 | */
16 | SDImageCacheTypeNone,
17 | /**
18 | * The image was obtained from the disk cache.
19 | */
20 | SDImageCacheTypeDisk,
21 | /**
22 | * The image was obtained from the memory cache.
23 | */
24 | SDImageCacheTypeMemory
25 | };
26 |
27 | typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType);
28 |
29 | typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache);
30 |
31 | typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize);
32 |
33 | /**
34 | * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed
35 | * asynchronous so it doesn’t add unnecessary latency to the UI.
36 | */
37 | @interface SDImageCache : NSObject
38 |
39 | /**
40 | * Decompressing images that are downloaded and cached can improve peformance but can consume lot of memory.
41 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption.
42 | */
43 | @property (assign, nonatomic) BOOL shouldDecompressImages;
44 |
45 | /**
46 | * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory.
47 | */
48 | @property (assign, nonatomic) NSUInteger maxMemoryCost;
49 |
50 | /**
51 | * The maximum length of time to keep an image in the cache, in seconds
52 | */
53 | @property (assign, nonatomic) NSInteger maxCacheAge;
54 |
55 | /**
56 | * The maximum size of the cache, in bytes.
57 | */
58 | @property (assign, nonatomic) NSUInteger maxCacheSize;
59 |
60 | /**
61 | * Returns global shared cache instance
62 | *
63 | * @return SDImageCache global instance
64 | */
65 | + (SDImageCache *)sharedImageCache;
66 |
67 | /**
68 | * Init a new cache store with a specific namespace
69 | *
70 | * @param ns The namespace to use for this cache store
71 | */
72 | - (id)initWithNamespace:(NSString *)ns;
73 |
74 | /**
75 | * Add a read-only cache path to search for images pre-cached by SDImageCache
76 | * Useful if you want to bundle pre-loaded images with your app
77 | *
78 | * @param path The path to use for this read-only cache path
79 | */
80 | - (void)addReadOnlyCachePath:(NSString *)path;
81 |
82 | /**
83 | * Store an image into memory and disk cache at the given key.
84 | *
85 | * @param image The image to store
86 | * @param key The unique image cache key, usually it's image absolute URL
87 | */
88 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key;
89 |
90 | /**
91 | * Store an image into memory and optionally disk cache at the given key.
92 | *
93 | * @param image The image to store
94 | * @param key The unique image cache key, usually it's image absolute URL
95 | * @param toDisk Store the image to disk cache if YES
96 | */
97 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk;
98 |
99 | /**
100 | * Store an image into memory and optionally disk cache at the given key.
101 | *
102 | * @param image The image to store
103 | * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage
104 | * @param imageData The image data as returned by the server, this representation will be used for disk storage
105 | * instead of converting the given image object into a storable/compressed image format in order
106 | * to save quality and CPU
107 | * @param key The unique image cache key, usually it's image absolute URL
108 | * @param toDisk Store the image to disk cache if YES
109 | */
110 | - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk;
111 |
112 | /**
113 | * Query the disk cache asynchronously.
114 | *
115 | * @param key The unique key used to store the wanted image
116 | */
117 | - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock;
118 |
119 | /**
120 | * Query the memory cache synchronously.
121 | *
122 | * @param key The unique key used to store the wanted image
123 | */
124 | - (UIImage *)imageFromMemoryCacheForKey:(NSString *)key;
125 |
126 | /**
127 | * Query the disk cache synchronously after checking the memory cache.
128 | *
129 | * @param key The unique key used to store the wanted image
130 | */
131 | - (UIImage *)imageFromDiskCacheForKey:(NSString *)key;
132 |
133 | /**
134 | * Remove the image from memory and disk cache synchronously
135 | *
136 | * @param key The unique image cache key
137 | */
138 | - (void)removeImageForKey:(NSString *)key;
139 |
140 |
141 | /**
142 | * Remove the image from memory and disk cache synchronously
143 | *
144 | * @param key The unique image cache key
145 | * @param completion An block that should be executed after the image has been removed (optional)
146 | */
147 | - (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion;
148 |
149 | /**
150 | * Remove the image from memory and optionally disk cache synchronously
151 | *
152 | * @param key The unique image cache key
153 | * @param fromDisk Also remove cache entry from disk if YES
154 | */
155 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk;
156 |
157 | /**
158 | * Remove the image from memory and optionally disk cache synchronously
159 | *
160 | * @param key The unique image cache key
161 | * @param fromDisk Also remove cache entry from disk if YES
162 | * @param completion An block that should be executed after the image has been removed (optional)
163 | */
164 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion;
165 |
166 | /**
167 | * Clear all memory cached images
168 | */
169 | - (void)clearMemory;
170 |
171 | /**
172 | * Clear all disk cached images. Non-blocking method - returns immediately.
173 | * @param completion An block that should be executed after cache expiration completes (optional)
174 | */
175 | - (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion;
176 |
177 | /**
178 | * Clear all disk cached images
179 | * @see clearDiskOnCompletion:
180 | */
181 | - (void)clearDisk;
182 |
183 | /**
184 | * Remove all expired cached image from disk. Non-blocking method - returns immediately.
185 | * @param completionBlock An block that should be executed after cache expiration completes (optional)
186 | */
187 | - (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock;
188 |
189 | /**
190 | * Remove all expired cached image from disk
191 | * @see cleanDiskWithCompletionBlock:
192 | */
193 | - (void)cleanDisk;
194 |
195 | /**
196 | * Get the size used by the disk cache
197 | */
198 | - (NSUInteger)getSize;
199 |
200 | /**
201 | * Get the number of images in the disk cache
202 | */
203 | - (NSUInteger)getDiskCount;
204 |
205 | /**
206 | * Asynchronously calculate the disk cache's size.
207 | */
208 | - (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock;
209 |
210 | /**
211 | * Async check if image exists in disk cache already (does not load the image)
212 | *
213 | * @param key the key describing the url
214 | * @param completionBlock the block to be executed when the check is done.
215 | * @note the completion block will be always executed on the main queue
216 | */
217 | - (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock;
218 |
219 | /**
220 | * Check if image exists in disk cache already (does not load the image)
221 | *
222 | * @param key the key describing the url
223 | *
224 | * @return YES if an image exists for the given key
225 | */
226 | - (BOOL)diskImageExistsWithKey:(NSString *)key;
227 |
228 | /**
229 | * Get the cache path for a certain key (needs the cache path root folder)
230 | *
231 | * @param key the key (can be obtained from url using cacheKeyForURL)
232 | * @param path the cach path root folder
233 | *
234 | * @return the cache path
235 | */
236 | - (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path;
237 |
238 | /**
239 | * Get the default cache path for a certain key
240 | *
241 | * @param key the key (can be obtained from url using cacheKeyForURL)
242 | *
243 | * @return the default cache path
244 | */
245 | - (NSString *)defaultCachePathForKey:(NSString *)key;
246 |
247 | @end
248 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageCompat.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | * (c) Jamie Pinkham
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | */
9 |
10 | #import
11 |
12 | #ifdef __OBJC_GC__
13 | #error SDWebImage does not support Objective-C Garbage Collection
14 | #endif
15 |
16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0
17 | #error SDWebImage doesn't support Deployement Target version < 5.0
18 | #endif
19 |
20 | #if !TARGET_OS_IPHONE
21 | #import
22 | #ifndef UIImage
23 | #define UIImage NSImage
24 | #endif
25 | #ifndef UIImageView
26 | #define UIImageView NSImageView
27 | #endif
28 | #else
29 |
30 | #import
31 |
32 | #endif
33 |
34 | #ifndef NS_ENUM
35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
36 | #endif
37 |
38 | #ifndef NS_OPTIONS
39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
40 | #endif
41 |
42 | #if OS_OBJECT_USE_OBJC
43 | #undef SDDispatchQueueRelease
44 | #undef SDDispatchQueueSetterSementics
45 | #define SDDispatchQueueRelease(q)
46 | #define SDDispatchQueueSetterSementics strong
47 | #else
48 | #undef SDDispatchQueueRelease
49 | #undef SDDispatchQueueSetterSementics
50 | #define SDDispatchQueueRelease(q) (dispatch_release(q))
51 | #define SDDispatchQueueSetterSementics assign
52 | #endif
53 |
54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image);
55 |
56 | typedef void(^SDWebImageNoParamsBlock)();
57 |
58 | #define dispatch_main_sync_safe(block)\
59 | if ([NSThread isMainThread]) {\
60 | block();\
61 | } else {\
62 | dispatch_sync(dispatch_get_main_queue(), block);\
63 | }
64 |
65 | #define dispatch_main_async_safe(block)\
66 | if ([NSThread isMainThread]) {\
67 | block();\
68 | } else {\
69 | dispatch_async(dispatch_get_main_queue(), block);\
70 | }
71 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageCompat.m:
--------------------------------------------------------------------------------
1 | //
2 | // SDWebImageCompat.m
3 | // SDWebImage
4 | //
5 | // Created by Olivier Poitrey on 11/12/12.
6 | // Copyright (c) 2012 Dailymotion. All rights reserved.
7 | //
8 |
9 | #import "SDWebImageCompat.h"
10 |
11 | #if !__has_feature(objc_arc)
12 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
13 | #endif
14 |
15 | inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) {
16 | if (!image) {
17 | return nil;
18 | }
19 |
20 | if ([image.images count] > 0) {
21 | NSMutableArray *scaledImages = [NSMutableArray array];
22 |
23 | for (UIImage *tempImage in image.images) {
24 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)];
25 | }
26 |
27 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration];
28 | }
29 | else {
30 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
31 | CGFloat scale = 1.0;
32 | if (key.length >= 8) {
33 | // Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext)
34 | NSRange range = [key rangeOfString:@"@2x." options:0 range:NSMakeRange(key.length - 8, 5)];
35 | if (range.location != NSNotFound) {
36 | scale = 2.0;
37 | }
38 | }
39 |
40 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
41 | image = scaledImage;
42 | }
43 | return image;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageDecoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * Created by james on 9/28/11.
6 | *
7 | * For the full copyright and license information, please view the LICENSE
8 | * file that was distributed with this source code.
9 | */
10 |
11 | #import
12 | #import "SDWebImageCompat.h"
13 |
14 | @interface UIImage (ForceDecode)
15 |
16 | + (UIImage *)decodedImageWithImage:(UIImage *)image;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageDecoder.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * Created by james on 9/28/11.
6 | *
7 | * For the full copyright and license information, please view the LICENSE
8 | * file that was distributed with this source code.
9 | */
10 |
11 | #import "SDWebImageDecoder.h"
12 |
13 | @implementation UIImage (ForceDecode)
14 |
15 | + (UIImage *)decodedImageWithImage:(UIImage *)image {
16 | if (image.images) {
17 | // Do not decode animated images
18 | return image;
19 | }
20 |
21 | CGImageRef imageRef = image.CGImage;
22 | CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
23 | CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize};
24 |
25 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
26 | CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
27 |
28 | int infoMask = (bitmapInfo & kCGBitmapAlphaInfoMask);
29 | BOOL anyNonAlpha = (infoMask == kCGImageAlphaNone ||
30 | infoMask == kCGImageAlphaNoneSkipFirst ||
31 | infoMask == kCGImageAlphaNoneSkipLast);
32 |
33 | // CGBitmapContextCreate doesn't support kCGImageAlphaNone with RGB.
34 | // https://developer.apple.com/library/mac/#qa/qa1037/_index.html
35 | if (infoMask == kCGImageAlphaNone && CGColorSpaceGetNumberOfComponents(colorSpace) > 1) {
36 | // Unset the old alpha info.
37 | bitmapInfo &= ~kCGBitmapAlphaInfoMask;
38 |
39 | // Set noneSkipFirst.
40 | bitmapInfo |= kCGImageAlphaNoneSkipFirst;
41 | }
42 | // Some PNGs tell us they have alpha but only 3 components. Odd.
43 | else if (!anyNonAlpha && CGColorSpaceGetNumberOfComponents(colorSpace) == 3) {
44 | // Unset the old alpha info.
45 | bitmapInfo &= ~kCGBitmapAlphaInfoMask;
46 | bitmapInfo |= kCGImageAlphaPremultipliedFirst;
47 | }
48 |
49 | // It calculates the bytes-per-row based on the bitsPerComponent and width arguments.
50 | CGContextRef context = CGBitmapContextCreate(NULL,
51 | imageSize.width,
52 | imageSize.height,
53 | CGImageGetBitsPerComponent(imageRef),
54 | 0,
55 | colorSpace,
56 | bitmapInfo);
57 | CGColorSpaceRelease(colorSpace);
58 |
59 | // If failed, return undecompressed image
60 | if (!context) return image;
61 |
62 | CGContextDrawImage(context, imageRect, imageRef);
63 | CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context);
64 |
65 | CGContextRelease(context);
66 |
67 | UIImage *decompressedImage = [UIImage imageWithCGImage:decompressedImageRef scale:image.scale orientation:image.imageOrientation];
68 | CGImageRelease(decompressedImageRef);
69 | return decompressedImage;
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageDownloader.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageCompat.h"
11 | #import "SDWebImageOperation.h"
12 |
13 | typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) {
14 | SDWebImageDownloaderLowPriority = 1 << 0,
15 | SDWebImageDownloaderProgressiveDownload = 1 << 1,
16 |
17 | /**
18 | * By default, request prevent the of NSURLCache. With this flag, NSURLCache
19 | * is used with default policies.
20 | */
21 | SDWebImageDownloaderUseNSURLCache = 1 << 2,
22 |
23 | /**
24 | * Call completion block with nil image/imageData if the image was read from NSURLCache
25 | * (to be combined with `SDWebImageDownloaderUseNSURLCache`).
26 | */
27 |
28 | SDWebImageDownloaderIgnoreCachedResponse = 1 << 3,
29 | /**
30 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for
31 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled.
32 | */
33 |
34 | SDWebImageDownloaderContinueInBackground = 1 << 4,
35 |
36 | /**
37 | * Handles cookies stored in NSHTTPCookieStore by setting
38 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES;
39 | */
40 | SDWebImageDownloaderHandleCookies = 1 << 5,
41 |
42 | /**
43 | * Enable to allow untrusted SSL ceriticates.
44 | * Useful for testing purposes. Use with caution in production.
45 | */
46 | SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6,
47 |
48 | /**
49 | * Put the image in the high priority queue.
50 | */
51 | SDWebImageDownloaderHighPriority = 1 << 7,
52 | };
53 |
54 | typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
55 | /**
56 | * Default value. All download operations will execute in queue style (first-in-first-out).
57 | */
58 | SDWebImageDownloaderFIFOExecutionOrder,
59 |
60 | /**
61 | * All download operations will execute in stack style (last-in-first-out).
62 | */
63 | SDWebImageDownloaderLIFOExecutionOrder
64 | };
65 |
66 | extern NSString *const SDWebImageDownloadStartNotification;
67 | extern NSString *const SDWebImageDownloadStopNotification;
68 |
69 | typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
70 |
71 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished);
72 |
73 | typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers);
74 |
75 | /**
76 | * Asynchronous downloader dedicated and optimized for image loading.
77 | */
78 | @interface SDWebImageDownloader : NSObject
79 |
80 | /**
81 | * Decompressing images that are downloaded and cached can improve peformance but can consume lot of memory.
82 | * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption.
83 | */
84 | @property (assign, nonatomic) BOOL shouldDecompressImages;
85 |
86 | @property (assign, nonatomic) NSInteger maxConcurrentDownloads;
87 |
88 | /**
89 | * Shows the current amount of downloads that still need to be downloaded
90 | */
91 | @property (readonly, nonatomic) NSUInteger currentDownloadCount;
92 |
93 |
94 | /**
95 | * The timeout value (in seconds) for the download operation. Default: 15.0.
96 | */
97 | @property (assign, nonatomic) NSTimeInterval downloadTimeout;
98 |
99 |
100 | /**
101 | * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`.
102 | */
103 | @property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder;
104 |
105 | /**
106 | * Singleton method, returns the shared instance
107 | *
108 | * @return global shared instance of downloader class
109 | */
110 | + (SDWebImageDownloader *)sharedDownloader;
111 |
112 | /**
113 | * Set username
114 | */
115 | @property (strong, nonatomic) NSString *username;
116 |
117 | /**
118 | * Set password
119 | */
120 | @property (strong, nonatomic) NSString *password;
121 |
122 | /**
123 | * Set filter to pick headers for downloading image HTTP request.
124 | *
125 | * This block will be invoked for each downloading image request, returned
126 | * NSDictionary will be used as headers in corresponding HTTP request.
127 | */
128 | @property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter;
129 |
130 | /**
131 | * Set a value for a HTTP header to be appended to each download HTTP request.
132 | *
133 | * @param value The value for the header field. Use `nil` value to remove the header.
134 | * @param field The name of the header field to set.
135 | */
136 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
137 |
138 | /**
139 | * Returns the value of the specified HTTP header field.
140 | *
141 | * @return The value associated with the header field field, or `nil` if there is no corresponding header field.
142 | */
143 | - (NSString *)valueForHTTPHeaderField:(NSString *)field;
144 |
145 | /**
146 | * Sets a subclass of `SDWebImageDownloaderOperation` as the default
147 | * `NSOperation` to be used each time SDWebImage constructs a request
148 | * operation to download an image.
149 | *
150 | * @param operationClass The subclass of `SDWebImageDownloaderOperation` to set
151 | * as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`.
152 | */
153 | - (void)setOperationClass:(Class)operationClass;
154 |
155 | /**
156 | * Creates a SDWebImageDownloader async downloader instance with a given URL
157 | *
158 | * The delegate will be informed when the image is finish downloaded or an error has happen.
159 | *
160 | * @see SDWebImageDownloaderDelegate
161 | *
162 | * @param url The URL to the image to download
163 | * @param options The options to be used for this download
164 | * @param progressBlock A block called repeatedly while the image is downloading
165 | * @param completedBlock A block called once the download is completed.
166 | * If the download succeeded, the image parameter is set, in case of error,
167 | * error parameter is set with the error. The last parameter is always YES
168 | * if SDWebImageDownloaderProgressiveDownload isn't use. With the
169 | * SDWebImageDownloaderProgressiveDownload option, this block is called
170 | * repeatedly with the partial image object and the finished argument set to NO
171 | * before to be called a last time with the full image and finished argument
172 | * set to YES. In case of error, the finished argument is always YES.
173 | *
174 | * @return A cancellable SDWebImageOperation
175 | */
176 | - (id )downloadImageWithURL:(NSURL *)url
177 | options:(SDWebImageDownloaderOptions)options
178 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
179 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock;
180 |
181 | /**
182 | * Sets the download queue suspension state
183 | */
184 | - (void)setSuspended:(BOOL)suspended;
185 |
186 | @end
187 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageDownloader.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageDownloader.h"
10 | #import "SDWebImageDownloaderOperation.h"
11 | #import
12 |
13 | NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification";
14 | NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification";
15 |
16 | static NSString *const kProgressCallbackKey = @"progress";
17 | static NSString *const kCompletedCallbackKey = @"completed";
18 |
19 | @interface SDWebImageDownloader ()
20 |
21 | @property (strong, nonatomic) NSOperationQueue *downloadQueue;
22 | @property (weak, nonatomic) NSOperation *lastAddedOperation;
23 | @property (assign, nonatomic) Class operationClass;
24 | @property (strong, nonatomic) NSMutableDictionary *URLCallbacks;
25 | @property (strong, nonatomic) NSMutableDictionary *HTTPHeaders;
26 | // This queue is used to serialize the handling of the network responses of all the download operation in a single queue
27 | @property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue;
28 |
29 | @end
30 |
31 | @implementation SDWebImageDownloader
32 |
33 | + (void)initialize {
34 | // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator )
35 | // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
36 | if (NSClassFromString(@"SDNetworkActivityIndicator")) {
37 |
38 | #pragma clang diagnostic push
39 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
40 | id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")];
41 | #pragma clang diagnostic pop
42 |
43 | // Remove observer in case it was previously added.
44 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil];
45 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil];
46 |
47 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator
48 | selector:NSSelectorFromString(@"startActivity")
49 | name:SDWebImageDownloadStartNotification object:nil];
50 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator
51 | selector:NSSelectorFromString(@"stopActivity")
52 | name:SDWebImageDownloadStopNotification object:nil];
53 | }
54 | }
55 |
56 | + (SDWebImageDownloader *)sharedDownloader {
57 | static dispatch_once_t once;
58 | static id instance;
59 | dispatch_once(&once, ^{
60 | instance = [self new];
61 | });
62 | return instance;
63 | }
64 |
65 | - (id)init {
66 | if ((self = [super init])) {
67 | _operationClass = [SDWebImageDownloaderOperation class];
68 | _shouldDecompressImages = YES;
69 | _executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
70 | _downloadQueue = [NSOperationQueue new];
71 | _downloadQueue.maxConcurrentOperationCount = 6;
72 | _URLCallbacks = [NSMutableDictionary new];
73 | _HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/webp,image/*;q=0.8" forKey:@"Accept"];
74 | _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT);
75 | _downloadTimeout = 15.0;
76 | }
77 | return self;
78 | }
79 |
80 | - (void)dealloc {
81 | [self.downloadQueue cancelAllOperations];
82 | SDDispatchQueueRelease(_barrierQueue);
83 | }
84 |
85 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field {
86 | if (value) {
87 | self.HTTPHeaders[field] = value;
88 | }
89 | else {
90 | [self.HTTPHeaders removeObjectForKey:field];
91 | }
92 | }
93 |
94 | - (NSString *)valueForHTTPHeaderField:(NSString *)field {
95 | return self.HTTPHeaders[field];
96 | }
97 |
98 | - (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads {
99 | _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads;
100 | }
101 |
102 | - (NSUInteger)currentDownloadCount {
103 | return _downloadQueue.operationCount;
104 | }
105 |
106 | - (NSInteger)maxConcurrentDownloads {
107 | return _downloadQueue.maxConcurrentOperationCount;
108 | }
109 |
110 | - (void)setOperationClass:(Class)operationClass {
111 | _operationClass = operationClass ?: [SDWebImageDownloaderOperation class];
112 | }
113 |
114 | - (id )downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock {
115 | __block SDWebImageDownloaderOperation *operation;
116 | __weak SDWebImageDownloader *wself = self;
117 |
118 | [self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{
119 | NSTimeInterval timeoutInterval = wself.downloadTimeout;
120 | if (timeoutInterval == 0.0) {
121 | timeoutInterval = 15.0;
122 | }
123 |
124 | // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
125 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval];
126 | request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies);
127 | request.HTTPShouldUsePipelining = YES;
128 | if (wself.headersFilter) {
129 | request.allHTTPHeaderFields = wself.headersFilter(url, [wself.HTTPHeaders copy]);
130 | }
131 | else {
132 | request.allHTTPHeaderFields = wself.HTTPHeaders;
133 | }
134 | operation = [[wself.operationClass alloc] initWithRequest:request
135 | options:options
136 | progress:^(NSInteger receivedSize, NSInteger expectedSize) {
137 | SDWebImageDownloader *sself = wself;
138 | if (!sself) return;
139 | __block NSArray *callbacksForURL;
140 | dispatch_sync(sself.barrierQueue, ^{
141 | callbacksForURL = [sself.URLCallbacks[url] copy];
142 | });
143 | for (NSDictionary *callbacks in callbacksForURL) {
144 | SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
145 | if (callback) callback(receivedSize, expectedSize);
146 | }
147 | }
148 | completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
149 | SDWebImageDownloader *sself = wself;
150 | if (!sself) return;
151 | __block NSArray *callbacksForURL;
152 | dispatch_barrier_sync(sself.barrierQueue, ^{
153 | callbacksForURL = [sself.URLCallbacks[url] copy];
154 | if (finished) {
155 | [sself.URLCallbacks removeObjectForKey:url];
156 | }
157 | });
158 | for (NSDictionary *callbacks in callbacksForURL) {
159 | SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
160 | if (callback) callback(image, data, error, finished);
161 | }
162 | }
163 | cancelled:^{
164 | SDWebImageDownloader *sself = wself;
165 | if (!sself) return;
166 | dispatch_barrier_async(sself.barrierQueue, ^{
167 | [sself.URLCallbacks removeObjectForKey:url];
168 | });
169 | }];
170 | operation.shouldDecompressImages = wself.shouldDecompressImages;
171 |
172 | if (wself.username && wself.password) {
173 | operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession];
174 | }
175 |
176 | if (options & SDWebImageDownloaderHighPriority) {
177 | operation.queuePriority = NSOperationQueuePriorityHigh;
178 | } else if (options & SDWebImageDownloaderLowPriority) {
179 | operation.queuePriority = NSOperationQueuePriorityLow;
180 | }
181 |
182 | [wself.downloadQueue addOperation:operation];
183 | if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) {
184 | // Emulate LIFO execution order by systematically adding new operations as last operation's dependency
185 | [wself.lastAddedOperation addDependency:operation];
186 | wself.lastAddedOperation = operation;
187 | }
188 | }];
189 |
190 | return operation;
191 | }
192 |
193 | - (void)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock andCompletedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock forURL:(NSURL *)url createCallback:(SDWebImageNoParamsBlock)createCallback {
194 | // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data.
195 | if (url == nil) {
196 | if (completedBlock != nil) {
197 | completedBlock(nil, nil, nil, NO);
198 | }
199 | return;
200 | }
201 |
202 | dispatch_barrier_sync(self.barrierQueue, ^{
203 | BOOL first = NO;
204 | if (!self.URLCallbacks[url]) {
205 | self.URLCallbacks[url] = [NSMutableArray new];
206 | first = YES;
207 | }
208 |
209 | // Handle single download of simultaneous download request for the same URL
210 | NSMutableArray *callbacksForURL = self.URLCallbacks[url];
211 | NSMutableDictionary *callbacks = [NSMutableDictionary new];
212 | if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy];
213 | if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy];
214 | [callbacksForURL addObject:callbacks];
215 | self.URLCallbacks[url] = callbacksForURL;
216 |
217 | if (first) {
218 | createCallback();
219 | }
220 | });
221 | }
222 |
223 | - (void)setSuspended:(BOOL)suspended {
224 | [self.downloadQueue setSuspended:suspended];
225 | }
226 |
227 | @end
228 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageDownloaderOperation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageDownloader.h"
11 | #import "SDWebImageOperation.h"
12 |
13 | @interface SDWebImageDownloaderOperation : NSOperation
14 |
15 | /**
16 | * The request used by the operation's connection.
17 | */
18 | @property (strong, nonatomic, readonly) NSURLRequest *request;
19 |
20 |
21 | @property (assign, nonatomic) BOOL shouldDecompressImages;
22 |
23 | /**
24 | * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default.
25 | *
26 | * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`.
27 | */
28 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage;
29 |
30 | /**
31 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`.
32 | *
33 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present.
34 | */
35 | @property (nonatomic, strong) NSURLCredential *credential;
36 |
37 | /**
38 | * The SDWebImageDownloaderOptions for the receiver.
39 | */
40 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options;
41 |
42 | /**
43 | * Initializes a `SDWebImageDownloaderOperation` object
44 | *
45 | * @see SDWebImageDownloaderOperation
46 | *
47 | * @param request the URL request
48 | * @param options downloader options
49 | * @param progressBlock the block executed when a new chunk of data arrives.
50 | * @note the progress block is executed on a background queue
51 | * @param completedBlock the block executed when the download is done.
52 | * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue
53 | * @param cancelBlock the block executed if the download (operation) is cancelled
54 | *
55 | * @return the initialized instance
56 | */
57 | - (id)initWithRequest:(NSURLRequest *)request
58 | options:(SDWebImageDownloaderOptions)options
59 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
60 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock
61 | cancelled:(SDWebImageNoParamsBlock)cancelBlock;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageManager.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageCompat.h"
10 | #import "SDWebImageOperation.h"
11 | #import "SDWebImageDownloader.h"
12 | #import "SDImageCache.h"
13 |
14 | typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
15 | /**
16 | * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying.
17 | * This flag disable this blacklisting.
18 | */
19 | SDWebImageRetryFailed = 1 << 0,
20 |
21 | /**
22 | * By default, image downloads are started during UI interactions, this flags disable this feature,
23 | * leading to delayed download on UIScrollView deceleration for instance.
24 | */
25 | SDWebImageLowPriority = 1 << 1,
26 |
27 | /**
28 | * This flag disables on-disk caching
29 | */
30 | SDWebImageCacheMemoryOnly = 1 << 2,
31 |
32 | /**
33 | * This flag enables progressive download, the image is displayed progressively during download as a browser would do.
34 | * By default, the image is only displayed once completely downloaded.
35 | */
36 | SDWebImageProgressiveDownload = 1 << 3,
37 |
38 | /**
39 | * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed.
40 | * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation.
41 | * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics.
42 | * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image.
43 | *
44 | * Use this flag only if you can't make your URLs static with embeded cache busting parameter.
45 | */
46 | SDWebImageRefreshCached = 1 << 4,
47 |
48 | /**
49 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for
50 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled.
51 | */
52 | SDWebImageContinueInBackground = 1 << 5,
53 |
54 | /**
55 | * Handles cookies stored in NSHTTPCookieStore by setting
56 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES;
57 | */
58 | SDWebImageHandleCookies = 1 << 6,
59 |
60 | /**
61 | * Enable to allow untrusted SSL ceriticates.
62 | * Useful for testing purposes. Use with caution in production.
63 | */
64 | SDWebImageAllowInvalidSSLCertificates = 1 << 7,
65 |
66 | /**
67 | * By default, image are loaded in the order they were queued. This flag move them to
68 | * the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which
69 | * could take a while).
70 | */
71 | SDWebImageHighPriority = 1 << 8,
72 |
73 | /**
74 | * By default, placeholder images are loaded while the image is loading. This flag will delay the loading
75 | * of the placeholder image until after the image has finished loading.
76 | */
77 | SDWebImageDelayPlaceholder = 1 << 9,
78 |
79 | /**
80 | * We usually don't call transformDownloadedImage delegate method on animated images,
81 | * as most transformation code would mangle it.
82 | * Use this flag to transform them anyway.
83 | */
84 | SDWebImageTransformAnimatedImage = 1 << 10,
85 | };
86 |
87 | typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL);
88 |
89 | typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL);
90 |
91 | typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url);
92 |
93 |
94 | @class SDWebImageManager;
95 |
96 | @protocol SDWebImageManagerDelegate
97 |
98 | @optional
99 |
100 | /**
101 | * Controls which image should be downloaded when the image is not found in the cache.
102 | *
103 | * @param imageManager The current `SDWebImageManager`
104 | * @param imageURL The url of the image to be downloaded
105 | *
106 | * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied.
107 | */
108 | - (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL;
109 |
110 | /**
111 | * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory.
112 | * NOTE: This method is called from a global queue in order to not to block the main thread.
113 | *
114 | * @param imageManager The current `SDWebImageManager`
115 | * @param image The image to transform
116 | * @param imageURL The url of the image to transform
117 | *
118 | * @return The transformed image object.
119 | */
120 | - (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL;
121 |
122 | @end
123 |
124 | /**
125 | * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes.
126 | * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache).
127 | * You can use this class directly to benefit from web image downloading with caching in another context than
128 | * a UIView.
129 | *
130 | * Here is a simple example of how to use SDWebImageManager:
131 | *
132 | * @code
133 |
134 | SDWebImageManager *manager = [SDWebImageManager sharedManager];
135 | [manager downloadWithURL:imageURL
136 | options:0
137 | progress:nil
138 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
139 | if (image) {
140 | // do something with image
141 | }
142 | }];
143 |
144 | * @endcode
145 | */
146 | @interface SDWebImageManager : NSObject
147 |
148 | @property (weak, nonatomic) id delegate;
149 |
150 | @property (strong, nonatomic, readonly) SDImageCache *imageCache;
151 | @property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader;
152 |
153 | /**
154 | * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can
155 | * be used to remove dynamic part of an image URL.
156 | *
157 | * The following example sets a filter in the application delegate that will remove any query-string from the
158 | * URL before to use it as a cache key:
159 | *
160 | * @code
161 |
162 | [[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) {
163 | url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path];
164 | return [url absoluteString];
165 | }];
166 |
167 | * @endcode
168 | */
169 | @property (nonatomic, copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter;
170 |
171 | /**
172 | * Returns global SDWebImageManager instance.
173 | *
174 | * @return SDWebImageManager shared instance
175 | */
176 | + (SDWebImageManager *)sharedManager;
177 |
178 | /**
179 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise.
180 | *
181 | * @param url The URL to the image
182 | * @param options A mask to specify options to use for this request
183 | * @param progressBlock A block called while image is downloading
184 | * @param completedBlock A block called when operation has been completed.
185 | *
186 | * This parameter is required.
187 | *
188 | * This block has no return value and takes the requested UIImage as first parameter.
189 | * In case of error the image parameter is nil and the second parameter may contain an NSError.
190 | *
191 | * The third parameter is an `SDImageCacheType` enum indicating if the image was retrived from the local cache
192 | * or from the memory cache or from the network.
193 | *
194 | * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is
195 | * downloading. This block is thus called repetidly with a partial image. When image is fully downloaded, the
196 | * block is called a last time with the full image and the last parameter set to YES.
197 | *
198 | * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation
199 | */
200 | - (id )downloadImageWithURL:(NSURL *)url
201 | options:(SDWebImageOptions)options
202 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
203 | completed:(SDWebImageCompletionWithFinishedBlock)completedBlock;
204 |
205 | /**
206 | * Saves image to cache for given URL
207 | *
208 | * @param image The image to cache
209 | * @param url The URL to the image
210 | *
211 | */
212 |
213 | - (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url;
214 |
215 | /**
216 | * Cancel all current opreations
217 | */
218 | - (void)cancelAll;
219 |
220 | /**
221 | * Check one or more operations running
222 | */
223 | - (BOOL)isRunning;
224 |
225 | /**
226 | * Check if image has already been cached
227 | *
228 | * @param url image url
229 | *
230 | * @return if the image was already cached
231 | */
232 | - (BOOL)cachedImageExistsForURL:(NSURL *)url;
233 |
234 | /**
235 | * Check if image has already been cached on disk only
236 | *
237 | * @param url image url
238 | *
239 | * @return if the image was already cached (disk only)
240 | */
241 | - (BOOL)diskImageExistsForURL:(NSURL *)url;
242 |
243 | /**
244 | * Async check if image has already been cached
245 | *
246 | * @param url image url
247 | * @param completionBlock the block to be executed when the check is finished
248 | *
249 | * @note the completion block is always executed on the main queue
250 | */
251 | - (void)cachedImageExistsForURL:(NSURL *)url
252 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock;
253 |
254 | /**
255 | * Async check if image has already been cached on disk only
256 | *
257 | * @param url image url
258 | * @param completionBlock the block to be executed when the check is finished
259 | *
260 | * @note the completion block is always executed on the main queue
261 | */
262 | - (void)diskImageExistsForURL:(NSURL *)url
263 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock;
264 |
265 |
266 | /**
267 | *Return the cache key for a given URL
268 | */
269 | - (NSString *)cacheKeyForURL:(NSURL *)url;
270 |
271 | @end
272 |
273 |
274 | #pragma mark - Deprecated
275 |
276 | typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`");
277 | typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`");
278 |
279 |
280 | @interface SDWebImageManager (Deprecated)
281 |
282 | /**
283 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise.
284 | *
285 | * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:`
286 | */
287 | - (id )downloadWithURL:(NSURL *)url
288 | options:(SDWebImageOptions)options
289 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
290 | completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`");
291 |
292 | @end
293 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageManager.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageManager.h"
10 | #import
11 |
12 | @interface SDWebImageCombinedOperation : NSObject
13 |
14 | @property (assign, nonatomic, getter = isCancelled) BOOL cancelled;
15 | @property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock;
16 | @property (strong, nonatomic) NSOperation *cacheOperation;
17 |
18 | @end
19 |
20 | @interface SDWebImageManager ()
21 |
22 | @property (strong, nonatomic, readwrite) SDImageCache *imageCache;
23 | @property (strong, nonatomic, readwrite) SDWebImageDownloader *imageDownloader;
24 | @property (strong, nonatomic) NSMutableArray *failedURLs;
25 | @property (strong, nonatomic) NSMutableArray *runningOperations;
26 |
27 | @end
28 |
29 | @implementation SDWebImageManager
30 |
31 | + (id)sharedManager {
32 | static dispatch_once_t once;
33 | static id instance;
34 | dispatch_once(&once, ^{
35 | instance = [self new];
36 | });
37 | return instance;
38 | }
39 |
40 | - (id)init {
41 | if ((self = [super init])) {
42 | _imageCache = [self createCache];
43 | _imageDownloader = [SDWebImageDownloader sharedDownloader];
44 | _failedURLs = [NSMutableArray new];
45 | _runningOperations = [NSMutableArray new];
46 | }
47 | return self;
48 | }
49 |
50 | - (SDImageCache *)createCache {
51 | return [SDImageCache sharedImageCache];
52 | }
53 |
54 | - (NSString *)cacheKeyForURL:(NSURL *)url {
55 | if (self.cacheKeyFilter) {
56 | return self.cacheKeyFilter(url);
57 | }
58 | else {
59 | return [url absoluteString];
60 | }
61 | }
62 |
63 | - (BOOL)cachedImageExistsForURL:(NSURL *)url {
64 | NSString *key = [self cacheKeyForURL:url];
65 | if ([self.imageCache imageFromMemoryCacheForKey:key] != nil) return YES;
66 | return [self.imageCache diskImageExistsWithKey:key];
67 | }
68 |
69 | - (BOOL)diskImageExistsForURL:(NSURL *)url {
70 | NSString *key = [self cacheKeyForURL:url];
71 | return [self.imageCache diskImageExistsWithKey:key];
72 | }
73 |
74 | - (void)cachedImageExistsForURL:(NSURL *)url
75 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock {
76 | NSString *key = [self cacheKeyForURL:url];
77 |
78 | BOOL isInMemoryCache = ([self.imageCache imageFromMemoryCacheForKey:key] != nil);
79 |
80 | if (isInMemoryCache) {
81 | // making sure we call the completion block on the main queue
82 | dispatch_async(dispatch_get_main_queue(), ^{
83 | if (completionBlock) {
84 | completionBlock(YES);
85 | }
86 | });
87 | return;
88 | }
89 |
90 | [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) {
91 | // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch
92 | if (completionBlock) {
93 | completionBlock(isInDiskCache);
94 | }
95 | }];
96 | }
97 |
98 | - (void)diskImageExistsForURL:(NSURL *)url
99 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock {
100 | NSString *key = [self cacheKeyForURL:url];
101 |
102 | [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) {
103 | // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch
104 | if (completionBlock) {
105 | completionBlock(isInDiskCache);
106 | }
107 | }];
108 | }
109 |
110 | - (id )downloadImageWithURL:(NSURL *)url
111 | options:(SDWebImageOptions)options
112 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
113 | completed:(SDWebImageCompletionWithFinishedBlock)completedBlock {
114 | // Invoking this method without a completedBlock is pointless
115 | NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead");
116 |
117 | // Very common mistake is to send the URL using NSString object instead of NSURL. For some strange reason, XCode won't
118 | // throw any warning for this type mismatch. Here we failsafe this error by allowing URLs to be passed as NSString.
119 | if ([url isKindOfClass:NSString.class]) {
120 | url = [NSURL URLWithString:(NSString *)url];
121 | }
122 |
123 | // Prevents app crashing on argument type error like sending NSNull instead of NSURL
124 | if (![url isKindOfClass:NSURL.class]) {
125 | url = nil;
126 | }
127 |
128 | __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new];
129 | __weak SDWebImageCombinedOperation *weakOperation = operation;
130 |
131 | BOOL isFailedUrl = NO;
132 | @synchronized (self.failedURLs) {
133 | isFailedUrl = [self.failedURLs containsObject:url];
134 | }
135 |
136 | if (!url || (!(options & SDWebImageRetryFailed) && isFailedUrl)) {
137 | dispatch_main_sync_safe(^{
138 | NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil];
139 | completedBlock(nil, error, SDImageCacheTypeNone, YES, url);
140 | });
141 | return operation;
142 | }
143 |
144 | @synchronized (self.runningOperations) {
145 | [self.runningOperations addObject:operation];
146 | }
147 | NSString *key = [self cacheKeyForURL:url];
148 |
149 | operation.cacheOperation = [self.imageCache queryDiskCacheForKey:key done:^(UIImage *image, SDImageCacheType cacheType) {
150 | if (operation.isCancelled) {
151 | @synchronized (self.runningOperations) {
152 | [self.runningOperations removeObject:operation];
153 | }
154 |
155 | return;
156 | }
157 |
158 | if ((!image || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) {
159 | if (image && options & SDWebImageRefreshCached) {
160 | dispatch_main_sync_safe(^{
161 | // If image was found in the cache bug SDWebImageRefreshCached is provided, notify about the cached image
162 | // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server.
163 | completedBlock(image, nil, cacheType, YES, url);
164 | });
165 | }
166 |
167 | // download if no image or requested to refresh anyway, and download allowed by delegate
168 | SDWebImageDownloaderOptions downloaderOptions = 0;
169 | if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority;
170 | if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload;
171 | if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache;
172 | if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground;
173 | if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies;
174 | if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates;
175 | if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority;
176 | if (image && options & SDWebImageRefreshCached) {
177 | // force progressive off if image already cached but forced refreshing
178 | downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;
179 | // ignore image read from NSURLCache if image if cached but force refreshing
180 | downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
181 | }
182 | id subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished) {
183 | if (weakOperation.isCancelled) {
184 | // Do nothing if the operation was cancelled
185 | // See #699 for more details
186 | // if we would call the completedBlock, there could be a race condition between this block and another completedBlock for the same object, so if this one is called second, we will overwrite the new data
187 | }
188 | else if (error) {
189 | dispatch_main_sync_safe(^{
190 | if (!weakOperation.isCancelled) {
191 | completedBlock(nil, error, SDImageCacheTypeNone, finished, url);
192 | }
193 | });
194 |
195 | if (error.code != NSURLErrorNotConnectedToInternet && error.code != NSURLErrorCancelled && error.code != NSURLErrorTimedOut) {
196 | @synchronized (self.failedURLs) {
197 | if (![self.failedURLs containsObject:url]) {
198 | [self.failedURLs addObject:url];
199 | }
200 | }
201 | }
202 | }
203 | else {
204 | BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly);
205 |
206 | if (options & SDWebImageRefreshCached && image && !downloadedImage) {
207 | // Image refresh hit the NSURLCache cache, do not call the completion block
208 | }
209 | else if (downloadedImage && (!downloadedImage.images || (options & SDWebImageTransformAnimatedImage)) && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)]) {
210 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
211 | UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
212 |
213 | if (transformedImage && finished) {
214 | BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage];
215 | [self.imageCache storeImage:transformedImage recalculateFromImage:imageWasTransformed imageData:data forKey:key toDisk:cacheOnDisk];
216 | }
217 |
218 | dispatch_main_sync_safe(^{
219 | if (!weakOperation.isCancelled) {
220 | completedBlock(transformedImage, nil, SDImageCacheTypeNone, finished, url);
221 | }
222 | });
223 | });
224 | }
225 | else {
226 | if (downloadedImage && finished) {
227 | [self.imageCache storeImage:downloadedImage recalculateFromImage:NO imageData:data forKey:key toDisk:cacheOnDisk];
228 | }
229 |
230 | dispatch_main_sync_safe(^{
231 | if (!weakOperation.isCancelled) {
232 | completedBlock(downloadedImage, nil, SDImageCacheTypeNone, finished, url);
233 | }
234 | });
235 | }
236 | }
237 |
238 | if (finished) {
239 | @synchronized (self.runningOperations) {
240 | [self.runningOperations removeObject:operation];
241 | }
242 | }
243 | }];
244 | operation.cancelBlock = ^{
245 | [subOperation cancel];
246 |
247 | @synchronized (self.runningOperations) {
248 | [self.runningOperations removeObject:weakOperation];
249 | }
250 | };
251 | }
252 | else if (image) {
253 | dispatch_main_sync_safe(^{
254 | if (!weakOperation.isCancelled) {
255 | completedBlock(image, nil, cacheType, YES, url);
256 | }
257 | });
258 | @synchronized (self.runningOperations) {
259 | [self.runningOperations removeObject:operation];
260 | }
261 | }
262 | else {
263 | // Image not in cache and download disallowed by delegate
264 | dispatch_main_sync_safe(^{
265 | if (!weakOperation.isCancelled) {
266 | completedBlock(nil, nil, SDImageCacheTypeNone, YES, url);
267 | }
268 | });
269 | @synchronized (self.runningOperations) {
270 | [self.runningOperations removeObject:operation];
271 | }
272 | }
273 | }];
274 |
275 | return operation;
276 | }
277 |
278 | - (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url {
279 | if (image && url) {
280 | NSString *key = [self cacheKeyForURL:url];
281 | [self.imageCache storeImage:image forKey:key toDisk:YES];
282 | }
283 | }
284 |
285 | - (void)cancelAll {
286 | @synchronized (self.runningOperations) {
287 | NSArray *copiedOperations = [self.runningOperations copy];
288 | [copiedOperations makeObjectsPerformSelector:@selector(cancel)];
289 | [self.runningOperations removeObjectsInArray:copiedOperations];
290 | }
291 | }
292 |
293 | - (BOOL)isRunning {
294 | return self.runningOperations.count > 0;
295 | }
296 |
297 | @end
298 |
299 |
300 | @implementation SDWebImageCombinedOperation
301 |
302 | - (void)setCancelBlock:(SDWebImageNoParamsBlock)cancelBlock {
303 | // check if the operation is already cancelled, then we just call the cancelBlock
304 | if (self.isCancelled) {
305 | if (cancelBlock) {
306 | cancelBlock();
307 | }
308 | _cancelBlock = nil; // don't forget to nil the cancelBlock, otherwise we will get crashes
309 | } else {
310 | _cancelBlock = [cancelBlock copy];
311 | }
312 | }
313 |
314 | - (void)cancel {
315 | self.cancelled = YES;
316 | if (self.cacheOperation) {
317 | [self.cacheOperation cancel];
318 | self.cacheOperation = nil;
319 | }
320 | if (self.cancelBlock) {
321 | self.cancelBlock();
322 |
323 | // TODO: this is a temporary fix to #809.
324 | // Until we can figure the exact cause of the crash, going with the ivar instead of the setter
325 | // self.cancelBlock = nil;
326 | _cancelBlock = nil;
327 | }
328 | }
329 |
330 | @end
331 |
332 |
333 | @implementation SDWebImageManager (Deprecated)
334 |
335 | // deprecated method, uses the non deprecated method
336 | // adapter for the completion block
337 | - (id )downloadWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedWithFinishedBlock)completedBlock {
338 | return [self downloadImageWithURL:url
339 | options:options
340 | progress:progressBlock
341 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
342 | if (completedBlock) {
343 | completedBlock(image, error, cacheType, finished);
344 | }
345 | }];
346 | }
347 |
348 | @end
349 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImageOperation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 |
11 | @protocol SDWebImageOperation
12 |
13 | - (void)cancel;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImagePrefetcher.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageManager.h"
11 |
12 | @class SDWebImagePrefetcher;
13 |
14 | @protocol SDWebImagePrefetcherDelegate
15 |
16 | @optional
17 |
18 | /**
19 | * Called when an image was prefetched.
20 | *
21 | * @param imagePrefetcher The current image prefetcher
22 | * @param imageURL The image url that was prefetched
23 | * @param finishedCount The total number of images that were prefetched (successful or not)
24 | * @param totalCount The total number of images that were to be prefetched
25 | */
26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount;
27 |
28 | /**
29 | * Called when all images are prefetched.
30 | * @param imagePrefetcher The current image prefetcher
31 | * @param totalCount The total number of images that were prefetched (whether successful or not)
32 | * @param skippedCount The total number of images that were skipped
33 | */
34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount;
35 |
36 | @end
37 |
38 | typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls);
39 | typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls);
40 |
41 | /**
42 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority.
43 | */
44 | @interface SDWebImagePrefetcher : NSObject
45 |
46 | /**
47 | * The web image manager
48 | */
49 | @property (strong, nonatomic, readonly) SDWebImageManager *manager;
50 |
51 | /**
52 | * Maximum number of URLs to prefetch at the same time. Defaults to 3.
53 | */
54 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads;
55 |
56 | /**
57 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority.
58 | */
59 | @property (nonatomic, assign) SDWebImageOptions options;
60 |
61 | /**
62 | * Queue options for Prefetcher. Defaults to Main Queue.
63 | */
64 | @property (nonatomic, assign) dispatch_queue_t prefetcherQueue;
65 |
66 | @property (weak, nonatomic) id delegate;
67 |
68 | /**
69 | * Return the global image prefetcher instance.
70 | */
71 | + (SDWebImagePrefetcher *)sharedImagePrefetcher;
72 |
73 | /**
74 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching,
75 | * currently one image is downloaded at a time,
76 | * and skips images for failed downloads and proceed to the next image in the list
77 | *
78 | * @param urls list of URLs to prefetch
79 | */
80 | - (void)prefetchURLs:(NSArray *)urls;
81 |
82 | /**
83 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching,
84 | * currently one image is downloaded at a time,
85 | * and skips images for failed downloads and proceed to the next image in the list
86 | *
87 | * @param urls list of URLs to prefetch
88 | * @param progressBlock block to be called when progress updates;
89 | * first parameter is the number of completed (successful or not) requests,
90 | * second parameter is the total number of images originally requested to be prefetched
91 | * @param completionBlock block to be called when prefetching is completed
92 | * first param is the number of completed (successful or not) requests,
93 | * second parameter is the number of skipped requests
94 | */
95 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock;
96 |
97 | /**
98 | * Remove and cancel queued list
99 | */
100 | - (void)cancelPrefetching;
101 |
102 |
103 | @end
104 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/SDWebImagePrefetcher.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImagePrefetcher.h"
10 |
11 | #if (!defined(DEBUG) && !defined (SD_VERBOSE)) || defined(SD_LOG_NONE)
12 | #define NSLog(...)
13 | #endif
14 |
15 | @interface SDWebImagePrefetcher ()
16 |
17 | @property (strong, nonatomic) SDWebImageManager *manager;
18 | @property (strong, nonatomic) NSArray *prefetchURLs;
19 | @property (assign, nonatomic) NSUInteger requestedCount;
20 | @property (assign, nonatomic) NSUInteger skippedCount;
21 | @property (assign, nonatomic) NSUInteger finishedCount;
22 | @property (assign, nonatomic) NSTimeInterval startedTime;
23 | @property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock;
24 | @property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock;
25 |
26 | @end
27 |
28 | @implementation SDWebImagePrefetcher
29 |
30 | + (SDWebImagePrefetcher *)sharedImagePrefetcher {
31 | static dispatch_once_t once;
32 | static id instance;
33 | dispatch_once(&once, ^{
34 | instance = [self new];
35 | });
36 | return instance;
37 | }
38 |
39 | - (id)init {
40 | if ((self = [super init])) {
41 | _manager = [SDWebImageManager new];
42 | _options = SDWebImageLowPriority;
43 | _prefetcherQueue = dispatch_get_main_queue();
44 | self.maxConcurrentDownloads = 3;
45 | }
46 | return self;
47 | }
48 |
49 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads {
50 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads;
51 | }
52 |
53 | - (NSUInteger)maxConcurrentDownloads {
54 | return self.manager.imageDownloader.maxConcurrentDownloads;
55 | }
56 |
57 | - (void)startPrefetchingAtIndex:(NSUInteger)index {
58 | if (index >= self.prefetchURLs.count) return;
59 | self.requestedCount++;
60 | [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
61 | if (!finished) return;
62 | self.finishedCount++;
63 |
64 | if (image) {
65 | if (self.progressBlock) {
66 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]);
67 | }
68 | NSLog(@"Prefetched %@ out of %@", @(self.finishedCount), @(self.prefetchURLs.count));
69 | }
70 | else {
71 | if (self.progressBlock) {
72 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]);
73 | }
74 | NSLog(@"Prefetched %@ out of %@ (Failed)", @(self.finishedCount), @(self.prefetchURLs.count));
75 |
76 | // Add last failed
77 | self.skippedCount++;
78 | }
79 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) {
80 | [self.delegate imagePrefetcher:self
81 | didPrefetchURL:self.prefetchURLs[index]
82 | finishedCount:self.finishedCount
83 | totalCount:self.prefetchURLs.count
84 | ];
85 | }
86 | if (self.prefetchURLs.count > self.requestedCount) {
87 | dispatch_async(self.prefetcherQueue, ^{
88 | [self startPrefetchingAtIndex:self.requestedCount];
89 | });
90 | }
91 | else if (self.finishedCount == self.requestedCount) {
92 | [self reportStatus];
93 | if (self.completionBlock) {
94 | self.completionBlock(self.finishedCount, self.skippedCount);
95 | self.completionBlock = nil;
96 | }
97 | }
98 | }];
99 | }
100 |
101 | - (void)reportStatus {
102 | NSUInteger total = [self.prefetchURLs count];
103 | NSLog(@"Finished prefetching (%@ successful, %@ skipped, timeElasped %.2f)", @(total - self.skippedCount), @(self.skippedCount), CFAbsoluteTimeGetCurrent() - self.startedTime);
104 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) {
105 | [self.delegate imagePrefetcher:self
106 | didFinishWithTotalCount:(total - self.skippedCount)
107 | skippedCount:self.skippedCount
108 | ];
109 | }
110 | }
111 |
112 | - (void)prefetchURLs:(NSArray *)urls {
113 | [self prefetchURLs:urls progress:nil completed:nil];
114 | }
115 |
116 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock {
117 | [self cancelPrefetching]; // Prevent duplicate prefetch request
118 | self.startedTime = CFAbsoluteTimeGetCurrent();
119 | self.prefetchURLs = urls;
120 | self.completionBlock = completionBlock;
121 | self.progressBlock = progressBlock;
122 |
123 | if(urls.count == 0){
124 | if(completionBlock){
125 | completionBlock(0,0);
126 | }
127 | }else{
128 | // Starts prefetching from the very first image on the list with the max allowed concurrency
129 | NSUInteger listCount = self.prefetchURLs.count;
130 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
131 | [self startPrefetchingAtIndex:i];
132 | }
133 | }
134 | }
135 |
136 | - (void)cancelPrefetching {
137 | self.prefetchURLs = nil;
138 | self.skippedCount = 0;
139 | self.requestedCount = 0;
140 | self.finishedCount = 0;
141 | [self.manager cancelAll];
142 | }
143 |
144 | @end
145 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIButton+WebCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageCompat.h"
10 | #import "SDWebImageManager.h"
11 |
12 | /**
13 | * Integrates SDWebImage async downloading and caching of remote images with UIButtonView.
14 | */
15 | @interface UIButton (WebCache)
16 |
17 | /**
18 | * Get the current image URL.
19 | */
20 | - (NSURL *)sd_currentImageURL;
21 |
22 | /**
23 | * Get the image URL for a control state.
24 | *
25 | * @param state Which state you want to know the URL for. The values are described in UIControlState.
26 | */
27 | - (NSURL *)sd_imageURLForState:(UIControlState)state;
28 |
29 | /**
30 | * Set the imageView `image` with an `url`.
31 | *
32 | * The download is asynchronous and cached.
33 | *
34 | * @param url The url for the image.
35 | * @param state The state that uses the specified title. The values are described in UIControlState.
36 | */
37 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state;
38 |
39 | /**
40 | * Set the imageView `image` with an `url` and a placeholder.
41 | *
42 | * The download is asynchronous and cached.
43 | *
44 | * @param url The url for the image.
45 | * @param state The state that uses the specified title. The values are described in UIControlState.
46 | * @param placeholder The image to be set initially, until the image request finishes.
47 | * @see sd_setImageWithURL:placeholderImage:options:
48 | */
49 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder;
50 |
51 | /**
52 | * Set the imageView `image` with an `url`, placeholder and custom options.
53 | *
54 | * The download is asynchronous and cached.
55 | *
56 | * @param url The url for the image.
57 | * @param state The state that uses the specified title. The values are described in UIControlState.
58 | * @param placeholder The image to be set initially, until the image request finishes.
59 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
60 | */
61 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;
62 |
63 | /**
64 | * Set the imageView `image` with an `url`.
65 | *
66 | * The download is asynchronous and cached.
67 | *
68 | * @param url The url for the image.
69 | * @param state The state that uses the specified title. The values are described in UIControlState.
70 | * @param completedBlock A block called when operation has been completed. This block has no return value
71 | * and takes the requested UIImage as first parameter. In case of error the image parameter
72 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
73 | * indicating if the image was retrived from the local cache or from the network.
74 | * The fourth parameter is the original image url.
75 | */
76 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock;
77 |
78 | /**
79 | * Set the imageView `image` with an `url`, placeholder.
80 | *
81 | * The download is asynchronous and cached.
82 | *
83 | * @param url The url for the image.
84 | * @param state The state that uses the specified title. The values are described in UIControlState.
85 | * @param placeholder The image to be set initially, until the image request finishes.
86 | * @param completedBlock A block called when operation has been completed. This block has no return value
87 | * and takes the requested UIImage as first parameter. In case of error the image parameter
88 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
89 | * indicating if the image was retrived from the local cache or from the network.
90 | * The fourth parameter is the original image url.
91 | */
92 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock;
93 |
94 | /**
95 | * Set the imageView `image` with an `url`, placeholder and custom options.
96 | *
97 | * The download is asynchronous and cached.
98 | *
99 | * @param url The url for the image.
100 | * @param state The state that uses the specified title. The values are described in UIControlState.
101 | * @param placeholder The image to be set initially, until the image request finishes.
102 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
103 | * @param completedBlock A block called when operation has been completed. This block has no return value
104 | * and takes the requested UIImage as first parameter. In case of error the image parameter
105 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
106 | * indicating if the image was retrived from the local cache or from the network.
107 | * The fourth parameter is the original image url.
108 | */
109 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
110 |
111 | /**
112 | * Set the backgroundImageView `image` with an `url`.
113 | *
114 | * The download is asynchronous and cached.
115 | *
116 | * @param url The url for the image.
117 | * @param state The state that uses the specified title. The values are described in UIControlState.
118 | */
119 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state;
120 |
121 | /**
122 | * Set the backgroundImageView `image` with an `url` and a placeholder.
123 | *
124 | * The download is asynchronous and cached.
125 | *
126 | * @param url The url for the image.
127 | * @param state The state that uses the specified title. The values are described in UIControlState.
128 | * @param placeholder The image to be set initially, until the image request finishes.
129 | * @see sd_setImageWithURL:placeholderImage:options:
130 | */
131 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder;
132 |
133 | /**
134 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options.
135 | *
136 | * The download is asynchronous and cached.
137 | *
138 | * @param url The url for the image.
139 | * @param state The state that uses the specified title. The values are described in UIControlState.
140 | * @param placeholder The image to be set initially, until the image request finishes.
141 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
142 | */
143 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;
144 |
145 | /**
146 | * Set the backgroundImageView `image` with an `url`.
147 | *
148 | * The download is asynchronous and cached.
149 | *
150 | * @param url The url for the image.
151 | * @param state The state that uses the specified title. The values are described in UIControlState.
152 | * @param completedBlock A block called when operation has been completed. This block has no return value
153 | * and takes the requested UIImage as first parameter. In case of error the image parameter
154 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
155 | * indicating if the image was retrived from the local cache or from the network.
156 | * The fourth parameter is the original image url.
157 | */
158 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock;
159 |
160 | /**
161 | * Set the backgroundImageView `image` with an `url`, placeholder.
162 | *
163 | * The download is asynchronous and cached.
164 | *
165 | * @param url The url for the image.
166 | * @param state The state that uses the specified title. The values are described in UIControlState.
167 | * @param placeholder The image to be set initially, until the image request finishes.
168 | * @param completedBlock A block called when operation has been completed. This block has no return value
169 | * and takes the requested UIImage as first parameter. In case of error the image parameter
170 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
171 | * indicating if the image was retrived from the local cache or from the network.
172 | * The fourth parameter is the original image url.
173 | */
174 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock;
175 |
176 | /**
177 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options.
178 | *
179 | * The download is asynchronous and cached.
180 | *
181 | * @param url The url for the image.
182 | * @param placeholder The image to be set initially, until the image request finishes.
183 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
184 | * @param completedBlock A block called when operation has been completed. This block has no return value
185 | * and takes the requested UIImage as first parameter. In case of error the image parameter
186 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
187 | * indicating if the image was retrived from the local cache or from the network.
188 | * The fourth parameter is the original image url.
189 | */
190 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
191 |
192 | /**
193 | * Cancel the current image download
194 | */
195 | - (void)sd_cancelImageLoadForState:(UIControlState)state;
196 |
197 | /**
198 | * Cancel the current backgroundImage download
199 | */
200 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state;
201 |
202 | @end
203 |
204 |
205 | @interface UIButton (WebCacheDeprecated)
206 |
207 | - (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`");
208 | - (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`");
209 |
210 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`");
211 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`");
212 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`");
213 |
214 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:completed:`");
215 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:completed:`");
216 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:completed:`");
217 |
218 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:`");
219 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:`");
220 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:`");
221 |
222 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:completed:`");
223 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`");
224 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`");
225 |
226 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`");
227 | - (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`");
228 |
229 | @end
230 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIButton+WebCache.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIButton+WebCache.h"
10 | #import "objc/runtime.h"
11 | #import "UIView+WebCacheOperation.h"
12 |
13 | static char imageURLStorageKey;
14 |
15 | @implementation UIButton (WebCache)
16 |
17 | - (NSURL *)sd_currentImageURL {
18 | NSURL *url = self.imageURLStorage[@(self.state)];
19 |
20 | if (!url) {
21 | url = self.imageURLStorage[@(UIControlStateNormal)];
22 | }
23 |
24 | return url;
25 | }
26 |
27 | - (NSURL *)sd_imageURLForState:(UIControlState)state {
28 | return self.imageURLStorage[@(state)];
29 | }
30 |
31 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state {
32 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
33 | }
34 |
35 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
36 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
37 | }
38 |
39 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
40 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
41 | }
42 |
43 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock {
44 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock];
45 | }
46 |
47 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock {
48 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock];
49 | }
50 |
51 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
52 |
53 | [self setImage:placeholder forState:state];
54 | [self sd_cancelImageLoadForState:state];
55 |
56 | if (!url) {
57 | [self.imageURLStorage removeObjectForKey:@(state)];
58 |
59 | dispatch_main_async_safe(^{
60 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
61 | if (completedBlock) {
62 | completedBlock(nil, error, SDImageCacheTypeNone, url);
63 | }
64 | });
65 |
66 | return;
67 | }
68 |
69 | self.imageURLStorage[@(state)] = url;
70 |
71 | __weak UIButton *wself = self;
72 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
73 | if (!wself) return;
74 | dispatch_main_sync_safe(^{
75 | __strong UIButton *sself = wself;
76 | if (!sself) return;
77 | if (image) {
78 | [sself setImage:image forState:state];
79 | }
80 | if (completedBlock && finished) {
81 | completedBlock(image, error, cacheType, url);
82 | }
83 | });
84 | }];
85 | [self sd_setImageLoadOperation:operation forState:state];
86 | }
87 |
88 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state {
89 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
90 | }
91 |
92 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
93 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
94 | }
95 |
96 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
97 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
98 | }
99 |
100 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock {
101 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock];
102 | }
103 |
104 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock {
105 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock];
106 | }
107 |
108 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
109 | [self sd_cancelImageLoadForState:state];
110 |
111 | [self setBackgroundImage:placeholder forState:state];
112 |
113 | if (url) {
114 | __weak UIButton *wself = self;
115 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
116 | if (!wself) return;
117 | dispatch_main_sync_safe(^{
118 | __strong UIButton *sself = wself;
119 | if (!sself) return;
120 | if (image) {
121 | [sself setBackgroundImage:image forState:state];
122 | }
123 | if (completedBlock && finished) {
124 | completedBlock(image, error, cacheType, url);
125 | }
126 | });
127 | }];
128 | [self sd_setBackgroundImageLoadOperation:operation forState:state];
129 | } else {
130 | dispatch_main_async_safe(^{
131 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
132 | if (completedBlock) {
133 | completedBlock(nil, error, SDImageCacheTypeNone, url);
134 | }
135 | });
136 | }
137 | }
138 |
139 | - (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state {
140 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
141 | }
142 |
143 | - (void)sd_cancelImageLoadForState:(UIControlState)state {
144 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
145 | }
146 |
147 | - (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state {
148 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
149 | }
150 |
151 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state {
152 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
153 | }
154 |
155 | - (NSMutableDictionary *)imageURLStorage {
156 | NSMutableDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey);
157 | if (!storage)
158 | {
159 | storage = [NSMutableDictionary dictionary];
160 | objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
161 | }
162 |
163 | return storage;
164 | }
165 |
166 | @end
167 |
168 |
169 | @implementation UIButton (WebCacheDeprecated)
170 |
171 | - (NSURL *)currentImageURL {
172 | return [self sd_currentImageURL];
173 | }
174 |
175 | - (NSURL *)imageURLForState:(UIControlState)state {
176 | return [self sd_imageURLForState:state];
177 | }
178 |
179 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state {
180 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
181 | }
182 |
183 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
184 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
185 | }
186 |
187 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
188 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
189 | }
190 |
191 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock {
192 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
193 | if (completedBlock) {
194 | completedBlock(image, error, cacheType);
195 | }
196 | }];
197 | }
198 |
199 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock {
200 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
201 | if (completedBlock) {
202 | completedBlock(image, error, cacheType);
203 | }
204 | }];
205 | }
206 |
207 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
208 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
209 | if (completedBlock) {
210 | completedBlock(image, error, cacheType);
211 | }
212 | }];
213 | }
214 |
215 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state {
216 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
217 | }
218 |
219 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
220 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
221 | }
222 |
223 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
224 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
225 | }
226 |
227 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock {
228 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
229 | if (completedBlock) {
230 | completedBlock(image, error, cacheType);
231 | }
232 | }];
233 | }
234 |
235 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock {
236 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
237 | if (completedBlock) {
238 | completedBlock(image, error, cacheType);
239 | }
240 | }];
241 | }
242 |
243 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
244 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
245 | if (completedBlock) {
246 | completedBlock(image, error, cacheType);
247 | }
248 | }];
249 | }
250 |
251 | - (void)cancelCurrentImageLoad {
252 | // in a backwards compatible manner, cancel for current state
253 | [self sd_cancelImageLoadForState:self.state];
254 | }
255 |
256 | - (void)cancelBackgroundImageLoadForState:(UIControlState)state {
257 | [self sd_cancelBackgroundImageLoadForState:state];
258 | }
259 |
260 | @end
261 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImage+GIF.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+GIF.h
3 | // LBGIFImage
4 | //
5 | // Created by Laurin Brandner on 06.01.12.
6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (GIF)
12 |
13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name;
14 |
15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data;
16 |
17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImage+GIF.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+GIF.m
3 | // LBGIFImage
4 | //
5 | // Created by Laurin Brandner on 06.01.12.
6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import "UIImage+GIF.h"
10 | #import
11 |
12 | @implementation UIImage (GIF)
13 |
14 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data {
15 | if (!data) {
16 | return nil;
17 | }
18 |
19 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
20 |
21 | size_t count = CGImageSourceGetCount(source);
22 |
23 | UIImage *animatedImage;
24 |
25 | if (count <= 1) {
26 | animatedImage = [[UIImage alloc] initWithData:data];
27 | }
28 | else {
29 | NSMutableArray *images = [NSMutableArray array];
30 |
31 | NSTimeInterval duration = 0.0f;
32 |
33 | for (size_t i = 0; i < count; i++) {
34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL);
35 |
36 | duration += [self sd_frameDurationAtIndex:i source:source];
37 |
38 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]];
39 |
40 | CGImageRelease(image);
41 | }
42 |
43 | if (!duration) {
44 | duration = (1.0f / 10.0f) * count;
45 | }
46 |
47 | animatedImage = [UIImage animatedImageWithImages:images duration:duration];
48 | }
49 |
50 | CFRelease(source);
51 |
52 | return animatedImage;
53 | }
54 |
55 | + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
56 | float frameDuration = 0.1f;
57 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
58 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
59 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary];
60 |
61 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime];
62 | if (delayTimeUnclampedProp) {
63 | frameDuration = [delayTimeUnclampedProp floatValue];
64 | }
65 | else {
66 |
67 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime];
68 | if (delayTimeProp) {
69 | frameDuration = [delayTimeProp floatValue];
70 | }
71 | }
72 |
73 | // Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
74 | // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
75 | // a duration of <= 10 ms. See and
76 | // for more information.
77 |
78 | if (frameDuration < 0.011f) {
79 | frameDuration = 0.100f;
80 | }
81 |
82 | CFRelease(cfFrameProperties);
83 | return frameDuration;
84 | }
85 |
86 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name {
87 | CGFloat scale = [UIScreen mainScreen].scale;
88 |
89 | if (scale > 1.0f) {
90 | NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"];
91 |
92 | NSData *data = [NSData dataWithContentsOfFile:retinaPath];
93 |
94 | if (data) {
95 | return [UIImage sd_animatedGIFWithData:data];
96 | }
97 |
98 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
99 |
100 | data = [NSData dataWithContentsOfFile:path];
101 |
102 | if (data) {
103 | return [UIImage sd_animatedGIFWithData:data];
104 | }
105 |
106 | return [UIImage imageNamed:name];
107 | }
108 | else {
109 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
110 |
111 | NSData *data = [NSData dataWithContentsOfFile:path];
112 |
113 | if (data) {
114 | return [UIImage sd_animatedGIFWithData:data];
115 | }
116 |
117 | return [UIImage imageNamed:name];
118 | }
119 | }
120 |
121 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size {
122 | if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) {
123 | return self;
124 | }
125 |
126 | CGSize scaledSize = size;
127 | CGPoint thumbnailPoint = CGPointZero;
128 |
129 | CGFloat widthFactor = size.width / self.size.width;
130 | CGFloat heightFactor = size.height / self.size.height;
131 | CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor;
132 | scaledSize.width = self.size.width * scaleFactor;
133 | scaledSize.height = self.size.height * scaleFactor;
134 |
135 | if (widthFactor > heightFactor) {
136 | thumbnailPoint.y = (size.height - scaledSize.height) * 0.5;
137 | }
138 | else if (widthFactor < heightFactor) {
139 | thumbnailPoint.x = (size.width - scaledSize.width) * 0.5;
140 | }
141 |
142 | NSMutableArray *scaledImages = [NSMutableArray array];
143 |
144 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
145 |
146 | for (UIImage *image in self.images) {
147 | [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)];
148 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
149 |
150 | [scaledImages addObject:newImage];
151 | }
152 |
153 | UIGraphicsEndImageContext();
154 |
155 | return [UIImage animatedImageWithImages:scaledImages duration:self.duration];
156 | }
157 |
158 | @end
159 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImage+MultiFormat.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+MultiFormat.h
3 | // SDWebImage
4 | //
5 | // Created by Olivier Poitrey on 07/06/13.
6 | // Copyright (c) 2013 Dailymotion. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (MultiFormat)
12 |
13 | + (UIImage *)sd_imageWithData:(NSData *)data;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImage+MultiFormat.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+MultiFormat.m
3 | // SDWebImage
4 | //
5 | // Created by Olivier Poitrey on 07/06/13.
6 | // Copyright (c) 2013 Dailymotion. All rights reserved.
7 | //
8 |
9 | #import "UIImage+MultiFormat.h"
10 | #import "UIImage+GIF.h"
11 | #import "NSData+ImageContentType.h"
12 | #import
13 |
14 | #ifdef SD_WEBP
15 | #import "UIImage+WebP.h"
16 | #endif
17 |
18 | @implementation UIImage (MultiFormat)
19 |
20 | + (UIImage *)sd_imageWithData:(NSData *)data {
21 | UIImage *image;
22 | NSString *imageContentType = [NSData sd_contentTypeForImageData:data];
23 | if ([imageContentType isEqualToString:@"image/gif"]) {
24 | image = [UIImage sd_animatedGIFWithData:data];
25 | }
26 | #ifdef SD_WEBP
27 | else if ([imageContentType isEqualToString:@"image/webp"])
28 | {
29 | image = [UIImage sd_imageWithWebPData:data];
30 | }
31 | #endif
32 | else {
33 | image = [[UIImage alloc] initWithData:data];
34 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data];
35 | if (orientation != UIImageOrientationUp) {
36 | image = [UIImage imageWithCGImage:image.CGImage
37 | scale:image.scale
38 | orientation:orientation];
39 | }
40 | }
41 |
42 |
43 | return image;
44 | }
45 |
46 |
47 | +(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData {
48 | UIImageOrientation result = UIImageOrientationUp;
49 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
50 | if (imageSource) {
51 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
52 | if (properties) {
53 | CFTypeRef val;
54 | int exifOrientation;
55 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);
56 | if (val) {
57 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation);
58 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation];
59 | } // else - if it's not set it remains at up
60 | CFRelease((CFTypeRef) properties);
61 | } else {
62 | //NSLog(@"NO PROPERTIES, FAIL");
63 | }
64 | CFRelease(imageSource);
65 | }
66 | return result;
67 | }
68 |
69 | #pragma mark EXIF orientation tag converter
70 | // Convert an EXIF image orientation to an iOS one.
71 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html
72 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation {
73 | UIImageOrientation orientation = UIImageOrientationUp;
74 | switch (exifOrientation) {
75 | case 1:
76 | orientation = UIImageOrientationUp;
77 | break;
78 |
79 | case 3:
80 | orientation = UIImageOrientationDown;
81 | break;
82 |
83 | case 8:
84 | orientation = UIImageOrientationLeft;
85 | break;
86 |
87 | case 6:
88 | orientation = UIImageOrientationRight;
89 | break;
90 |
91 | case 2:
92 | orientation = UIImageOrientationUpMirrored;
93 | break;
94 |
95 | case 4:
96 | orientation = UIImageOrientationDownMirrored;
97 | break;
98 |
99 | case 5:
100 | orientation = UIImageOrientationLeftMirrored;
101 | break;
102 |
103 | case 7:
104 | orientation = UIImageOrientationRightMirrored;
105 | break;
106 | default:
107 | break;
108 | }
109 | return orientation;
110 | }
111 |
112 |
113 |
114 | @end
115 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImageView+HighlightedWebCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageCompat.h"
11 | #import "SDWebImageManager.h"
12 |
13 | /**
14 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state.
15 | */
16 | @interface UIImageView (HighlightedWebCache)
17 |
18 | /**
19 | * Set the imageView `highlightedImage` with an `url`.
20 | *
21 | * The download is asynchronous and cached.
22 | *
23 | * @param url The url for the image.
24 | */
25 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url;
26 |
27 | /**
28 | * Set the imageView `highlightedImage` with an `url` and custom options.
29 | *
30 | * The download is asynchronous and cached.
31 | *
32 | * @param url The url for the image.
33 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
34 | */
35 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options;
36 |
37 | /**
38 | * Set the imageView `highlightedImage` with an `url`.
39 | *
40 | * The download is asynchronous and cached.
41 | *
42 | * @param url The url for the image.
43 | * @param completedBlock A block called when operation has been completed. This block has no return value
44 | * and takes the requested UIImage as first parameter. In case of error the image parameter
45 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
46 | * indicating if the image was retrived from the local cache or from the network.
47 | * The fourth parameter is the original image url.
48 | */
49 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock;
50 |
51 | /**
52 | * Set the imageView `highlightedImage` with an `url` and custom options.
53 | *
54 | * The download is asynchronous and cached.
55 | *
56 | * @param url The url for the image.
57 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
58 | * @param completedBlock A block called when operation has been completed. This block has no return value
59 | * and takes the requested UIImage as first parameter. In case of error the image parameter
60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
61 | * indicating if the image was retrived from the local cache or from the network.
62 | * The fourth parameter is the original image url.
63 | */
64 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
65 |
66 | /**
67 | * Set the imageView `highlightedImage` with an `url` and custom options.
68 | *
69 | * The download is asynchronous and cached.
70 | *
71 | * @param url The url for the image.
72 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
73 | * @param progressBlock A block called while image is downloading
74 | * @param completedBlock A block called when operation has been completed. This block has no return value
75 | * and takes the requested UIImage as first parameter. In case of error the image parameter
76 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
77 | * indicating if the image was retrived from the local cache or from the network.
78 | * The fourth parameter is the original image url.
79 | */
80 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
81 |
82 | /**
83 | * Cancel the current download
84 | */
85 | - (void)sd_cancelCurrentHighlightedImageLoad;
86 |
87 | @end
88 |
89 |
90 | @interface UIImageView (HighlightedWebCacheDeprecated)
91 |
92 | - (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`");
93 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`");
94 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`");
95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`");
96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`");
97 |
98 | - (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`");
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImageView+HighlightedWebCache.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIImageView+HighlightedWebCache.h"
10 | #import "UIView+WebCacheOperation.h"
11 |
12 | #define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage"
13 |
14 | @implementation UIImageView (HighlightedWebCache)
15 |
16 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url {
17 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil];
18 | }
19 |
20 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options {
21 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil];
22 | }
23 |
24 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock {
25 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock];
26 | }
27 |
28 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
29 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock];
30 | }
31 |
32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
33 | [self sd_cancelCurrentHighlightedImageLoad];
34 |
35 | if (url) {
36 | __weak UIImageView *wself = self;
37 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
38 | if (!wself) return;
39 | dispatch_main_sync_safe (^
40 | {
41 | if (!wself) return;
42 | if (image) {
43 | wself.highlightedImage = image;
44 | [wself setNeedsLayout];
45 | }
46 | if (completedBlock && finished) {
47 | completedBlock(image, error, cacheType, url);
48 | }
49 | });
50 | }];
51 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey];
52 | } else {
53 | dispatch_main_async_safe(^{
54 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
55 | if (completedBlock) {
56 | completedBlock(nil, error, SDImageCacheTypeNone, url);
57 | }
58 | });
59 | }
60 | }
61 |
62 | - (void)sd_cancelCurrentHighlightedImageLoad {
63 | [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey];
64 | }
65 |
66 | @end
67 |
68 |
69 | @implementation UIImageView (HighlightedWebCacheDeprecated)
70 |
71 | - (void)setHighlightedImageWithURL:(NSURL *)url {
72 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil];
73 | }
74 |
75 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options {
76 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil];
77 | }
78 |
79 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock {
80 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
81 | if (completedBlock) {
82 | completedBlock(image, error, cacheType);
83 | }
84 | }];
85 | }
86 |
87 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
88 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
89 | if (completedBlock) {
90 | completedBlock(image, error, cacheType);
91 | }
92 | }];
93 | }
94 |
95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock {
96 | [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
97 | if (completedBlock) {
98 | completedBlock(image, error, cacheType);
99 | }
100 | }];
101 | }
102 |
103 | - (void)cancelCurrentHighlightedImageLoad {
104 | [self sd_cancelCurrentHighlightedImageLoad];
105 | }
106 |
107 | @end
108 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImageView+WebCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageCompat.h"
10 | #import "SDWebImageManager.h"
11 |
12 | /**
13 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView.
14 | *
15 | * Usage with a UITableViewCell sub-class:
16 | *
17 | * @code
18 |
19 | #import
20 |
21 | ...
22 |
23 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
24 | {
25 | static NSString *MyIdentifier = @"MyIdentifier";
26 |
27 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
28 |
29 | if (cell == nil) {
30 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]
31 | autorelease];
32 | }
33 |
34 | // Here we use the provided sd_setImageWithURL: method to load the web image
35 | // Ensure you use a placeholder image otherwise cells will be initialized with no image
36 | [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
37 | placeholderImage:[UIImage imageNamed:@"placeholder"]];
38 |
39 | cell.textLabel.text = @"My Text";
40 | return cell;
41 | }
42 |
43 | * @endcode
44 | */
45 | @interface UIImageView (WebCache)
46 |
47 | /**
48 | * Get the current image URL.
49 | *
50 | * Note that because of the limitations of categories this property can get out of sync
51 | * if you use sd_setImage: directly.
52 | */
53 | - (NSURL *)sd_imageURL;
54 |
55 | /**
56 | * Set the imageView `image` with an `url`.
57 | *
58 | * The download is asynchronous and cached.
59 | *
60 | * @param url The url for the image.
61 | */
62 | - (void)sd_setImageWithURL:(NSURL *)url;
63 |
64 | /**
65 | * Set the imageView `image` with an `url` and a placeholder.
66 | *
67 | * The download is asynchronous and cached.
68 | *
69 | * @param url The url for the image.
70 | * @param placeholder The image to be set initially, until the image request finishes.
71 | * @see sd_setImageWithURL:placeholderImage:options:
72 | */
73 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder;
74 |
75 | /**
76 | * Set the imageView `image` with an `url`, placeholder and custom options.
77 | *
78 | * The download is asynchronous and cached.
79 | *
80 | * @param url The url for the image.
81 | * @param placeholder The image to be set initially, until the image request finishes.
82 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
83 | */
84 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;
85 |
86 | /**
87 | * Set the imageView `image` with an `url`.
88 | *
89 | * The download is asynchronous and cached.
90 | *
91 | * @param url The url for the image.
92 | * @param completedBlock A block called when operation has been completed. This block has no return value
93 | * and takes the requested UIImage as first parameter. In case of error the image parameter
94 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
95 | * indicating if the image was retrived from the local cache or from the network.
96 | * The fourth parameter is the original image url.
97 | */
98 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock;
99 |
100 | /**
101 | * Set the imageView `image` with an `url`, placeholder.
102 | *
103 | * The download is asynchronous and cached.
104 | *
105 | * @param url The url for the image.
106 | * @param placeholder The image to be set initially, until the image request finishes.
107 | * @param completedBlock A block called when operation has been completed. This block has no return value
108 | * and takes the requested UIImage as first parameter. In case of error the image parameter
109 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
110 | * indicating if the image was retrived from the local cache or from the network.
111 | * The fourth parameter is the original image url.
112 | */
113 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock;
114 |
115 | /**
116 | * Set the imageView `image` with an `url`, placeholder and custom options.
117 | *
118 | * The download is asynchronous and cached.
119 | *
120 | * @param url The url for the image.
121 | * @param placeholder The image to be set initially, until the image request finishes.
122 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
123 | * @param completedBlock A block called when operation has been completed. This block has no return value
124 | * and takes the requested UIImage as first parameter. In case of error the image parameter
125 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
126 | * indicating if the image was retrived from the local cache or from the network.
127 | * The fourth parameter is the original image url.
128 | */
129 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
130 |
131 | /**
132 | * Set the imageView `image` with an `url`, placeholder and custom options.
133 | *
134 | * The download is asynchronous and cached.
135 | *
136 | * @param url The url for the image.
137 | * @param placeholder The image to be set initially, until the image request finishes.
138 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
139 | * @param progressBlock A block called while image is downloading
140 | * @param completedBlock A block called when operation has been completed. This block has no return value
141 | * and takes the requested UIImage as first parameter. In case of error the image parameter
142 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
143 | * indicating if the image was retrived from the local cache or from the network.
144 | * The fourth parameter is the original image url.
145 | */
146 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
147 |
148 | /**
149 | * Set the imageView `image` with an `url` and a optionaly placeholder image.
150 | *
151 | * The download is asynchronous and cached.
152 | *
153 | * @param url The url for the image.
154 | * @param placeholder The image to be set initially, until the image request finishes.
155 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
156 | * @param progressBlock A block called while image is downloading
157 | * @param completedBlock A block called when operation has been completed. This block has no return value
158 | * and takes the requested UIImage as first parameter. In case of error the image parameter
159 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
160 | * indicating if the image was retrived from the local cache or from the network.
161 | * The fourth parameter is the original image url.
162 | */
163 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
164 |
165 | /**
166 | * Download an array of images and starts them in an animation loop
167 | *
168 | * @param arrayOfURLs An array of NSURL
169 | */
170 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs;
171 |
172 | /**
173 | * Cancel the current download
174 | */
175 | - (void)sd_cancelCurrentImageLoad;
176 |
177 | - (void)sd_cancelCurrentAnimationImagesLoad;
178 |
179 | @end
180 |
181 |
182 | @interface UIImageView (WebCacheDeprecated)
183 |
184 | - (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`");
185 |
186 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`");
187 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`");
188 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`");
189 |
190 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`");
191 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`");
192 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`");
193 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`");
194 |
195 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`");
196 |
197 | - (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`");
198 |
199 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`");
200 |
201 | @end
202 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIImageView+WebCache.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIImageView+WebCache.h"
10 | #import "objc/runtime.h"
11 | #import "UIView+WebCacheOperation.h"
12 |
13 | static char imageURLKey;
14 |
15 | @implementation UIImageView (WebCache)
16 |
17 | - (void)sd_setImageWithURL:(NSURL *)url {
18 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
19 | }
20 |
21 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder {
22 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
23 | }
24 |
25 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
26 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil];
27 | }
28 |
29 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock {
30 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock];
31 | }
32 |
33 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock {
34 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock];
35 | }
36 |
37 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
38 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
39 | }
40 |
41 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
42 | [self sd_cancelCurrentImageLoad];
43 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
44 |
45 | if (!(options & SDWebImageDelayPlaceholder)) {
46 | dispatch_main_async_safe(^{
47 | self.image = placeholder;
48 | });
49 | }
50 |
51 | if (url) {
52 | __weak UIImageView *wself = self;
53 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
54 | if (!wself) return;
55 | dispatch_main_sync_safe(^{
56 | if (!wself) return;
57 | if (image) {
58 | wself.image = image;
59 | [wself setNeedsLayout];
60 | } else {
61 | if ((options & SDWebImageDelayPlaceholder)) {
62 | wself.image = placeholder;
63 | [wself setNeedsLayout];
64 | }
65 | }
66 | if (completedBlock && finished) {
67 | completedBlock(image, error, cacheType, url);
68 | }
69 | });
70 | }];
71 | [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"];
72 | } else {
73 | dispatch_main_async_safe(^{
74 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
75 | if (completedBlock) {
76 | completedBlock(nil, error, SDImageCacheTypeNone, url);
77 | }
78 | });
79 | }
80 | }
81 |
82 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
83 | NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url];
84 | UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key];
85 |
86 | [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock];
87 | }
88 |
89 | - (NSURL *)sd_imageURL {
90 | return objc_getAssociatedObject(self, &imageURLKey);
91 | }
92 |
93 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
94 | [self sd_cancelCurrentAnimationImagesLoad];
95 | __weak UIImageView *wself = self;
96 |
97 | NSMutableArray *operationsArray = [[NSMutableArray alloc] init];
98 |
99 | for (NSURL *logoImageURL in arrayOfURLs) {
100 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
101 | if (!wself) return;
102 | dispatch_main_sync_safe(^{
103 | __strong UIImageView *sself = wself;
104 | [sself stopAnimating];
105 | if (sself && image) {
106 | NSMutableArray *currentImages = [[sself animationImages] mutableCopy];
107 | if (!currentImages) {
108 | currentImages = [[NSMutableArray alloc] init];
109 | }
110 | [currentImages addObject:image];
111 |
112 | sself.animationImages = currentImages;
113 | [sself setNeedsLayout];
114 | }
115 | [sself startAnimating];
116 | });
117 | }];
118 | [operationsArray addObject:operation];
119 | }
120 |
121 | [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"];
122 | }
123 |
124 | - (void)sd_cancelCurrentImageLoad {
125 | [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"];
126 | }
127 |
128 | - (void)sd_cancelCurrentAnimationImagesLoad {
129 | [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"];
130 | }
131 |
132 | @end
133 |
134 |
135 | @implementation UIImageView (WebCacheDeprecated)
136 |
137 | - (NSURL *)imageURL {
138 | return [self sd_imageURL];
139 | }
140 |
141 | - (void)setImageWithURL:(NSURL *)url {
142 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
143 | }
144 |
145 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder {
146 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
147 | }
148 |
149 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
150 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil];
151 | }
152 |
153 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock {
154 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
155 | if (completedBlock) {
156 | completedBlock(image, error, cacheType);
157 | }
158 | }];
159 | }
160 |
161 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock {
162 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
163 | if (completedBlock) {
164 | completedBlock(image, error, cacheType);
165 | }
166 | }];
167 | }
168 |
169 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
170 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
171 | if (completedBlock) {
172 | completedBlock(image, error, cacheType);
173 | }
174 | }];
175 | }
176 |
177 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock {
178 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
179 | if (completedBlock) {
180 | completedBlock(image, error, cacheType);
181 | }
182 | }];
183 | }
184 |
185 | - (void)cancelCurrentArrayLoad {
186 | [self sd_cancelCurrentAnimationImagesLoad];
187 | }
188 |
189 | - (void)cancelCurrentImageLoad {
190 | [self sd_cancelCurrentImageLoad];
191 | }
192 |
193 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
194 | [self sd_setAnimationImagesWithURLs:arrayOfURLs];
195 | }
196 |
197 | @end
198 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIView+WebCacheOperation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageManager.h"
11 |
12 | @interface UIView (WebCacheOperation)
13 |
14 | /**
15 | * Set the image load operation (storage in a UIView based dictionary)
16 | *
17 | * @param operation the operation
18 | * @param key key for storing the operation
19 | */
20 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key;
21 |
22 | /**
23 | * Cancel all operations for the current UIView and key
24 | *
25 | * @param key key for identifying the operations
26 | */
27 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key;
28 |
29 | /**
30 | * Just remove the operations corresponding to the current UIView and key without cancelling them
31 | *
32 | * @param key key for identifying the operations
33 | */
34 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/Vendor/SDWebImage/UIView+WebCacheOperation.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIView+WebCacheOperation.h"
10 | #import "objc/runtime.h"
11 |
12 | static char loadOperationKey;
13 |
14 | @implementation UIView (WebCacheOperation)
15 |
16 | - (NSMutableDictionary *)operationDictionary {
17 | NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey);
18 | if (operations) {
19 | return operations;
20 | }
21 | operations = [NSMutableDictionary dictionary];
22 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
23 | return operations;
24 | }
25 |
26 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key {
27 | [self sd_cancelImageLoadOperationWithKey:key];
28 | NSMutableDictionary *operationDictionary = [self operationDictionary];
29 | [operationDictionary setObject:operation forKey:key];
30 | }
31 |
32 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key {
33 | // Cancel in progress downloader from queue
34 | NSMutableDictionary *operationDictionary = [self operationDictionary];
35 | id operations = [operationDictionary objectForKey:key];
36 | if (operations) {
37 | if ([operations isKindOfClass:[NSArray class]]) {
38 | for (id operation in operations) {
39 | if (operation) {
40 | [operation cancel];
41 | }
42 | }
43 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){
44 | [(id) operations cancel];
45 | }
46 | [operationDictionary removeObjectForKey:key];
47 | }
48 | }
49 |
50 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key {
51 | NSMutableDictionary *operationDictionary = [self operationDictionary];
52 | [operationDictionary removeObjectForKey:key];
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // BRMultilevelMeun
4 | //
5 | // Created by gitBurning on 15/4/17.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // BRMultilevelMeun
4 | //
5 | // Created by gitBurning on 15/4/17.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "MultilevelMenu.h"
11 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width
12 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height
13 |
14 | @interface ViewController ()
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 |
23 |
24 | NSMutableArray * lis=[NSMutableArray arrayWithCapacity:0];
25 |
26 |
27 | /**
28 | * 构建需要数据 2层或者3层数据 (ps 2层也当作3层来处理)
29 | */
30 | NSInteger countMax=6;
31 | for (int i=0; i
75 | */
76 | MultilevelMenu * view=[[MultilevelMenu alloc] initWithFrame:CGRectMake(0, 64, kScreenWidth, kScreenHeight-64) WithData:lis withSelectIndex:^(NSInteger left, NSInteger right,rightMeun* info) {
77 |
78 | NSLog(@"点击的 菜单%@",info.meunName);
79 | }];
80 |
81 |
82 | view.needToScorllerIndex=0;
83 |
84 | view.isRecordLastScroll=YES;
85 | [self.view addSubview:view];
86 | // Do any additional setup after loading the view, typically from a nib.
87 | }
88 | -(void)viewWillAppear:(BOOL)animated
89 | {
90 |
91 | }
92 | - (void)didReceiveMemoryWarning {
93 | [super didReceiveMemoryWarning];
94 | // Dispose of any resources that can be recreated.
95 | }
96 |
97 | @end
98 |
--------------------------------------------------------------------------------
/BRMultilevelMeun/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // BRMultilevelMeun
4 | //
5 | // Created by gitBurning on 15/4/17.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/BRMultilevelMeunTests/BRMultilevelMeunTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // BRMultilevelMeunTests.m
3 | // BRMultilevelMeunTests
4 | //
5 | // Created by gitBurning on 15/4/17.
6 | // Copyright (c) 2015年 BR. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface BRMultilevelMeunTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation BRMultilevelMeunTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/BRMultilevelMeunTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | zom.com.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribute
2 |
3 | ## Introduction
4 |
5 | First, thank you for considering contributing to BRMultilevelMeun! It's people like you that make the open source community such a great community! 😊
6 |
7 | We welcome any type of contribution, not only code. You can help with
8 |
9 | - **QA**: file bug reports, the more details you can give the better (e.g. screenshots with the console open)
10 | - **Marketing**: writing blog posts, howto's, printing stickers, ...
11 | - **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
12 | - **Code**: take a look at the [open issues](issues). Even if you can't write code, commenting on them, showing that you care about a given issue matters. It helps us triage them.
13 | - **Money**: we welcome financial contributions in full transparency on our [open collective](https://opencollective.com/BRMultilevelMeun).
14 |
15 | ## Your First Contribution
16 |
17 | Working on your first Pull Request? You can learn how from this _free_ series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
18 |
19 | ## Submitting code
20 |
21 | Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it. The pull request should also contain tests.
22 |
23 | ## Code review process
24 |
25 | The bigger the pull request, the longer it will take to review and merge. Try to break down large pull requests in smaller chunks that are easier to review and merge.
26 | It is also always helpful to have some context for your pull request. What was the purpose? Why does it matter to you?
27 |
28 | ## Financial contributions
29 |
30 | We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/BRMultilevelMeun).
31 | Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed.
32 |
33 | ## Questions
34 |
35 | If you have any questions, create an [issue](issue) (protip: do a quick search first to see if someone else didn't ask the same question before!).
36 | You can also reach us at hello@BRMultilevelMeun.opencollective.com.
37 |
38 | ## Credits
39 |
40 | ### Code Contributors
41 |
42 | This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
43 |
44 |
45 | ### Financial Contributors
46 |
47 | Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/BRMultilevelMeun/contribute)]
48 |
49 | #### Individuals
50 |
51 |
52 |
53 | #### Organizations
54 |
55 | Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/BRMultilevelMeun/contribute)]
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/Menu.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burning-git/BRMultilevelMeun/a77ac594fa4184415baee36a7db2a56fb6b6e61f/Menu.gif
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | BRMultilevelMeun
3 | ###===================
4 | 类似于京东分类效果------多级菜单。左右菜单 分离,同时 提供 记录上一次滑动的痕迹
5 |
6 | ###效果图
7 | 
8 |
9 | ## Contributors
10 |
11 | ### Code Contributors
12 |
13 | This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
14 |
15 |
16 | ### Financial Contributors
17 |
18 | Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/BRMultilevelMeun/contribute)]
19 |
20 | #### Individuals
21 |
22 |
23 |
24 | #### Organizations
25 |
26 | Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/BRMultilevelMeun/contribute)]
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/tempShop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/burning-git/BRMultilevelMeun/a77ac594fa4184415baee36a7db2a56fb6b6e61f/tempShop.png
--------------------------------------------------------------------------------