N:
      vec_pointers_.push_back(AMotionEvent_getPointerId(event, 0));
      break;
    case AMOTION_EVENT_ACTION_POINTER_DOWN: {
      int32_t iIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
                       AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
      vec_pointers_.push_back(AMotionEvent_getPointerId(event, iIndex));
      if (count == 2) {
        // Start new pinch
        ret = GESTURE_STATE_START;
      }
    } break;
    case AMOTION_EVENT_ACTION_UP:
      vec_pointers_.pop_back();
      break;
    case AMOTION_EVENT_ACTION_POINTER_UP: {
      int32_t index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
                      AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
      int32_t released_pointer_id = AMotionEvent_getPointerId(event, index);

      std::vector<int32_t>::iterator it = vec_pointers_.begin();
      std::vector<int32_t>::iterator it_end = vec_pointers_.end();
      int32_t i = 0;
      for (; it != it_end; ++it, ++i) {
        if (*it == released_pointer_id) {
          vec_pointers_.erase(it);
          break;
        }
      }

      if (i <= 1) {
        // Reset pinch or drag
        if (count != 2) {
          // Start new pinch
          ret = GESTURE_STATE_START | GESTURE_STATE_END;
        }
      }
    } break;
    case AMOTION_EVENT_ACTION_MOVE:
      switch (count) {
        case 1:
          break;
        default:
          // Multi touch
          ret = GESTURE_STATE_MOVE;
          break;
      }
      break;
    case AMOTION_EVENT_ACTION_CANCEL:
      break;
  }

  return ret;
}

bool PinchDetector::GetPointers(Vec2& v1, Vec2& v2) {
  if (vec_pointers_.size() < 2) return false;

  int32_t index = FindIndex(event_, vec_pointers_[0]);
  if (index == -1) return false;

  float x = AMotionEvent_getX(event_, index);
  float y = AMotionEvent_getY(event_, index);

  index = FindIndex(event_, vec_pointers_[1]);
  if (index == -1) return false;

  float x2 = AMotionEvent_getX(event_, index);
  float y2 = AMotionEvent_getY(event_, index);

  v1 = Vec2(x, y);
  v2 = Vec2(x2, y2);

  return true;
}

//--------------------------------------------------------------------------------
// DragDetector
//--------------------------------------------------------------------------------

int32_t DragDetector::FindIndex(const AInputEvent* event, int32_t id) {
  int32_t count = AMotionEvent_getPointerCount(event);
  for (auto i = 0; i < count; ++i) {
    if (id == AMotionEvent_getPointerId(event, i)) return i;
  }
  return -1;
}

GESTURE_STATE DragDetector::Detect(const AInputEvent* event) {
  GESTURE_STATE ret = GESTURE_STATE_NONE;
  int32_t action = AMotionEvent_getAction(event);
  int32_t index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
                  AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
  uint32_t flags = action & AMOTION_EVENT_ACTION_MASK;
  event_ = event;

  int32_t count = AMotionEvent_getPointerCount(event);
  switch (flags) {
    case AMOTION_EVENT_ACTION_DOWN:
      vec_pointers_.push_back(AMotionEvent_getPointerId(event, 0));
      ret = G/*
 * Copyright 2010 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gradle.api.tasks;

import java.lang.annotation.*;

/**
 * <p>Marks a property as specifying an input file for a task.</p>
 *
 * <p>This annotation should be attached to the getter method or the field for the property.</p>
 *
 * <p>This will cause the task to be considered out-of-date when the file path or contents
 * have changed. To make the up-to-date check only dependent on the path and not the contents
 * of the file or directory, annotate it instead with {@link org.gradle.api.tasks.Input}.
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD})
public @interface InputFile {
}