Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2172] Window show/hide methods not working in latest git

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:58:18.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsiOS
Labelsdefect, ios, iphone, rplist, window
Reporterctredway
AssigneeBlain Hamon
Created2011-04-15T03:12:37.000+0000
Updated2011-04-17T01:58:18.000+0000

Description

On the iphone, using the hide/show methods will hide a window but will not show it again. However, manually setting the visible property does work.

Below code shows this:
var app = {

setupActivity: function(message) {
    this.activityTrans = Ti.UI.createWindow(
        {backgroundColor: "#fff", opacity: 0.65, zIndex: 1});
    this.activityWin = Ti.UI.createWindow(
        {opacity: 0.9,
         backgroundImage: 'images/gradround.png',
         top: "40%", height: 80, left: "20%", right: "20%", zIndex: 2,
         color:"#fff"
        });
    this.activity = Ti.UI.createActivityIndicator(
        {top: 30, height: 25, color:"#fff",
         style:Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN});
    this.activity.show();
    this.activityWin.add(this.activity);
    this.activityLabel = Ti.UI.createLabel(
        {left: 5, right: 5, top: 35, height: 35,
         text: "", color: "#fff", textAlign: "center",
         font:{fontSize:16}
        });
    this.activityWin.add(this.activityLabel);

    this.activityTrans.open();
    this.activityWin.open();
    this.activity.message = message;
    Titanium.App.idleTimerDisabled = true;
},

activityOn: function (message) {
    if (!message) {
        message = "Loading...";
    }
    if (!this.activityWin) {
        this.setupActivity(message);
    } else {
        this.activityWin.height = 80;
        this.activityWin.left = "20%";
        this.activityWin.right = "20%";
        this.activityLabel.text = "";
        this.activity.message = message;
        this.activity.top = 30;
        this.activity.show();
        this.activityWin.show();
        this.activityTrans.show();
        Titanium.App.idleTimerDisabled = true;
    }
    this.activityLabelShown = false;
    this.activityProgressShown = false;
},

activityOff: function (keepTrans) {
    if (this.activity) {
        Titanium.App.idleTimerDisabled = false;
        this.activity.hide(); // android
        this.activityWin.hide();
        if (!keepTrans) {
            this.activityTrans.hide();
        }
        if (this.progressBar) {
            this.progressBar.hide();
        }
    }
}

};

app.activityOn("message 1");
setTimeout(function () {

           app.activityOff();
           setTimeout(function () {
                          app.activityOn("message 2");
                      }, 2000);
       }, 2000);

Comments

  1. Stephen Tramer 2011-04-15

    Mislabeled the bug as #2272 instead of #2172 in the commit. Commit is 7604111. Marking fixed-in-qa.

  2. Damien Elmes 2011-04-15

    Hmm, this has resolved the problem with the code above, but my webviews as reported in http://developer.appcelerator.com/helpdesk/view/50571">http://developer.appcelerator.com/helpdesk/view/50571 are not rendering correctly. I'll try build you a test case tonight or tomorrow.

  3. Damien Elmes 2011-04-15

    The following code works in 1.4.x but not the current git.

    ~~~ var debug = Ti.API.debug;

    var app = {

       setup: function () {
           this.win = Ti.UI.createWindow({});
           this.web = Ti.UI.createWebView({html:"<html><body>hello</body></html>"});
           this.web2 = Ti.UI.createWebView({html:"<html><body>world</body></html>"});
           this.win.add(this.web);
           this.win.add(this.web2);
           this.win.open();
       },
       
       toggle: function () {
           if (this.web2.visible) {
               debug("visible");
               this.web2.hide();
           } else {
               debug("invisible");
               this.web2.show();
           }
       }
       

    };

    app.setup();
    setInterval(function () {

                  app.toggle();
              }, 2000);
       

    ~~~

  4. Damien Elmes 2011-04-15

    Sorry, again without the crappy formatting:

       var debug = Ti.API.debug;
       
       var app = {
       
       setup: function () {
           this.win = Ti.UI.createWindow({});
           this.web = Ti.UI.createWebView({html:"<html><body>hello</body></html>"});
           this.web2 = Ti.UI.createWebView({html:"<html><body>world</body></html>"});
           this.win.add(this.web);
           this.win.add(this.web2);
           this.win.open();
       },
       
       toggle: function () {
           if (this.web2.visible) {
               debug("visible");
               this.web2.hide();
           } else {
               debug("invisible");
               this.web2.show();
           }
       }
       
       };
       
       app.setup();
       setInterval(function () {
       
                  app.toggle();
              }, 2000);
       
  5. Stephen Tramer 2011-04-15

    Reopening.

  6. Jeff Haynie 2011-04-15

    (from [d62a7e28e9188a95c9fa4993fbfdf33152529b01]) [#2172 state:fixed-in-qa] zindex now forcefully reset (to add view to hierarchy) before reposition when setting 'visible', if necessary. http://github.com/appcelerator/titanium_mobile/commit/d62a7e28e9188a95c9fa4993fbfdf33152529b01"> http://github.com/appcelerator/titanium_mobile/commit/d62a7e28e9188...

  7. Damien Elmes 2011-04-15

    Thanks, this looks fixed now

  8. Damien Elmes 2011-04-15

    Sorry, spoke too soon. Various other regressions now. The following code works on 1.4.x, not on 1.5. Comments at the bottom of file

       var debug = Ti.API.debug;
       
       var app = {
           setupActivity: function(message) {
               this.activityTrans = Ti.UI.createWindow(
                   {backgroundColor: "#fff", opacity: 0.65, zIndex: 1});
               this.activityWin = Ti.UI.createWindow(
                   {opacity: 0.9,
                    backgroundImage: 'images/gradround.png',
                    top: "40%", height: 80, left: "20%", right: "20%", zIndex: 2,
                    color:"#fff"
                   });
               this.activity = Ti.UI.createActivityIndicator(
                   {top: 30, height: 25, color:"#fff",
                    style:Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN});
               this.activity.show();
               this.activityWin.add(this.activity);
               this.activityLabel = Ti.UI.createLabel(
                   {left: 5, right: 5, top: 35, height: 35,
                    text: "", color: "#fff", textAlign: "center",
                    font:{fontSize:16}
                   });
               this.activityWin.add(this.activityLabel);
       
               this.activityTrans.open();
               this.activityWin.open();
               this.activity.message = message;
               Titanium.App.idleTimerDisabled = true;
           },
       
           activityOn: function (message) {
               if (!message) {
                   message = "Loading...";
               }
               if (!this.activityWin) {
                   this.setupActivity(message);
               } else {
                   this.activityWin.height = 80;
                   this.activityWin.left = "20%";
                   this.activityWin.right = "20%";
                   this.activityLabel.text = "";
                   this.activity.message = message;
                   this.activity.top = 30;
                   this.activity.show();
                   this.activityWin.show();
                   this.activityTrans.show();
                   Titanium.App.idleTimerDisabled = true;
               }
               this.activityLabelShown = false;
               this.activityProgressShown = false;
           },
       
           activityOff: function (keepTrans) {
               if (this.activity) {
                   Titanium.App.idleTimerDisabled = false;
                   this.activity.hide(); // android
                   this.activityWin.hide();
                   if (!keepTrans) {
                       this.activityTrans.hide();
                   }
                   if (this.progressBar) {
                       this.progressBar.hide();
                   }
               }
           },
       
           activityProgress: function (value) {
               this.activity.top = 15;
               if (!this.progressBar) {
                   this.progressBar = Ti.UI.createProgressBar(
                       {width:150, min:0, max:1, value:0,
                    height:15, color:'#88F',
                    style:Titanium.UI.iPhone.ProgressBarStyle.PLAIN,
                    bottom:15});
                   this.progressBar.show();
                   this.activityWin.add(this.progressBar);
                   this.activityProgressShown = true;
               } else {
                   this.progressBar.show();
                   if (!this.activityProgressShown) {
                       this.activityProgressShown = true;
                   }
               }
               this.progressBar.value = value;
           }
       
       };
       
       function t1 () {
           // notice the text & spinner don't appear
           debug("t1");
           app.activityOn("message 1");
           setTimeout(t2, 2000);
       }
       
       function t2 () {
           // neither does the progress bar
           debug("t2");
           app.activityProgress(0.5);
           setTimeout(t3, 2000);
       }
       
       function t3 () {
           debug("t3");
           app.activityOff();
           // spinner appears but message still missing
           app.activityOn("message 2");
       }
       
       t1();
       
  9. Stephen Tramer 2011-04-15

    Reopening again.

  10. Jeff Haynie 2011-04-15

    (from [8a65922b971cb93c6f6b024362d5016a65c5bee3]) [#2172 state:fixed-in-qa] show/hide works for activityIndicator and progressBar again. http://github.com/appcelerator/titanium_mobile/commit/8a65922b971cb93c6f6b024362d5016a65c5bee3"> http://github.com/appcelerator/titanium_mobile/commit/8a65922b971cb...

  11. Damien Elmes 2011-04-15

    Thanks, looks good after a quick test.

  12. Thomas Huelbert 2011-04-15

    1.5.0.3ee6a97, 4th gen ipod touch, 3g iphone

JSON Source