diff --git a/librx/Base.lproj/Main.storyboard b/librx/Base.lproj/Main.storyboard
index e373541..bed2d0c 100644
--- a/librx/Base.lproj/Main.storyboard
+++ b/librx/Base.lproj/Main.storyboard
@@ -228,11 +228,11 @@
@@ -245,13 +245,13 @@
-
-
+
@@ -350,6 +350,7 @@
+
@@ -907,13 +908,13 @@
+
-
diff --git a/librx/CreatePostViewController.swift b/librx/CreatePostViewController.swift
index 9beb7a6..266d5d5 100644
--- a/librx/CreatePostViewController.swift
+++ b/librx/CreatePostViewController.swift
@@ -26,7 +26,9 @@ class CreatePostViewController: UITableViewController {
let link = self.share_link?.text
let type = self.share_type?.text
- let post = Post(viewedTimes: 0, title: title!, createdAt: "", type: type!, url: link!)
+ let post = Post(viewedTimes: 0, title: title!,
+ createdAt: "", type: type!, url: link!,
+ thumbnail: "")
LibrxService.createPost(post) { [weak self](result) -> () in
self!.dismissViewControllerAnimated(true, completion: nil)
diff --git a/librx/ExploreCell.swift b/librx/ExploreCell.swift
index 19faff5..4a81a05 100644
--- a/librx/ExploreCell.swift
+++ b/librx/ExploreCell.swift
@@ -11,7 +11,7 @@ import UIKit
class ExploreCell: UICollectionViewCell {
@IBOutlet weak var nameLabel: UILabel!
-
-
@IBOutlet weak var iconImage: UIImageView!
+
+
}
diff --git a/librx/ExploreCollectionReusableView.swift b/librx/ExploreCollectionReusableView.swift
index 3e91cb5..3723028 100644
--- a/librx/ExploreCollectionReusableView.swift
+++ b/librx/ExploreCollectionReusableView.swift
@@ -18,14 +18,14 @@ class ExploreCollectionViewController: UICollectionViewController, UICollectionV
"Java","IOS","Ruby",
"Python", "前端开发","安卓",
"设计","资源","Github",
- "点子","工具箱","音乐"
+ "点子","工具箱","音乐","程序员"
]
var icons = [
"Java", "iPhone", "Minecraft",
"Python", "CSS", "Android",
"Robot","Forrst", "GitHub",
- "Idea","Toolbox","Music"
+ "Idea","Toolbox","Music", "Sun"
]
override func viewDidLoad() {
diff --git a/librx/Images.xcassets/Sun.imageset/Contents.json b/librx/Images.xcassets/Sun.imageset/Contents.json
new file mode 100644
index 0000000..b3e0360
--- /dev/null
+++ b/librx/Images.xcassets/Sun.imageset/Contents.json
@@ -0,0 +1,23 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "Sun.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "Sun@2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "Sun@3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/librx/Images.xcassets/Sun.imageset/Sun.png b/librx/Images.xcassets/Sun.imageset/Sun.png
new file mode 100644
index 0000000..1095a1e
Binary files /dev/null and b/librx/Images.xcassets/Sun.imageset/Sun.png differ
diff --git a/librx/Images.xcassets/Sun.imageset/Sun@2x.png b/librx/Images.xcassets/Sun.imageset/Sun@2x.png
new file mode 100644
index 0000000..0fc3776
Binary files /dev/null and b/librx/Images.xcassets/Sun.imageset/Sun@2x.png differ
diff --git a/librx/Images.xcassets/Sun.imageset/Sun@3x.png b/librx/Images.xcassets/Sun.imageset/Sun@3x.png
new file mode 100644
index 0000000..0bb1d5c
Binary files /dev/null and b/librx/Images.xcassets/Sun.imageset/Sun@3x.png differ
diff --git a/librx/LibrxService.swift b/librx/LibrxService.swift
index bac09c0..0141a0e 100644
--- a/librx/LibrxService.swift
+++ b/librx/LibrxService.swift
@@ -16,10 +16,14 @@ import JWT
struct LibrxService {
private static let baseURL = "http://uat.librme.com/api/v1/"
+// private static let baseURL = "http://localhost:3000/api/v1/"
private static let defaultEncodeToken = "493bc0c0da778dc02aeeb1914bfcf0a9"
+ private static let defaultThumail = "http://7pn5d3.com1.z0.glb.clouddn.com/9050353.png"
private static let clientID = ""
private static let clientSecret = ""
+ private var imageCache = NSMutableDictionary()
+
private enum ResourcePath: Printable {
case SignIn
@@ -75,19 +79,34 @@ struct LibrxService {
var posts:[Post] = []
for index in 0.. 30 {
+ title = title.substringToIndex(advance(post.title.endIndex, -4)) + "..."
+ }
+
+
+ cell.nameLabel.text = title
+
+ if let img = imageCache[post.thumbnail] {
+ cell.thumbnilImageView?.image = img
+ }else{
+
+ let thumbnailUrl = NSURL(string: post.thumbnail)
+ let request: NSURLRequest = NSURLRequest(URL: thumbnailUrl!)
+ let mainQueue = NSOperationQueue.mainQueue()
+
+ NSURLConnection.sendAsynchronousRequest(request, queue: mainQueue, completionHandler: { (response, data, error) -> Void in
+ if error == nil {
+ // Convert the downloaded data in to a UIImage object
+ let image = UIImage(data: data)
+ // Store the image in to our cache
+ self.imageCache[post.thumbnail] = image
+ // Update the cell
+ dispatch_async(dispatch_get_main_queue(), {
+ if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) as? CustomTableCell {
+ cellToUpdate.thumbnilImageView?.image = image
+ }
+ })
+ }
+ else {
+ println("Error: \(error.localizedDescription)")
+ }
+ })
+
+ }
+
return cell
}