Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Unified Diff: pkg/immi_samples/lib/ios/ImmiSamples/ImagePresenter.mm

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/immi_samples/lib/ios/ImmiSamples/ImagePresenter.mm
diff --git a/pkg/immi_samples/lib/ios/ImmiSamples/ImagePresenter.mm b/pkg/immi_samples/lib/ios/ImmiSamples/ImagePresenter.mm
deleted file mode 100644
index 8d50e951a72e86b7df13da53316deb72ded1145b..0000000000000000000000000000000000000000
--- a/pkg/immi_samples/lib/ios/ImmiSamples/ImagePresenter.mm
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-#import "ImagePresenter.h"
-
-@interface ImagePresenter ()
-@property id<ImageCache> imageCache;
-@end
-
-@implementation ImagePresenter
-
-- (void)setCache:(id<ImageCache>)cache {
- self.imageCache = cache;
-}
-
-- (void)setDefaultImage:(UIImage*)defaultImage {
- self.image = defaultImage;
-}
-
-- (void)presentImageFromData:(NSData*) imageData {
- self.image = [UIImage imageWithData:imageData];
-}
-
-- (void)patchImage:(ImagePatch*)patch {
- if (patch.url.changed) {
- [self performSelectorOnMainThread:@selector(loadImageFromUrl:)
- withObject:patch.url.current
- waitUntilDone:NO];
- }
-}
-
-- (void)presentImage:(ImageNode*)node {
- [self performSelectorOnMainThread:@selector(loadImageFromUrl:)
- withObject:node.url
- waitUntilDone:NO];
-}
-
-- (void)loadImageFromUrl:(NSString*)url {
- assert(NSThread.isMainThread);
-
- if (self.imageCache == nil) {
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
- NSData* imageData =
- [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
- [self presentImageFromData:imageData];
- });
- } else {
- id cachedImage = [self.imageCache get:url];
- if (cachedImage != nil) {
- if ([cachedImage isKindOfClass:NSMutableArray.class]) {
- [cachedImage addObject:self];
- } else {
- [self presentImageFromData:cachedImage];
- }
- } else {
- NSMutableArray* waitingImages = [[NSMutableArray alloc] init];
- [waitingImages addObject:self];
- [self.imageCache put:url value:waitingImages];
-
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
- NSData* imageData =
- [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
-
- if (imageData == nil) return;
-
- dispatch_async(dispatch_get_main_queue(), ^{
- NSMutableArray* queue = [self.imageCache get:url];
- [self.imageCache put:url value:imageData];
-
- [queue enumerateObjectsUsingBlock:^(ImagePresenter* imagePresenter,
- NSUInteger idx,
- BOOL* stop) {
- [imagePresenter presentImageFromData:imageData];
- }];
- });
- });
- }
- }
-}
-
-@end
« no previous file with comments | « pkg/immi_samples/lib/ios/ImmiSamples/ImagePresenter.h ('k') | pkg/immi_samples/lib/ios/ImmiSamples/LoginPresenter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698