title: how to disable free hand drawing on google map when clear button is pressed
body: <p>I am working on project which needs to add free hand drawing on google map.I have done drawing successfully on google map. But my problem is when i clicked clear button it remove all things what ever i draw on map but i does not disable the edit mode that means when i touched screen again then it again started drawing.</p>
  
  <p>i want when i clicked clear button, it clear every thing and again map is in initial mode as it is before.</p>
  
  <p>here are some screenshot </p>
  
  <p>1.<a href="https://i.stack.imgur.com/nEUv0.png" rel="nofollow noreferrer">this screenshot after clicking clear button and still i am able to draw on map</a></p>
  
  <p>here are some relative code...</p>
  
  <p>this is under my map activity</p>
  
  <pre><code>private void drawOnMap() {
          mcontent = (FrameLayout) findViewById(signature);
          save_button = (ImageButton) findViewById(R.id.save_button);
          save_button.setEnabled(false);
          exit_edit_mode = (ImageButton) findViewById(R.id.exit_edit_mode);
          mSignature = new signature(this, null);
          mcontent.addView(mSignature);
  
          save_button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  mSignature.save();
              }
          });
          exit_edit_mode.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  mSignature.clear();
                  mGoogleMap.getUiSettings().setScrollGesturesEnabled(true);
              }
          });
  </code></pre>
  
  <p>this is my class which perform drawing on google map</p>
  
  <pre><code>public class signature extends View {
      static final float STROKE_WIDTH = 10f;
      static final float HALF_STROKE_WIDTH = STROKE_WIDTH / 2;
  
      Paint paint = new Paint();
      Path path = new Path();
  
      float lastTouchX;
      float lastTouchY;
      final RectF dirtyRect = new RectF();
  
      public signature(Context context, AttributeSet attrs) {
          super(context, attrs);
          paint.setAntiAlias(true);
          paint.setColor(Color.GREEN);
          paint.setStyle(Paint.Style.STROKE);
          paint.setStrokeJoin(Paint.Join.ROUND);
          paint.setStrokeWidth(STROKE_WIDTH);
      }
  
      public void clear() {
          path.reset();
          invalidate();
          save_button.setEnabled(false);
  
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          // TODO Auto-generated method stub
          canvas.drawPath(path, paint);
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          float eventX = event.getX();
          float eventY = event.getY();
          //save.setEnabled(true);
  
          switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                  path.moveTo(eventX, eventY);
                  lastTouchX = eventX;
                  lastTouchY = eventY;
                  return true;
  
              case MotionEvent.ACTION_MOVE:
  
              case MotionEvent.ACTION_UP:
  
                  resetDirtyRect(eventX, eventY);
                  int historySize = event.getHistorySize();
                  for (int i = 0; i &lt; historySize; i++) {
                      float historicalX = event.getHistoricalX(i);
                      float historicalY = event.getHistoricalY(i);
                      path.lineTo(historicalX, historicalY);
                  }
                  path.lineTo(eventX, eventY);
                  break;
          }
  
          invalidate((int) (dirtyRect.left - HALF_STROKE_WIDTH),
                  (int) (dirtyRect.top - HALF_STROKE_WIDTH),
                  (int) (dirtyRect.right + HALF_STROKE_WIDTH),
                  (int) (dirtyRect.bottom + HALF_STROKE_WIDTH));
  
          lastTouchX = eventX;
          lastTouchY = eventY;
  
          return true;
      }
  
      private void resetDirtyRect(float eventX, float eventY) {
          dirtyRect.left = Math.min(lastTouchX, eventX);
          dirtyRect.right = Math.max(lastTouchX, eventX);
          dirtyRect.top = Math.min(lastTouchY, eventY);
          dirtyRect.bottom = Math.max(lastTouchY, eventY);
      }
  }
  </code></pre>
  
  <p>thanks in advance</p>