Skip to content

Commit

Permalink
Fix crash when artwork data cant be transformed into uiimage
Browse files Browse the repository at this point in the history
  • Loading branch information
GianniCarlo committed Jun 26, 2019
1 parent 3a022a3 commit 2643962
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BookPlayer/Library/LibraryViewController.swift
Expand Up @@ -375,7 +375,7 @@ extension LibraryViewController {
}
let nextIndex = forward ? currentIndex + 1 : currentIndex - 1

while nextIndex >= 0 && nextIndex < playListCells.count {
while nextIndex >= 0, nextIndex < playListCells.count {
let cell = playListCells[nextIndex]
return UIAccessibilityCustomRotorItemResult(targetElement: cell, targetRange: nil)
}
Expand Down
4 changes: 2 additions & 2 deletions Shared/Extensions/UIColor+Sweetercolor.swift
Expand Up @@ -408,9 +408,9 @@ extension UIColor {
h_p_bar = h_1_p + h_2_p
} else if abs(h_1_p - h_2_p) <= 180 {
h_p_bar = (h_1_p + h_2_p) / 2
} else if abs(h_1_p - h_2_p) > 180 && (h_1_p + h_2_p) < 360 {
} else if abs(h_1_p - h_2_p) > 180, (h_1_p + h_2_p) < 360 {
h_p_bar = (h_1_p + h_2_p + 360) / 2
} else if abs(h_1_p - h_2_p) > 180 && (h_1_p + h_2_p) >= 360 {
} else if abs(h_1_p - h_2_p) > 180, (h_1_p + h_2_p) >= 360 {
h_p_bar = (h_1_p + h_2_p - 360) / 2
}

Expand Down
5 changes: 3 additions & 2 deletions Shared/Models/LibraryItem+CoreDataClass.swift
Expand Up @@ -18,11 +18,12 @@ public class LibraryItem: NSManagedObject, Codable {
return cachedArtwork
}

guard let artworkData = self.artworkData else {
guard let artworkData = self.artworkData,
let image = UIImage(data: artworkData as Data) else {
return #imageLiteral(resourceName: "defaultArtwork")
}

self.cachedArtwork = UIImage(data: artworkData as Data)
self.cachedArtwork = image
return self.cachedArtwork!
}

Expand Down
2 changes: 1 addition & 1 deletion Shared/WatchConnectivityService.swift
Expand Up @@ -24,7 +24,7 @@ public class WatchConnectivityService: NSObject, WCSessionDelegate {
// consider prompting the user to install it for a better experience

#if os(iOS)
if let session = self.session, session.isPaired && session.isWatchAppInstalled {
if let session = self.session, session.isPaired, session.isWatchAppInstalled {
return session
} else {
return nil
Expand Down

0 comments on commit 2643962

Please sign in to comment.