How to Implement Pull to Refresh in BlackBerry 10 CascadesSun 20 January 2013 by Xitij Ritesh Patel
Over the last little bit, I’ve been doing a lot of work on some apps for BlackBerry 10. With January 30th fast approaching, I was coding like a madman to try and meet the deadline, so I can get my hands on some awesome swag.
One of the apps I built uses a UI paradigm called “Pull to Refresh.” If the user is viewing a stream of data, they can pull down on the list and reveal a hidden item that notifies them they can refresh the stream contents by releasing their touch. A number of people have asked me how to implement this.
Again, because of the speed of development that’s possible with BB Tart, I was able to put together a crude, but workable sample demonstrating how to implement this feature. Furthermore, I even integrated it with ADN’s global feed. I simply pulled a couple of libraries from Github and putting the building blocks together. I went from idea to functioning sample in 12 hours, with 6 hours of sleep in between.
As you can see, everything you need is in the blackberry-py-pulltorefresh GitHub repo. The app was built on top of my blackberry-py-bootstrap repo. I’d be more than willing to accept help/pull requests on the project to help improve it for all developers. The file you should look at in particular is PullToRefresh.qml.
You’ll note that I implemented a LayoutUpdateHandler to monitor changes in the item. If the Y-coordinate is equal to exactly 0, then it fires the refreshTriggered() signal. In my testing, this works relatively well since the control will snap to 0 when it is released past the threshold. However, it can sometimes be triggered while the user is still interacting with the control. Therefore, a better way would be to detect if the user is touching the control, and only firing if they’re not.
I hope that helps most of you BlackBerry 10 developers looking to implement this in your app. When I first got this working, I couldn’t stop playing with it! Hopefully this gives you the jumpstart you need. Oh and take a look through the rest of the repository, there’s some good stuff in there including a way to asynchronously load remote images.
Google Chromebook and Ubuntu
I got my Google ARM Chromebook!
I was really excited for this device. I’ve been using a thick, heavy, and relatively underpowered Acer laptop for the last 5 years. I really wanted something thin and light to do my development work on that I could use on the go ...read more
Migrating to Amazon EC2
I’ve been pining over the Google Chromebook lately, as I’ve been wanting to become more mobile with my developer setup. In an effort to make this a reality, I started looking at my options for a VPS.
I currently have two VPSes running, one with prgmr and one ...read more
Why I Like BlackBerry 10 and Why I Don’t Hate iOS/Android
Low-carb Keto-friendly Gluten-free Peanut Butter Cookies
Having lost a few pounds, I felt the desire to indulge a bit. I haven’t been counting calories for the last few days, but I’m intending to start again tomorrow. Normally, I don’t have room in my calorie allowances to eat keto-friendly desserts, but I decided to ...read more
Hacking My Health
I am a hacker. Always have been, and always will be. It’s no wonder that I went into engineering. It’s also no wonder that I am taking the same approach to fixing my health.
I am overweight. I was 216.6 lbs about 3 weeks ago. At ...
Building a FreeNAS Box
I’ve been having a lot of trouble lately trying to figure out the best solution for backing up my data. Recently, I’ve been accumulating a large number of files, photos, and videos that I’d like to keep safe. Moreover, I’d like this data to be accessible ...read more
The Entrepreneurial Spirit
Compiling tesseract for BlackBerry 10
I’ve been on a hiatus from the blog for some time, so I figure I’ll write something up that should be useful to a few people.
Recently, I had an idea for an app, and part of it would utilize some OCR capabilities. Some quick Google searching revealed ...read more
Conference Call with RIM
Signing up with prgmr
I’ve used several different VPS providers in the past. My first experience was with Slicehost, with whom I was happy with until about 1.5 years ago. I decided that I was fed up with their lack of competitiveness against other providers.
I switched to Linode, which I use ...read more
A Desktop Bridge Too Far
The image above is a screenshot of the e-mail I received at 11:30am on Tuesday, May 29, 2012, approximately 1.5 hours after I had launched Desktop Bridge. It effectively killed two weeks of effort to launch a product from start to finish. I lost the opportunity to measure ...read more
Results of Launching Desktop Bridge
If you don’t know what Desktop Bridge is, the YouTube video above should help illustrate what it does.
Many of us have likely have had an idea similar to Desktop Bridge. I’m sure many of you have thought that it would be great to access your phone’s ...read more
PySide on the BlackBerry PlayBook
Achievement Unlocked: M License
After nearly 2 years of riding a motorcycle, I’ve finally obtained my M license! It was a bit of an ordeal, since I had not taken the Green Goblin out of hibernation at all, even with all the gorgeous weather we’ve had. I simply didn’t have the ...read more
Updates & I picked up a new toy!
So I haven’t got too much work done in the last few days, due to having come down with a bit of a cold. It’s not that bad, but it’s right in my sinuses, so my eyes and nose are always watery. Makes it difficult to concentrate ...read more
Let’s try this again
I’m setting up my blog, once again. I’m going to do my best to make it stick this time. For now, I’m off to bed. It’s 6:30am. I need to stop doing this.read more