Activity Indicator causes black flash on Android.

You must Login before you can answer or comment on any questions.

Application type: mobile Titanium SDK: 2.1.2 (08/24/12 14:46 ed7f777) Platform & version: Android 4.1.1 Device: Any Host Operating System: Win7 x64 Titanium Studio: 2.1.2.201208301612

/resources/app.js

var MyApp = {};
 
Ti.include(
    'window.js'
    , 'test1.js'
    , 'test2.js'
    , 'test3.js'
    );
 
MyApp.Window.Open(MyApp.Test1);
/resources/window.js
(function () {
 
    MyApp.Window = {};
 
    // --------------------------------------------------------------------------
 
    MyApp.Window.ActivityIndicator = Ti.UI.createActivityIndicator({
        message:'Loading...',
        width: Ti.UI.SIZE,
        height:Ti.UI.SIZE,
        top:'50dp',
        left:'100dp'
        });
 
    MyApp.Window.ShowAC = function (activity)
    { 
        MyApp.Window.ActivityIndicator.show();
        MyApp.Window.ACLoaded = true;
    };
 
    MyApp.Window.HideAC = function (activity)
    { 
        MyApp.Window.ActivityIndicator.hide();
        MyApp.Window.ACLoaded = false; 
    };
 
    MyApp.Window.Open = function (activity)
    {
        activity.Window.fireEvent('myapp:loadwin');
        activity.Window.open();
    };
 
}());
/resources/test1.js
(function () {
 
    MyApp.Test1 = {};
 
    // --------------------------------------------------------------------------
 
    MyApp.Test1.Window = Ti.UI.createWindow({
        title: 'Test 1'
        , width: Ti.UI.FILL 
        , height: Ti.UI.FILL 
        , backgroundColor: '#FFFFF' 
        });
 
    // --------------------------------------------------------------------------
 
    function AddControls ()
    {
        var view = Ti.UI.createView({
            width: Ti.UI.FILL 
            , height: Ti.UI.FILL
            });
 
        var btn = Ti.UI.createButton({ 
            title: 'Test 2'
            , width: '100dp'
            , height: '100dp'  
            });
 
        btn.addEventListener('click', function (e)
        {
            MyApp.Window.Open(MyApp.Test2);
            MyApp.Test1.Window.close();
        });
 
        view.add(btn);
        MyApp.Test1.Window.add(view);
 
        MyApp.Window.HideAC(MyApp.Test1);
    };
 
    // --------------------------------------------------------------------------
 
    MyApp.Test1.Window.addEventListener('myapp:loadwin', function (e)
    {
        MyApp.Window.ShowAC(MyApp.Test1);
 
        AddControls();
    });
 
}());
/resources/test2.js
(function () {
 
    MyApp.Test2 = {};
 
    // --------------------------------------------------------------------------
 
    MyApp.Test2.Window = Ti.UI.createWindow({
        title: 'Test 2'
        , width: Ti.UI.FILL 
        , height: Ti.UI.FILL 
        , backgroundColor: '#FFFFF' 
        });
 
    // --------------------------------------------------------------------------
 
    function AddControls ()
    {
        var view = Ti.UI.createView({
            width: Ti.UI.FILL 
            , height: Ti.UI.FILL
            });
 
        var btn = Ti.UI.createButton({ 
            title: 'Test 3'
            , width: '100dp'
            , height: '100dp'  
            });
 
        btn.addEventListener('click', function (e)
        {
            MyApp.Window.Open(MyApp.Test3);
            MyApp.Test2.Window.close();
        });
 
        view.add(btn);
        MyApp.Test2.Window.add(view);
 
        MyApp.Window.HideAC(MyApp.Test2);
    };
 
    // --------------------------------------------------------------------------
 
    MyApp.Test2.Window.addEventListener('myapp:loadwin', function (e)
    {
        MyApp.Window.ShowAC(MyApp.Test2);
 
        AddControls();
    });
 
}());
/resources/test3.js
(function () {
 
    MyApp.Test3 = {};
 
    // --------------------------------------------------------------------------
 
    MyApp.Test3.Window = Ti.UI.createWindow({
        title: 'Test 3' 
        , width: Ti.UI.FILL 
        , height: Ti.UI.FILL 
        , backgroundColor: '#FFFFF' 
        });
 
    // --------------------------------------------------------------------------
 
    function AddControls ()
    {
        var view = Ti.UI.createView({
            width: Ti.UI.FILL 
            , height: Ti.UI.FILL
            });
 
        var btn = Ti.UI.createButton({ 
            title: 'Test 1'
            , width: '100dp'
            , height: '100dp'  
            });
 
        btn.addEventListener('click', function (e)
        {
            MyApp.Window.Open(MyApp.Test1);
            MyApp.Test3.Window.close();
        });
 
        view.add(btn);
        MyApp.Test3.Window.add(view);
 
        MyApp.Window.HideAC(MyApp.Test3);
    };
 
    // --------------------------------------------------------------------------
 
    MyApp.Test3.Window.addEventListener('myapp:loadwin', function (e)
    {
        MyApp.Window.ShowAC(MyApp.Test3);
 
        AddControls();
    });
 
}());

1 Answer

Ok, Im only guessing here, because this is alot of code to go throwing into a new project, but I would say that you get the black flash because of the background color on your windows. If you look at your code, your background colors look like this: backgroundColor: '#FFFFF'. Thats only 5 characters in a hex property that needs either 3 or 6. I believe that #FFFFF actually displays as black. Try adding a 6th F to make the proper hex color and the background won't flash as black before you add the rest of the window elements.

— answered 9 months ago by Anthony Decena
answer permalink
4 Comments
  • That indeed made the test case mimic the behavior of the app. That fixed the test case, but the problem still exists in the app. All color codes are correct. I'm using a tableview setup so everything has a proper background color. Window, view, table, section, row yet I'm still seeing the black flash occasionally. What else could cause this behavior?

    — commented 9 months ago by Tyler Presley

  • Something I just noticed. My other app has this zoom effect when the window opens. The test case has a nice fade. IDK what the difference is but I don't have any transitions setup. It seems to do it when you have that zoom transition and an active activityindicator. How do I get rid of the zoom transition?

    — commented 9 months ago by Tyler Presley

  • I believe the transitions between windows are controlled by the version of the OS installed on the device. But you can try setting the animation to false when opening new windows. ie:

    win.open({animate:false});

    — commented 9 months ago by Anthony Decena

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!