Skip to content

Commit

Permalink
update self.dynamicType to static type to avoid potential issues of f…
Browse files Browse the repository at this point in the history
…inding default images in NSBundle
  • Loading branch information
Zhao Wang committed Mar 13, 2016
1 parent 217c912 commit 1699199
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ public class MessageViewModelDefaultBuilder {

public func createMessageViewModel(message: MessageModelProtocol) -> MessageViewModelProtocol {
// Override to use default avatarImage
return MessageViewModel(dateFormatter: self.dynamicType.dateFormatter, showsTail: false, messageModel: message, avatarImage: nil)
return MessageViewModel(dateFormatter: MessageViewModelDefaultBuilder.dateFormatter, showsTail: false, messageModel: message, avatarImage: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ public class PhotoMessageCollectionViewCellDefaultStyle: PhotoMessageCollectionV
lazy private var baseStyle = BaseMessageCollectionViewCellDefaultStyle()

lazy private var maskImageIncomingTail: UIImage = {
return UIImage(named: "bubble-incoming-tail", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)!
return UIImage(named: "bubble-incoming-tail", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!
}()

lazy private var maskImageIncomingNoTail: UIImage = {
return UIImage(named: "bubble-incoming", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)!
return UIImage(named: "bubble-incoming", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!
}()

lazy private var maskImageOutgoingTail: UIImage = {
return UIImage(named: "bubble-outgoing-tail", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)!
return UIImage(named: "bubble-outgoing-tail", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!
}()

lazy private var maskImageOutgoingNoTail: UIImage = {
return UIImage(named: "bubble-outgoing", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)!
return UIImage(named: "bubble-outgoing", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!
}()

lazy private var placeholderBackgroundIncoming: UIImage = {
Expand All @@ -69,7 +69,7 @@ public class PhotoMessageCollectionViewCellDefaultStyle: PhotoMessageCollectionV
}()

lazy private var placeholderIcon: UIImage = {
return UIImage(named: "photo-bubble-placeholder-icon", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)!
return UIImage(named: "photo-bubble-placeholder-icon", inBundle: NSBundle(forClass: PhotoMessageCollectionViewCellDefaultStyle.self), compatibleWithTraitCollection: nil)!
}()

public func maskingImage(viewModel viewModel: PhotoMessageViewModelProtocol) -> UIImage {
Expand Down
4 changes: 2 additions & 2 deletions ChattoAdditions/Source/Input/Photos/LiveCameraCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class LiveCameraCell: UICollectionViewCell {
private func updateIcon() {
switch self.authorizationStatus {
case .NotDetermined, .Authorized:
self.iconImageView.image = UIImage(named: Constants.cameraImageName, inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)
self.iconImageView.image = UIImage(named: Constants.cameraImageName, inBundle: NSBundle(forClass: LiveCameraCell.self), compatibleWithTraitCollection: nil)
case .Restricted, .Denied:
self.iconImageView.image = UIImage(named: Constants.lockedCameraImageName, inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)
self.iconImageView.image = UIImage(named: Constants.lockedCameraImageName, inBundle: NSBundle(forClass: LiveCameraCell.self), compatibleWithTraitCollection: nil)
}
self.setNeedsLayout()
}
Expand Down
6 changes: 3 additions & 3 deletions ChattoAdditions/Source/Input/Photos/PhotosChatInputItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import Foundation
lazy private var internalTabView: UIButton = {
var button = UIButton(type: .Custom)
button.exclusiveTouch = true
button.setImage(UIImage(named: "camera-icon-unselected", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil), forState: .Normal)
button.setImage(UIImage(named: "camera-icon-selected", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil), forState: .Highlighted)
button.setImage(UIImage(named: "camera-icon-selected", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil), forState: .Selected)
button.setImage(UIImage(named: "camera-icon-unselected", inBundle: NSBundle(forClass: PhotosChatInputItem.self), compatibleWithTraitCollection: nil), forState: .Normal)
button.setImage(UIImage(named: "camera-icon-selected", inBundle: NSBundle(forClass: PhotosChatInputItem.self), compatibleWithTraitCollection: nil), forState: .Highlighted)
button.setImage(UIImage(named: "camera-icon-selected", inBundle: NSBundle(forClass: PhotosChatInputItem.self), compatibleWithTraitCollection: nil), forState: .Selected)
return button
}()

Expand Down
2 changes: 1 addition & 1 deletion ChattoAdditions/Source/Input/Photos/PhotosInputCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PhotosInputPlaceholderCell: UICollectionViewCell {
private func commonInit() {
self.imageView = UIImageView()
self.imageView.contentMode = .Center
self.imageView.image = UIImage(named: Constants.imageName, inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)
self.imageView.image = UIImage(named: Constants.imageName, inBundle: NSBundle(forClass: PhotosInputPlaceholderCell.self), compatibleWithTraitCollection: nil)
self.contentView.addSubview(self.imageView)
self.contentView.backgroundColor = Constants.backgroundColor
}
Expand Down
6 changes: 3 additions & 3 deletions ChattoAdditions/Source/Input/Text/TextChatInputItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import Foundation
lazy private var internalTabView: UIButton = {
var button = UIButton(type: .Custom)
button.exclusiveTouch = true
button.setImage(UIImage(named: "text-icon-unselected", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil), forState: .Normal)
button.setImage(UIImage(named: "text-icon-selected", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil), forState: .Highlighted)
button.setImage(UIImage(named: "text-icon-selected", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil), forState: .Selected)
button.setImage(UIImage(named: "text-icon-unselected", inBundle: NSBundle(forClass: TextChatInputItem.self), compatibleWithTraitCollection: nil), forState: .Normal)
button.setImage(UIImage(named: "text-icon-selected", inBundle: NSBundle(forClass: TextChatInputItem.self), compatibleWithTraitCollection: nil), forState: .Highlighted)
button.setImage(UIImage(named: "text-icon-selected", inBundle: NSBundle(forClass: TextChatInputItem.self), compatibleWithTraitCollection: nil), forState: .Selected)
return button
}()

Expand Down
2 changes: 1 addition & 1 deletion ChattoApp/ChattoApp/Source/DemoChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DemoChatViewController: BaseChatViewController {

override func viewDidLoad() {
super.viewDidLoad()
let image = UIImage(named: "bubble-incoming-tail-border", inBundle: NSBundle(forClass: self.dynamicType), compatibleWithTraitCollection: nil)?.bma_tintWithColor(UIColor.blueColor())
let image = UIImage(named: "bubble-incoming-tail-border", inBundle: NSBundle(forClass: DemoChatViewController.self), compatibleWithTraitCollection: nil)?.bma_tintWithColor(UIColor.blueColor())
super.chatItemsDecorator = ChatItemsDemoDecorator()
let addIncomingMessageButton = UIBarButtonItem(image: image, style: .Plain, target: self, action: "addRandomIncomingMessage")
self.navigationItem.rightBarButtonItem = addIncomingMessageButton
Expand Down

0 comments on commit 1699199

Please sign in to comment.