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_marginLeft="@dimen/dashboard_parking_left_margin"
android:layout_marginRight="@dimen/dashFavIconMargin" android:layout_marginRight="@dimen/dashFavIconMargin"
android:src="@drawable/ic_action_start_navigation" android:src="@drawable/ic_action_start_navigation"
android:scaleType="centerInside" android:scaleType="center"
android:background="@drawable/btn_inset_circle_no_shadow"/> android:background="@drawable/btn_inset_circle_no_shadow"/>
<LinearLayout <LinearLayout

View file

@ -114,11 +114,6 @@ public class DashParkingFragment extends DashLocationFragment {
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon); ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
if (loc != null) { if (loc != null) {
DashLocationView dv = new DashLocationView(direction, (TextView) mainView.findViewById(R.id.distance), position); 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.paint = false;
dv.arrowResId = R.drawable.ic_action_start_navigation; dv.arrowResId = R.drawable.ic_action_start_navigation;
distances.add(dv); distances.add(dv);

View file

@ -74,18 +74,34 @@ public class DirectionDrawable extends Drawable {
this.angle = 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 @Override
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
canvas.save(); canvas.save();
if (arrowImage != null) { if (arrowImage != null) {
int w = arrowImage.getIntrinsicWidth(); int w = arrowImage.getIntrinsicWidth();
int h = arrowImage.getIntrinsicHeight(); int h = arrowImage.getIntrinsicHeight();
int dx = canvas.getWidth() - w; int dx = canvas.getWidth() - w;
int dy = canvas.getHeight() - h; int dy = canvas.getHeight() - h;
arrowImage.setBounds(0, 0, w, h); arrowImage.setBounds(0, 0, w, h);
canvas.rotate(angle, canvas.getWidth() / 2, canvas.getHeight() / 2); canvas.rotate(angle, w / 2, h / 2);
canvas.translate(dx/2, dy/2); canvas.translate(dx / 3, dy / 3);
arrowImage.draw(canvas); arrowImage.draw(canvas);
} else { } else {
canvas.rotate(angle, canvas.getWidth() / 2, canvas.getHeight() / 2); canvas.rotate(angle, canvas.getWidth() / 2, canvas.getHeight() / 2);