Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 51

sarahk
Code is Art
Profile
Posts: 159
Reg: Jul 16, 2014
Auckland
10,290
08/30/14 07:12 PM (9 years ago)

Does/Can refresh scrape all the dataURLs?

When a dataURL is requested a check is made to see if there is already a local copy - if not then the url is requested. Presumably if the user is offline then the app will refuse to load the page. Is it possible to tie into the standard refresh button a request to download all dataURLs once (because some may be referenced more than once) and if a json file had references to other dataURLs then they too would be downloaded and so on. That would mean that if a user downloaded an app, had a quick look to see if it might be useful, closes it and then goes out of wifi (think kids with no data plan) and reopens the app then all the latest content would be there. The other way would be to load the files in the docs section but these wouldn't be able to be updated would they?
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
08/31/14 01:49 AM (9 years ago)
>load the files in the docs section but these wouldn't be able to be updated would they? No, they wouldn't. You would have to resort to coding to do that, probably with a button for manual syncing when the phone is again in range.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
08/31/14 08:29 AM (9 years ago)
Generally, this would be bad practice for the mobile world. Users expect their apps to launch instantly and to show the first screen immediately. As a background activity, the downloads of the dataURLs can happen while the User is interacting with the Home screen and other already loaded screens. Upon first load of the BT_config.txt file, an array of dataURLs should be formed. That array can be the basis of background downloading and caching of those screens. - What should be done upon a data refresh? (Wipe the array and cache? Selective deletes?) - What should be done about referenced image, audio and video files? As you can see, it's not a simple coding task. It's definitely possible. Most likely will impact the BT Core, unless we can programmatically override a few things through sub-classing or categories. -- Niraj
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
08/31/14 12:17 PM (9 years ago)
Check out my Advanced Search plugin. It does this very thing when it loads. Just copy that code to whatever plugin you have as your home screen and you should be fine.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
08/31/14 01:49 PM (9 years ago)
Of course, if you know your way around code a bit, you can get even more fancy. In the app I'm currently working on, I have all the data being loaded as soon as the app is fired up, in the appDelegate. It does this in the background, first loading all child items for all screens from cache, then downloading a fresh copy from the server. (this actually happens in a custom downloader class I created, but which is called by the appDelegate) The child items all get saved to a mutable array on the appDelegate, which the screens access in layout out their tables, etc. Because the downloading is happening in the background and I don't know what people's internet connection is like, I setup a system notification for when the fresh copy has finished downloading and is parsed. Then, each screen subscribes to that notification to find out if a fresh copy has been made available. They are only notified if the fresh copy is different than the cached copy. The result is super quick downloading of child items for all screens, making it seamless to open them up. And if a screen is already open before the downloader is finished, that screen is notified and then redraws its layout with the fresh data. Considering my UI approach which makes significant use of the new Facebook Pop physics animation framework, this works out really well.
 
sarahk
Code is Art
Profile
Posts: 159
Reg: Jul 16, 2014
Auckland
10,290
like
08/31/14 02:18 PM (9 years ago)
Thanks Chris - I'll take a look
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
08/31/14 04:23 PM (9 years ago)
Great technique, Chris! Please consider sharing it on the Wednesday DevTalks with Susan. -- Niraj
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
08/31/14 04:42 PM (9 years ago)
Cool! I really need this.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.