Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2521] ActionBar.setActionView() not executed in the UI Thread

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2013-05-07T21:34:27.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid
ReporterThomas Keunebroek
AssigneeShak Hossain
Created2012-12-13T10:28:37.000+0000
Updated2016-03-08T07:41:35.000+0000

Description

Hi, I'm using the new Titanium version, that adds Android's ActionBar support. I have a refresh button as Action, and I'd like to display an ActivityIndicator where the user presses it, while the view is being refreshed. Here's a very simple piece of code:
var activity = win.activity;
	activity.onCreateOptionsMenu = function(e) {
	var menu = e.menu;
	var refresh = menu.add({
		title: 'Refresh',
		icon: Titanium.App.Android.R.drawable.ic_menu_refresh,
		showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS
	});
	refresh.addEventListener('click', function() {
		var activityIndicator = Ti.UI.createActivityIndicator({
			color: 'white',
			font: {
				 fontFamily: 'Droid Sans',
				 fontSize: 26,
				 fontWeight: 'bold'
			},
			style: Ti.UI.ActivityIndicatorStyle.PLAIN,
		});
		this.setActionView(activityIndicator);
	});
I end up with a Ti Runtime Error, as shown in the attachment. Thanks for your help guys! EDIT: sorry, should be moved to the TIMOB project. Can't figure out how to do it myself though

Attachments

FileDateSize
setActionView_error.png2012-12-13T10:28:37.000+000046637

Comments

  1. Carter Lathrop 2013-05-07

    Thomas, Thanks for bringing this to our attention. In order for a community ticket (TC) to be moved to Mobile it has to be first verified, this is why you cannot move it yourself. As for your ticket, would you mind providing a runnable test case that shows the behavior. Having an app.js that can be easily copied and pasted into a project that can clearly show the bug allows for a speedy review and transition to Ti-Mobile. Once the test case is provided I will gladly take a look at it. For future reference: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report Thanks for your cooperation, Carter
  2. Mostafizur Rahman 2013-12-10

    Hello, We tested this issue with the test code below. We can’t reproduce this issue in Ti SDK 3.1.3GA. Please install the latest SDK and test your app. If you continue to get error, please send us a test case with steps to reproduce.

    Testing Environment:

    Ti CLI 3.3.0 Titanium SDK: 3.1.3 and later Android SDK: 4.2.2

    Test Code

    app.js
       var win = Ti.UI.createWindow({
       	navBarHidden : false,
       	title : 'Action Bar',
       	backgroundColor : '#000'
       
       });
       
       // var activity = win.activity;
       win.activity.onCreateOptionsMenu = function(e) {
       	var menu = e.menu;
       	var refresh = menu.add({
       		title : 'Refresh',
       		showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS
       	});
       
       	refresh.addEventListener('click', function() {
       		var activityIndicator = Ti.UI.createActivityIndicator({
       			color : 'white',
       			font : {
       				fontSize : 26,
       				fontWeight : 'bold'
       			},
       			style : Ti.UI.ActivityIndicatorStyle.DARK,
       		});
       		this.setActionView(activityIndicator);
       	});
       
       };
       
       win.open(); 
       
       
    tiapp.xml
        <android xmlns:android="http://schemas.android.com/apk/res/android">
               <tool-api-level>16</tool-api-level>
               <manifest>
                   <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
               </manifest>
           </android>
       
       

    Steps to Test

    1. Create a sample Project 2. Update app.js file with my test code 3. Update tiapp.xml file with above code 4. And run this project with testing environment Thanks
  3. Shak Hossain 2014-01-20

    Closing since the issue is not reproducible and the reporter has not got back to us with any further updated comments.

JSON Source