Need AndroidArchitecture Paging Library to continue fetching pages after sending it an empty list - android-architecture-components

I'm using AndroidArchitecture Paging Library 1.0.0 successfully with a PageKeyedDataSource. But, my service will sometimes return an empty list even though subsequent pages will have items. In loadInitial method, I call:
callback.onResult(emptyList, nextPageToLoad)
Because, I pass it an empty list, it thinks there are no more pages to load and won't call loadAfter. However, I need it to continue to load more pages. I could detect the empty list condition and pass it a non-empty list with fake items. However, then I need to hack my adapter to filter out those fake items. Is there an easier way to get the paging lib to continue fetching pages after sending it an empty list? FYI: my nextPageToLoad is 2 in this case. Also, I've tried Paging Lib 1.0.1 and it didn't make a difference.

Related

Perform sever-side caching of 3rd party images

I just added some functionality to my site which, when a user hovers their mouse over a link (to a 3rd party page), a preview of the link is created from the meta tags on the target page and displayed. I'm worried about the implications of hot-linking in my current implementation.
I'm now thinking of implementing some kind of server-side caching such that the first request for the preview fetches the info and image from the target page, but each subsequent request (up to some age limit) is served from a cache on my host. I'm relatively confident that I could implement something of my own, but is there an off-the-shelf solution for something like this? I'm self-taught so I'm guessing that my DIY solution would be less than optimal. Thanks.
Edit I implemented a DIY solution (see below) but I'm still open to suggestions as to how this could be accomplished efficiently.
I couldn't find any off-the-shelf solutions so I wrote one in PHP.
It accepts a URL as a HTTP GET parameter and does some error checking. If error-checking passes, it opens a JSON-encoded database from disk and parses the data into an array of Record objects that contain the info that I want. The supplied URL is used as the array key. If the key exists in the array, the cached info is returned. Otherwise, the web page is fetched, meta tags parsed, image saved locally, and cached data returned. The cached info is then inserted into the database. After the cached info is returned to the requesting page, each record is examined for its expiration date and expired records are removed. Each request for a cached record extends its expiration date. Lastly, the database is JSON-encoded and written back to disk.

Alt data dependency between actions not stores

I have a react app where I'm using alt for the flux architecture side of things.
I have a situation where I have two stores which are fed by ajax calls in their corresponding actions.
Having read the alt getting started page on data dependencies it mentions dependencies between stores using waitFor - http://alt.js.org/guide/wait-for/ but I don't see a way to use this kind of approach if one of my store actions is dependent on another store action (both of which are async).
If I was doing this inside a single action handler, I might return or chain some promises but I'm not sure how to implement this across action handlers. Has anyone achieved this? or am I going about my usage of ajax in react the wrong way?
EDIT: More detail.
In my example I have a list of nodes defined in a local json config file, my node-store makes an ajax request to get the node detail.
Once it's complete, a different component (with a different action handler and store) wants to use the node collection to make an ajax query to different endpoints a node may expose.
The nodes are re-used across many different components so I don't want to roll their functionality into several different stores/action handlers if possible.

Sencha Touch 2 - How to Abort store load with ajax/json

How can I abort a store load while the ajax call is still executing? I have a simple store with proxy type of 'ajax' and 'json' reader.
The documentation does not indicate any way to abort this. I have noticed that jsonp does allow aborting a load in progress. Do I have to switch to jsonp?
The motivation here is that I have a search bar and list object that gets populated with results. The actual search on the backend can take 5-10 seconds. So if a user starts a search then quickly wants to do another search (in case, for example, the first search was a typo), then the new search needs to abort the first search ajax call. Otherwise, I am seeing mixed results showing up in my search results.
As usual, any help is greatly appreciated!
Mohammad
The solution I have used in the past to solve this exact problem is to track each request with an incrementing counter and as requests complete I check the counter and if a request has been made with a higher counter I disregard the result.

Codeigniter cache page

I have a site developed in codeigniter.
In the page search I have a form that when I compile It I send a request to a servere with CURL and return me an xml.
This query and the print date is about 15seconds because I have to make more query with many server and this time is necessary.
But the problem is: I have a list of element, when I click on an element I make a query to retrieve the data of the element.
But if I click back or click to go back to all element searched I don't want to make an other query that takes 15second.
When I search the element I have a get request and I have a link like this:
http://myurl/backend/hotel/hotel_list?nation=94&city=1007&check-in=12%2FApr%2F2013&check-out=13%2FApr%2F2013&n_single_rooms=1&n_double_rooms=0&n_triple_rooms=0&n_extra_beds=0
I load the page and I can have more elements. i click on some of this in a simple link like this:
http://myurl/backend/hotel/hotel_view?id_service=tra_0_YYW
When I enter into this page I have to go back to the previous url (the first) without remake the query that takes more seconds.
I can't cache the result because is a realtime database and change every minutes or second but I thinked to cache the page search when I enter on it and if i go back to it reload from cache if the time is minor than 2 minutes for example.
Is this a good way or there is a more perfmormant way to do this in codeigniter?
I can't put in session because there is large data.
The other solution are:
- cache page (but every minutes I have to delete it)
- cache result (but every minutes I have to delete it)
- create sessionflashdata (but I have a large amount of data)
is there a way with the browser when I go back to don't remake the page?
Thanks
cache page (but every minutes I have to delete it)
I think you can easily implement it with codeigniter's page caching function "$this->output->cache(1);"
cache result (but every minutes I have to delete it)
You will have to use codeigniter's object caching method to implement it.
create sessionflashdata (but I have a large amount of data)
Its not a good idea to save huge data in session. Rather use 'database session' instead, which will help you handling similar way and codeigniter has its integrated support.
Hope this helps. You can read more about all kind of codeigniter caching if you are just starting with it.

How can I update my data automatically without using AJAX or any loop checking method?

I have a data table page that have to be update right after the database is updated.
I am not allowed to use any loop checking method including AJAX.
Supposing you're able to detect the insertion in database serverside, the usual solution is to use, like StackOverflow does, websockets.
They allow you to push data from the server to the browser with very little overhead, without useless pulling requests and without client-side loops.

Resources