Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19257] Android: hide() doesn't work every time on Activity Indicator at launch

GitHub Issuen/a
TypeBug
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 4.1.1
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterShawn Lan
AssigneeUnknown
Created2015-07-24T00:33:54.000+0000
Updated2019-11-08T03:54:55.000+0000

Description

Create a default Alloy project with the following: index.xml:
<Alloy>
	<Window class="container">
		<ActivityIndicator id="actInd1" />
	</Window>
</Alloy>
index.js
$.index.open();
$.actInd1.show();
$.actInd1.hide();
At launch, sometimes the indicator still shows. Not every time you'll see this issue, so you have to keep exiting and relaunching the app to see it happen. My app loads external url at launch. It shows an indicator when loading, and hides it when finished or failed. In cases like network failure, the indicator.hide() is called almost right away, but not actually hided every time.

Comments

  1. David van de Meer 2019-11-08

    Hey guys - just had this bug happen to me on a app I am creating and showing an activityIndicator, then doing some network checking for a url, when the url is found the activityIndicator is hidden via activityIndicator.hide() , this works. But when the url is not found because of network error (airplane mode, no internet) the activityIndicator is hidden via activityIndicator.hide() - but the activityIndicator is still visible on the screen - when checking the activityIndicator.visible property that shows false???!! So there must be a bug somewhere - how do I go about having this 4 year old bug looked into? Also when adding a setTimeout for the activityIndicator.hide() it hides just fine
  2. David van de Meer 2019-11-08

    Titanium Version: Titanium 7.4.2 Android Device: Xiaomi Mi A1 Android Version: Android Version 9 I just built and ran the test above and it does if fact still fail to hide the ActivityIndicator. Adding the hide inside a setTimeout does allow it to hide. index.js
       $.index.open();
       $.actInd1.show();
       setTimeout(function(){ 
       	$.actInd1.hide();
       }, 500);
       
    Another use case that caused me to find this bug is using Titanium.Network.Online to check if phone has internet before doing url checks / calls.
       $.index.open();
       $.actInd1.show();
       
       if(Titanium.Network.online){
       	var url = "http://www.appcelerator.com";
       	var client = Ti.Network.createHTTPClient({
       		// function called when the response data is available
       		onload : function(e) {
       			Ti.API.info("Received text: " + this.responseText);
       	        $.actInd1.hide();
       		},
       		// function called when an error occurs, including a timeout
       		onerror : function(e) {
       			Ti.API.debug(e.error);
       			$.actInd1.hide();
       		},
       	});
       	// Prepare the connection.
       	client.open("GET", url);
       	// Send the request.
       	client.send();
       
       }else{
       	$.actInd1.hide();
       	Ti.API.info("ActivityIndicator Visible: " + $.actInd1.visible);
       };
       
    1. Run code on phone with internet - ActivityIndicator will hide. 2. Place phone in airplane more - run - ActivityIndicator will not hide index.js 3. Notice the log states visible = false - but on phone screen its still visible
       [INFO]  ActivityIndicator Visible: false
       

JSON Source