Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

[BUG] hidden window doesn't come back (regression in 1.5)

The following code shows a progress window, hides it, and shows it again. This works in 1.4.1.1 (and has since 1.2.x), but doesn't work on the current dev code.

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);
— asked October 19th 2010 by Damien Elmes
  • bug
  • iphone
  • layout
0 Comments

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.