Change icons in swipes

This commit is contained in:
PavelRatushny 2017-09-22 17:02:39 +03:00
parent 9ddecb34ce
commit 05f9ae23d7
2 changed files with 9 additions and 9 deletions

View file

@ -81,7 +81,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
private float marginSides = getResources().getDimension(R.dimen.list_content_padding);
private Bitmap deleteBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_delete_dark);
private Bitmap resetBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_reset_to_default_dark);
private Bitmap historyBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_marker_passed);
private boolean iconHidden;
@Override
@ -129,9 +129,9 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
float textMarginTop = ((float) itemView.getHeight() - (float) textHeight) / 2;
if (dX > 0) {
c.drawRect(itemView.getLeft(), itemView.getTop(), dX, itemView.getBottom(), backgroundPaint);
float iconMarginTop = ((float) itemView.getHeight() - (float) resetBitmap.getHeight()) / 2;
c.drawBitmap(resetBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + resetBitmap.getWidth(),
float iconMarginTop = ((float) itemView.getHeight() - (float) historyBitmap.getHeight()) / 2;
c.drawBitmap(historyBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + historyBitmap.getWidth(),
itemView.getTop() + textMarginTop + textHeight, textPaint);
} else {
c.drawRect(itemView.getRight() + dX, itemView.getTop(), itemView.getRight(), itemView.getBottom(), backgroundPaint);

View file

@ -26,7 +26,7 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
private float marginSides;
private Bitmap deleteBitmap;
private Bitmap resetBitmap;
private Bitmap historyBitmap;
private boolean iconHidden;
private boolean night;
@ -41,7 +41,7 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
this.adapter = adapter;
marginSides = mapActivity.getResources().getDimension(R.dimen.list_content_padding);
deleteBitmap = BitmapFactory.decodeResource(mapActivity.getResources(), R.drawable.ic_action_delete_dark);
resetBitmap = BitmapFactory.decodeResource(mapActivity.getResources(), R.drawable.ic_action_reset_to_default_dark);
historyBitmap = BitmapFactory.decodeResource(mapActivity.getResources(), R.drawable.ic_action_marker_passed);
night = !mapActivity.getMyApplication().getSettings().isLightContent();
backgroundPaint.setColor(ContextCompat.getColor(mapActivity, night ? R.color.dashboard_divider_dark : R.color.dashboard_divider_light));
@ -104,9 +104,9 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
float textMarginTop = ((float) itemView.getHeight() - (float) textHeight) / 2;
if (dX > 0) {
c.drawRect(itemView.getLeft(), itemView.getTop(), dX, itemView.getBottom(), backgroundPaint);
float iconMarginTop = ((float) itemView.getHeight() - (float) resetBitmap.getHeight()) / 2;
c.drawBitmap(resetBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + resetBitmap.getWidth(),
float iconMarginTop = ((float) itemView.getHeight() - (float) historyBitmap.getHeight()) / 2;
c.drawBitmap(historyBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
c.drawText(moveToHistoryStr, itemView.getLeft() + 2 * marginSides + historyBitmap.getWidth(),
itemView.getTop() + textMarginTop + textHeight, textPaint);
} else {
c.drawRect(itemView.getRight() + dX, itemView.getTop(), itemView.getRight(), itemView.getBottom(), backgroundPaint);