Unify views

This commit is contained in:
Victor Shcherb 2011-11-27 23:00:47 +01:00
parent 893c4d96a8
commit eb5e19aaa1
18 changed files with 165 additions and 182 deletions

View file

@ -122,7 +122,6 @@ std::string getString(jstring st) {
const char* utf = globalEnv()->GetStringUTFChars(st, NULL); const char* utf = globalEnv()->GetStringUTFChars(st, NULL);
std::string res(utf); std::string res(utf);
globalEnv()->ReleaseStringUTFChars(st, utf); globalEnv()->ReleaseStringUTFChars(st, utf);
globalEnv()->DeleteLocalRef(st);
return res; return res;
} }

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/back_to_loc_disabled" />
<item android:state_pressed="true" android:drawable="@drawable/back_to_loc_pressed" />
<item android:state_focused="true" android:drawable="@drawable/back_to_loc_pressed" />
<item android:drawable="@drawable/back_to_loc_normal" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/globus_pressed" />
<item android:state_focused="true" android:drawable="@drawable/globus_pressed" />
<item android:drawable="@drawable/globus_normal" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -611,7 +611,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
} }
} }
protected void backToLocationImpl() { public void backToLocationImpl() {
backToLocation.setVisibility(View.INVISIBLE); backToLocation.setVisibility(View.INVISIBLE);
PointLocationLayer locationLayer = mapLayers.getLocationLayer(); PointLocationLayer locationLayer = mapLayers.getLocationLayer();
if(!isMapLinkedToLocation()){ if(!isMapLinkedToLocation()){

View file

@ -132,16 +132,15 @@ public class MapActivityLayers {
// 7. point navigation layer // 7. point navigation layer
navigationLayer = new PointNavigationLayer(); navigationLayer = new PointNavigationLayer();
mapView.addLayer(navigationLayer, 7); mapView.addLayer(navigationLayer, 7);
// 8. map info layer // 8. context menu layer
mapInfoLayer = new MapInfoLayer(activity, routeLayer);
mapView.addLayer(mapInfoLayer, 8);
// 9. context menu layer
contextMenuLayer = new ContextMenuLayer(activity); contextMenuLayer = new ContextMenuLayer(activity);
mapView.addLayer(contextMenuLayer, 9); mapView.addLayer(contextMenuLayer, 8);
// 9. map info layer
mapInfoLayer = new MapInfoLayer(activity, routeLayer);
mapView.addLayer(mapInfoLayer, 9);
// 10. route info layer // 10. route info layer
routeInfoLayer = new RouteInfoLayer(routingHelper, (LinearLayout) activity.findViewById(R.id.RouteLayout)); routeInfoLayer = new RouteInfoLayer(routingHelper, (LinearLayout) activity.findViewById(R.id.RouteLayout));
mapView.addLayer(routeInfoLayer, 10); mapView.addLayer(routeInfoLayer, 10);
// 11. route info layer // 11. route info layer
mapControlsLayer = new MapControlsLayer(activity); mapControlsLayer = new MapControlsLayer(activity);
mapView.addLayer(mapControlsLayer, 11); mapView.addLayer(mapControlsLayer, 11);

View file

@ -545,6 +545,10 @@ public class MapRenderRepositories {
renderer.generateNewBitmap(currentRenderingContext, cObjects, bmp, prefs.USE_ENGLISH_NAMES.get(), renderingReq, renderer.generateNewBitmap(currentRenderingContext, cObjects, bmp, prefs.USE_ENGLISH_NAMES.get(), renderingReq,
notifyList, fillColor); notifyList, fillColor);
} }
// Force to use rendering request in order to prevent Garbage Collector when it is used in C++
if(renderingReq != null){
System.out.println("Debug :" + renderingReq != null);
}
String renderingDebugInfo = currentRenderingContext.renderingDebugInfo; String renderingDebugInfo = currentRenderingContext.renderingDebugInfo;
currentRenderingContext.ended = true; currentRenderingContext.ended = true;
if (checkWhetherInterrupted()) { if (checkWhetherInterrupted()) {

View file

@ -12,8 +12,6 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RoutingHelper.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper.TurnType; import net.osmand.plus.routing.RoutingHelper.TurnType;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Matrix; import android.graphics.Matrix;
@ -36,9 +34,10 @@ import android.view.View;
import android.view.View.MeasureSpec; import android.view.View.MeasureSpec;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;
public class MapInfoLayer extends OsmandMapLayer { public class MapInfoLayer extends OsmandMapLayer {
@ -78,14 +77,8 @@ public class MapInfoLayer extends OsmandMapLayer {
private DisplayMetrics dm; private DisplayMetrics dm;
private float scaleCoefficient; private float scaleCoefficient;
private Bitmap compass;
private Paint paintImg; private Paint paintImg;
private final static int[] pressedState = new int[]{android.R.attr.state_pressed};
private final static int[] simpleState = new int[]{};
private TextInfoControl distanceControl; private TextInfoControl distanceControl;
private TextInfoControl speedControl; private TextInfoControl speedControl;
private TextInfoControl leftTimeControl; private TextInfoControl leftTimeControl;
@ -184,7 +177,6 @@ public class MapInfoLayer extends OsmandMapLayer {
pathTransform.postScale(scaleCoefficient, scaleCoefficient); pathTransform.postScale(scaleCoefficient, scaleCoefficient);
pathTransform.postTranslate(boundsForMiniRoute.left, boundsForMiniRoute.top); pathTransform.postTranslate(boundsForMiniRoute.left, boundsForMiniRoute.top);
compass = BitmapFactory.decodeResource(view.getResources(), R.drawable.compass);
LEFT_MARGIN_X = (int) (LEFT_MARGIN_X * scaleCoefficient); LEFT_MARGIN_X = (int) (LEFT_MARGIN_X * scaleCoefficient);
STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient); STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient);
@ -193,27 +185,22 @@ public class MapInfoLayer extends OsmandMapLayer {
LEFT_MARGIN_Y = statusBar.getMeasuredHeight() ; LEFT_MARGIN_Y = statusBar.getMeasuredHeight() ;
Drawable time = view.getResources().getDrawable(R.drawable.info_time); Drawable time = view.getResources().getDrawable(R.drawable.info_time);
speedControl = new TextInfoControl(R.drawable.box_top, null, time.getMinimumWidth(), paintText, paintSubText); speedControl = new TextInfoControl(R.drawable.box_top, null, 0, paintText, paintSubText);
leftTimeControl = new TextInfoControl(R.drawable.box_top, null, time.getMinimumWidth(), paintText, paintSubText) { leftTimeControl = new TextInfoControl(R.drawable.box_top, time, 0, paintText, paintSubText);
leftTimeControl.setOnClickListener(new View.OnClickListener() {
@Override @Override
public boolean isClickable() { public void onClick(View v) {
return true;
}
@Override
public void click() {
showArrivalTime = !showArrivalTime; showArrivalTime = !showArrivalTime;
view.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME.set(showArrivalTime); view.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME.set(showArrivalTime);
view.refreshMap(); view.refreshMap();
} }
}; });
distanceControl = new TextInfoControl(R.drawable.box_top, view.getResources().getDrawable(R.drawable.info_target), 0, distanceControl = new TextInfoControl(R.drawable.box_top, view.getResources().getDrawable(R.drawable.info_target), 0,
paintText, paintSubText) { paintText, paintSubText);
distanceControl.setOnClickListener(new View.OnClickListener() {
@Override @Override
public boolean isClickable() { public void onClick(View v) {
return true;
}
@Override
public void click() {
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread(); AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
LatLon pointToNavigate = view.getSettings().getPointToNavigate(); LatLon pointToNavigate = view.getSettings().getPointToNavigate();
if(pointToNavigate != null){ if(pointToNavigate != null){
@ -222,7 +209,7 @@ public class MapInfoLayer extends OsmandMapLayer {
fZoom, true); fZoom, true);
} }
} }
}; });
leftControls.add(distanceControl); leftControls.add(distanceControl);
leftControls.add(speedControl); leftControls.add(speedControl);
leftControls.add(leftTimeControl); leftControls.add(leftTimeControl);
@ -239,14 +226,17 @@ public class MapInfoLayer extends OsmandMapLayer {
public void relayoutLeftControls(MapInfoControl... cs){ public void relayoutLeftControls(MapInfoControl... cs){
for(MapInfoControl c : cs) { for(MapInfoControl c : cs) {
c.prefferedLayout(); c.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
} }
int w = 0; int w = 0;
for(MapInfoControl c : leftControls) { for(MapInfoControl c : leftControls) {
w = Math.max(w, c.getMeasuredWidth()); w = Math.max(w, c.getMeasuredWidth());
} }
int x = LEFT_MARGIN_X;
int y = LEFT_MARGIN_Y;
for(MapInfoControl c : leftControls) { for(MapInfoControl c : leftControls) {
c.layout(w, c.getHeight()); c.layout(x, y, x + w, y + c.getMeasuredHeight());
y += c.getMeasuredHeight();
} }
} }
@ -303,20 +293,13 @@ public class MapInfoLayer extends OsmandMapLayer {
drawRouteInfo(canvas); drawRouteInfo(canvas);
// draw left controls // draw left controls
int h = 0;
for(int i=0; i<leftControls.size(); i++){
h += leftControls.get(i).getHeight();
}
h += LEFT_MARGIN_Y;
for (int i = leftControls.size() - 1; i >= 0; i--) { for (int i = leftControls.size() - 1; i >= 0; i--) {
h -= leftControls.get(i).getHeight(); if(leftControls.get(i).getMeasuredHeight() > 0) {
canvas.save();
canvas.translate(LEFT_MARGIN_X, h);
if(leftControls.get(i).isVisible()) {
leftControls.get(i).onDraw(canvas); leftControls.get(i).onDraw(canvas);
} }
canvas.restore();
} }
// draw status bar
if(statusBar.getRight() == 0) { if(statusBar.getRight() == 0) {
Rect statusBarPadding = new Rect(); Rect statusBarPadding = new Rect();
statusBarBackground.getPadding(statusBarPadding); statusBarBackground.getPadding(statusBarPadding);
@ -441,30 +424,39 @@ public class MapInfoLayer extends OsmandMapLayer {
return true; return true;
} }
private View pressedView = null;
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
int x = (int)event.getX(); int x = (int) event.getX();
int y = (int)event.getY(); int y = (int) event.getY();
if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getAction() == MotionEvent.ACTION_DOWN) {
MapInfoControl control = detectLeftControl(x, y); pressedView = null;
if (control != null && control.isClickable()) { ArrayList<View> touchables = statusBar.getTouchables();
control.setPressed(true); touchables.addAll(leftControls);
view.refreshMap(); for (View v : touchables) {
} if (v.getMeasuredHeight() > 0 && v.isClickable()) {
} if (v.getLeft() <= x && x <= v.getRight() && v.getTop() <= y && y <= v.getBottom()) {
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { pressedView = v;
MapInfoControl control = detectLeftControl(x, y); break;
for(MapInfoControl c : leftControls){
if(c.isPressed()) {
if(control == c) {
c.click();
} }
c.setPressed(false);
} }
}
if (pressedView != null) {
pressedView.setPressed(true);
view.refreshMap(); view.refreshMap();
} }
return pressedView != null;
} }
return false; boolean pressed = pressedView != null;
if (pressed && (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL)) {
pressedView.setPressed(false);
if (pressedView.getLeft() <= x && x <= pressedView.getRight() && pressedView.getTop() <= y && y <= pressedView.getBottom()) {
pressedView.performClick();
}
view.refreshMap();
}
return pressed;
} }
@ -477,46 +469,25 @@ public class MapInfoLayer extends OsmandMapLayer {
return true; return true;
} }
} }
MapInfoControl control = detectLeftControl((int)point.x, (int)point.y);
if (control != null && control.isClickable()) {
control.click();
return true;
}
return false; return false;
} }
private MapInfoControl detectLeftControl(int x, int y) {
x -= LEFT_MARGIN_X;
y -= LEFT_MARGIN_Y;
if (y >= 0 && x >= 0) {
for (int i = 0; i < leftControls.size(); i++) {
if (leftControls.get(i).isVisible()) {
y -= leftControls.get(i).getHeight();
if (y <= 0) {
if (x <= leftControls.get(i).getWidth()) {
return leftControls.get(i);
} else {
return null;
}
}
}
}
}
return null;
}
private ViewGroup createStatusBar() { private ViewGroup createStatusBar() {
final int mw = (int) compass.getWidth() ; final Drawable compass = view.getResources().getDrawable(R.drawable.compass);
final int mh = (int) compass.getHeight() ; final int mw = (int) compass.getMinimumWidth() ;
FrameLayout statusBar = new FrameLayout(view.getContext()); final int mh = (int) compass.getMinimumHeight() ;
LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, LinearLayout statusBar = new LinearLayout(view.getContext());
Gravity.LEFT | Gravity.TOP); statusBar.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.leftMargin = (int) (5 * scaleCoefficient);
ImageView compassView = new ImageView(view.getContext()) { ImageView compassView = new ImageView(view.getContext()) {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
canvas.save(); canvas.save();
canvas.rotate(view.getRotate(), getLeft() + mw / 2, getTop() + mh / 2); canvas.translate(getLeft(), getTop());
canvas.drawBitmap(compass, getLeft(), getTop(), paintImg); canvas.rotate(view.getRotate(), mw / 2, mh / 2);
compass.draw(canvas);
canvas.restore(); canvas.restore();
} }
}; };
@ -526,82 +497,78 @@ public class MapInfoLayer extends OsmandMapLayer {
map.switchRotateMapMode(); map.switchRotateMapMode();
} }
}); });
compassView.setImageDrawable(compass);
statusBar.addView(compassView, params); statusBar.addView(compassView, params);
compassView.setImageBitmap(compass);
// Space
params = new LinearLayout.LayoutParams(0, 0, 1);
TextView space = new TextView(view.getContext());
statusBar.addView(space, params);
statusBar.setWeightSum(1);
params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
ImageView globus = new ImageView(view.getContext());
globus.setImageDrawable(view.getResources().getDrawable(R.drawable.globus));
globus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO show map dialog
}
});
statusBar.addView(globus, params);
params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
ImageView backToLocation = new ImageView(view.getContext());
backToLocation.setImageDrawable(view.getResources().getDrawable(R.drawable.back_to_loc));
backToLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
map.backToLocationImpl();
}
});
statusBar.addView(backToLocation, params);
statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
return statusBar; return statusBar;
} }
public abstract class MapInfoControl { public abstract class MapInfoControl extends View {
int width = 0; int width = 0;
int height = 0; int height = 0;
boolean pressed = false; boolean pressed = false;
Drawable background; Drawable background;
public MapInfoControl(int background){ public MapInfoControl(int background){
super(view.getContext());
this.background = view.getResources().getDrawable(background).mutate(); this.background = view.getResources().getDrawable(background).mutate();
} }
public boolean isClickable(){ @Override
return false;
}
public boolean isVisible() {
return true;
}
public void click() {
}
public boolean isPressed() {
return pressed;
}
public void setPressed(boolean pressed) { public void setPressed(boolean pressed) {
if(this.pressed != pressed) { super.setPressed(pressed);
this.pressed = pressed; background.setState(getDrawableState());
if(pressed) {
background.setState(pressedState);
} else {
background.setState(simpleState);
}
Rect padding = new Rect();
if(background.getPadding(padding)) {
background.setBounds(-padding.left, -padding.top,
width + padding.right, height + padding.bottom);
}
}
}
public int getWidth() {
return width;
}
public int getHeight() {
return isVisible() ? height : 0;
}
public void prefferedLayout(){
layout(getMeasuredWidth(), getMeasuredHeight());
}
public void layout(int w, int h) {
this.width = w;
this.height = h;
Rect padding = new Rect(); Rect padding = new Rect();
if(background.getPadding(padding)) { if (background.getPadding(padding)) {
background.setBounds(-padding.left, -padding.top, background.setBounds(-padding.left + getLeft(), getTop()
w + padding.right, h + padding.bottom); -padding.top, getRight() + padding.right, getBottom() + padding.bottom);
} }
} }
public abstract int getMeasuredWidth(); @Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
Rect padding = new Rect();
if (background.getPadding(padding)) {
background.setBounds(-padding.left + left, top
-padding.top, right + padding.right, bottom + padding.bottom);
}
}
public abstract int getMeasuredHeight(); @Override
protected void onDraw(Canvas cv) {
void onDraw(Canvas cv) {
background.draw(cv); background.draw(cv);
} }
} }
@ -612,7 +579,6 @@ public class MapInfoLayer extends OsmandMapLayer {
Paint textPaint; Paint textPaint;
String subtext; String subtext;
Paint subtextPaint; Paint subtextPaint;
int cacheMeasuredWidth = -1;
int leftMargin = 0; int leftMargin = 0;
private Drawable imageDrawable; private Drawable imageDrawable;
@ -621,42 +587,54 @@ public class MapInfoLayer extends OsmandMapLayer {
super(background); super(background);
this.leftMargin = leftMargin; this.leftMargin = leftMargin;
this.imageDrawable = drawable; this.imageDrawable = drawable;
if(imageDrawable != null) {
// Unknown reason to add 3*scaleCoefficient
imageDrawable.setBounds(0, (int) (3*scaleCoefficient), imageDrawable.getMinimumWidth(), imageDrawable.getMinimumHeight() +
(int)(3*scaleCoefficient));
}
this.textPaint = textPaint; this.textPaint = textPaint;
this.subtextPaint = subtextPaint; this.subtextPaint = subtextPaint;
} }
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if(imageDrawable != null) {
// Unknown reason to add 3*scaleCoefficient
imageDrawable.setBounds(getLeft(),
getTop() + (int) (3*scaleCoefficient),
getLeft() + imageDrawable.getMinimumWidth(),
getTop() + imageDrawable.getMinimumHeight() +
(int)(3*scaleCoefficient));
}
}
public void setText(String text, String subtext) { public void setText(String text, String subtext) {
this.text = text; this.text = text;
this.subtext = subtext; this.subtext = subtext;
cacheMeasuredWidth = -1; requestLayout();
} }
@Override @Override
public int getMeasuredWidth() { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (cacheMeasuredWidth == -1) { // ignore attributes
int w = 0; int w = 0;
if (text != null) { int h = 0;
if(imageDrawable != null) { if (text != null) {
w += imageDrawable.getBounds().width(); if(imageDrawable != null) {
} w += imageDrawable.getMinimumWidth();
w += leftMargin; }
w += textPaint.measureText(text); w += leftMargin;
if (subtext != null) { w += textPaint.measureText(text);
w += subtextPaint.measureText(subtext) + 2 * scaleCoefficient; if (subtext != null) {
} w += subtextPaint.measureText(subtext) + 2 * scaleCoefficient;
}
h = (int) (5 * scaleCoefficient + Math.max(textPaint.getTextSize(), subtextPaint.getTextSize()));
if(imageDrawable != null) {
h = Math.max(h, (int)(imageDrawable.getMinimumHeight()));
} }
cacheMeasuredWidth = w;
} }
return cacheMeasuredWidth; setMeasuredDimension(w, h);
} }
@Override @Override
void onDraw(Canvas cv) { protected void onDraw(Canvas cv) {
super.onDraw(cv); super.onDraw(cv);
if (isVisible()) { if (isVisible()) {
int margin = 0; int margin = 0;
@ -665,27 +643,17 @@ public class MapInfoLayer extends OsmandMapLayer {
margin = imageDrawable.getBounds().width(); margin = imageDrawable.getBounds().width();
} }
margin += leftMargin; margin += leftMargin;
cv.drawText(text, margin , getHeight() - scaleCoefficient, textPaint); cv.drawText(text, margin + getLeft(), getBottom() - 2 * scaleCoefficient, textPaint);
if (subtext != null) { if (subtext != null) {
cv.drawText(subtext, margin + 2 * scaleCoefficient + textPaint.measureText(text), cv.drawText(subtext, getLeft() + margin + 2 * scaleCoefficient + textPaint.measureText(text), getBottom()
getHeight() - scaleCoefficient, subtextPaint); - 2 * scaleCoefficient, subtextPaint);
} }
} }
} }
@Override
public boolean isVisible() { public boolean isVisible() {
return text != null && text.length() > 0; return text != null && text.length() > 0;
} }
@Override
public int getMeasuredHeight() {
int h = (int) (2 * scaleCoefficient + Math.max(textPaint.getTextSize(), subtextPaint.getTextSize()));
if(imageDrawable != null) {
h = Math.max(h, (int)(imageDrawable.getMinimumHeight()));
}
return h;
}
} }