Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix phonegap issues

  • Loading branch information...
commit 29767c646896e25afdf2d6cb61731ebbd7a58636 1 parent 50ae4af
@revolunet authored
View
4 android/assets/www/app.js
@@ -17,6 +17,10 @@ Ext.application({
xclass: 'PhonegapDemo.view.Main'
});
+ // load phonegap stuff
+ document.addEventListener("deviceready", function () {
+ mainPanel.fireEvent("deviceready");
+ } , true);
}
});
View
8 android/assets/www/app/controller/Main.js
@@ -35,6 +35,8 @@ Ext.define('PhonegapDemo.controller.Main', {
onDeviceReady: function() {
// get phonegap contacts when ready
+ // save scope for phonegap callback
+ var me = this;
var fields = ['id', 'displayName', 'photos', 'phoneNumbers', 'emails'];
navigator.contacts.find(fields, function(contacts) {
var validContacts = [],
@@ -42,12 +44,12 @@ Ext.define('PhonegapDemo.controller.Main', {
for (var i = 0, l = contacts.length; i < l; i++) {
// filter results
- if (contacts[i].photos.length > 1 && contacts[i].photos[0].value !== '' && contacts[i].displayName && contacts[i].phoneNumbers.length > 0) {
+ if (contacts[i].photos.length > 0 && contacts[i].photos[0].value !== '' && contacts[i].displayName && contacts[i].phoneNumbers.length > 0) {
validContacts.push(contacts[i]);
}
}
store.add(validContacts);
- this.updateHomeInfo(store.getCount());
+ me.updateHomeInfo(store.getCount());
}, function() {
navigator.notification.alert("cannot access phone contacts :/");
});
@@ -93,7 +95,7 @@ Ext.define('PhonegapDemo.controller.Main', {
item = home.items.last(),
mainPanel = this.getMainPanel(),
listButton = this.getListButton(),
- html = "<div id='status'>" + count + " contact"+ (count > 1 ? 's' : '') +" found.</div>";
+ html = "<div id='status'>" + count + " contact"+ (count > 1 ? 's' : '') +" found</div>";
item.setHtml(html);
mainPanel.setMasked(false);
View
11 android/assets/www/index.html
@@ -10,19 +10,10 @@
<script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>
<!-- // <script src="http://jsconsole.com/remote.js?revotest"></script> -->
-
- <script type="text/javascript">
- function onBodyLoad() {
- // alert(40);
- document.addEventListener("deviceready", function() {
- //PhonegapDemo.
- }, false);
- }
- </script>
<script type="text/javascript" src="app.js"></script>
</head>
- <body onload="onBodyLoad()"></body>
+ <body></body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.