Ejemplo n.º 1
0
  private void initPositions() {
    // we always animate to this position, might as well save it.
    // TODO shouldnt be capitalized.
    X_ORIGINAL_POSITION = mContext.getWallpaperDesiredMinimumWidth() / 10;
    Y_ORIGINAL_POSITION = (int) mHudView.getTopOfHud() + 25;

    // set width
    width = mContext.getWallpaperDesiredMinimumWidth() - 50;
    RECT_LENGTH = X_ORIGINAL_POSITION + width;
    RECT_WIDTH = Y_ORIGINAL_POSITION + height;
    locationRect = new Rect(X_ORIGINAL_POSITION, Y_ORIGINAL_POSITION, RECT_LENGTH, RECT_WIDTH);
    xText = X_ORIGINAL_POSITION;

    // set threshold
    EVENT_BACKWARD_THRESHOLD = (int) (mContext.getWallpaperDesiredMinimumWidth() * .1); // 1/20
  }
Ejemplo n.º 2
0
  /**
   * I want to slide the Event right off
   *
   * @param event - the event the user did. This will allow us to keep HudView lean and mean :-).
   * @return - nothing really, I am not relying on this boolean return, but I kept it for future
   *     possibilities.
   */
  public boolean touchInside(MotionEvent event) {
    if (!locationRect.contains((int) event.getX(), (int) event.getY())) return false;
    else {
      // log("touch is inside");
      // touch has come in

      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
          // log("down");
          // no need to move view if animating.
          if (!isAnimating) xDown = event.getX() + X_ORIGINAL_POSITION;

          return true;

        case MotionEvent.ACTION_MOVE:
          // no adjustments if we are animating
          if (!isAnimating) {
            // log("moving");
            xMove = event.getX() + X_ORIGINAL_POSITION;
            xOffsetTouch = xMove - xDown;
            isDragging = true;
            xText = (int) xOffsetTouch;
            // log("position of xText == " + xText);
            mHudView.invalidate();
            // if finger has dragged forward or backwards enough to instigate a "EventChange"
            if (xText > EVENT_FORWARD_THRESHOLD + X_ORIGINAL_POSITION
                || xText < EVENT_BACKWARD_THRESHOLD - X_ORIGINAL_POSITION) {
              isAnimating = true;
              fingerOff();
            }
          }
          return true;
          // no need to call finger off if we are aniamting, animating, because of ACTION_MOVE
        case MotionEvent.ACTION_UP:
          if (!isAnimating) fingerOff();
          return true;

        case MotionEvent.ACTION_CANCEL:
          if (!isAnimating) fingerOff();
          return true;
      }

      return true;
    }
  }
Ejemplo n.º 3
0
  private void fingerOff() {
    // log("finger off and I was dragging = " + isDragging);
    if (isDragging) {
      isDragging = false;
      // View was dragged far enough to animate into the next Event.
      if (xText < EVENT_BACKWARD_THRESHOLD - X_ORIGINAL_POSITION) {
        // log("next Event forward");
        animateChangeInEvent(true);
        return;

      }
      // finger went far enough to go backwards
      else if (xText > EVENT_FORWARD_THRESHOLD + X_ORIGINAL_POSITION) {
        log("next Event backwards.");
        animateChangeInEvent(false);
        return;
      } else {
        // TODO make a setup for going the other way too. that way we can grab events forward and
        // backwards
        Log.d("threshold", "not met");
        isDragging = false;
        xDown = 0;
        xMove = 0;

        xText = X_ORIGINAL_POSITION;

        mHudView.invalidate();
        return;
      }

    }
    // was not dragging bring the xText back.
    else {
      xText = X_ORIGINAL_POSITION;
    }
  }
Ejemplo n.º 4
0
 public int getEventsSize() {
   return mHudView.getEventSize();
 }
Ejemplo n.º 5
0
  public int setNextEvent(int index) {
    // log("setNextEvent");
    // isTaskRunning = false;
    if (mHudView.getEventSize() > index) { // calendar[0] = Wed

      String dayOfMonth = mHudView.getEvent(index).dayOfMonth;
      String time = ConverterUtil.normalizeTime(mHudView.getEvent(index).time);
      String title = mHudView.getEvent(index).title;
      String description = mHudView.getEvent(index).desc;
      String month = mHudView.getEvent(index).month;

      // tvTitleRow.setText(month + " " + dayOfMonth + "  " + time);
      mEventInfo = (month + " " + dayOfMonth + "  " + time);
      mEventTitle = title;
      mEventDesc = description;

      mEventIndex = index;
      Log.d("initCalendarHud", "events larger than index and it is " + mEventIndex);

    }
    // nothing has changed but the index that has been passed through is larger than
    // the events size so we go back to 0
    else if (mHudView.getEventSize() > 0) {
      Log.d("initCalendarHud", "events smaller than index and greater than 0");

      String dayOfMonth = mHudView.getEvent(0).dayOfMonth;
      String time = ConverterUtil.normalizeTime(mHudView.getEvent(0).time);
      String title = mHudView.getEvent(0).title;
      String description = mHudView.getEvent(0).desc;
      String month = mHudView.getEvent(0).month;

      // tvTitleRow.setText(month + " " + dayOfMonth + "  " + time);
      mEventInfo = (month + " " + dayOfMonth + "  " + time);
      mEventTitle = title;
      mEventDesc = description;

      mEventIndex = 0;
    }
    // log("mEvents.size = " + mHudView.getEventSize());
    // log("return " + mEventIndex);
    mHudView.invalidate();
    return mEventIndex;
  }