-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Meme updation from the server; Fix the TIFF images getting saved inst…
…ead of compressed JPEGs.
- Loading branch information
Showing
114 changed files
with
11,494 additions
and
2,307 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Meme Maker Mac/Assets.xcassets/MemeBlank.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "MemeBlank.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ class SettingsViewController: NSViewController { | |
@IBOutlet weak var darkModeButton: NSButton! | ||
|
||
@IBOutlet weak var lastUpdatedLabel: NSTextField! | ||
|
||
@IBOutlet weak var updationSpinner: NSProgressIndicator! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
@@ -24,6 +26,8 @@ class SettingsViewController: NSViewController { | |
|
||
// darkModeButton.state = SettingsManager.getBool(ksettings) | ||
|
||
lastUpdatedLabel.stringValue = "Last updated: " + SettingsManager.getLastUpdateDateString() | ||
|
||
} | ||
|
||
} | ||
|
@@ -39,16 +43,54 @@ extension SettingsViewController { | |
} | ||
|
||
@IBAction func updateMemesAction(sender: AnyObject) { | ||
// Perform update... | ||
let fetcher = MemeFetcher() | ||
fetcher.fetchMemes() | ||
updationSpinner.hidden = false | ||
updationSpinner.startAnimation(self) | ||
NSNotificationCenter.defaultCenter().addObserverForName(kFetchCompleteNotification, object: nil, queue: NSOperationQueue.mainQueue()) { (notification) in | ||
self.updationSpinner.stopAnimation(self) | ||
self.updationSpinner.hidden = true | ||
self.lastUpdatedLabel.stringValue = "Last updated: " + SettingsManager.getLastUpdateDateString() | ||
} | ||
} | ||
|
||
@IBAction func reportBugAction(sender: AnyObject) { | ||
|
||
let shareItems = [getSystemDetails()] | ||
let service = NSSharingService(named: NSSharingServiceNameComposeEmail) | ||
service?.delegate = self | ||
service?.recipients = ["[email protected]"] | ||
service?.subject = "Meme maker bug report" | ||
service?.performWithItems(shareItems) | ||
} | ||
|
||
@IBAction func feedbackAction(sender: AnyObject) { | ||
|
||
let shareItems = [getSystemDetails()] | ||
let service = NSSharingService(named: NSSharingServiceNameComposeEmail) | ||
service?.delegate = self | ||
service?.recipients = ["[email protected]"] | ||
service?.subject = "Meme maker feedback/suggestion" | ||
service?.performWithItems(shareItems) | ||
} | ||
|
||
func getSystemDetails() -> String { | ||
if let dict = NSDictionary(contentsOfFile: "/System/Library/CoreServices/SystemVersion.plist") { | ||
let details = "\n\n\nSystem version = \(dict["ProductName"]!) \(dict["ProductVersion"]!)\n" | ||
return details | ||
} | ||
return "" | ||
} | ||
|
||
} | ||
|
||
extension SettingsViewController: NSSharingServiceDelegate { | ||
|
||
func sharingService(sharingService: NSSharingService, didShareItems items: [AnyObject]) { | ||
print("share success") | ||
} | ||
|
||
func sharingService(sharingService: NSSharingService, didFailToShareItems items: [AnyObject], error: NSError) { | ||
print("share failure") | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// MemeFetcher.swift | ||
// Meme Maker Mac | ||
// | ||
// Created by Avikant Saini on 7/6/16. | ||
// Copyright © 2016 avikantz. All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
|
||
public class MemeFetcher: NSObject { | ||
|
||
private var context: NSManagedObjectContext? = nil | ||
|
||
private var memes = NSMutableArray() | ||
private var fetchedMemes = NSMutableArray() | ||
|
||
override init() { | ||
super.init() | ||
let appDelegate = NSApplication.sharedApplication().delegate as! AppDelegate | ||
context = appDelegate.managedObjectContext | ||
} | ||
|
||
public func fetchMemes() -> Void { | ||
fetchMemes(0) | ||
} | ||
|
||
private func fetchMemes(paging: Int) -> Void { | ||
let request = NSMutableURLRequest(URL: apiMemesPaging(paging)) | ||
request.HTTPMethod = "GET" | ||
NSURLSession.sharedSession().dataTaskWithRequest(request) { (data, response, error) in | ||
if (error != nil) { | ||
print("Error: %@", error?.localizedDescription) | ||
return | ||
} | ||
if (data != nil) { | ||
do { | ||
let persistentStoreCoordinator = self.context?.persistentStoreCoordinator | ||
let asyncContext: NSManagedObjectContext = NSManagedObjectContext(concurrencyType: .PrivateQueueConcurrencyType) | ||
asyncContext.persistentStoreCoordinator = persistentStoreCoordinator | ||
|
||
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) | ||
let code = json.valueForKey("code") as! Int | ||
if (code == 200) { | ||
let jsonmemes = json.valueForKey("data") as! NSArray | ||
let memesArray = XMeme.getAllMemesFromArray(jsonmemes, context: asyncContext)! | ||
for meme in memesArray { | ||
self.fetchedMemes.addObject(meme) | ||
} | ||
try asyncContext.save() | ||
dispatch_async(dispatch_get_main_queue(), { | ||
self.fetchMemes(paging + 1) | ||
}) | ||
} | ||
else { | ||
self.memes = self.fetchedMemes | ||
dispatch_async(dispatch_get_main_queue(), { | ||
SettingsManager.saveLastUpdateDate() | ||
NSNotificationCenter.defaultCenter().postNotificationName(kFetchCompleteNotification, object: nil, userInfo: ["memes": self.memes]) | ||
}) | ||
return | ||
} | ||
} | ||
catch _ { | ||
print("Unable to parse") | ||
return | ||
} | ||
} | ||
}.resume() | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.