From e54e5a688f90e92bb0540c791682145153d44783 Mon Sep 17 00:00:00 2001
From: Anqi Xu
Date: Sun, 24 Jun 2012 00:46:42 -0400
Subject: Minor code refactoring
---
Resources/friendship/core/FacebookFQL.js | 50 ++++++++++++--------------------
Resources/friendship/ui/LikeList.js | 15 ++--------
2 files changed, 21 insertions(+), 44 deletions(-)
diff --git a/Resources/friendship/core/FacebookFQL.js b/Resources/friendship/core/FacebookFQL.js
index 99d64f6..7abf0c0 100644
--- a/Resources/friendship/core/FacebookFQL.js
+++ b/Resources/friendship/core/FacebookFQL.js
@@ -5,41 +5,27 @@
Ti.Facebook.requestWithGraphPath(fqlURL, {}, 'GET', fqlCallback);
};
- fs.core.queryAllFriendPostsFQL = function() {
+ fs.core.handleFQLResponse = function(response, eventName) {
+ if (response.success) {
+ var data = JSON.parse(response.result);
+ Ti.API.fireEvent(eventName, {data: data});
+ } else if (response.error) {
+ Ti.API.fireEvent("processFQLError", {what: response.error}); // TODO: add event listener to processFQLError and print the .what field
+ } else {
+ Ti.API.fireEvent("processFQLError", {what: "unrecognized query response"});
+ }
+ }; // TODO: find some way to handle timeout (via Ti.Facebook....)
+
+ fs.core.handleAllFriendPostsFQLResponse = function (result) { fs.core.handleFQLResponse(result, "processPosts"); };
+ fs.core.queryAllFriendPostsFQL = function() { // TODO: make a variant that takes in user list and other filter info
var query = "SELECT page_id, name, description, page_url, pic_square, fan_count, type, website, general_info ";
query += "FROM page WHERE page_id ";
query += "IN (SELECT page_id FROM page_fan WHERE uid ";
//query += "= " + Ti.Facebook.uid + ")";
query += "IN (SELECT uid2 FROM friend WHERE uid1 = " + Titanium.Facebook.uid + "))";
- //query += "order by last_name limit 20";
- Ti.Facebook.request('fql.query', {query: query}, fs.core.handleAllFriendPostsFQL);
- // TODO: after calling this fn, display the loading animation
- };
-
- /*
- fs.core.handleFQLResponse = function(callback) {
- };
- */
-
- fs.core.handleAllFriendPostsFQL = function(result) {
- if (result.success) {
- var postsList = JSON.parse(result.result);
-
- /*
- Ti.API.info(postsList.length);
- Ti.API.info(postsList[0].name);
- Ti.API.info(postsList[0].page_id);
- Ti.API.info(postsList[0].website);
- */
-
- Ti.API.fireEvent("processPosts", {list:postsList});
- } else if (result.error) {
- //Ti.API.info("ERROR: " + result.error); // TODO: remove
- Ti.API.fireEvent("processFQLError", {what:result.error});
- } else {
- //Ti.API.info("ERROR: unknown response from FQL query"); // TODO: remove
- Ti.API.fireEvent("processFQLError", {what:"unknown FQL response"});
- }
- }; // TODO: handle timeouts
-
+ query += " limit 20"; // TODO: remove the limit
+ Ti.API.info(query); // TODO: remove debug printout
+ Ti.Facebook.request('fql.query', {query: query}, fs.core.handleAllFriendPostsFQLResponse);
+ Ti.API.fireEvent("displayLoadingAnimation");
+ };
})();
diff --git a/Resources/friendship/ui/LikeList.js b/Resources/friendship/ui/LikeList.js
index ce01096..b5a5e6b 100644
--- a/Resources/friendship/ui/LikeList.js
+++ b/Resources/friendship/ui/LikeList.js
@@ -48,19 +48,10 @@
fs.ui.createLikeList = function() {
var ll_view = Ti.UI.createTableView();
- /*
- ll_view.addEventListener('click', function(e) {
- Ti.UI.currentTabGroup.activeTab.open(fs.ui.createWebViewWin({
- title: e.title,
- url: e.url
- }));
- });
- */
- Ti.API.addEventListener( "processPosts", function( list ) {
- //Ti.UI.createAlertDialog( {title:"Items: " + list.list.length} ).show();
- for ( key in list.list ) {
- ll_view.appendRow( create_row( list.list[key] ) );
+ Ti.API.addEventListener("processPosts", function(d) {
+ for ( key in d.data ) {
+ ll_view.appendRow( create_row( d.data[key] ) );
}
});
--
cgit v1.2.3
From 0ff7e70b07e350ac3bb0181b0a92b0127bea2d09 Mon Sep 17 00:00:00 2001
From: Teddy Wing
Date: Sun, 24 Jun 2012 00:49:21 -0400
Subject: Activity indicator: created a big activity indicator that puts itself
in the middle of the screen when something's happening.
---
Resources/friendship/ui/ActivityIndicator.js | 34 ++++++++++++++++++++++++++++
Resources/friendship/ui/ApplicationWindow.js | 4 ++++
Resources/friendship/ui/LikeList.js | 7 ++++++
Resources/friendship/ui/ui.js | 3 ++-
tiapp.xml | 2 +-
5 files changed, 48 insertions(+), 2 deletions(-)
create mode 100644 Resources/friendship/ui/ActivityIndicator.js
diff --git a/Resources/friendship/ui/ActivityIndicator.js b/Resources/friendship/ui/ActivityIndicator.js
new file mode 100644
index 0000000..d74a563
--- /dev/null
+++ b/Resources/friendship/ui/ActivityIndicator.js
@@ -0,0 +1,34 @@
+(function() {
+ fs.ui.createLoadingView = function() {
+ var loading_view = Ti.UI.createView({
+ height: 100,
+ width: 100,
+ visible: false
+ });
+
+ var background = Ti.UI.createView({
+ backgroundColor: '#222',
+ opacity: 0.82,
+ borderRadius: 10
+ });
+ var loader = Ti.UI.createActivityIndicator({
+ style: Titanium.UI.iPhone.ActivityIndicatorStyle.BIG
+ });
+
+ loading_view.add(background);
+ loading_view.add(loader);
+ loader.show();
+
+ Ti.App.addEventListener('app:show.loader', function() {
+ if (!loading_view.visible) {
+ loading_view.visible = true;
+ }
+ });
+
+ Ti.App.addEventListener('app:hide.loader', function() {
+ loading_view.visible = false;
+ });
+
+ return loading_view;
+ };
+})();
diff --git a/Resources/friendship/ui/ApplicationWindow.js b/Resources/friendship/ui/ApplicationWindow.js
index 5243bd3..babc43c 100644
--- a/Resources/friendship/ui/ApplicationWindow.js
+++ b/Resources/friendship/ui/ApplicationWindow.js
@@ -10,6 +10,10 @@
var debug_button = Ti.UI.createButton({title: 'Debug'});
debug_button.addEventListener('click', function(e) {
+ // Show loading view
+ var loading = fs.ui.createLoadingView();
+ win.add(loading);
+ Ti.App.fireEvent('app:show.loader');
Ti.API.info('Logged in: ' + JSON.stringify(Ti.Facebook.loggedIn));
if (Ti.Facebook.loggedIn) {
diff --git a/Resources/friendship/ui/LikeList.js b/Resources/friendship/ui/LikeList.js
index ce01096..1e4c815 100644
--- a/Resources/friendship/ui/LikeList.js
+++ b/Resources/friendship/ui/LikeList.js
@@ -57,11 +57,18 @@
});
*/
+ var loading = fs.ui.createLoadingView();
+ ll_view.add(loading);
+
+ // Ti.App.fireEvent('app:show.loader');
+
Ti.API.addEventListener( "processPosts", function( list ) {
//Ti.UI.createAlertDialog( {title:"Items: " + list.list.length} ).show();
for ( key in list.list ) {
ll_view.appendRow( create_row( list.list[key] ) );
}
+
+ Ti.App.fireEvent('app:hide.loader');
});
return ll_view;
diff --git a/Resources/friendship/ui/ui.js b/Resources/friendship/ui/ui.js
index 76def2e..f810b87 100644
--- a/Resources/friendship/ui/ui.js
+++ b/Resources/friendship/ui/ui.js
@@ -6,5 +6,6 @@ Ti.include(
'/friendship/ui/ApplicationWindow.js',
'/friendship/ui/LikeList.js',
'/friendship/ui/LoginWindow.js',
- '/friendship/ui/WebView.js'
+ '/friendship/ui/WebView.js',
+ '/friendship/ui/ActivityIndicator.js'
)
diff --git a/tiapp.xml b/tiapp.xml
index 6c7786d..9cc4a2f 100644
--- a/tiapp.xml
+++ b/tiapp.xml
@@ -7,7 +7,7 @@
false
false
- 2.0.2.GA
+ 1.6.2
com.likefeed.LikeFeed
LikeFeed
1.0
--
cgit v1.2.3