Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add haiku sample

  • Loading branch information...
commit 5168626b6def503b389ff7686b884deec9caa882 1 parent bd3fb5b
@chris4403 chris4403 authored
View
12 Resources/app.js
@@ -114,10 +114,22 @@ function showApplicationBase() {
window:win4
});
+ var win5 = Titanium.UI.createWindow({
+ title:'ハイク',
+ url : './window/haiku.js',
+ backgroundColor:'#fff'
+ });
+ var tab5 = Titanium.UI.createTab({
+ icon:'KS_nav_ui.png',
+ title:'Haiku',
+ window:win5
+ });
+
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.addTab(tab3);
tabGroup.addTab(tab4);
+ tabGroup.addTab(tab5);
tabGroup.open();
}
View
47 Resources/lib/hatena_util.js
@@ -235,3 +235,50 @@ Hatena.Util.createDiaryRow = function(item) {
});
return row;
}
+
+//http://developer.hatena.ne.jp/ja/documents/haiku/apis/rest#auth
+Hatena.Util.createHaikuRow = function(item) {
+ var row = Ti.UI.createTableViewRow();
+ row.height = 'auto';
+ var authorImage = Ti.UI.createImageView({
+ image : item.user.profile_image_url,
+ top : 2,
+ left : 2,
+ width : 32,
+ height : 32
+ });
+ row.add(authorImage);
+ var keyword = Ti.UI.createLabel({
+ left : 36,
+ height : 12,
+ top : 2,
+ width : 'auto',
+ textAlign : 'left',
+ font : {fontSize: 10},
+ color : "#999999",
+ text : item.keyword
+ });
+ row.add(keyword);
+ var body = Ti.UI.createLabel({
+ left : 36,
+ top : 14,
+ height : 'auto',
+ width : 'auto',
+ textAlign : 'left',
+ text : item.text
+ });
+ row.add(body);
+ row.link = item.link;
+ row.addEventListener('click', function(e) {
+ var win = Ti.UI.createWindow({
+ title : item.keyword
+ });
+ var webview = Ti.UI.createWebView({
+ url : item.link
+ });
+ win.add(webview);
+ Ti.UI.currentTab.open(win);
+ });
+ return row;
+}
+
View
19 Resources/window/haiku.js
@@ -0,0 +1,19 @@
+Ti.include('../lib/hatena_util.js');
+var oAuthAdapter = Ti.App.HatenaOAuthAdapter;
+oAuthAdapter.loadAccessToken('hatena');
+var haikuResponse = oAuthAdapter.send({
+ url : 'http://h.hatena.ne.jp/api/statuses/public_timeline.json',
+ parameters : null,
+ title : 'ハイク',
+ successMessage: '',
+ errorMessage: 'Error'
+});
+if (haikuResponse) {
+ haikuResponse = eval("(" + haikuResponse + ")");
+ var tableView = Ti.UI.createTableView({data:null});
+ for (var i = 0 , len = haikuResponse.length; i < len ; i++) {
+ var item = haikuResponse[i];
+ tableView.appendRow(Hatena.Util.createHaikuRow(item));
+ }
+ Ti.UI.currentWindow.add(tableView);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.