mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-22 11:03:21 -04:00
Global Queue Refactor
This commit is contained in:
parent
4cc59ab187
commit
01fe39afda
@ -83,7 +83,6 @@
|
||||
978C58A21C1CFD850077AE47 /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C58A11C1CFD850077AE47 /* Reachability.swift */; };
|
||||
978C58AD1C1CFF700077AE47 /* PreferenceLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C58AC1C1CFF700077AE47 /* PreferenceLibrary.swift */; };
|
||||
978C58AF1C1CFFE30077AE47 /* SwiftyUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C58AE1C1CFFE30077AE47 /* SwiftyUserDefaults.swift */; };
|
||||
978C58B11C1E02970077AE47 /* AppDelegateObjs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 978C58B01C1E02970077AE47 /* AppDelegateObjs.swift */; };
|
||||
97999D891C52D27D003CAFF3 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97999D881C52D27D003CAFF3 /* SearchBar.swift */; };
|
||||
97A2AB8C1C1B80FF00052E74 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A2AB8B1C1B80FF00052E74 /* AppDelegate.swift */; };
|
||||
97A2AB941C1B80FF00052E74 /* Kiwix.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 97A2AB921C1B80FF00052E74 /* Kiwix.xcdatamodeld */; };
|
||||
@ -104,7 +103,6 @@
|
||||
97CCC4E81C1F0D970041DAEE /* BarButtonItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97CCC4E71C1F0D970041DAEE /* BarButtonItems.swift */; };
|
||||
97DA06C71CB6DA3400EBA609 /* LibraryLocalBookDetailTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DA06C61CB6DA3400EBA609 /* LibraryLocalBookDetailTBVC.swift */; };
|
||||
97DF23551CE807A1003E1E5A /* GlobalOperationQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DF23541CE807A1003E1E5A /* GlobalOperationQueue.swift */; };
|
||||
97DF23571CE8083C003E1E5A /* LibraryScanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DF23561CE8083C003E1E5A /* LibraryScanOperation.swift */; };
|
||||
97E067241C52980F0079C13C /* MainVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E067231C52980F0079C13C /* MainVC.swift */; };
|
||||
97E067261C52AA000079C13C /* MainVCWebViewD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E067251C52AA000079C13C /* MainVCWebViewD.swift */; };
|
||||
97E067281C52AC360079C13C /* MainVCOtherD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E067271C52AC360079C13C /* MainVCOtherD.swift */; };
|
||||
@ -266,7 +264,6 @@
|
||||
978C58A11C1CFD850077AE47 /* Reachability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
|
||||
978C58AC1C1CFF700077AE47 /* PreferenceLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferenceLibrary.swift; sourceTree = "<group>"; };
|
||||
978C58AE1C1CFFE30077AE47 /* SwiftyUserDefaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyUserDefaults.swift; sourceTree = "<group>"; };
|
||||
978C58B01C1E02970077AE47 /* AppDelegateObjs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegateObjs.swift; sourceTree = "<group>"; };
|
||||
97999D881C52D27D003CAFF3 /* SearchBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
|
||||
97A2AB881C1B80FF00052E74 /* Kiwix.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Kiwix.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97A2AB8B1C1B80FF00052E74 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = AppDelegate.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||
@ -292,7 +289,6 @@
|
||||
97CCC4E71C1F0D970041DAEE /* BarButtonItems.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarButtonItems.swift; sourceTree = "<group>"; };
|
||||
97DA06C61CB6DA3400EBA609 /* LibraryLocalBookDetailTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryLocalBookDetailTBVC.swift; sourceTree = "<group>"; };
|
||||
97DF23541CE807A1003E1E5A /* GlobalOperationQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GlobalOperationQueue.swift; sourceTree = "<group>"; };
|
||||
97DF23561CE8083C003E1E5A /* LibraryScanOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryScanOperation.swift; sourceTree = "<group>"; };
|
||||
97E067231C52980F0079C13C /* MainVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainVC.swift; sourceTree = "<group>"; };
|
||||
97E067251C52AA000079C13C /* MainVCWebViewD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainVCWebViewD.swift; sourceTree = "<group>"; };
|
||||
97E067271C52AC360079C13C /* MainVCOtherD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainVCOtherD.swift; sourceTree = "<group>"; };
|
||||
@ -696,7 +692,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97A2AB8B1C1B80FF00052E74 /* AppDelegate.swift */,
|
||||
978C58B01C1E02970077AE47 /* AppDelegateObjs.swift */,
|
||||
978C587A1C1CCC9C0077AE47 /* Storyboards */,
|
||||
978C58821C1CCDAF0077AE47 /* Controllers */,
|
||||
977998821C1E2A5C00B1DD5E /* View */,
|
||||
@ -830,7 +825,6 @@
|
||||
970103F91C6824FA00DC48F6 /* RefreshLibraryOperation.swift */,
|
||||
97B50C7E1CA1E4810010BD79 /* UIOperations.swift */,
|
||||
973970EC1CB9A04C00350507 /* SearchOperation.swift */,
|
||||
97DF23561CE8083C003E1E5A /* LibraryScanOperation.swift */,
|
||||
);
|
||||
name = Operation;
|
||||
sourceTree = "<group>";
|
||||
@ -1147,7 +1141,6 @@
|
||||
9714D8D71C6E5C2600AABCA7 /* LTBarButtonItem.swift in Sources */,
|
||||
97E571221CA0500400FF4F1D /* ReachabilityCondition.swift in Sources */,
|
||||
97E570FE1CA0500400FF4F1D /* BlockOperation.swift in Sources */,
|
||||
97DF23571CE8083C003E1E5A /* LibraryScanOperation.swift in Sources */,
|
||||
973381631C331D660016CEFB /* ArticleCells.swift in Sources */,
|
||||
97E571211CA0500400FF4F1D /* PushCapability-OSX.swift in Sources */,
|
||||
97E571241CA0500400FF4F1D /* SilentCondition.swift in Sources */,
|
||||
@ -1167,7 +1160,6 @@
|
||||
97A7140A1C274FCB00951244 /* DirectoryMonitor.swift in Sources */,
|
||||
978C58841C1CCE4D0077AE47 /* LanguageTBVC.swift in Sources */,
|
||||
97E571071CA0500400FF4F1D /* GroupOperation.swift in Sources */,
|
||||
978C58B11C1E02970077AE47 /* AppDelegateObjs.swift in Sources */,
|
||||
97E5711E1CA0500400FF4F1D /* PhotosCapability.swift in Sources */,
|
||||
97E5711C1CA0500400FF4F1D /* PassbookCapability.swift in Sources */,
|
||||
97E5710D1CA0500400FF4F1D /* LocationCapability-OSX.swift in Sources */,
|
||||
|
@ -12,15 +12,10 @@ import CoreData
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate, OperationQueueDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
let globalOperationQueue = OperationQueue()
|
||||
|
||||
func recordActiveSession() {
|
||||
Preference.activeUseHistory.append(NSDate())
|
||||
}
|
||||
|
||||
func operationQueue(operationQueue: OperationQueue, operationDidFinish operation: NSOperation, withErrors errors: [NSError]) {
|
||||
print(globalOperationQueue.operationCount)
|
||||
}
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
NSURLProtocol.registerClass(KiwixURLProtocol)
|
||||
@ -40,8 +35,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, OperationQueueDelegate {
|
||||
func applicationWillResignActive(application: UIApplication) {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
UIApplication.updateApplicationIconBadgeNumber()
|
||||
// UIApplication.updateApplicationIconBadgeNumber()
|
||||
}
|
||||
|
||||
// class func updateApplicationIconBadgeNumber() {
|
||||
// guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else {return}
|
||||
// guard settings.types.contains(UIUserNotificationType.Badge) else {return}
|
||||
// //UIApplication.sharedApplication().applicationIconBadgeNumber = downloader.taskCount ?? 0
|
||||
// }
|
||||
|
||||
func applicationDidEnterBackground(application: UIApplication) {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
|
@ -1,25 +0,0 @@
|
||||
//
|
||||
// AppDelegateObjs.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris on 12/13/15.
|
||||
// Copyright © 2015 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIApplication {
|
||||
|
||||
// MARK: - Class Accessor
|
||||
|
||||
class var globalOperationQueue: OperationQueue {
|
||||
get {return appDelegate.globalOperationQueue}
|
||||
}
|
||||
|
||||
class func updateApplicationIconBadgeNumber() {
|
||||
guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() else {return}
|
||||
guard settings.types.contains(UIUserNotificationType.Badge) else {return}
|
||||
//UIApplication.sharedApplication().applicationIconBadgeNumber = downloader.taskCount ?? 0
|
||||
}
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ class LanguageTBVC: UITableViewController, NSFetchedResultsControllerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func sortByCountDesc(var languages: [Language]) -> [Language] {
|
||||
languages.sortInPlace { (language1, language2) -> Bool in
|
||||
func sortByCountDesc(languages: [Language]) -> [Language] {
|
||||
return languages.sort { (language1, language2) -> Bool in
|
||||
guard let count1 = language1.books?.count else {return false}
|
||||
guard let count2 = language2.books?.count else {return false}
|
||||
if count1 == count2 {
|
||||
@ -71,7 +71,6 @@ class LanguageTBVC: UITableViewController, NSFetchedResultsControllerDelegate {
|
||||
return count1 > count2
|
||||
}
|
||||
}
|
||||
return languages
|
||||
}
|
||||
|
||||
// MARK: - Table view data source
|
||||
|
@ -112,7 +112,7 @@ class LibraryLocalTBVC: UITableViewController, NSFetchedResultsControllerDelegat
|
||||
|
||||
func emptyDataSetDidTapButton(scrollView: UIScrollView!) {
|
||||
let operation = ShowHelpPageOperation(type: .ImportBookLearnMore, presentationContext: self)
|
||||
UIApplication.appDelegate.globalOperationQueue.addOperation(operation)
|
||||
GlobalOperationQueue.sharedInstance.addOperation(operation)
|
||||
}
|
||||
|
||||
// MARK: - TableView Data Source
|
||||
|
@ -89,12 +89,12 @@ class LibraryOnlineTBVC: UITableViewController, NSFetchedResultsControllerDelega
|
||||
let codes = errors.map() {$0.code}
|
||||
if codes.contains(OperationErrorCode.NetworkError.rawValue) {
|
||||
let alertOperation = RefreshLibraryInternetRequiredAlert(presentationContext: self)
|
||||
UIApplication.appDelegate.globalOperationQueue.addOperation(alertOperation)
|
||||
GlobalOperationQueue.sharedInstance.addOperation(alertOperation)
|
||||
}
|
||||
} else {
|
||||
guard !Preference.libraryHasShownPreferredLanguagePrompt else {return}
|
||||
let operation = RefreshLibraryLanguageFilterAlert(libraryOnlineTBVC: self)
|
||||
UIApplication.appDelegate.globalOperationQueue.addOperation(operation)
|
||||
GlobalOperationQueue.sharedInstance.addOperation(operation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
//
|
||||
// LibraryScanOperation.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris Li on 5/14/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class LibraryScanOperation: Operation {
|
||||
|
||||
}
|
@ -69,7 +69,7 @@ class MainVC: UIViewController {
|
||||
func showGetStartedAlert() {
|
||||
guard !Preference.hasShowGetStartedAlert else {return}
|
||||
let operation = GetStartedAlert(mainController: self)
|
||||
UIApplication.appDelegate.globalOperationQueue.addOperation(operation)
|
||||
GlobalOperationQueue.sharedInstance.addOperation(operation)
|
||||
Preference.hasShowGetStartedAlert = true
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ class GetStartedAlert: AlertOperation {
|
||||
}
|
||||
addAction(NSLocalizedString("Import", comment: comment), style: .Default) { (alert) in
|
||||
let operation = ShowHelpPageOperation(type: .ImportBookLearnMore, presentationContext: mainController)
|
||||
UIApplication.appDelegate.globalOperationQueue.addOperation(operation)
|
||||
GlobalOperationQueue.sharedInstance.addOperation(operation)
|
||||
}
|
||||
addAction(NSLocalizedString("Dismiss", comment: comment))
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class ZIMMultiReader: NSObject, DirectoryMonitorDelegate {
|
||||
|
||||
func directoryMonitorDidObserveChange() {
|
||||
let operation = RescanZimMultiReaderOperation()
|
||||
UIApplication.globalOperationQueue.addOperation(operation)
|
||||
GlobalOperationQueue.sharedInstance.addOperation(operation)
|
||||
}
|
||||
|
||||
// MARK: - Refresh
|
||||
|
Loading…
x
Reference in New Issue
Block a user