aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/network/SmileyImage.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/network/SmileyImage.java')
-rw-r--r--main/src/cgeo/geocaching/network/SmileyImage.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/network/SmileyImage.java b/main/src/cgeo/geocaching/network/SmileyImage.java
new file mode 100644
index 0000000..9bb811e
--- /dev/null
+++ b/main/src/cgeo/geocaching/network/SmileyImage.java
@@ -0,0 +1,40 @@
+package cgeo.geocaching.network;
+
+import cgeo.geocaching.list.StoredList;
+import cgeo.geocaching.utils.ImageUtils;
+import cgeo.geocaching.utils.ImageUtils.LineHeightContainerDrawable;
+
+import org.apache.commons.lang3.tuple.ImmutablePair;
+
+import rx.Observable;
+
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.widget.TextView;
+
+/**
+ * Specialized image class for fetching and displaying smileys in the log book.
+ */
+public class SmileyImage extends HtmlImage {
+
+ public SmileyImage(final String geocode, final TextView view) {
+ super(geocode, false, StoredList.STANDARD_LIST_ID, false, view);
+ }
+
+ @Override
+ protected ImmutablePair<BitmapDrawable, Boolean> scaleImage(final ImmutablePair<Bitmap, Boolean> loadResult) {
+ final Bitmap bitmap = loadResult.left;
+ if (bitmap == null) {
+ return ImmutablePair.of((BitmapDrawable) null, loadResult.right);
+ }
+ final BitmapDrawable drawable = new BitmapDrawable(view.getResources(), bitmap);
+ drawable.setBounds(ImageUtils.scaleImageToLineHeight(drawable, view));
+ return ImmutablePair.of(drawable, loadResult.right);
+ }
+
+ @Override
+ protected BitmapDrawable getContainerDrawable(final Observable<BitmapDrawable> drawable) {
+ return new LineHeightContainerDrawable(view, drawable);
+ }
+
+}