mirror of https://github.com/opa334/TrollStore.git
Performance fixes
This commit is contained in:
parent
b766a8586f
commit
55437694e3
|
@ -1,5 +1,9 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TSAppTableViewController : UITableViewController
|
||||
{
|
||||
UIImage* _placeholderIcon;
|
||||
NSArray* _cachedAppPaths;
|
||||
}
|
||||
|
||||
@end
|
|
@ -8,8 +8,25 @@
|
|||
|
||||
@implementation TSAppTableViewController
|
||||
|
||||
- (void)loadCachedAppPaths
|
||||
{
|
||||
_cachedAppPaths = [[TSApplicationsManager sharedInstance] installedAppPaths];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if(self)
|
||||
{
|
||||
[self loadCachedAppPaths];
|
||||
_placeholderIcon = [UIImage _applicationIconImageForBundleIdentifier:@"com.apple.WebSheet" format:10 scale:[UIScreen mainScreen].scale];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)reloadTable
|
||||
{
|
||||
[self loadCachedAppPaths];
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self.tableView reloadData];
|
||||
|
@ -43,7 +60,7 @@
|
|||
{
|
||||
TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance];
|
||||
|
||||
NSString* appPath = [appsManager installedAppPaths][indexPath.row];
|
||||
NSString* appPath = _cachedAppPaths[indexPath.row];
|
||||
NSString* appId = [appsManager appIdForAppPath:appPath];
|
||||
BOOL didOpen = [appsManager openApplicationWithBundleID:appId];
|
||||
|
||||
|
@ -62,7 +79,7 @@
|
|||
{
|
||||
TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance];
|
||||
|
||||
NSString* appPath = [appsManager installedAppPaths][indexPath.row];
|
||||
NSString* appPath = _cachedAppPaths[indexPath.row];
|
||||
NSString* appId = [appsManager appIdForAppPath:appPath];
|
||||
NSString* appName = [appsManager displayNameForAppPath:appPath];
|
||||
|
||||
|
@ -99,7 +116,7 @@
|
|||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return [[TSApplicationsManager sharedInstance] installedAppPaths].count;
|
||||
return _cachedAppPaths.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
@ -108,18 +125,30 @@
|
|||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"ApplicationCell"];
|
||||
}
|
||||
|
||||
NSString* appPath = [[TSApplicationsManager sharedInstance] installedAppPaths][indexPath.row];
|
||||
NSString* appPath = _cachedAppPaths[indexPath.row];
|
||||
NSString* appId = [[TSApplicationsManager sharedInstance] appIdForAppPath:appPath];
|
||||
NSString* appVersion = [[TSApplicationsManager sharedInstance] versionStringForAppPath:appPath];
|
||||
|
||||
// Configure the cell...
|
||||
cell.textLabel.text = [[TSApplicationsManager sharedInstance] displayNameForAppPath:appPath];
|
||||
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ • %@", appVersion, appId];
|
||||
cell.imageView.image = [UIImage _applicationIconImageForBundleIdentifier:appId format:10 scale:[UIScreen mainScreen].scale];
|
||||
cell.imageView.image = _placeholderIcon;
|
||||
cell.imageView.layer.borderWidth = 0.2;
|
||||
cell.imageView.layer.borderColor = [UIColor blackColor].CGColor;
|
||||
cell.imageView.layer.cornerRadius = 13.8;
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
|
||||
{
|
||||
//usleep(1000 * 5000); // (test delay for debugging)
|
||||
UIImage* iconImage = [UIImage _applicationIconImageForBundleIdentifier:appId format:10 scale:[UIScreen mainScreen].scale];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if([tableView.indexPathsForVisibleRows containsObject:indexPath])
|
||||
{
|
||||
cell.imageView.image = iconImage;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
cell.preservesSuperviewLayoutMargins = NO;
|
||||
cell.separatorInset = UIEdgeInsetsZero;
|
||||
cell.layoutMargins = UIEdgeInsetsZero;
|
||||
|
@ -143,7 +172,7 @@
|
|||
{
|
||||
TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance];
|
||||
|
||||
NSString* appPath = [appsManager installedAppPaths][indexPath.row];
|
||||
NSString* appPath = _cachedAppPaths[indexPath.row];
|
||||
NSString* appId = [appsManager appIdForAppPath:appPath];
|
||||
NSString* appName = [appsManager displayNameForAppPath:appPath];
|
||||
|
||||
|
@ -164,6 +193,7 @@
|
|||
UIAlertAction* openAction = [UIAlertAction actionWithTitle: @"Open" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
[self openAppPressedForRowAtIndexPath:indexPath];
|
||||
[self deselectRow];
|
||||
}];
|
||||
[appSelectAlert addAction: openAction];
|
||||
|
||||
|
|
|
@ -42,8 +42,10 @@
|
|||
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
NSLog(@"1");
|
||||
[infoAlert dismissViewControllerAnimated:YES completion:^
|
||||
{
|
||||
NSLog(@"2");
|
||||
if(ret != 0)
|
||||
{
|
||||
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Install Error %d", ret] message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
|
Loading…
Reference in New Issue