Parking drawable

This commit is contained in:
Victor Shcherb 2015-04-01 15:38:27 +02:00
parent d6cbfa18f8
commit d83ecbc507
3 changed files with 21 additions and 10 deletions

View file

@ -21,7 +21,7 @@
android:layout_marginLeft="@dimen/dashboard_parking_left_margin"
android:layout_marginRight="@dimen/dashFavIconMargin"
android:src="@drawable/ic_action_start_navigation"
android:scaleType="centerInside"
android:scaleType="center"
android:background="@drawable/btn_inset_circle_no_shadow"/>
<LinearLayout

View file

@ -114,13 +114,8 @@ public class DashParkingFragment extends DashLocationFragment {
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
if (loc != null) {
DashLocationView dv = new DashLocationView(direction, (TextView) mainView.findViewById(R.id.distance), position);
// Drawable dds = getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_start_navigation,
// R.color.color_distance);
// DirectionDrawable dd = new DirectionDrawable(mainView.getContext(),
// dds.getIntrinsicWidth(), dds.getIntrinsicHeight());
// direction.setImageDrawable(dd);
dv.paint = false;
dv.arrowResId = R.drawable.ic_action_start_navigation;
dv.arrowResId = R.drawable.ic_action_start_navigation;
distances.add(dv);
}

View file

@ -73,19 +73,35 @@ public class DirectionDrawable extends Drawable {
public void setAngle(float angle) {
this.angle = angle;
}
@Override
public int getIntrinsicWidth() {
if (arrowImage != null) {
return arrowImage.getIntrinsicWidth();
}
return super.getIntrinsicWidth();
}
@Override
public int getIntrinsicHeight() {
if (arrowImage != null) {
return arrowImage.getIntrinsicHeight();
}
return super.getIntrinsicHeight();
}
@Override
public void draw(Canvas canvas) {
canvas.save();
if (arrowImage != null) {
int w = arrowImage.getIntrinsicWidth();
int h = arrowImage.getIntrinsicHeight();
int dx = canvas.getWidth() - w;
int dy = canvas.getHeight() - h;
arrowImage.setBounds(0, 0, w, h);
canvas.rotate(angle, canvas.getWidth() / 2, canvas.getHeight() / 2);
canvas.translate(dx/2, dy/2);
canvas.rotate(angle, w / 2, h / 2);
canvas.translate(dx / 3, dy / 3);
arrowImage.draw(canvas);
} else {
canvas.rotate(angle, canvas.getWidth() / 2, canvas.getHeight() / 2);