diff options
| author | Teddy Wing | 2012-06-24 06:02:20 -0400 | 
|---|---|---|
| committer | Teddy Wing | 2012-06-24 06:02:20 -0400 | 
| commit | f53f17326e4163a37c1d1520ef7f87c2c527b70c (patch) | |
| tree | 11327e702c510601d5d1d36b8e089eaa1d0711e7 | |
| parent | 233fc3bfd46e32a10a7e3f17ed20da98877a0368 (diff) | |
| parent | 50c4169dc1f769e20f5c64f6ec959f87bea35716 (diff) | |
| download | LikeFeed-f53f17326e4163a37c1d1520ef7f87c2c527b70c.tar.bz2 | |
Merge branch 'master' of github.com:teddywing/LikeFeed
| -rw-r--r-- | Resources/friendship/core/DataManipulation.js | 1 | ||||
| -rw-r--r-- | Resources/friendship/friendship.js | 2 | ||||
| -rw-r--r-- | Resources/friendship/ui/LikeList.js | 29 | 
3 files changed, 21 insertions, 11 deletions
| diff --git a/Resources/friendship/core/DataManipulation.js b/Resources/friendship/core/DataManipulation.js index e582ed9..ae18a89 100644 --- a/Resources/friendship/core/DataManipulation.js +++ b/Resources/friendship/core/DataManipulation.js @@ -5,4 +5,5 @@  	fs.data.reverseChronoLikedIDs = Array();  	fs.data.numLikesFetched = 0;  	fs.data.NUM_LIKES_PER_FETCH = 20; +	fs.data.isQueryingMore = false;  })();
\ No newline at end of file diff --git a/Resources/friendship/friendship.js b/Resources/friendship/friendship.js index fd61403..0e785e7 100644 --- a/Resources/friendship/friendship.js +++ b/Resources/friendship/friendship.js @@ -1,7 +1,9 @@  var fs = {}; +  (function() {  	fs.app = {}; +	fs.app.isAndroid = (Ti.Platform.osname === 'android');  })();  Ti.include( diff --git a/Resources/friendship/ui/LikeList.js b/Resources/friendship/ui/LikeList.js index 69b44a7..3ff885f 100644 --- a/Resources/friendship/ui/LikeList.js +++ b/Resources/friendship/ui/LikeList.js @@ -233,6 +233,7 @@  				}  			} +			ll_view.setData(Array());  			if (e.data.length > 0) {			  				var tuples = []; @@ -253,8 +254,10 @@  	   			ll_view.footerTitle = "0 / " + fs.data.reverseChronoLikedIDs.length + " loaded"; +	   			fs.data.isQueryingMore = true;  	   			fs.core.fetchMoreLikes(fs.data.NUM_LIKES_PER_FETCH);  	   		} else { +	   			fs.data.isQueryingMore = false;  	   			ll_view.footerTitle = "0 / 0 loaded";  				Ti.App.fireEvent('app:hide.loader');  	   		}  @@ -267,20 +270,24 @@  			}    			ll_view.footerTitle = fs.data.numLikesFetched + " / " + fs.data.reverseChronoLikedIDs.length + " loaded"; -			/* -			if (fs.data.numLikesFetched < fs.data.reverseChronoLikedIDs.length) { -				fs.core.fetchMoreLikes(fs.data.NUM_LIKES_PER_FETCH); -			} -			*/ -			// TODO: when UI scrolls to bottom, can call this (might need mutex) +  			fs.data.isQueryingMore = false; +  			Ti.App.fireEvent('app:hide.loader');  		}); -		ll_view.addEventListener("scrollEnd", function(e) { -			Ti.API.info("scroll ended"); -			Ti.API.info(e.contentOffset.y); -			Ti.API.info(ll_view.height); -		}); +		ll_view.addEventListener("scroll", function(e) { +			if (fs.app.isAndroid && (e.totalItemCount < e.firstVisibleItem + e.visibleItemCount + 3) +            		|| (!fs.app.isAndroid && (e.contentOffset.y + e.size.height + 100 > e.contentSize.height))) { +        		if (fs.data.numLikesFetched < fs.data.reverseChronoLikedIDs.length) { +        			if (!fs.data.isQueryingMore) { +            			fs.data.isQueryingMore = true; +						fs.core.fetchMoreLikes(fs.data.NUM_LIKES_PER_FETCH); +        			} +        		} else { +        			fs.data.isQueryingMore = false; +        		} +            } +	    });  		return ll_view;  	}; | 
