OOAppEditCell.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // OOAppEditCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2018/5/10.
  6. // Copyright © 2018年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import CocoaLumberjack
  10. class OOAppEditCell: UITableViewCell,Configurable {
  11. @IBOutlet weak var appIcon: UIImageView!
  12. @IBOutlet weak var appNameLabel: UILabel!
  13. override func awakeFromNib() {
  14. super.awakeFromNib()
  15. // Initialization code
  16. }
  17. override func setSelected(_ selected: Bool, animated: Bool) {
  18. super.setSelected(selected, animated: animated)
  19. // Configure the view for the selected state
  20. }
  21. func config(withItem item: Any?) {
  22. guard let app = item as? O2App else {
  23. return
  24. }
  25. //名字
  26. appNameLabel.text = app.title
  27. initImg(app: app)
  28. }
  29. private func initImg(app:O2App){
  30. let storeBoard = app.storyBoard
  31. if storeBoard == "webview" {
  32. guard let iconUrl = AppDelegate.o2Collect.generateURLWithAppContextKey(ApplicationContext.applicationContextKey2, query: ApplicationContext.applicationIconQuery, parameter: ["##applicationId##":app.appId! as AnyObject]) else {
  33. DDLogError("没有获取到icon的url。。。。。。")
  34. return
  35. }
  36. let url = URL(string: iconUrl)
  37. let size = self.appIcon.bounds.size
  38. if size.width == 0 {
  39. self.appIcon.bounds.size = CGSize(width: 38, height: 38)
  40. }
  41. self.appIcon.image = UIImage(named: app.normalIcon!)
  42. self.appIcon.highlightedImage = UIImage(named: app.normalIcon!)
  43. self.appIcon.hnk_setImageFromURL(url!)
  44. // let cache = Shared.imageCache
  45. // let format = HanekeGlobals.UIKit.formatWithSize(CGSize(width: 38, height: 38), scaleMode: .AspectFill)
  46. // let formatName = format.name
  47. // cache.addFormat(format)
  48. // let fetcher = NetworkFetcher<UIImage>(URL: url!)
  49. // cache.fetch(fetcher: fetcher, formatName: formatName).onSuccess { image in
  50. // self.appIcon.image = image
  51. // self.appIcon.highlightedImage = image
  52. // }
  53. }else {
  54. self.appIcon.image = UIImage(named: app.normalIcon!)
  55. self.appIcon.highlightedImage = UIImage(named: app.normalIcon!)
  56. }
  57. }
  58. }