Skip to content

Commit

Permalink
Fixed crash on rotation while parsing large books and closes issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
hebertialmeida committed Dec 8, 2015
1 parent da59b4e commit 647f64e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- AEXML (2.0.1)
- FolioReaderKit (0.1.0):
- FolioReaderKit (0.3.2):
- AEXML
- FontBlaster
- JSQWebViewController
Expand All @@ -22,7 +22,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
AEXML: d6bb5b994521fcf3667ee8ccc1ed533f31b19218
FolioReaderKit: 54173ab1bfc90d6e19dd76d8b8633e31b2c763cf
FolioReaderKit: d8334f7728762f2706f6d1ec3ac6d501bcab2482
FontBlaster: 8165fef7f0556ba766836a2f5654a16cd0251e27
JSQWebViewController: 2e416ae6604676510812bbda050d63a1488003a4
SSZipArchive: 5f30a0af2cb3d48c0ff83b1e18029f7041ac3c38
Expand Down
8 changes: 6 additions & 2 deletions Source/FolioReaderCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICollectio
// MARK: - Device rotation

override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
if !FolioReader.sharedInstance.isReaderReady { return }

setPageSize(toInterfaceOrientation)
updateCurrentPage()

Expand All @@ -303,16 +305,18 @@ class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UICollectio
self.collectionView.setContentOffset(self.frameForPage(currentPageNumber).origin, animated: false)
self.collectionView.collectionViewLayout.invalidateLayout()
})


}

override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
if !FolioReader.sharedInstance.isReaderReady { return }

// Update pages
pagesForCurrentPage(currentPage)
}

override func willAnimateRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
if !FolioReader.sharedInstance.isReaderReady { return }

if currentPageNumber+1 >= totalPages {
UIView.animateWithDuration(duration, animations: {
self.collectionView.setContentOffset(self.frameForPage(currentPageNumber).origin, animated: false)
Expand Down
2 changes: 2 additions & 0 deletions Source/FolioReaderContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class FolioReaderContainer: UIViewController, FolioReaderSidePanelDelegate {
if FolioReader.defaults.valueForKey(kBookId) == nil {
self.toggleLeftPanel()
}

FolioReader.sharedInstance.isReaderReady = true
})
})
} else {
Expand Down
1 change: 1 addition & 0 deletions Source/FolioReaderKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class FolioReader {
var readerSidePanel: FolioReaderSidePanel!
var readerContainer: FolioReaderContainer!
var isReaderOpen = false
var isReaderReady = false

var nightMode: Bool {
get { return FolioReader.defaults.valueForKey(kNightMode) as! Bool }
Expand Down
1 change: 1 addition & 0 deletions Source/FolioReaderSidePanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class FolioReaderSidePanel: UIViewController, UITableViewDelegate, UITableViewDa
func didSelectClose(sender: UIBarButtonItem) {
self.dismissViewControllerAnimated(true, completion: {
FolioReader.sharedInstance.isReaderOpen = false
FolioReader.sharedInstance.isReaderReady = false
})
}

Expand Down

0 comments on commit 647f64e

Please sign in to comment.