Просмотр исходного кода

ERP MOBILE增加登出后清空search 结果
修复通知执行线程错误的bug

Ray Zhang 7 лет назад
Родитель
Сommit
a7fbda63ff

+ 103 - 93
RedAnt ERP Mobile/common/ActiveViewController.m

@@ -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;
+            }
+        }});
+    
+
 
 
     
     
 }
 }

+ 8 - 0
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -2301,6 +2301,14 @@
     [self.collectionview reloadData];
     [self.collectionview reloadData];
 }
 }
 #pragma mark - RA_NOTIFICAITON
 #pragma mark - RA_NOTIFICAITON
+-(void) clear_data
+{
+    self.category_data = nil;
+    self.offset = 0;
+    self.keywords = nil;
+    self.searchBar.text = nil;
+    [self.collectionview reloadData];
+}
 -(void) refresh_ui
 -(void) refresh_ui
 {
 {
     [self.collectionview reloadData];
     [self.collectionview reloadData];

BIN
Redant Drivers/Redant Drivers.xcworkspace/xcuserdata/ray.xcuserdatad/UserInterfaceState.xcuserstate