Java Code Examples for android.support.v4.widget.ViewDragHelper#STATE_IDLE

The following examples show how to use android.support.v4.widget.ViewDragHelper#STATE_IDLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlidingUpPanelLayout.java    From AntennaPodSP with MIT License 6 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    int anchoredTop = (int)(mAnchorPoint*mSlideRange);

    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            if (mSlideState != SlideState.EXPANDED) {
                updateObscuredViewVisibility();
                dispatchOnPanelExpanded(mSlideableView);
                mSlideState = SlideState.EXPANDED;
            }
        } else if (mSlideOffset == (float)anchoredTop/(float)mSlideRange) {
            if (mSlideState != SlideState.ANCHORED) {
                updateObscuredViewVisibility();
                dispatchOnPanelAnchored(mSlideableView);
                mSlideState = SlideState.ANCHORED;
            }
        } else if (mSlideState != SlideState.COLLAPSED) {
            dispatchOnPanelCollapsed(mSlideableView);
            mSlideState = SlideState.COLLAPSED;
        }
    }
}
 
Example 2
Source File: SlidingUpPanelLayout.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    int anchoredTop = (int)(mAnchorPoint*mSlideRange);

    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            if (mSlideState != SlideState.EXPANDED) {
                updateObscuredViewVisibility();
                dispatchOnPanelExpanded(mSlideableView);
                mSlideState = SlideState.EXPANDED;
            }
        } else if (mSlideOffset == (float)anchoredTop/(float)mSlideRange) {
            if (mSlideState != SlideState.ANCHORED) {
                updateObscuredViewVisibility();
                dispatchOnPanelAnchored(mSlideableView);
                mSlideState = SlideState.ANCHORED;
            }
        } else if (mSlideState != SlideState.COLLAPSED) {
            dispatchOnPanelCollapsed(mSlideableView);
            mSlideState = SlideState.COLLAPSED;
        }
    }
}
 
Example 3
Source File: SlidingPaneLayout.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            if (mState != STATE_CLOSED) {
                mState = STATE_CLOSED;
                if (mPanelSlideListener != null)
                    mPanelSlideListener.onPanelClosed();
            }
        } else if (Math.abs(mSlideOffset - (1 - (float)mOverhangSize / mSlideRange))
                   <= 0.001) {
            if (mState != STATE_OPENED) {
                mState = STATE_OPENED;
                if (mPanelSlideListener != null)
                    mPanelSlideListener.onPanelOpened();
            }
        } else if (mSlideOffset == 1) {
            if (mState != STATE_OPENED_ENTIRELY) {
                mState = STATE_OPENED_ENTIRELY;
                if (mPanelSlideListener != null)
                    mPanelSlideListener.onPanelOpenedEntirely();
            }
        }
    }
}
 
Example 4
Source File: SlidingUpPanelLayout.java    From BlackLight with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    int anchoredTop = (int)(mAnchorPoint*mSlideRange);

    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            if (mSlideState != SlideState.EXPANDED) {
                updateObscuredViewVisibility();
                dispatchOnPanelExpanded(mSlideableView);
                mSlideState = SlideState.EXPANDED;
            }
        } else if (mSlideOffset == (float)anchoredTop/(float)mSlideRange) {
            if (mSlideState != SlideState.ANCHORED) {
                updateObscuredViewVisibility();
                dispatchOnPanelAnchored(mSlideableView);
                mSlideState = SlideState.ANCHORED;
            }
        } else if (mSlideState != SlideState.COLLAPSED) {
            dispatchOnPanelCollapsed(mSlideableView);
            mSlideState = SlideState.COLLAPSED;
        }
    }
}
 
Example 5
Source File: SlidingUpPanelLayout.java    From AndroidSlidingUpPanel-foursquare-map-demo with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    int anchoredTop = (int)(mAnchorPoint*mSlideRange);

    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            if (mSlideState != SlideState.EXPANDED) {
                updateObscuredViewVisibility();
                dispatchOnPanelExpanded(mSlideableView);
                mSlideState = SlideState.EXPANDED;
            }
        } else if (mSlideOffset == (float)anchoredTop/(float)mSlideRange) {
            if (mSlideState != SlideState.ANCHORED) {
                updateObscuredViewVisibility();
                dispatchOnPanelAnchored(mSlideableView);
                mSlideState = SlideState.ANCHORED;
            }
        } else if (mSlideState != SlideState.COLLAPSED) {
            dispatchOnPanelCollapsed(mSlideableView);
            mSlideState = SlideState.COLLAPSED;
        }
    }
}
 
Example 6
Source File: SwipeRevealLayout.java    From SwipeRevealLayout with MIT License 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (isDragLocked()) {
        return super.onInterceptTouchEvent(ev);
    }

    mDragHelper.processTouchEvent(ev);
    mGestureDetector.onTouchEvent(ev);
    accumulateDragDist(ev);

    boolean couldBecomeClick = couldBecomeClick(ev);
    boolean settling = mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING;
    boolean idleAfterScrolled = mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE
            && mIsScrolling;

    // must be placed as the last statement
    mPrevX = ev.getX();
    mPrevY = ev.getY();

    // return true => intercept, cannot trigger onClick event
    return !couldBecomeClick && (settling || idleAfterScrolled);
}
 
Example 7
Source File: SlidingLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            updateObscuredViewsVisibility(mSlideableView);
            dispatchOnPanelClosed(mSlideableView);
            mPreservedOpenState = false;
        } else {
            dispatchOnPanelOpened(mSlideableView);
            mPreservedOpenState = true;
        }
    }
}
 
Example 8
Source File: SlideLayout.java    From SlideActivity with MIT License 5 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    if (widthMode != MeasureSpec.EXACTLY) {
        throw new IllegalStateException("Width must have an exact value or MATCH_PARENT");
    }

    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);
    if (heightMode != MeasureSpec.EXACTLY) {
        throw new IllegalStateException("Width must have an exact value or MATCH_PARENT");
    }

    final int childCount = getChildCount();

    // We'll find the current one below.
    mSlideableView = null;

    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();

        int childWidthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
        int childHeightSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);

        child.measure(childWidthSpec, childHeightSpec);
        lp.slideable = true;
        mSlideableView = child;
    }

    setMeasuredDimension(widthSize, heightSize);
    mCanSlide = true;

    if (mDragHelper.getViewDragState() != ViewDragHelper.STATE_IDLE) {
        // Cancel scrolling in progress, it's no longer relevant.
        mDragHelper.abort();
    }
}
 
Example 9
Source File: ToolbarPanelLayout.java    From ToolbarPanel with MIT License 5 votes vote down vote up
/**
 * Resolve the shared state of all drawers from the component ViewDragHelpers.
 * Should be called whenever a ViewDragHelper's state changes.
 */
void updateDrawerState(int activeState) {

    if (activeState == ViewDragHelper.STATE_IDLE) {
        if (dragOffset == 0) {
            dispatchOnPanelClosed();
        } else if (dragOffset == 1) {
            dispatchOnDrawerOpened();
        }
    }
}
 
Example 10
Source File: BehaviorDelegate.java    From DrawerBehavior with Apache License 2.0 5 votes vote down vote up
private void updateDrawerState(int activeState, View activeDrawer) {
  final int state = dragger.getViewDragState();

  if (activeDrawer != null && activeState == ViewDragHelper.STATE_IDLE) {
    if (onScreen == 0) {
      dispatchOnDrawerClosed(activeDrawer);
    } else if (onScreen == 1) {
      dispatchOnDrawerOpened(activeDrawer);
    }
  }

  if (state != drawerState) {
    drawerState = state;
  }
}
 
Example 11
Source File: SwipeBackLayout.java    From SwipeBackLibrary with Apache License 2.0 5 votes vote down vote up
@Override
        public void onViewDragStateChanged(int state) {
            super.onViewDragStateChanged(state);
            if (mListeners != null && !mListeners.isEmpty()) {
                for (SwipeListener listener : mListeners) {
                    listener.onScrollStateChange(state, mScrollPercent);
                }
            }
//            Log.i("======", "onViewDragStateChanged:" + state + ":" + mScrollPercent);

            if (state == ViewDragHelper.STATE_IDLE) {
                if (mScrollPercent >= 1){
                    if (mFragment != null && !mFragment.isDetached()){//结束当前fragment时,取消动画
                        ISwipeBackFragment iSwipeBackFragment = (ISwipeBackFragment)mFragment;
                        iSwipeBackFragment.getPreFragment().setLockable(true);

                        iSwipeBackFragment.setLockable(true);
                        mFragment.getFragmentManager().popBackStackImmediate();
                        iSwipeBackFragment.setLockable(false);

                        iSwipeBackFragment.getPreFragment().setLockable(false);
                    }else if (mActivity != null && !mActivity.isFinishing()){
                        mActivity.finish();
                    }
                }else{
                    recovery(getPreSwipeBackLayout());
                    if (mActivity != null) Utils.convertActivityFromTranslucent(mActivity);
                }
            }
        }
 
Example 12
Source File: SwipeBackLayout.java    From SwipeBackLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    final boolean drawContent = child == mContentView;

    boolean ret = super.drawChild(canvas, child, drawingTime);
    if (mScrimOpacity > 0 && drawContent
            && mViewDragHelper.getViewDragState() != ViewDragHelper.STATE_IDLE) {
        if (mHasShadow) drawShadow(canvas, child);
        drawScrim(canvas, child);
    }
    return ret;
}
 
Example 13
Source File: SwipeBackLayout.java    From AndroidProjects with MIT License 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            updateObscuredViewsVisibility(mSlideableView);
            dispatchOnPanelClosed(mSlideableView);
            mPreservedOpenState = false;
        } else {
            dispatchOnPanelOpened(mSlideableView);
            mPreservedOpenState = true;
        }
    }
}
 
Example 14
Source File: SlideFrameLayout.java    From AccountBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            updateObscuredViewsVisibility(mSlideableView);
            mPreservedOpenState = false;
        } else {
            mPreservedOpenState = true;
        }
    }
}
 
Example 15
Source File: SlidingRootNavLayout.java    From SlidingRootNav with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (dragState == ViewDragHelper.STATE_IDLE && state != ViewDragHelper.STATE_IDLE) {
        notifyDragStart();
    } else if (dragState != ViewDragHelper.STATE_IDLE && state == ViewDragHelper.STATE_IDLE) {
        isMenuHidden = calculateIsMenuHidden();
        notifyDragEnd(isMenuOpened());
    }
    dragState = state;
}
 
Example 16
Source File: SlidingPaneLayout.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) {
        if (mSlideOffset == 0) {
            updateObscuredViewsVisibility(mSlideableView);
            dispatchOnPanelClosed(mSlideableView);
            mPreservedOpenState = false;
        } else {
            dispatchOnPanelOpened(mSlideableView);
            mPreservedOpenState = true;
        }
    }
}
 
Example 17
Source File: SwipeBackLayout.java    From Readhub with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (state == draggingState) return;

    if ((draggingState == ViewDragHelper.STATE_DRAGGING ||
        draggingState == ViewDragHelper.STATE_SETTLING) &&
        state == ViewDragHelper.STATE_IDLE) {
        // the view stopped from moving.
        if (draggingOffset == getDragRange()) {
            finish();
        }
    }

    draggingState = state;
}
 
Example 18
Source File: ViewDragHelperView.java    From Android_UE with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (state == ViewDragHelper.STATE_IDLE) {
        View captureView = mViewDragHelper.getCapturedView();
        if (captureView != null) {
            captureView.setElevation(captureView.getElevation() - 1);
        }
    }
}
 
Example 19
Source File: DragHelperGridView.java    From PlusDemo with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (state == ViewDragHelper.STATE_IDLE) {
        View capturedView = dragHelper.getCapturedView();
        if (capturedView != null) {
            capturedView.setElevation(capturedView.getElevation() - 1);
        }
    }
}
 
Example 20
Source File: SwipeBackLayout.java    From SwipeBack with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewDragStateChanged(int state) {
    if (state == draggingState) return;

    if ((draggingState == ViewDragHelper.STATE_DRAGGING || draggingState == ViewDragHelper.STATE_SETTLING) &&
            state == ViewDragHelper.STATE_IDLE) {
        // the view stopped from moving.
        if (draggingOffset == getDragRange()) {
            onFinishListener.onFinishState();
        }
    }

    draggingState = state;
}