Ejemplo n.º 1
0
        @Override
        public void handleMessage(Message msg) {
          super.handleMessage(msg);

          switch (mState) {
            case STATE_SHOWING:
              // Fade in effect
              mAlphaRate += (1 - mAlphaRate) * 0.2;
              if (mAlphaRate > 0.9) {
                mAlphaRate = 1;
                setState(STATE_SHOWN);
              }

              mListView.invalidate();
              fade(10);
              break;
            case STATE_SHOWN:
              // If no action, hide automatically
              setState(STATE_HIDING);
              break;
            case STATE_HIDING:
              // Fade out effect
              mAlphaRate -= mAlphaRate * 0.2;
              if (mAlphaRate < 0.1) {
                mAlphaRate = 0;
                setState(STATE_HIDDEN);
              }

              mListView.invalidate();
              fade(10);
              break;
          }
        }
Ejemplo n.º 2
0
  public IndexScroller(Context context, PullToRefreshPinnedSectionListView lv) {
    mDensity = context.getResources().getDisplayMetrics().density;
    mScaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
    mListView = lv;
    setAdapter(mListView.getAdapter());

    mIndexbarWidth = 20 * mDensity;
    mIndexbarMargin = 10 * mDensity;
    mPreviewPadding = 5 * mDensity;
  }
Ejemplo n.º 3
0
  public boolean onTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
      case MotionEvent.ACTION_DOWN:
        // If down event occurs inside index bar region, start indexing
        if (mState != STATE_HIDDEN && contains(ev.getX(), ev.getY())) {
          setState(STATE_SHOWN);

          // It demonstrates that the motion event started from index bar
          mIsIndexing = true;
          // Determine which section the point is in, and move the list to
          // that section
          mCurrentSection = getSectionByPoint(ev.getY());
          mListView.setSelection(mIndexer.getPositionForSection(mCurrentSection));
          return true;
        }
        break;
      case MotionEvent.ACTION_MOVE:
        if (mIsIndexing) {
          // If this event moves inside index bar
          if (contains(ev.getX(), ev.getY())) {
            // Determine which section the point is in, and move the
            // list to that section
            mCurrentSection = getSectionByPoint(ev.getY());
            mListView.setSelection(mIndexer.getPositionForSection(mCurrentSection));
          }
          return true;
        }
        break;
      case MotionEvent.ACTION_UP:
        if (mIsIndexing) {
          mIsIndexing = false;
          mCurrentSection = -1;
        }
        if (mState == STATE_SHOWN) {
          setState(STATE_HIDING);
          mListView.invalidate();
          return true;
        }
        break;
    }
    return false;
  }