Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Slosh
Posts: 38
Registered: ‎01-24-2014
My Device: Q5

Pull to Refresh

Hello everyone,

 

I work like this example:

https://github.com/mrnickel/bb10pulltorefresh

 

But there is a problem, and displays in the console:
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile

 

Then I import the example and appears the same problem.

 

Is there a solution or any suggestions.

Developer
santito95
Posts: 134
Registered: ‎02-24-2013
My Device: BlackBerry Z10 LE

Re: Pull to Refresh

maybe a problem caused by the cascades libpng profile, I have the same problem on my app but really It does not affect nothing inside.

 

You have issues related with that message in the debug console?

Developer
BBSJdev
Posts: 6,118
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Pull to Refresh

These are not errors just warnings and can be safely ignored for your apps.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Slosh
Posts: 38
Registered: ‎01-24-2014
My Device: Q5

Re: Pull to Refresh

Ok, but there is a problem in my application and also the example.

 

The problem:
Rotation without stopping, and does not update the data.

 

 

My application:

 

 

 

The example:

 

New Developer
Slosh
Posts: 38
Registered: ‎01-24-2014
My Device: Q5

Re: Pull to Refresh

 UP for help!

Developer
santito95
Posts: 134
Registered: ‎02-24-2013
My Device: BlackBerry Z10 LE

Re: Pull to Refresh

I'm not sure of because it you can't load the data, can you share us the onRefresh event from your code?
New Developer
Slosh
Posts: 38
Registered: ‎01-24-2014
My Device: Q5

Re: Pull to Refresh

I've worked like example:

 

function onRefreshTriggered() {
          myListView.loading = true;
            }

 

Developer
santito95
Posts: 134
Registered: ‎02-24-2013
My Device: BlackBerry Z10 LE

Re: Pull to Refresh

We need more information, are you running the same code (Exactly the same)  like the sample?

 

put the onRefreshTriggered code please.

 

Cheers!

 

 

New Developer
Slosh
Posts: 38
Registered: ‎01-24-2014
My Device: Q5

Re: Pull to Refresh

Ok

 

ListView {
    signal refreshTriggered()
    property bool loading: false
    id: refreshableList
    leadingVisualSnapThreshold: 2.0
    leadingVisual: RefreshHeader {
        id: refreshHandler
        onRefreshTriggered: {
            refreshableList.refreshTriggered();
        }
    }
    onTouch: {
        refreshHandler.onListViewTouch(event);
    }
    onLoadingChanged: {
        refreshHandler.refreshing = refreshableList.loading;
                 
        if(!refreshHandler.refreshing) {
            // If the refresh is done 
            // Force scroll to top to ensure that all items are visible
            scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
        }
    }
}

 

RefreshHeader:

Container {
    signal refreshTriggered
    id: refreshContainer
    property bool readyForRefresh: false
    property bool refreshing: false       
    property string refreshedAt: ""
    property int refresh_threshold: 20  
    horizontalAlignment: HorizontalAlignment.Fill
    layout: DockLayout {
    }

    Container {
        id: refreshStatusContainer
        horizontalAlignment: HorizontalAlignment.Fill
        ImageView {
            id: refreshImage
            imageSource: "asset:///images/refresh.png"
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
            preferredHeight: 75.0
            preferredWidth: 75.0
        }
        Label {
            id: refreshStatus
            text: qsTr("Pull to refresh")
            verticalAlignment: VerticalAlignment.Center
            textStyle.textAlign: TextAlign.Center
            leftPadding: 0.0
            topPadding: 10.0
            bottomPadding: 10.0
            textStyle.color: Color.create("#ffffff")
            horizontalAlignment: HorizontalAlignment.Fill
        }
    }
    Container {
        horizontalAlignment: HorizontalAlignment.Fill
        ActivityIndicator {
            id: loadingIndicator
            preferredWidth: 100
            preferredHeight: 100
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
        }
    }
    Divider {
        opacity: 0.0
    }
    attachedObjects: [
        LayoutUpdateHandler {
            id: refreshHandler
            onLayoutFrameChanged: {
                if (refreshing) {
                    return;
                }
                readyForRefresh = false;

                if (layoutFrame.y >= 0) {
                    refreshImage.rotationZ = layoutFrame.y*2;
                    if (layoutFrame.y >= refresh_threshold) {
                        if (! refreshing) {
                            readyForRefresh = true;
                        }
                        refreshStatus.text = qsTr("Release to refresh")
                    }
                } else if (layoutFrame.y >= -100) {
                    refreshStatusContainer.visible = true;
                    if (refreshContainer.refreshedAt == "") {
                        refreshStatus.text = qsTr("Pull to refresh")
                    } else {
                        refreshStatus.text = qsTr("Pull to refresh. Last refreshed ") + timeSince(refreshContainer.refreshedAt);
                    }
                    refreshImage.rotationZ = 0;
                } else {
                    //don't refresh
                    refreshImage.rotationZ = 0;
                }
            }
        }
    ]
    function released() {
        if (readyForRefresh) {
            readyForRefresh = false;
            refreshing = false;
            refreshTriggered();
        }
    }
    onRefreshingChanged: {
        if (refreshing) {
            var tmpDate = new Date();
            refreshContainer.refreshedAt = tmpDate.getTime() / 1000;
                        
            refreshStatusContainer.visible = false;
            loadingIndicator.visible = true;
            loadingIndicator.running = true;
        } else {
            loadingIndicator.running = false;
            loadingIndicator.visible = false;
            refreshStatusContainer.visible = true;
            refreshContainer.setPreferredHeight(0);
        }
    }
    function timeSince(date) {
        var seconds = Math.floor(((new Date().getTime() / 1000) - date)), interval = Math.floor(seconds / 31536000);
        if (interval > 1) return qsTr("%L1y ago").arg(interval);
        interval = Math.floor(seconds / 2592000);
        if (interval > 1) return qsTr("%L1m ago").arg(interval)
        interval = Math.floor(seconds / 86400);
        if (interval >= 1) return qsTr("%L1d ago").arg(interval)
        interval = Math.floor(seconds / 3600);
        if (interval >= 1) return qsTr("%L1h ago").arg(interval)
        interval = Math.floor(seconds / 60);
        if (interval > 1) return qsTr("%L1m ago").arg(interval)
        return qsTr("just now");
    }
    function onListViewTouch(event) {
        refreshContainer.resetPreferredHeight();
        if (event.touchType == TouchType.Up) { //pulled and released
            released();
        }
    }
}

 

Developer
greenmr
Posts: 919
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Pull to Refresh

Many months ago I wrote a pull-to-refresh tutorial for a Blog I was starting up, but then never officially launched it due to time constraints. Just in case it might help you, here is the link. I do this all in C++ now, but this is the way I did it in earlier versions of my multiFEED app.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.