aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/CacheDetailActivity.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-04-05 14:55:40 +0200
committerSamuel Tardieu <sam@rfc1149.net>2014-04-05 18:23:20 +0200
commitcca4c9b0bcc1bd7742d419166fd5cfd5415fde9e (patch)
tree5c88f703e8130e07ff98e0f13277a8fddc44d2b1 /main/src/cgeo/geocaching/CacheDetailActivity.java
parentde71f9ba50bf7ee8f8987402b52912b014c5b460 (diff)
downloadcgeo-cca4c9b0bcc1bd7742d419166fd5cfd5415fde9e.zip
cgeo-cca4c9b0bcc1bd7742d419166fd5cfd5415fde9e.tar.gz
cgeo-cca4c9b0bcc1bd7742d419166fd5cfd5415fde9e.tar.bz2
Do not use AndroidObservable
This lets us return to an unmodified version of RxJava.
Diffstat (limited to 'main/src/cgeo/geocaching/CacheDetailActivity.java')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java119
1 files changed, 59 insertions, 60 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index f525955..0f86de6 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -45,6 +45,7 @@ import cgeo.geocaching.utils.CryptUtils;
import cgeo.geocaching.utils.ImageUtils;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.MatcherWrapper;
+import cgeo.geocaching.utils.RxUtils;
import cgeo.geocaching.utils.SimpleCancellableHandler;
import cgeo.geocaching.utils.SimpleHandler;
import cgeo.geocaching.utils.TextUtils;
@@ -61,7 +62,6 @@ import rx.Observer;
import rx.Scheduler.Inner;
import rx.Subscriber;
import rx.Subscription;
-import rx.android.observables.AndroidObservable;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
@@ -878,7 +878,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
view = (ScrollView) getLayoutInflater().inflate(R.layout.cachedetail_details_page, null);
// Start loading preview map
- AndroidObservable.bindActivity(CacheDetailActivity.this, previewMap.subscribeOn(Schedulers.io())).subscribe(new Action1<BitmapDrawable>() {
+ RxUtils.subscribeOnIOThenUI(previewMap, new Action1<BitmapDrawable>() {
@Override
public void call(final BitmapDrawable image) {
final Bitmap bitmap = image.getBitmap();
@@ -1605,71 +1605,70 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
});
- AndroidObservable.bindActivity(this, producer.subscribeOn(Schedulers.io()))
- .subscribe(new Observer<Spanned>() {
- @Override
- public void onCompleted() {
- if (null != loadingIndicatorView) {
- loadingIndicatorView.setVisibility(View.GONE);
- }
- }
+ RxUtils.subscribeOnIOThenUI(producer, new Observer<Spanned>() {
+ @Override
+ public void onCompleted() {
+ if (null != loadingIndicatorView) {
+ loadingIndicatorView.setVisibility(View.GONE);
+ }
+ }
- @Override
- public void onError(final Throwable throwable) {
- showToast(res.getString(R.string.err_load_descr_failed));
- }
+ @Override
+ public void onError(final Throwable throwable) {
+ showToast(res.getString(R.string.err_load_descr_failed));
+ }
- @Override
- public void onNext(final Spanned description) {
- if (StringUtils.isNotBlank(descriptionString)) {
- try {
- descriptionView.setText(description, TextView.BufferType.SPANNABLE);
- } catch (final Exception e) {
- // On 4.1, there is sometimes a crash on measuring the layout: https://code.google.com/p/android/issues/detail?id=35412
- Log.e("Android bug setting text: ", e);
- // remove the formatting by converting to a simple string
- descriptionView.setText(description.toString());
- }
- descriptionView.setMovementMethod(AnchorAwareLinkMovementMethod.getInstance());
- fixTextColor(descriptionString);
- descriptionView.setVisibility(View.VISIBLE);
- registerForContextMenu(descriptionView);
+ @Override
+ public void onNext(final Spanned description) {
+ if (StringUtils.isNotBlank(descriptionString)) {
+ try {
+ descriptionView.setText(description, TextView.BufferType.SPANNABLE);
+ } catch (final Exception e) {
+ // On 4.1, there is sometimes a crash on measuring the layout: https://code.google.com/p/android/issues/detail?id=35412
+ Log.e("Android bug setting text: ", e);
+ // remove the formatting by converting to a simple string
+ descriptionView.setText(description.toString());
+ }
+ descriptionView.setMovementMethod(AnchorAwareLinkMovementMethod.getInstance());
+ fixTextColor(descriptionString);
+ descriptionView.setVisibility(View.VISIBLE);
+ registerForContextMenu(descriptionView);
+ }
+ }
+
+ /**
+ * Handle caches with black font color in dark skin and white font color in light skin
+ * by changing background color of the view
+ *
+ * @param text
+ * to be checked
+ */
+ private void fixTextColor(final String text) {
+ int backcolor;
+ if (Settings.isLightSkin()) {
+ backcolor = color.white;
+
+ for (final Pattern pattern : LIGHT_COLOR_PATTERNS) {
+ final MatcherWrapper matcher = new MatcherWrapper(pattern, text);
+ if (matcher.find()) {
+ descriptionView.setBackgroundResource(color.darker_gray);
+ return;
}
}
+ } else {
+ backcolor = color.black;
- /**
- * Handle caches with black font color in dark skin and white font color in light skin
- * by changing background color of the view
- *
- * @param text
- * to be checked
- */
- private void fixTextColor(final String text) {
- int backcolor;
- if (Settings.isLightSkin()) {
- backcolor = color.white;
-
- for (final Pattern pattern : LIGHT_COLOR_PATTERNS) {
- final MatcherWrapper matcher = new MatcherWrapper(pattern, text);
- if (matcher.find()) {
- descriptionView.setBackgroundResource(color.darker_gray);
- return;
- }
- }
- } else {
- backcolor = color.black;
-
- for (final Pattern pattern : DARK_COLOR_PATTERNS) {
- final MatcherWrapper matcher = new MatcherWrapper(pattern, text);
- if (matcher.find()) {
- descriptionView.setBackgroundResource(color.darker_gray);
- return;
- }
- }
+ for (final Pattern pattern : DARK_COLOR_PATTERNS) {
+ final MatcherWrapper matcher = new MatcherWrapper(pattern, text);
+ if (matcher.find()) {
+ descriptionView.setBackgroundResource(color.darker_gray);
+ return;
}
- descriptionView.setBackgroundResource(backcolor);
}
- });
+ }
+ descriptionView.setBackgroundResource(backcolor);
+ }
+ });
}
private class WaypointsViewCreator extends AbstractCachingPageViewCreator<ListView> {