PkRSS icon indicating copy to clipboard operation
PkRSS copied to clipboard

Many RSS link in one request/variable

Open FeFB opened this issue 9 years ago • 4 comments

Hi. First overall, thanks for the PkRSS. It is useful and works great!

In my project, the main page will show RSS from different RSS links. Thus the app need does more than one async() task or the library has a way to process a List of RSS links and save in the same variable? Can I do with just one Callback?

My Solution, and it works, is create one Callback object for each .async RSS request. For example:

    PkRSS.with(this).load("LINK1")callback(c1).handler(new Handler()).async();
    PkRSS.with(this).load("LINK2").callback(c2).handler(new Handler()).async();
    PkRSS.with(this).load("LINK3").callback(c3).handler(new Handler()).async();
    PkRSS.with(this).load("LINK4").callback(c4).handler(new Handler()).async();

Each callback (c1,c2,c3, c4) will save the Articles in the same variable a ArrayList <Articles>

I call a method in the callbacks that has a synchronized (LOCK) to save in the same variable. Is it a good practice ? or Not?

The another way that I thought is use a Mix Aggregator Tool like http://www.rssmix.com/

If has another possible solution, I will appreciate it if you let me know.

Thanks.

FeFB avatar Jan 06 '16 01:01 FeFB

That's an interesting use-case I didn't think of.

Given that your callbacks are all executing in the same UI thread, I don't see the synchronized lock being necessary unless you're accessing it from a background thread. You can also create a custom PkRSS singleton instance in your Application's (not activity's) onCreate() so you don't need to append new Handler() all the time.

Also, if your callbacks are all doing the same thing, you don't need to have multiple callbacks. You can reuse the same callback for this.

I'll consider adding built-in functionality for this in the future so that they're all saved into the same collection.

Pkmmte avatar Jan 26 '16 22:01 Pkmmte

Is this Version 1.3.0 coming?

GerhardPue avatar Jun 28 '17 22:06 GerhardPue

@GerhardPue Unfortunately, I haven't had the time to work on version 1.3.0.

However, the storage modules proposed in a different issue would likely be a good solution to this. It would enable functionality such as:

PkRSS.with(this).load("LINK1").and("LINK2").saveInto(module).async();

I'll try to find some time to work on it this upcoming month. With so many changes, I may as well completely refactor this library into version 2.0.

Pkmmte avatar Jun 28 '17 22:06 Pkmmte

Thanks for answer

If every link can parse from its own Parser, its a great Update

GerhardPue avatar Jul 04 '17 19:07 GerhardPue