Skip to content
This repository has been archived by the owner on Sep 4, 2018. It is now read-only.

Commit

Permalink
Keep the packages table view content offset unchanged after reloading…
Browse files Browse the repository at this point in the history
… the packages
  • Loading branch information
guillaumealgis committed Apr 5, 2016
1 parent 0574449 commit c0bd675
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Alcatraz/Controllers/ATZPackageTableViewDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

- (instancetype)initWithPackages:(NSArray*)packages tableViewOwner:(id)owner;

- (void)updatePackages:(NSArray*)packages;

- (void)configureTableView:(NSTableView*)tableView;
- (void)filterUsingPredicate:(NSPredicate*)predicate;

Expand Down
4 changes: 4 additions & 0 deletions Alcatraz/Controllers/ATZPackageTableViewDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ - (instancetype)initWithPackages:(NSArray*)packages tableViewOwner:(id)owner {
return self;
}

- (void)updatePackages:(NSArray*)packages {
_packages = packages;
}

- (void)configureTableView:(NSTableView *)tableView {
NSNib* nib = [[NSNib alloc] initWithNibNamed:NSStringFromClass([ATZPackageListTableCellView class]) bundle:[Alcatraz sharedPlugin].bundle];
[tableView registerNib:nib forIdentifier:packageCellIdentifier];
Expand Down
17 changes: 12 additions & 5 deletions Alcatraz/Controllers/ATZPluginWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,19 @@ - (IBAction)resetPackageRepoPath:(id)sender {
}

- (void)reloadTableView {
self.tableViewDelegate = [[ATZPackageTableViewDelegate alloc] initWithPackages:self.packages tableViewOwner:self];
self.tableView.delegate = self.tableViewDelegate;
self.tableView.dataSource = self.tableViewDelegate;
[self.tableViewDelegate configureTableView:self.tableView];
if (!self.tableViewDelegate) {
self.tableViewDelegate = [[ATZPackageTableViewDelegate alloc] initWithPackages:self.packages
tableViewOwner:self];
self.tableView.delegate = self.tableViewDelegate;
self.tableView.dataSource = self.tableViewDelegate;

[self.tableViewDelegate configureTableView:self.tableView];
}
else {
[self.tableViewDelegate updatePackages:self.packages];
}

[self updatePredicate];
[self.tableView reloadData];
}

#pragma mark - Private
Expand Down

0 comments on commit c0bd675

Please sign in to comment.