Skip to content

Commit

Permalink
Merge pull request #31 from pingwang2011/timob-10818
Browse files Browse the repository at this point in the history
timob-10818: KitchenSink: Android: Need to update the Activity Indicator and Progress Bar test
  • Loading branch information
srahim committed Sep 11, 2012
2 parents f067b9e + b931759 commit 3247702
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 207 deletions.
293 changes: 163 additions & 130 deletions Resources/ui/common/controls/activity_indicator.js
Original file line number Diff line number Diff line change
@@ -1,187 +1,213 @@
function activity_indicator() {
var osname = Ti.Platform.osname;
var isIos = osname === 'iphone' || osname === 'ipad';
var sdkVersion = parseFloat(Ti.version);
var ActivityIndicatorStyle;
if (isIos) {
ActivityIndicatorStyle = Titanium.UI.iPhone.ActivityIndicatorStyle;
} else if (sdkVersion >= 3.0){
ActivityIndicatorStyle = Titanium.UI.ActivityIndicatorStyle;
}

var win = Ti.UI.createWindow({
backgroundColor: '#13386c'
backgroundColor : '#13386c'
});

//
// BASE INDICATOR
//
var actInd = Titanium.UI.createActivityIndicator({
bottom:10,
height:50,
width:150
bottom : 10,
width : Ti.UI.SIZE,
height : Ti.UI.SIZE
});
if (Ti.UI.iPhone) {
actInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN;
if (ActivityIndicatorStyle) {
actInd.style = ActivityIndicatorStyle.PLAIN;
}

var button0 = Titanium.UI.createButton({
title:'Hide',
height:35,
width:130,
top:10,
right:20
});

button0.addEventListener('click', function()
{
title : 'Hide',
height : 35,
width : 130,
top : 10,
right : 20
});

button0.addEventListener('click', function() {
actInd.message = null;
actInd.hide();
});



//
// BASIC ACTIVITY INDICATOR
//
var button1 = Titanium.UI.createButton({
title:'Show (Basic)',
height:35,
width:130,
top:10,
left:20
});

button1.addEventListener('click', function()
{
title : 'Show (Basic)',
height : 35,
width : 130,
top : 10,
left : 20
});

button1.addEventListener('click', function() {
actInd.show();
});



//
// ACTIVITY INDICATOR (BIG)
//
var button2 = Titanium.UI.createButton({
title:'Show Indicator (BIG)',
height:35,
width:200,
top:55
});

button2.addEventListener('click', function()
{
actInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.BIG;
title : 'Show Indicator (BIG)',
height : 35,
width : 200,
top : 55
});

button2.addEventListener('click', function() {
actInd.style = ActivityIndicatorStyle.BIG;
actInd.show();
});

//
// ACTIVITY INDICATOR (DARK)
//
var button3 = Titanium.UI.createButton({
title:'Show Indicator (DARK)',
height:35,
width:200,
top:100
});

button3.addEventListener('click', function()
{
actInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.DARK;
title : 'Show Indicator (DARK)',
height : 35,
width : 200,
top : 100
});

button3.addEventListener('click', function() {
actInd.style = ActivityIndicatorStyle.DARK;
actInd.show();
});

//
// ACTIVITY INDICATOR (BIG_DARK)
//
var button8 = Titanium.UI.createButton({
title : 'Show Indicator (BIG_DARK)',
height : 35,
width : 200,
top : 145
});

button8.addEventListener('click', function() {
actInd.style = ActivityIndicatorStyle.BIG_DARK;
actInd.show();
});

//
// ACTIVITY INDICATOR (MESSAGE)
//
var button4 = Titanium.UI.createButton({
title:'Show Indicator (Message)',
height:35,
width:200,
top:145
});

button4.addEventListener('click', function()
{
actInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN;
actInd.font = {fontFamily:'Helvetica Neue', fontSize:15,fontWeight:'bold'};
title : 'Show Indicator (Message)',
height : 35,
width : 200,
top : 145
});
if (!isIos) {
button4.top = 190;
}
button4.addEventListener('click', function() {
actInd.style = ActivityIndicatorStyle.PLAIN;
actInd.font = {
fontFamily : 'Helvetica Neue',
fontSize : 15,
fontWeight : 'bold'
};
actInd.color = 'white';
actInd.message = 'Loading...';
actInd.width = 210;
actInd.show();
});

//
// ACTIVITY INDICATOR (TOOLBAR)
//
var toolActInd = Titanium.UI.createActivityIndicator();

var button5 = Titanium.UI.createButton({
title:'Show Indicator (Toolbar)',
height:35,
width:200,
top:190
});

button5.addEventListener('click', function()
{
title : 'Show Indicator (Toolbar)',
height : 35,
width : 200,
top : 190
});

button5.addEventListener('click', function() {
toolActInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN;
toolActInd.font = {fontFamily:'Helvetica Neue', fontSize:15,fontWeight:'bold'};
toolActInd.font = {
fontFamily : 'Helvetica Neue',
fontSize : 15,
fontWeight : 'bold'
};
toolActInd.color = 'white';
toolActInd.message = 'Loading...';
win.setToolbar([toolActInd],{animated:true});
win.setToolbar([toolActInd], {
animated : true
});
toolActInd.show();
setTimeout(function()
{
setTimeout(function() {
toolActInd.hide();
win.setToolbar(null,{animated:true});
},3000);

win.setToolbar(null, {
animated : true
});
}, 3000);

});

//
// ACTIVITY INDICATOR (NAVBAR)
//
var navActInd = Titanium.UI.createActivityIndicator();

var button6 = Titanium.UI.createButton({
title:'Show Indicator (Navbar)',
height:35,
width:200,
top:235
});

button6.addEventListener('click', function()
{

title : 'Show Indicator (Navbar)',
height : 35,
width : 200,
top : 235
});

button6.addEventListener('click', function() {

win.setRightNavButton(navActInd);
navActInd.show();
setTimeout(function()
{
setTimeout(function() {
navActInd.hide();
win.setRightNavButton(null);
},3000);

}, 3000);

});

//
// ACTIVITY INDICATOR (TITLE CONTROL)
//
var button7 = Titanium.UI.createButton({
title:'Show Indicator (Title)',
height:35,
width:200,
top:280
});

button7.addEventListener('click', function()
{
title : 'Show Indicator (Title)',
height : 35,
width : 200,
top : 280
});

button7.addEventListener('click', function() {
win.setTitleControl(actInd);
actInd.show();

setTimeout(function()
{

setTimeout(function() {
actInd.hide();
win.setTitleControl(null);
win.title = 'Activity Indicator';
},3000);

}, 3000);
});

win.add(actInd);
// add iphone elements
if (Titanium.Platform.name == 'iPhone OS')
{


// add iOS elements
if (isIos) {
win.add(button1);
win.add(button0);
win.add(button2);
Expand All @@ -190,26 +216,33 @@ function activity_indicator() {
win.add(button5);
win.add(button6);
win.add(button7);
}
else if (Ti.Platform.osname === 'android')
{
win.addEventListener('open', function(e) {
actInd.show();
actInd.message = 'Loading...';
setTimeout(function()
{
actInd.hide();
},2000);
});
} else {
actInd.show();
actInd.message = 'Loading...';
setTimeout(function()
{
actInd.hide();
},2000);
if (sdkVersion < 3.0) {
if (Ti.Platform.osname === 'android') {
win.addEventListener('open', function(e) {
actInd.show();
actInd.message = 'Loading...';
setTimeout(function() {
actInd.hide();
}, 2000);
});
} else {
actInd.show();
actInd.message = 'Loading...';
setTimeout(function() {
actInd.hide();
}, 2000);
}
} else {// Use the new Activity Indicator (TIMOB-6092)
win.add(button1);
win.add(button0);
win.add(button2);
win.add(button3);
win.add(button8);
win.add(button4);
}
}

return win;
};

Expand Down

0 comments on commit 3247702

Please sign in to comment.