{"id":15888930,"url":"https://github.com/markrickert/remote-image-bug-example","last_synced_at":"2025-04-02T16:47:12.593Z","repository":{"id":31925180,"uuid":"35494569","full_name":"markrickert/remote-image-bug-example","owner":"markrickert","description":"Shows an issue with JMImageCache and remote image loading in PM::TableScreens","archived":false,"fork":false,"pushed_at":"2015-05-12T15:57:56.000Z","size":2284,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T07:27:28.732Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markrickert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-12T14:55:26.000Z","updated_at":"2015-05-12T14:55:45.000Z","dependencies_parsed_at":"2022-08-25T05:50:26.930Z","dependency_job_id":null,"html_url":"https://github.com/markrickert/remote-image-bug-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrickert%2Fremote-image-bug-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrickert%2Fremote-image-bug-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrickert%2Fremote-image-bug-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrickert%2Fremote-image-bug-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markrickert","download_url":"https://codeload.github.com/markrickert/remote-image-bug-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246854380,"owners_count":20844752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T06:40:34.672Z","updated_at":"2025-04-02T16:47:12.547Z","avatar_url":"https://github.com/markrickert.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"remote-image-bug\n===================\n\nAn issue where with JMImageCache in a `PM::TableScreen` with remote images, the remote image operation isn't canceled so it keeps setting the image on the reused cells.\n\n![Example](example.gif?raw=true)\n\nHere's how I've solved it in a custom `PM::TableViewCell` with `SDWebImage` which DOES have an operation canceling feature:\n\n```ruby\n# Should be included in a custom UITableViewCell\nmodule RemoteImageCell\n  def prepareForReuse\n    @image_operation.each do |k,v|\n      v.cancel\n    end\n    @image_operation = {}\n  end\n\n  def set_remote_image(url, image_location = nil)\n    @image_operation ||= {}\n\n    url = NSURL.URLWithString(url) unless url.is_a?(NSURL)\n    image_location = self.imageView if image_location.nil?\n\n    @image_operation[url.absoluteString] = manager.downloadWithURL(url,\n      options:SDWebImageRefreshCached,\n      progress:nil,\n      completed: -\u003e image, error, cacheType, finished {\n        image_location.image = image unless image.nil?\n    })\n  end\n\n  def set_placeholder_image(image, image_location = nil)\n    image_location = self.imageView if image_location.nil?\n\n    image_location.image = UIImage.imageNamed(image)\n    image_location.layer.masksToBounds = true\n    image_location.layer.cornerRadius = 20\n  end\n\n  def remote_image=(url)\n    set_remote_image(url)\n  end\n\n  def placeholder_image=(image)\n    set_placeholder_image(image)\n  end\n\n  def manager\n    SDWebImageManager.sharedManager\n  end\n\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkrickert%2Fremote-image-bug-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkrickert%2Fremote-image-bug-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkrickert%2Fremote-image-bug-example/lists"}