Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2411] Android: PagingControl / showPagingControl property not working

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2011-04-18T23:09:25.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M06
ComponentsAndroid
Labelsandroid, defect, release-1.6.0, reported-1.5.1, view
ReporterPaul Dowsett
AssigneeDon Thorp
Created2011-04-15T03:18:58.000+0000
Updated2011-04-18T23:09:25.000+0000

Description

Currently showPagingControl has no effect. Don confirms this functionality is already implemented for android, but a recent change caused it to cease working.

(added by bill:)

failcase app.js, in which paging controls (back/forward arrows) do not appear:

Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({  
    title:'Test',
    backgroundColor:'#000',
    exitOnClose: true
});

function getOrientation(o)
{  //Came from orientation.js, but we didn't need the buttons and such
    switch (o)
    {
        case Titanium.UI.PORTRAIT:
            return 'portrait';
        case Titanium.UI.UPSIDE_PORTRAIT:
            return 'upside portrait';
        case Titanium.UI.LANDSCAPE_LEFT:
            return 'landscape left';
        case Titanium.UI.LANDSCAPE_RIGHT:
            return 'landscape right';
        case Titanium.UI.FACE_UP:
            return 'face up';
        case Titanium.UI.FACE_DOWN:
            return 'face down';
        case Titanium.UI.UNKNOWN:
            return 'unknown';
    }
}


win.backgroundColor = '#ccc';

// initialize to all modes
win.orientationModes = [
    Titanium.UI.PORTRAIT,
    Titanium.UI.LANDSCAPE_LEFT,
    Titanium.UI.LANDSCAPE_RIGHT
];


//
// orientation change listener
//
Ti.Gesture.addEventListener('orientationchange',function(e)
{

    // get orienation from event object
    var orientation = getOrientation(e.orientation);
});

var view1 = Ti.UI.createView({
    backgroundColor:'red'
});
var l1 = Ti.UI.createLabel({
    text:'View 1',
    color:'#fff',
    width:'auto',
    height:'auto'
});
view1.add(l1);

var view2 = Ti.UI.createView({
    backgroundColor:'blue'
});
var l2 = Ti.UI.createLabel({
    text:'Click Me (View 2 - see log)',
    color:'#fff',
    width:'auto',
    height:'auto'
});
view2.add(l2);

var view3 = Ti.UI.createView({
    backgroundColor:'green'
});
var l3 = Ti.UI.createLabel({
    text:'View 3',
    color:'#fff',
    width:'auto',
    height:'auto'
});
view3.add(l3);

var view4 = Ti.UI.createView({
    backgroundColor:'black'
});
var l4 = Ti.UI.createLabel({
    text:'View 4',
    color:'#fff',
    width:'auto',
    height:'auto'
});
view4.add(l4);


var scrollView = Titanium.UI.createScrollableView({
    views:[view1,view2,view3,view4],
    showPagingControl:true,
    pagingControlHeight:30,
    maxZoomScale:2.0,
    currentPage:1
});

win.add(scrollView);

var i=1;
var activeView = view1;

scrollView.addEventListener('scroll', function(e)
{
    activeView = e.view;  // the object handle to the view that is about to become visible
    i = e.currentPage;
    Titanium.API.info("scroll called - current index " + i + ' active view ' + activeView);
});
scrollView.addEventListener('click', function(e)
{
    Ti.API.info('ScrollView received click event, source = ' + e.source);
});
scrollView.addEventListener('touchend', function(e)
{
    Ti.API.info('ScrollView received touchend event, source = ' + e.source);
});

// add button to dynamically add a view
var add = Titanium.UI.createButton({
    title:'Add',
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
add.addEventListener('click',function()
{
    var newView = Ti.UI.createView({
        backgroundColor:'purple'
    });
    var l = Ti.UI.createLabel({
        text:'View ' + (scrollView.views.length+1),
        color:'#fff',
        width:'auto',
        height:'auto'
    });
    newView.add(l);
    scrollView.addView(newView);
});

// jump button to dynamically change go directly to a page (non-animated)
var jump = Titanium.UI.createButton({
    title:'Jump',
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
jump.addEventListener('click',function()
{
    i = (scrollView.currentPage + 1) % scrollView.views.length;
    scrollView.currentPage = i;
});

// change button to dynamically change a view
var change = Titanium.UI.createButton({
    title:'Change',
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
change.addEventListener('click',function()
{
    var newView = Ti.UI.createView({
        backgroundColor:'#ff9900'
    });
    var l = Ti.UI.createLabel({
        text:'View (Changed) ' + (i+1),
        color:'#fff',
        height:'auto',
        width:'auto'
    });
    newView.add(l);
    var ar = [];
    for (var x=0;x<scrollView.views.length;x++)
    {
        if (x==i)
        {
            Ti.API.info('SETTING TO NEW VIEW ' + x);
            ar[x] = newView;
        }
        else
        {
            Ti.API.info('SETTING TO OLD VIEW ' + x);

            ar[x] = scrollView.views[x];
        }
    }
    scrollView.views = ar;
});

// move scroll view left
var left = Titanium.UI.createButton({
    image:'icon_arrow_left.png'
});
left.addEventListener('click', function(e)
{
    if (i === 0) {
        return;
    }
    i--;
    scrollView.scrollToView(i);
});

// move scroll view right
var right = Titanium.UI.createButton({
    image:'icon_arrow_right.png'
});
right.addEventListener('click', function(e)
{
    if (i == (scrollView.views.length-1)){
        return;
    }
    i++;
    scrollView.scrollToView(scrollView.views[i]);
});
var flexSpace = Titanium.UI.createButton({
    systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});

if (Titanium.Platform.osname == 'iphone' || Titanium.Platform.osname == 'ipad')
{
    // set toolbar
    win.setToolbar([flexSpace,left,change,add,jump,right,flexSpace]);
}
else
{
    var toolbar = Titanium.UI.createView({
        bottom: 10,
        height: 50,
        backgroundColor: '#333333',
        borderRadius: 10,
        opacity: 0.3,
        left: 10,
        right: 10
    });

    var floater = Titanium.UI.createView({
        width:320,
        height: 'auto',
        opacity: 0
    });

    toolbar.add(floater);

    left.left = 10;
    left.width = 30;

    change.left = 50;
    change.width = 70;
    change.height = 35;

    add.left = 130;
    add.width = 70;
    add.height = 35;

    jump.left = 210;
    jump.width = 70;
    jump.height = 35;

    right.right = 10;
    right.width = 30;

    floater.add(left);
    floater.add(change);
    floater.add(add);
    floater.add(jump);
    floater.add(right);
    win.add(toolbar);
}

win.open();

Comments

  1. Bill Dawson 2011-04-15

    (from [20335d8603e2708b59a18bafbb91b7292278de8e]) [#2411 state:fixed-in-qa] Properly handle showPagingControl property in ScrollableView https://github.com/appcelerator/titanium_mobile/commit/20335d8603e2708b59a18bafbb91b7292278de8e"> https://github.com/appcelerator/titanium_mobile/commit/20335d8603e2...

  2. Don Thorp 2011-04-15

    Verified on G1/1.6 and Nexus One/2.2.1 using build #e1cb22a

  3. Bill Dawson 2011-04-15

    (from [74c5f4c81e631223feecf57b87f1232fae7fe998]) [#2411 state:fixed-in-qa] make sure delayed handler messages get cleared when views get cleared https://github.com/appcelerator/titanium_mobile/commit/74c5f4c81e631223feecf57b87f1232fae7fe998"> https://github.com/appcelerator/titanium_mobile/commit/74c5f4c81e63...

JSON Source