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

Refactor file browser

- Rename reload/update methods for clarity
- `updateSearchPaths` will only refresh the table as new results come in, instead of right away which would result in the table showing 0 items while results were being gathered
Tanner Bennett лет назад: 7
Родитель
Сommit
462b38a473
1 измененных файлов с 9 добавлено и 9 удалено
  1. 9 9
      Classes/GlobalStateExplorers/FLEXFileBrowserTableViewController.m

+ 9 - 9
Classes/GlobalStateExplorers/FLEXFileBrowserTableViewController.m

@@ -71,7 +71,7 @@
             });
             });
         });
         });
 
 
-        [self reloadChildPaths];
+        [self reloadCurrentPath];
     }
     }
     return self;
     return self;
 }
 }
@@ -113,11 +113,10 @@
 - (void)willDismissSearchController:(UISearchController *)searchController
 - (void)willDismissSearchController:(UISearchController *)searchController
 {
 {
     [self.operationQueue cancelAllOperations];
     [self.operationQueue cancelAllOperations];
-    [self reloadChildPaths];
+    [self reloadCurrentPath];
     [self.tableView reloadData];
     [self.tableView reloadData];
 }
 }
 
 
-
 #pragma mark - Table view data source
 #pragma mark - Table view data source
 
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
@@ -349,14 +348,14 @@
 - (void)reloadDisplayedPaths
 - (void)reloadDisplayedPaths
 {
 {
     if (self.searchController.isActive) {
     if (self.searchController.isActive) {
-        [self reloadSearchPaths];
+        [self updateSearchPaths];
     } else {
     } else {
-        [self reloadChildPaths];
+        [self reloadCurrentPath];
+        [self.tableView reloadData];
     }
     }
-    [self.tableView reloadData];
 }
 }
 
 
-- (void)reloadChildPaths
+- (void)reloadCurrentPath
 {
 {
     NSMutableArray<NSString *> *childPaths = [NSMutableArray array];
     NSMutableArray<NSString *> *childPaths = [NSMutableArray array];
     NSArray<NSString *> *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.path error:NULL];
     NSArray<NSString *> *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.path error:NULL];
@@ -366,7 +365,7 @@
     self.childPaths = childPaths;
     self.childPaths = childPaths;
 }
 }
 
 
-- (void)reloadSearchPaths
+- (void)updateSearchPaths
 {
 {
     self.searchPaths = nil;
     self.searchPaths = nil;
     self.searchPathsSize = nil;
     self.searchPathsSize = nil;
@@ -388,7 +387,8 @@
 
 
 @implementation FLEXFileBrowserTableViewCell
 @implementation FLEXFileBrowserTableViewCell
 
 
-- (void)forwardAction:(SEL)action withSender:(id)sender {
+- (void)forwardAction:(SEL)action withSender:(id)sender
+{
     id target = [self.nextResponder targetForAction:action withSender:sender];
     id target = [self.nextResponder targetForAction:action withSender:sender];
     [[UIApplication sharedApplication] sendAction:action to:target from:self forEvent:nil];
     [[UIApplication sharedApplication] sendAction:action to:target from:self forEvent:nil];
 }
 }