|
@@ -286,119 +286,129 @@
|
|
|
#pragma mark - Notification
|
|
#pragma mark - Notification
|
|
|
- (void)OnUpdatePrice: (NSNotification *)notification
|
|
- (void)OnUpdatePrice: (NSNotification *)notification
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- if(self.disable_refresh)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- NSDictionary* dict = [notification userInfo];
|
|
|
|
|
- NSArray* arr= dict[@"receiver"];
|
|
|
|
|
-
|
|
|
|
|
- //如果当前对象不在不是指定接收者,也不是广播通信,就返回。
|
|
|
|
|
- if([arr indexOfObject:[self class_name]]==NSNotFound&& arr.count>0)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- //如果当前对象本身不支持此动作,则返回
|
|
|
|
|
- if(![self respondsToSelector:@selector(refresh_price)])
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- //如果当前已有的处理层级更高(reload),则不处理,交给reload 处理。
|
|
|
|
|
- if(self.notification_refreshLevel<NotificationRefreshLevelView)
|
|
|
|
|
- {
|
|
|
|
|
- if([self isVisible])
|
|
|
|
|
- {
|
|
|
|
|
- [self refresh_price];
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelView;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ if(self.disable_refresh)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* dict = [notification userInfo];
|
|
|
|
|
+ NSArray* arr= dict[@"receiver"];
|
|
|
|
|
+
|
|
|
|
|
+ //如果当前对象不在不是指定接收者,也不是广播通信,就返回。
|
|
|
|
|
+ if([arr indexOfObject:[self class_name]]==NSNotFound&& arr.count>0)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ //如果当前对象本身不支持此动作,则返回
|
|
|
|
|
+ if(![self respondsToSelector:@selector(refresh_price)])
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ //如果当前已有的处理层级更高(reload),则不处理,交给reload 处理。
|
|
|
|
|
+ if(self.notification_refreshLevel<NotificationRefreshLevelView)
|
|
|
|
|
+ {
|
|
|
|
|
+ if([self isVisible])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self refresh_price];
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelView;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)OnRefreshUI: (NSNotification *)notification
|
|
- (void)OnRefreshUI: (NSNotification *)notification
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- if(self.disable_refresh)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- NSDictionary* dict = [notification userInfo];
|
|
|
|
|
- NSArray* arr= dict[@"receiver"];
|
|
|
|
|
- if([arr indexOfObject:[self class_name]]==NSNotFound&& arr.count>0)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if(![self respondsToSelector:@selector(refresh_ui)])
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if(self.notification_refreshLevel<NotificationRefreshLevelView)
|
|
|
|
|
- {
|
|
|
|
|
- if([self isVisible])
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ if(self.disable_refresh)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* dict = [notification userInfo];
|
|
|
|
|
+ NSArray* arr= dict[@"receiver"];
|
|
|
|
|
+ if([arr indexOfObject:[self class_name]]==NSNotFound&& arr.count>0)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ if(![self respondsToSelector:@selector(refresh_ui)])
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ if(self.notification_refreshLevel<NotificationRefreshLevelView)
|
|
|
|
|
+ {
|
|
|
|
|
+ if([self isVisible])
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ [self refresh_ui];
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelView;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- [self refresh_ui];
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelView;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
- (void)OnReloadData: (NSNotification *)notification
|
|
- (void)OnReloadData: (NSNotification *)notification
|
|
|
{
|
|
{
|
|
|
- if(self.disable_refresh)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- NSDictionary* dict = [notification userInfo];
|
|
|
|
|
- NSArray* arr= dict[@"receiver"];
|
|
|
|
|
- if([arr indexOfObject:[self class_name]]==NSNotFound&& arr.count>0)
|
|
|
|
|
- return;
|
|
|
|
|
- if(![self respondsToSelector:@selector(reload_data)])
|
|
|
|
|
- return;
|
|
|
|
|
- if(self.notification_refreshLevel<NotificationRefreshLevelData)
|
|
|
|
|
- {
|
|
|
|
|
- if([self isVisible])
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- [self reload_data];
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelData;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ if(self.disable_refresh)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* dict = [notification userInfo];
|
|
|
|
|
+ NSArray* arr= dict[@"receiver"];
|
|
|
|
|
+ if([arr indexOfObject:[self class_name]]==NSNotFound&& arr.count>0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ if(![self respondsToSelector:@selector(reload_data)])
|
|
|
|
|
+ return;
|
|
|
|
|
+ if(self.notification_refreshLevel<NotificationRefreshLevelData)
|
|
|
|
|
+ {
|
|
|
|
|
+ if([self isVisible])
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ [self reload_data];
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelData;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- (void)OnClearData: (NSNotification *)notification
|
|
- (void)OnClearData: (NSNotification *)notification
|
|
|
{
|
|
{
|
|
|
- if(![self respondsToSelector:@selector(clear_data)])
|
|
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ if(![self respondsToSelector:@selector(clear_data)])
|
|
|
return;
|
|
return;
|
|
|
- if([self isVisible])
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- if([self respondsToSelector:@selector(clear_data)])
|
|
|
|
|
|
|
+ if([self isVisible])
|
|
|
{
|
|
{
|
|
|
- [self clear_data];
|
|
|
|
|
- if([self respondsToSelector:@selector(refresh_ui)])
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if([self respondsToSelector:@selector(clear_data)])
|
|
|
{
|
|
{
|
|
|
- [self refresh_ui];
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
|
|
+ [self clear_data];
|
|
|
|
|
+ if([self respondsToSelector:@selector(refresh_ui)])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self refresh_ui];
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelNone;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- if([self respondsToSelector:@selector(clear_data)])
|
|
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
- [self clear_data];
|
|
|
|
|
- self.notification_refreshLevel = NotificationRefreshLevelView;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if([self respondsToSelector:@selector(clear_data)])
|
|
|
|
|
+ {
|
|
|
|
|
+ [self clear_data];
|
|
|
|
|
+ self.notification_refreshLevel = NotificationRefreshLevelView;
|
|
|
|
|
+ }
|
|
|
|
|
+ }});
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|