Compare commits

...

2 Commits

Author SHA1 Message Date
Peter Kolpashchikov bc1b4733d7 LiveCameraCaptureSession issue fixed 2016-10-10 11:54:51 +01:00
Diego Sánchez 2892305ad5 Adds exclusive touch to bubble view (#224)
* Adds exclusive touch to bubble view

* Fixes wrong comparison found after Swift 3 migration
2016-09-26 18:23:57 +01:00
4 changed files with 19 additions and 15 deletions

View File

@ -161,6 +161,7 @@ public class BaseMessageCollectionViewCell<BubbleViewType where BubbleViewType:U
self.avatarView = self.createAvatarView()
self.avatarView.addGestureRecognizer(self.avatarTapGestureRecognizer)
self.bubbleView = self.createBubbleView()
self.bubbleView.exclusiveTouch = true
self.bubbleView.addGestureRecognizer(self.tapGestureRecognizer)
self.bubbleView.addGestureRecognizer(self.longPressGestureRecognizer)
self.contentView.addSubview(self.avatarView)

View File

@ -164,7 +164,7 @@ public final class TextBubbleView: UIView, MaximumLayoutWidthSpecificable, Backg
needsToUpdateText = true
}
if needsToUpdateText || self.textView != viewModel.text {
if needsToUpdateText || self.textView.text != viewModel.text {
self.textView.text = viewModel.text
}

View File

@ -38,7 +38,7 @@ class LiveCameraCaptureSession: LiveCameraCaptureSessionProtocol {
var isInitialized: Bool = false
var isCapturing: Bool {
return self.isInitialized && self.captureSession.running
return self.isInitialized && self.captureSession?.running ?? false
}
deinit {
@ -57,7 +57,7 @@ class LiveCameraCaptureSession: LiveCameraCaptureSessionProtocol {
operation.addExecutionBlock { [weak operation, weak self] in
guard let sSelf = self, strongOperation = operation where !strongOperation.cancelled else { return }
sSelf.addInputDevicesIfNeeded()
sSelf.captureSession.startRunning()
sSelf.captureSession?.startRunning()
dispatch_async(dispatch_get_main_queue(), completion)
}
self.queue.cancelAllOperations()
@ -68,7 +68,7 @@ class LiveCameraCaptureSession: LiveCameraCaptureSessionProtocol {
let operation = NSBlockOperation()
operation.addExecutionBlock { [weak operation, weak self] in
guard let sSelf = self, strongOperation = operation where !strongOperation.cancelled else { return }
sSelf.captureSession.stopRunning()
sSelf.captureSession?.stopRunning()
sSelf.removeInputDevices()
dispatch_async(dispatch_get_main_queue(), completion)
}
@ -85,23 +85,27 @@ class LiveCameraCaptureSession: LiveCameraCaptureSessionProtocol {
return queue
}()
private lazy var captureSession: AVCaptureSession = {
private lazy var captureSession: AVCaptureSession? = {
assert(!NSThread.isMainThread(), "This can be very slow, make sure it happens in a background thread")
let session = AVCaptureSession()
self.captureLayer = AVCaptureVideoPreviewLayer(session: session)
self.captureLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
self.isInitialized = true
return session
#if !(arch(i386) || arch(x86_64))
let session = AVCaptureSession()
self.captureLayer = AVCaptureVideoPreviewLayer(session: session)
self.captureLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
return session
#else
return nil
#endif
}()
private func addInputDevicesIfNeeded() {
assert(!NSThread.isMainThread(), "This can be very slow, make sure it happens in a background thread")
if self.captureSession.inputs?.count == 0 {
if self.captureSession?.inputs?.count == 0 {
let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
do {
let input = try AVCaptureDeviceInput(device: device)
self.captureSession.addInput(input)
self.captureSession?.addInput(input)
} catch {
}
@ -110,8 +114,8 @@ class LiveCameraCaptureSession: LiveCameraCaptureSessionProtocol {
private func removeInputDevices() {
assert(!NSThread.isMainThread(), "This can be very slow, make sure it happens in a background thread")
self.captureSession.inputs?.forEach { (input) in
self.captureSession.removeInput(input as! AVCaptureInput)
self.captureSession?.inputs?.forEach { (input) in
self.captureSession?.removeInput(input as! AVCaptureInput)
}
}
}

View File

@ -75,8 +75,7 @@ class PhotosInputDataProvider: NSObject, PhotosInputDataProviderProtocol, PHPhot
if let userLibraryCollection = PHAssetCollection.fetchAssetCollectionsWithType(.SmartAlbum, subtype: .SmartAlbumUserLibrary, options: nil).firstObject as? PHAssetCollection {
self.fetchResult = PHAsset.fetchAssetsInAssetCollection(userLibraryCollection, options: fetchOptions(NSPredicate(format: "mediaType = \(PHAssetMediaType.Image.rawValue)")))
}
else {
} else {
self.fetchResult = PHAsset.fetchAssetsWithMediaType(.Image, options: fetchOptions(nil))
}
super.init()