blob: ebac2bbabaebfdf81a38969ba3c3516da2ec7c92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package cgeo.geocaching.network;
import cgeo.geocaching.list.StoredList;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.widget.TextView;
public class SmileyImage extends HtmlImage {
public SmileyImage(final String geocode, final TextView view) {
super(geocode, false, StoredList.STANDARD_LIST_ID, false, view);
}
@Override
protected Pair<BitmapDrawable, Boolean> scaleImage(final Pair<Bitmap, Boolean> loadResult) {
final Bitmap bitmap = loadResult.getLeft();
BitmapDrawable drawable;
if (bitmap != null) {
final int lineHeight = (int) (view.getLineHeight() * 0.8);
drawable = new BitmapDrawable(view.getResources(), bitmap);
final int width = drawable.getIntrinsicWidth() * lineHeight / drawable.getIntrinsicHeight();
drawable.setBounds(0, 0, width, lineHeight);
}
else {
drawable = null;
}
return new ImmutablePair<>(drawable, loadResult.getRight());
}
}
|