mobile: show loading progress in title bar

This commit is contained in:
fkloft 2014-01-03 18:49:47 +01:00
parent 1f47ca87dd
commit a1d03ec69b
3 changed files with 33 additions and 9 deletions

View File

@ -59,7 +59,7 @@ window.MapDataRequest = function() {
this.FETCH_TO_REFRESH_FACTOR = 2; //refresh time is based on the time to complete a data fetch, times this value this.FETCH_TO_REFRESH_FACTOR = 2; //refresh time is based on the time to complete a data fetch, times this value
// ensure we have some initial map status // ensure we have some initial map status
this.setStatus ('startup'); this.setStatus ('startup', undefined, -1);
} }
@ -76,7 +76,7 @@ window.MapDataRequest.prototype.start = function() {
// then set a timeout to start the first refresh // then set a timeout to start the first refresh
this.refreshOnTimeout (this.STARTUP_REFRESH); this.refreshOnTimeout (this.STARTUP_REFRESH);
this.setStatus ('refreshing'); this.setStatus ('refreshing', undefined, -1);
this.cache && this.cache.startExpireInterval (15); this.cache && this.cache.startExpireInterval (15);
} }
@ -110,7 +110,7 @@ window.MapDataRequest.prototype.mapMoveEnd = function() {
} }
} }
this.setStatus('refreshing'); this.setStatus('refreshing', undefined, -1);
this.refreshOnTimeout(this.MOVE_REFRESH); this.refreshOnTimeout(this.MOVE_REFRESH);
} }
@ -120,7 +120,7 @@ window.MapDataRequest.prototype.idleResume = function() {
if (this.idle) { if (this.idle) {
console.log('refresh map idle resume'); console.log('refresh map idle resume');
this.idle = false; this.idle = false;
this.setStatus('idle restart'); this.setStatus('idle restart', undefined, -1);
this.refreshOnTimeout(this.IDLE_RESUME_REFRESH); this.refreshOnTimeout(this.IDLE_RESUME_REFRESH);
} }
} }
@ -262,7 +262,7 @@ window.MapDataRequest.prototype.refresh = function() {
} }
} }
this.setStatus ('loading'); this.setStatus ('loading', undefined, -1);
// technically a request hasn't actually finished - however, displayed portal data has been refreshed // technically a request hasn't actually finished - however, displayed portal data has been refreshed
// so as far as plugins are concerned, it should be treated as a finished request // so as far as plugins are concerned, it should be treated as a finished request

View File

@ -3,6 +3,7 @@
// gives user feedback about pending operations. Draws current status // gives user feedback about pending operations. Draws current status
// to website. Updates info in layer chooser. // to website. Updates info in layer chooser.
window.renderUpdateStatus = function() { window.renderUpdateStatus = function() {
var progress = 1;
// portal level display // portal level display
var t = '<span class="help portallevel" title="Indicates portal levels displayed. Zoom in to display lower level portals.">'; var t = '<span class="help portallevel" title="Indicates portal levels displayed. Zoom in to display lower level portals.">';
@ -20,19 +21,21 @@ window.renderUpdateStatus = function() {
t += ' <span class="map"><b>map</b>: '; t += ' <span class="map"><b>map</b>: ';
if (window.mapDataRequest) { if (window.mapDataRequest) {
var status = window.mapDataRequest.getStatus(); var status = window.mapDataRequest.getStatus();
// status.short - short description of status // status.short - short description of status
// status.long - longer description, for tooltip (optional) // status.long - longer description, for tooltip (optional)
// status.progress - fractional progress (from 0 to 1) of current state (optional) // status.progress - fractional progress (from 0 to 1; -1 for indeterminate) of current state (optional)
if (status.long) if (status.long)
t += '<span class="help" title="'+status.long+'">'+status.short+'</span>'; t += '<span class="help" title="'+status.long+'">'+status.short+'</span>';
else else
t += '<span>'+status.short+'</span>'; t += '<span>'+status.short+'</span>';
if (status.progress !== undefined) if (status.progress !== undefined) {
t += ' '+Math.floor(status.progress*100)+'%'; if(status.progress !== -1)
t += ' '+Math.floor(status.progress*100)+'%';
progress = status.progress;
}
} else { } else {
// no mapDataRequest object - no status known // no mapDataRequest object - no status known
t += '...unknown...'; t += '...unknown...';
@ -82,4 +85,7 @@ window.renderUpdateStatus = function() {
$('#innerstatus').html(t); $('#innerstatus').html(t);
//$('#updatestatus').click(function() { startRefreshTimeout(10); }); //$('#updatestatus').click(function() { startRefreshTimeout(10); });
//. <a style="cursor: pointer" onclick="startRefreshTimeout(10)" title="Refresh">⟳</a>'; //. <a style="cursor: pointer" onclick="startRefreshTimeout(10)" title="Refresh">⟳</a>';
if (typeof android !== 'undefined' && android && android.setProgress)
android.setProgress(progress);
} }

View File

@ -206,4 +206,22 @@ public class IITC_JSInterface {
} }
}); });
} }
@JavascriptInterface
public void setProgress(final double progress) {
mIitc.runOnUiThread(new Runnable() {
@Override
public void run() {
if (progress != -1) {
// maximum for setProgress is 10,000
mIitc.setProgressBarIndeterminate(false);
mIitc.setProgress((int) Math.round(progress * 10000));
}
else {
mIitc.setProgressBarIndeterminate(true);
mIitc.setProgress(1);
}
}
});
}
} }