Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/v3.4.2 #77

Merged
merged 8 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GiGLibrary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2698,7 +2698,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 3.4;
MARKETING_VERSION = 3.4.1;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.gigigo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2727,7 +2727,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 3.4;
MARKETING_VERSION = 3.4.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.gigigo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status](https://travis-ci.org/gigigoapps/gigigo-ios-lib.svg?branch=master)](https://travis-ci.org/gigigoapps/gigigo-ios-lib)
![Language](https://img.shields.io/badge/Language-Objective--C-orange.svg)
![Language](https://img.shields.io/badge/Language-Swift-orange.svg)
![Version](https://img.shields.io/badge/version-3.3.1-blue.svg)
![Version](https://img.shields.io/badge/version-3.4.1-blue.svg)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)


Expand Down
60 changes: 31 additions & 29 deletions Source/GIGUtils/Image/ImageDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,57 +51,59 @@ struct ImageDownloader {
ImageDownloader.queue[view] = request
ImageDownloader.stack.append(view)

if ImageDownloader.queue.count <= 3 {
if ImageDownloader.stack.count <= 3 {
self.downloadNext()
}
}

private func downloadNext() {
guard let view = ImageDownloader.stack.popLast() else { return }
guard let request = ImageDownloader.queue[view] else {
self.downloadNext()
return
}

request.fetch { response in
switch response.status {

case .success:
DispatchQueue.global().async {
if let image = try? response.image() {
DispatchQueue.main.async {
let width = view.width() * UIScreen.main.scale
let height = view.height() * UIScreen.main.scale
let resized = image.imageProportionally(with: CGSize(width: width, height: height))
ImageDownloader.images[request.baseURL] = resized
if let image = try? response.image() {
DispatchQueue(label: "com.gigigo.imagedownloader", qos: .background).async {
var finalImage = image
let width = view.width() * UIScreen.main.scale
let height = view.height() * UIScreen.main.scale
if let resized = image.imageProportionally(with: CGSize(width: width, height: height)) {
finalImage = resized
}
ImageDownloader.images.updateValue(finalImage, forKey: request.baseURL)

if let currentRequest = ImageDownloader.queue[view], request.baseURL == currentRequest.baseURL {
self.setAnimated(image: resized, in: view)
}

if let index = ImageDownloader.queue.index(forKey: view) {
ImageDownloader.queue.remove(at: index)
}
self.downloadNext()
}
} else if let imageGif = try? response.gif() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)

DispatchQueue.main.async {
ImageDownloader.images[request.baseURL] = imageGif

if let currentRequest = ImageDownloader.queue[view], request.baseURL == currentRequest.baseURL {
self.setAnimated(image: imageGif, in: view)
}

self.setAnimated(image: finalImage, in: view)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

if let index = ImageDownloader.queue.index(forKey: view) {
ImageDownloader.queue.remove(at: index)
}
self.downloadNext()
}
} else {
LogWarn("Al descargar la imagen,o se ha recibido un body vacio o no se se ha reconocido el tipo de imagen que es.")
self.downloadNext()
}
}
}
} else if let imageGif = try? response.gif() {
DispatchQueue.main.async {
ImageDownloader.images.updateValue(imageGif, forKey: request.baseURL)

if let currentRequest = ImageDownloader.queue[view], request.baseURL == currentRequest.baseURL {
self.setAnimated(image: imageGif, in: view)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

if let index = ImageDownloader.queue.index(forKey: view) {
ImageDownloader.queue.remove(at: index)
}
self.downloadNext()
}
} else {
LogWarn("Al descargar la imagen,o se ha recibido un body vacio o no se se ha reconocido el tipo de imagen que es.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 135 characters (line_length)

self.downloadNext()
}

default:
LogError(response.error)
Expand Down