Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
- print(indexPath.row)
- if itemStyle == .Grid {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: self.resourceCellIdentifier, for: indexPath) as! ResourceCollectionViewCell
- cell.delegate = self
- cell.tag = indexPath.row
- if self.filter == Filter.Collections || self.resourceArray?[indexPath.row].actionContent == nil {
- let resource: ActionContentTemplate?
- if self.filter == Filter.Collections {
- resource = self.collectionResourceArray?[indexPath.row].actionContentTemplate
- } else {
- resource = self.resourceArray?[indexPath.row].actionContentTemplate
- }
- DispatchQueue.global(qos: .userInitiated).async {
- cell.dataObject = resource
- }
- return cell
- } else {.....
- var dataObject: ActionContentTemplate? {
- didSet {
- var cellRow: Int = 0
- if self.actionContentTemplate != nil {
- ....
- DispatchQueue.main.async {
- cellRow = self.tag
- .....
- switch self.actionContentTemplate?.contentTypeID?.uintValue {
- case ContentTypeVideo.rawValue,
- ContentTypeVideoRecording.rawValue,
- ContentTypeScreenRecording.rawValue:
- .......
- case ContentTypeAttachment.rawValue:
- let fileType = (self.actionContentTemplate?.contentFileName as NSString?)?.pathExtension.lowercased()
- var placeholderImage: UIImage
- if fileType == "pdf" {
- placeholderImage = UIImage(named: "pdf")!
- } else if fileType == "doc" {
- placeholderImage = UIImage(named: "doc")!
- } else if fileType == "docx" {
- placeholderImage = UIImage(named: "doc")!
- } else if fileType == "xls" {
- placeholderImage = UIImage(named: "xls")!
- } else if fileType == "xlsx" {
- placeholderImage = UIImage(named: "xls")!
- } else if fileType == "ppt" {
- placeholderImage = UIImage(named: "ppt")!
- } else if fileType == "pptx" {
- placeholderImage = UIImage(named: "ppt")!
- } else {
- placeholderImage = UIImage(named: "plain")!
- }
- if let urlString = self.actionContentTemplate?.thumbnailURL {
- let imageURL = URL(string: urlString)
- SDWebImageManager.shared().loadImage(with: imageURL, options: [.continueInBackground, .scaleDownLargeImages], progress: nil) { (image, data, err, cacheType, finished, url) in
- DispatchQueue.main.async {
- if cellRow == self.tag {
- self.activityIndicator?.stopAnimating()
- self.imageView.image = image
- UIAnimation.fadeTransitionImageView(self.imageView)
- }
- }
- }
- }
- } else {
- DispatchQueue.main.async {
- self.activityIndicator?.stopAnimating()
- self.imageView.image = placeholderImage
- }
- }
- break
- .....
- SDWebImageManager.shared().loadImage(with: imageURL, options: [.continueInBackground, .scaleDownLargeImages], progress: nil) { (image, data, err, cacheType, finished, url) in
- DispatchQueue.main.async {
- if cellRow == self.tag {
- //IF I COMMENT OUT THESE TWO LINES BELOW THE ISSUES STOP (I think it is only the self.imageView.image = image line that is causing issues)
- // self.activityIndicator?.stopAnimating()
- // self.imageView.image = image
- UIAnimation.fadeTransitionImageView(self.imageView)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement