Skip to content
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.

Commit

Permalink
Performance Tunig
Browse files Browse the repository at this point in the history
  • Loading branch information
naoya committed Nov 2, 2011
1 parent 36e02b2 commit 653c1e1
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,4 +1,6 @@
.settings
tmp
build/
build.orig/
server/
.DS_Store
6 changes: 4 additions & 2 deletions Resources/bookmarks.coffee
Expand Up @@ -104,7 +104,8 @@ bookmarks2rows = (data, start, end) ->
bookmark:
user:
name: b.user
profile_image_url: $$$.profileImageUrl b.user
# profile_image_url: $$$.profileImageUrl b.user
profile_image_url: $$$.profileImageUrlLarge b.user
favicon_url: "http://favicon.st-hatena.com/?url=#{data.url}"
title: data.title
count: data.count
Expand Down Expand Up @@ -132,7 +133,8 @@ bookmarks2rows = (data, start, end) ->
imageContainer = Ti.UI.createView $$.timeline.profileImageContainer

image = HBFav.UI.createImageView $$.timeline.profileImage
image.imageWithCache $$$.profileImageUrl b.user
# image.imageWithCache $$$.profileImageUrl b.user
image.imageWithCache $$$.profileImageUrlLarge b.user
imageContainer.add image

bodyContainer = Ti.UI.createView $$.timeline.bodyContainer
Expand Down
4 changes: 2 additions & 2 deletions Resources/bookmarks.js
Expand Up @@ -105,7 +105,7 @@ bookmarks2rows = function(data, start, end) {
bookmark: {
user: {
name: b.user,
profile_image_url: $$$.profileImageUrl(b.user)
profile_image_url: $$$.profileImageUrlLarge(b.user)
},
favicon_url: "http://favicon.st-hatena.com/?url=" + data.url,
title: data.title,
Expand All @@ -117,7 +117,7 @@ bookmarks2rows = function(data, start, end) {
});
imageContainer = Ti.UI.createView($$.timeline.profileImageContainer);
image = HBFav.UI.createImageView($$.timeline.profileImage);
image.imageWithCache($$$.profileImageUrl(b.user));
image.imageWithCache($$$.profileImageUrlLarge(b.user));
imageContainer.add(image);
bodyContainer = Ti.UI.createView($$.timeline.bodyContainer);
name = Ti.UI.createLabel(_($$.timeline.nameLabel).extend({
Expand Down
5 changes: 2 additions & 3 deletions Resources/feed.coffee
Expand Up @@ -16,10 +16,9 @@ class Feed

imageContainer = Ti.UI.createView $$.timeline.profileImageContainer
image = HBFav.UI.createImageView $$.timeline.profileImage
# image.imageWithCache bookmark.user.profile_image_url
image.imageWithCache $$$.profileImageUrl bookmark.user.name
imageContainer.add image

# image.imageWithCache $$$.profileImageUrl bookmark.user.name
image.imageWithCache $$$.profileImageUrlLarge bookmark.user.name
bodyContainer = Ti.UI.createView $$.timeline.bodyContainer

name = Ti.UI.createLabel _($$.timeline.nameLabel).extend
Expand Down
2 changes: 1 addition & 1 deletion Resources/feed.js
Expand Up @@ -19,8 +19,8 @@ Feed = (function() {
});
imageContainer = Ti.UI.createView($$.timeline.profileImageContainer);
image = HBFav.UI.createImageView($$.timeline.profileImage);
image.imageWithCache($$$.profileImageUrl(bookmark.user.name));
imageContainer.add(image);
image.imageWithCache($$$.profileImageUrlLarge(bookmark.user.name));
bodyContainer = Ti.UI.createView($$.timeline.bodyContainer);
name = Ti.UI.createLabel(_($$.timeline.nameLabel).extend({
text: bookmark.user.name
Expand Down
2 changes: 1 addition & 1 deletion Resources/feedview.coffee
Expand Up @@ -53,7 +53,7 @@ class NormalState extends AbstractState
theEnd = e.contentSize.height
distance = theEnd - total
if distance < @lastDistance
nearEnd = theEnd * .90
nearEnd = theEnd * .98
if total >= nearEnd
@feedView.transitState new PagingStartState @feedView
@lastDistance = distance
Expand Down
2 changes: 1 addition & 1 deletion Resources/feedview.js
Expand Up @@ -75,7 +75,7 @@ NormalState = (function() {
theEnd = e.contentSize.height;
distance = theEnd - total;
if (distance < this.lastDistance) {
nearEnd = theEnd * .90;
nearEnd = theEnd * .98;
if (total >= nearEnd) {
this.feedView.transitState(new PagingStartState(this.feedView));
}
Expand Down
17 changes: 9 additions & 8 deletions Resources/styles.coffee
@@ -1,29 +1,30 @@
HBFav.UI.styles =
timeline:
profileImage:
backgroundColor: "#fff"
# opacity: 1.0
# width: 48
# height: 48
width: 32
height: 32
backgroundColor: "#fff"
width: 48
height: 48
# width: 32
# height: 32
top: 10
left: 10
# borderRadius: 5

profileImageContainer:
backgroundColor: "#fff"
width: 'auto'
height: '52'
height: 68
# height: '52'
top: 0
left: 0

bodyContainer:
layout: 'vertical'
width: 245
height: 'auto'
# left: 65
left: 50
left: 65
# left: 50
top: 0

nameLabel:
Expand Down
8 changes: 4 additions & 4 deletions Resources/styles.js
Expand Up @@ -3,23 +3,23 @@ HBFav.UI.styles = {
timeline: {
profileImage: {
backgroundColor: "#fff",
width: 32,
height: 32,
width: 48,
height: 48,
top: 10,
left: 10
},
profileImageContainer: {
backgroundColor: "#fff",
width: 'auto',
height: '52',
height: 68,
top: 0,
left: 0
},
bodyContainer: {
layout: 'vertical',
width: 245,
height: 'auto',
left: 50,
left: 65,
top: 0
},
nameLabel: {
Expand Down
16 changes: 8 additions & 8 deletions manifest
@@ -1,8 +1,8 @@
#appname:HBFav
#publisher:naoya
#url:http://b.hatena.ne.jp/naoya
#image:appicon.png
#appid:HBFav
#desc:not specified
#type:mobile
#guid:46cc50cf-bfc5-489a-ba4f-ba594eefedd8
#appname: HBFav
#publisher: naoya
#url: http://b.hatena.ne.jp/naoya
#image: appicon.png
#appid: HBFav
#desc: undefined
#type: mobile
#guid: 46cc50cf-bfc5-489a-ba4f-ba594eefedd8
93 changes: 87 additions & 6 deletions performance-1.7.3.patch
@@ -1,6 +1,24 @@
diff -Nur build.orig2/iphone/Classes/TiUILabel.m build/iphone/Classes/TiUILabel.m
--- build.orig2/iphone/Classes/TiUILabel.m 2011-10-24 16:29:16.000000000 +0900
+++ build/iphone/Classes/TiUILabel.m 2011-10-24 16:37:13.000000000 +0900
diff -Nur -x defines.h -x ApplicationRouting.m build.orig/iphone/Classes/ApplicationRouting.h build/iphone/Classes/ApplicationRouting.h
--- build.orig/iphone/Classes/ApplicationRouting.h 2011-11-02 21:29:34.000000000 +0900
+++ build/iphone/Classes/ApplicationRouting.h 2011-11-02 21:48:58.000000000 +0900
@@ -1,10 +1,13 @@
/**
* Appcelerator Titanium Mobile
- * This is generated code. Do not modify. Your changes will be lost.
+ * This is generated code. Do not modify. Your changes *will* be lost.
+ * Generated code is Copyright (c) 2009-2011 by Appcelerator, Inc.
+ * All Rights Reserved.
*/
#import <Foundation/Foundation.h>

@interface ApplicationRouting : NSObject {
}
+ (NSData*) resolveAppAsset:(NSString*)path;
+
@end
diff -Nur -x defines.h -x ApplicationRouting.m build.orig/iphone/Classes/TiUILabel.m build/iphone/Classes/TiUILabel.m
--- build.orig/iphone/Classes/TiUILabel.m 2011-11-02 21:29:35.000000000 +0900
+++ build/iphone/Classes/TiUILabel.m 2011-11-02 21:42:30.000000000 +0900
@@ -251,6 +251,20 @@
[[self label] setShadowOffset:size];
}
Expand All @@ -24,9 +42,9 @@ diff -Nur build.orig2/iphone/Classes/TiUILabel.m build/iphone/Classes/TiUILabel.
-#endif
\ No newline at end of file
+#endif
diff -Nur build.orig2/iphone/Classes/TiUIWebView.m build/iphone/Classes/TiUIWebView.m
--- build.orig2/iphone/Classes/TiUIWebView.m 2011-10-24 16:29:16.000000000 +0900
+++ build/iphone/Classes/TiUIWebView.m 2011-10-24 16:36:32.000000000 +0900
diff -Nur -x defines.h -x ApplicationRouting.m build.orig/iphone/Classes/TiUIWebView.m build/iphone/Classes/TiUIWebView.m
--- build.orig/iphone/Classes/TiUIWebView.m 2011-11-02 21:29:35.000000000 +0900
+++ build/iphone/Classes/TiUIWebView.m 2011-11-02 21:42:30.000000000 +0900
@@ -104,7 +104,7 @@

webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 10, 1)];
Expand All @@ -43,3 +61,66 @@ diff -Nur build.orig2/iphone/Classes/TiUIWebView.m build/iphone/Classes/TiUIWebV
-#endif
\ No newline at end of file
+#endif
diff -Nur -x defines.h -x ApplicationRouting.m build.orig/iphone/Classes/UIImage+Resize.m build/iphone/Classes/UIImage+Resize.m
--- build.orig/iphone/Classes/UIImage+Resize.m 2011-11-02 21:29:35.000000000 +0900
+++ build/iphone/Classes/UIImage+Resize.m 2011-11-02 21:48:51.000000000 +0900
@@ -21,57 +21,8 @@
image:(UIImage*)image
hires:(BOOL)hires
{
- CGImageRef imageRef = image.CGImage;
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-
- CGFloat scale = 1.0;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
- if ([TiUtils isIOS4OrGreater]) {
- scale = [image scale];
- // Force scaling to 2.0
- if ([TiUtils isRetinaDisplay] && hires) {
- scale = 2.0;
- }
- }
-#endif
-
- CGRect newRect = CGRectIntegral(CGRectMake(0, 0, newSize.width*scale, newSize.height*scale));
- CGRect transposedRect = CGRectMake(0, 0, newRect.size.height, newRect.size.width);
-
- // Build a context that's the same dimensions as the new size
- CGContextRef bitmap = CGBitmapContextCreate(NULL,
- newRect.size.width,
- newRect.size.height,
- 8,
- 0,
- colorSpace,
- kCGImageAlphaPremultipliedLast);
-
- // Rotate and/or flip the image if required by its orientation
- CGContextConcatCTM(bitmap, transform);
-
- // Set the quality level to use when rescaling
- CGContextSetInterpolationQuality(bitmap, quality);
-
- // Draw into the context; this scales the image
- CGContextDrawImage(bitmap, transpose ? transposedRect : newRect, imageRef);
-
- // Get the resized image from the context and a UIImage
- CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap);
- UIImage *newImage = nil;
- if ([TiUtils isIOS4OrGreater]) {
- newImage = [UIImage imageWithCGImage:newImageRef scale:scale orientation:UIImageOrientationUp];
- }
- else {
- newImage = [UIImage imageWithCGImage:newImageRef];
- }
-
- // Clean up
- CGContextRelease(bitmap);
- CGImageRelease(newImageRef);
- CGColorSpaceRelease(colorSpace);
-
- return newImage;
+ // patched: Do Nothing
+ return image;
}

// Returns an affine transform that takes into account the image orientation when drawing a scaled image
16 changes: 8 additions & 8 deletions tiapp.xml
Expand Up @@ -7,14 +7,14 @@
<target device="android">false</target>
<target device="blackberry">false</target>
</deployment-targets>
<id>HBFav</id>
<name>HBFav</name>
<version>1.0</version>
<publisher>naoya</publisher>
<url>https://github.com/naoya/HBFav</url>
<description>not specified</description>
<copyright>2011 by naoya</copyright>
<icon>images/appicon.png</icon>
<id>HBFav</id>
<name>HBFav</name>
<version>1.0</version>
<publisher>naoya</publisher>
<url>https://github.com/naoya/HBFav</url>
<description>not specified</description>
<copyright>2011 by naoya</copyright>
<icon>images/appicon.png</icon>
<persistent-wifi>false</persistent-wifi>
<prerendered-icon>false</prerendered-icon>
<statusbar-style>default</statusbar-style>
Expand Down

0 comments on commit 653c1e1

Please sign in to comment.