diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-02-16 12:38:52 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-02-16 22:19:43 +0100 |
| commit | 14ba161b7507480630d8ca9220e1b4099fc7d4d6 (patch) | |
| tree | 4440aa6a9c7bb40a8e75f64e1687acba3489f855 /main/src/cgeo/geocaching/CacheDetailActivity.java | |
| parent | 2919930439a3ff43efada3bcb5af34979fb8feac (diff) | |
| download | cgeo-14ba161b7507480630d8ca9220e1b4099fc7d4d6.zip cgeo-14ba161b7507480630d8ca9220e1b4099fc7d4d6.tar.gz cgeo-14ba161b7507480630d8ca9220e1b4099fc7d4d6.tar.bz2 | |
Update for RxJava 0.17.0-RC1
This is the release candidate version, which is being currently tested
at Netflix. In a few days, I'll update with the final version.
This release cleans up some bits of RxJava by integrating the
subscription inside a subscriber (which is an observer holding a
subscription) and fixes a leak with recurring tasks.
Diffstat (limited to 'main/src/cgeo/geocaching/CacheDetailActivity.java')
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index e031e93..54202a7 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -57,14 +57,12 @@ import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; - import rx.Observable; -import rx.Observable.OnSubscribeFunc; +import rx.Observable.OnSubscribe; import rx.Observer; -import rx.Subscription; +import rx.Subscriber; import rx.android.observables.AndroidObservable; import rx.schedulers.Schedulers; -import rx.subscriptions.Subscriptions; import rx.util.functions.Action1; import android.R.color; @@ -1667,30 +1665,29 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc */ private void loadDescription(final String descriptionString, final IndexOutOfBoundsAvoidingTextView descriptionView, final View loadingIndicatorView) { // The producer produces successives (without then with images) versions of the description. - final Observable<Spanned> producer = Observable.create(new OnSubscribeFunc<Spanned>() { + final Observable<Spanned> producer = Observable.create(new OnSubscribe<Spanned>() { @Override - public Subscription onSubscribe(final Observer<? super Spanned> observer) { + public void call(final Subscriber<? super Spanned> subscriber) { try { // Fast preview: parse only HTML without loading any images final HtmlImageCounter imageCounter = new HtmlImageCounter(); final UnknownTagsHandler unknownTagsHandler = new UnknownTagsHandler(); Spanned description = Html.fromHtml(descriptionString, imageCounter, unknownTagsHandler); addWarning(unknownTagsHandler, description); - observer.onNext(description); + subscriber.onNext(description); if (imageCounter.getImageCount() > 0) { // Complete view: parse again with loading images - if necessary ! If there are any images causing problems the user can see at least the preview description = Html.fromHtml(descriptionString, new HtmlImage(cache.getGeocode(), true, cache.getListId(), false), unknownTagsHandler); addWarning(unknownTagsHandler, description); - observer.onNext(description); + subscriber.onNext(description); } - observer.onCompleted(); + subscriber.onCompleted(); } catch (final Exception e) { Log.e("loadDescription", e); - observer.onError(e); + subscriber.onError(e); } - return Subscriptions.empty(); } // If description has an HTML construct which may be problematic to render, add a note at the end of the long description. |
