Permalink
Browse files

bug fixes for Android, refresh, and disabling avatar change for now

  • Loading branch information...
1 parent 1a58d05 commit beb470890c32da8b706d4d9bff8ab293cf301e3f @kwhinnery kwhinnery committed Oct 4, 2012
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -11,9 +11,11 @@ var sunday = [],
$.loading = Alloy.createController('loading');
$.index.add($.loading.getView());
+$.loading.start();
//Load agenda data
Session.getAll(function(e) {
+ $.loading.stop();
$.index.remove($.loading.getView());
if (e.success) {
var sessions = e.sessions;
@@ -67,6 +69,14 @@ if (!Alloy.isTablet) {
$.agendaTable.setData(tuesday);
}
});
+
+ //reset to day one if need be, since Android will not retain animation positions when a view has been unloaded from the hierarchy
+ $.on('focus', function() {
+ if ($.agendaTable && sunday.length > 0) {
+ $.agendaTable && ($.agendaTable.setData(sunday));
+ $.headerView.goTo(0);
+ }
+ });
}
//show session detail drawer
@@ -9,67 +9,74 @@ $.index.add($.loading.getView());
function loadContent() {
//Grab current agenda item
Session.getNext(function(e) {
- var session = e.next;
- $.title.text = session.name;
- $.presenter.text = session.custom_fields.presenter;
- $.location.text = session.custom_fields.location;
-
- if ($.dailySchedule) {
- var now = moment(),
- monDate = moment('Oct 22, 2012'),
- tueDate = moment('Oct 23, 2012');
- day = 'tuesday';
- if (now.diff(monDate) < 0) {
- day = 'sunday'
- }
- else if (now.diff(tueDate) < 0) {
- day = 'monday';
+ if (e.success) {
+ var session = e.next;
+ $.title.text = session.name;
+ $.presenter.text = session.custom_fields.presenter;
+ $.location.text = session.custom_fields.location;
+
+ if ($.dailySchedule) {
+ var now = moment(),
+ monDate = moment('Oct 22, 2012'),
+ tueDate = moment('Oct 23, 2012');
+ day = 'tuesday';
+ if (now.diff(monDate) < 0) {
+ day = 'sunday'
+ }
+ else if (now.diff(tueDate) < 0) {
+ day = 'monday';
+ }
+
+ Session.getForDay(day, function(ev) {
+ if (e.success) {
+ var data = [];
+ for (var i = 0, l = ev.sessions.length; i<l; i++) {
+ data.push(new ui.AgendaRow(ev.sessions[i]));
+ }
+ $.dailySchedule.setData(data);
+ }
+ else {
+ ui.alert('networkGenericErrorTitle', 'agendaNetworkError');
+ }
+ });
}
- Session.getForDay(day, function(ev) {
+ //Grab latest status updates
+ Status.query(function(e) {
+ $.loading.stop();
+ $.index.remove($.loading.getView());
if (e.success) {
var data = [];
- for (var i = 0, l = ev.sessions.length; i<l; i++) {
- data.push(new ui.AgendaRow(ev.sessions[i]));
+ for (var i = 0, l = e.statuses.length; i<l; i++) {
+ var status = e.statuses[i];
+ if (status.photo && !status.photo.processed) continue;
+ data.push(new ui.StatusRow(status));
}
- $.dailySchedule.setData(data);
+ $.streamTable.setData(data);
}
else {
- ui.alert('networkGenericErrorTitle', 'agendaNetworkError');
+ ui.alert('networkGenericErrorTitle', 'activityStreamError');
}
- });
+ },10);
+ }
+ else {
+ Ti.API.error('error fetching initial content: '+e);
+ ui.alert('networkGenericErrorTitle', 'agendaNetworkError');
}
-
- //Grab latest status updates
- Status.query(function(e) {
- $.index.remove($.loading.getView());
- if (e.success) {
- var data = [];
- for (var i = 0, l = e.statuses.length; i<l; i++) {
- data.push(new ui.StatusRow(e.statuses[i]));
- }
- $.streamTable.setData(data);
- }
- else {
- ui.alert('networkGenericErrorTitle', 'activityStreamError');
- }
- },10);
});
}
//Listen for status update, and refresh.
-Ti.App.addEventListener('app:status.update', function(e) {
- if (e.withPhoto && Ti.Platform.osname === 'android') {
- //swallow this for now - if we try to assign a URL to an image view we crash, so avoid doing it for now
- }
- else {
- loadContent();
- }
-});
+function startRefresh() {
+ $.index.add($.loading.getView());
+ $.loading.start();
+ loadContent();
+}
+Ti.App.addEventListener('app:status.update', startRefresh);
//Fire manually when this view receives "focus"
-$.on('focus', loadContent);
+$.on('focus', startRefresh);
//Go to activity stream
$.streamTable.on('click', function() {
@@ -11,13 +11,12 @@ if (!Ti.Network.online) {
ui.alert('networkErrTitle', 'networkErrMsg');
}
-
//create view hierarchy components
$.login = Alloy.createController('login');
-$.main = Alloy.createController('main');
//Check Login Status
if (User.confirmLogin()) {
+ $.main = Alloy.createController('main');
$.clouds && ($.index.remove($.clouds));
$.index.backgroundImage = '/img/general/bg-interior.png';
$.index.add($.main.getView());
@@ -31,6 +30,7 @@ else {
//Monitor Login Status
$.login.on('loginSuccess', function(e) {
+ $.main = Alloy.createController('main');
$.clouds && ($.index.remove($.clouds));
$.index.backgroundImage = '/img/general/bg-interior.png';
$.index.add($.main.getView());
@@ -10,8 +10,6 @@ $.loader.images = [
'/img/loading/load-cloud9.png'
];
-$.loader.start();
-
$.start = function() {
$.loader.start();
};
@@ -43,13 +43,16 @@ if (OS_IOS) {
//Login using network creds
$.login.on('click', function() {
$.index.parent.add($.loading.getView());
+ $.loading.start();
$.email.blur();
$.password.blur();
User.login($.email.value, $.password.value, function(e) {
$.trigger('loginSuccess', e);
$.password.value = '';
+ $.loading.stop();
$.index.parent.remove($.loading.getView());
}, function() {
+ $.loading.stop();
$.index.parent.remove($.loading.getView());
showError();
});
@@ -173,6 +173,7 @@ $.submit.on('click', function() {
var currentPost = $.post.value;
$.postContainer.add($.loading.getView());
+ $.loading.start();
Status.create({
message:(currentPost === '') ? 'Just uploaded from @codestrong 2012!' : currentPost, //empty string - status update tangram requires a message
photo:currentBlob
@@ -182,6 +183,7 @@ $.submit.on('click', function() {
if (twitterOn || fbOn) {
var args = {
success: function(ev) {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
ui.alert('updateSuccessTitle', 'updateSuccessText');
$.trigger('success');
@@ -190,6 +192,7 @@ $.submit.on('click', function() {
});
},
error: function(ev) {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
Ti.API.error('Error on social post: '+ev);
ui.alert('updateErrorTitle', 'updateErrorText');
@@ -234,6 +237,7 @@ $.submit.on('click', function() {
}
}
else {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
ui.alert('updateSuccessTitle', 'updateSuccessText');
$.trigger('success');
@@ -243,6 +247,7 @@ $.submit.on('click', function() {
}
}
else {
+ $.loading.stop();
$.postContainer.remove($.loading.getView());
Ti.API.error('Error on ACS post: '+e);
ui.alert('updateErrorTitle', 'updateErrorText');
@@ -19,8 +19,10 @@ if (userDetails.attributes.title) {
$.avatar.image = User.generateAvatarURL();
$.logout.on('click', function() {
+ $.loading.start();
$.index.add($.loading.getView());
User.logout(function(e) {
+ $.loading.stop();
$.index.remove($.loading.getView());
if (e.success) {
Ti.App.fireEvent('app:logout');
@@ -33,12 +35,21 @@ $.logout.on('click', function() {
//Handle image attachment
$.avatar.on('click', function() {
+ //TODO: Support image attachment - partially implemented, needs more testing for production.
+
var od = Ti.UI.createOptionDialog({
- options:[L('photoGallery'), L('camera'), L('cancel')],
- cancel:2,
- title:L('chooseAvatar')
+ options:['Go', L('cancel')],
+ cancel:1,
+ title:L('gravatar')
+ });
+ od.addEventListener('click', function(e) {
+ if (e.index === 0) {
+ Ti.Platform.openURL('http://gravatar.com');
+ }
});
+ od.show();
+ /*
od.addEventListener('click', function(e) {
var callbacks = {
success: function(e) {
@@ -71,6 +82,7 @@ $.avatar.on('click', function() {
else {
od.show();
}
+ */
});
@@ -5,12 +5,19 @@ $.loading = Alloy.createController('loading');
$.index.add($.loading.getView());
function loadRows() {
+ if (OS_ANDROID) {
+ $.table.setData([
+ {title:L('loadingLatest'), color:'#000'}
+ ]);
+ }
Status.query(function(e) {
+ $.loading.stop();
$.index.remove($.loading.getView());
if (e.success) {
var td = [];
for (var i = 0, l = e.statuses.length; i<l; i++) {
var status = e.statuses[i];
+ if (status.photo && !status.photo.processed) continue;
td.push(new ui.StatusRow(status));
}
$.table.setData(td);
@@ -21,18 +28,20 @@ function loadRows() {
});
}
+function startRefresh() {
+ $.index.add($.loading.getView());
+ $.loading.start();
+ loadRows();
+}
+
//Listen for status update, and refresh.
-Ti.App.addEventListener('app:status.update', function(e) {
- if (e.withPhoto && Ti.Platform.osname === 'android') {
- //swallow this for now - if we try to assign a URL to an image view we crash, so avoid doing it for now
- }
- else {
- loadRows();
- }
-});
+Ti.App.addEventListener('app:status.update', startRefresh);
//Fire manually when this view receives "focus"
-$.on('focus', loadRows);
+$.on('focus', startRefresh);
+
+//Refresh when requested
+$.refresh.on('click', startRefresh);
//Show a detail view for rows with an image
$.table.on('click', function(e) {
@@ -46,13 +55,13 @@ $.table.on('click', function(e) {
if (e.source.statusObject) {
statusObject = e.source.statusObject;
}
- else if (e.source.parent.sessionObject) {
+ else if (e.source.parent.statusObject) {
statusObject = e.source.parent.statusObject;
}
- else if (e.source.parent.parent && e.source.parent.parent.sessionObject) {
+ else if (e.source.parent.parent && e.source.parent.parent.statusObject) {
statusObject = e.source.parent.parent.statusObject;
}
- else if (e.source.parent.parent.parent && e.source.parent.parent.parent.sessionObject) {
+ else if (e.source.parent.parent.parent && e.source.parent.parent.parent.statusObject) {
statusObject = e.source.parent.parent.parent.statusObject;
}
}
@@ -113,5 +122,12 @@ $.table.on('click', function(e) {
web = null;
close = null;
});
+
+ if (OS_ANDROID) {
+ Ti.UI.createNotification({
+ message:L('pinch'),
+ duration:Ti.UI.NOTIFICATION_DURATION_LONG
+ }).show();
+ }
}
});
@@ -17,5 +17,10 @@ if (!Alloy.isTablet) {
$.venue.image = '/img/venue/venue-4th-floor.png';
}
});
+
+ //reset to day one if need be, since Android will not retain animation positions when a view has been unloaded from the hierarchy
+ $.on('focus', function() {
+ $.venue.image = '/img/venue/venue-3rd-floor.png';
+ $.headerView.goTo(0);
+ });
}
-
Oops, something went wrong.

0 comments on commit beb4708

Please sign in to comment.