/*
* Copyright (C) 2013 The Android Open Source Project
*
* 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 com.susion.boring.base.view.swipebacklayout;
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ScrollerCompat;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import java.util.Arrays;
/**
* ViewDragHelper is a utility class for writing custom ViewGroups. It offers a
* number of useful operations and state tracking for allowing a user to drag
* and reposition views within their parent ViewGroup.
*/
public class ViewDragHelper {
private static final String TAG = "ViewDragHelper";
/**
* A null/invalid pointer ID.
*/
public static final int INVALID_POINTER = -1;
/**
* A view is not currently being dragged or animating as a result of a
* fling/snap.
*/
public static final int STATE_IDLE = 0;
/**
* A view is currently being dragged. The position is currently changing as
* a result of user input or simulated user input.
*/
public static final int STATE_DRAGGING = 1;
/**
* A view is currently settling into place as a result of a fling or
* predefined non-interactive motion.
*/
public static final int STATE_SETTLING = 2;
/**
* Edge flag indicating that the left edge should be affected.
*/
public static final int EDGE_LEFT = 1 << 0;
/**
* Edge flag indicating that the right edge should be affected.
*/
public static final int EDGE_RIGHT = 1 << 1;
/**
* Edge flag indicating that the top edge should be affected.
*/
public static final int EDGE_TOP = 1 << 2;
/**
* Edge flag indicating that the bottom edge should be affected.
*/
public static final int EDGE_BOTTOM = 1 << 3;
/**
* Edge flag set indicating all edges should be affected.
*/
public static final int EDGE_ALL = EDGE_LEFT | EDGE_TOP | EDGE_RIGHT | EDGE_BOTTOM;
/**
* Indicates that a check should occur along the horizontal axis
*/
public static final int DIRECTION_HORIZONTAL = 1 << 0;
/**
* Indicates that a check should occur along the vertical axis
*/
public static final int DIRECTION_VERTICAL = 1 << 1;
/**
* Indicates that a check should occur along all axes
*/
public static final int DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
public static final int EDGE_SIZE = 20; // dp
private static final int BASE_SETTLE_DURATION = 256; // ms
private static final int MAX_SETTLE_DURATION = 600; // ms
// Current drag state; idle, dragging or settling
private int mDragState;
// Distance to travel before a drag may begin
private int mTouchSlop;
// Last known position/pointer tracking
private int mActivePointerId = INVALID_POINTER;
private float[] mInitialMotionX;
private float[] mInitialMotionY;
private float[] mLastMotionX;
private float[] mLastMotionY;
private int[] mInitialEdgeTouched;
private int[] mEdgeDragsInProgress;
private int[] mEdgeDragsLocked;
private int mPointersDown;
private VelocityTracker mVelocityTracker;
private float mMaxVelocity;
private float mMinVelocity;
private int mEdgeSize;
private int mTrackingEdges;
private ScrollerCompat mScroller;
private final Callback mCallback;
private View mCapturedView;
private boolean mReleaseInProgress;
private final ViewGroup mParentView;
/**
* A Callback is used as a communication channel with the ViewDragHelper
* back to the parent view using it. <code>on*</code>methods are invoked on
* siginficant events and several accessor methods are expected to provide
* the ViewDragHelper with more information about the state of the parent
* view upon request. The callback also makes decisions governing the range
* and draggability of child views.
*/
public static abstract class Callback {
/**
* Called when the drag state changes. See the <code>STATE_*</code>
* constants for more information.
*
* @param state The new drag state
* @see #STATE_IDLE
* @see #STATE_DRAGGING
* @see #STATE_SETTLING
*/
public void onViewDragStateChanged(int state) {
}
/**
* Called when the captured view's position changes as the result of a
* drag or settle.
*
* @param changedView View whose position changed
* @param left New X coordinate of the left edge of the view
* @param top New Y coordinate of the top edge of the view
* @param dx Change in X position from the last call
* @param dy Change in Y position from the last call
*/
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
}
/**
* Called when a child view is captured for dragging or settling. The ID
* of the pointer currently dragging the captured view is supplied. If
* activePointerId is identified as {@link #INVALID_POINTER} the capture
* is programmatic instead of pointer-initiated.
*
* @param capturedChild Child view that was captured
* @param activePointerId Pointer id tracking the child capture
*/
public void onViewCaptured(View capturedChild, int activePointerId) {
}
/**
* Called when the child view is no longer being actively dragged. The
* fling velocity is also supplied, if relevant. The velocity values may
* be clamped to system minimums or maximums.
* <p>
* Calling code may decide to fling or otherwise release the view to let
* it settle into place. It should do so using
* {@link #settleCapturedViewAt(int, int)} or
* {@link #flingCapturedView(int, int, int, int)}. If the Callback
* invokes one of these methods, the ViewDragHelper will enter
* {@link #STATE_SETTLING} and the view capture will not fully end until
* it comes to a complete stop. If neither of these methods is invoked
* before <code>onViewReleased</code> returns, the view will stop in
* place and the ViewDragHelper will return to {@link #STATE_IDLE}.
* </p>
*
* @param releasedChild The captured child view now being released
* @param xvel X velocity of the pointer as it left the screen in pixels
* per second.
* @param yvel Y velocity of the pointer as it left the screen in pixels
* per second.
*/
public void onViewReleased(View releasedChild, float xvel, float yvel) {
}
/**
* Called when one of the subscribed edges in the parent view has been
* touched by the user while no child view is currently captured.
*
* @param edgeFlags A combination of edge flags describing the edge(s)
* currently touched
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计-基于Java的Android app:Music Player设计与实现 (336个子文件)
gradlew.bat 2KB
.gitignore 146B
.gitignore 7B
build.gradle 2KB
build.gradle 559B
settings.gradle 15B
gradlew 5KB
universal-image-loader-1.9.5.jar 158KB
lite-orm-1.9.2.jar 122KB
gradle-wrapper.jar 52KB
ViewDragHelper.java 61KB
PlayListDetail.java 28KB
SwipeBackLayout.java 21KB
PlayMusicActivity.java 15KB
MediaSeekBar.java 14KB
MusicPlayerService.java 14KB
RVUtils.java 11KB
PlayListActivity.java 10KB
CollectActivity.java 8KB
MyLikeActivity.java 8KB
ServiceReceiverPresenter.java 8KB
DrawScaleImageView.java 7KB
JokeFragment.java 7KB
LocalMusicActivity.java 7KB
MusicPageFragment.java 6KB
ClientReceiverPresenter.java 6KB
SearchMusicActivity.java 6KB
LocalMusicPresenter.java 6KB
PictureFragment.java 6KB
MediaPlayPresenter.java 6KB
PictureViewActivity.java 6KB
ZhiHuEssayPresenter.java 6KB
MusicPlayQueueControlPresenter.java 6KB
SToolBar.java 6KB
FileUtils.java 6KB
MusicServiceInstruction.java 6KB
UIUtils.java 6KB
PictureCategoryWindow.java 5KB
ZhiHuEssayActivity.java 5KB
SplashActivity.java 5KB
ZhiHuFragment.java 5KB
DbBaseOperate.java 5KB
MusicPlayQueueWindow.java 5KB
LoadMoreRecycleView.java 5KB
PlayOperatorView.java 4KB
SimpleSong.java 4KB
AppInfoActivity.java 4KB
MusicPageConstantIH.java 4KB
SimplePictureList.java 4KB
MusicControlPanel.java 4KB
MainActivity.java 4KB
MusicDbOperator.java 4KB
Utils.java 4KB
MusicPlayControlView.java 4KB
SystemOperationUtils.java 4KB
NestScrollView.java 4KB
SearchBar.java 4KB
AlbumUtils.java 3KB
BaseRVAdapter.java 3KB
MusicModelTranslatePresenter.java 3KB
JokeIH.java 3KB
LoadMoreView.java 3KB
PlayListSong.java 3KB
TransitionHelper.java 3KB
BaseFragment.java 3KB
APIHelper.java 3KB
SimplePictureIH.java 3KB
ListFragment.java 3KB
TimeUtils.java 3KB
FileDownloadPresenter.java 3KB
MediaPlayerContract.java 3KB
BaseActivity.java 3KB
DrawerData.java 3KB
ZhiHuDailyNewsPresenter.java 3KB
ImagePipelineConfigFactory.java 3KB
LyricView.java 2KB
ReadPageFragment.java 2KB
PictureCategoryResult.java 2KB
NewsDetail.java 2KB
DialogMusicIH.java 2KB
ClientPlayModeCommand.java 2KB
MusicPageAdapter.java 2KB
FixedPopupWindow.java 2KB
ClientPlayQueueControlCommand.java 2KB
SimpleMusicIH.java 2KB
LocalMusicIH.java 2KB
ClientPlayControlCommand.java 2KB
ViewHolder.java 2KB
MediaPlayerThumb.java 2KB
MusicServiceContract.java 2KB
ZhiHuDailyAdapter.java 2KB
Song.java 2KB
DailyNews.java 2KB
CommonObserver.java 2KB
SwipeBackActivityHelper.java 2KB
StringUtils.java 2KB
PictureColumnIH.java 2KB
TopNewsIH.java 1KB
SearchMusicResultIH.java 1KB
BannerView.java 1KB
共 336 条
- 1
- 2
- 3
- 4
资源评论
爱吃苹果的Jemmy
- 粉丝: 75
- 资源: 1148
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- apk_com.huawei.ar.measure_120000320.apk
- ActivePerl-5.16.2.1602-MSWin32-x86-296513
- 2_附件1:2024春广东开放大学作业及教学平台操作指引.docx
- Mysql数据库考试题
- Cadence-16-6-电阻封装与3D模型
- 2023年12月青少年软件编程Python等级考试五级真题(含答案和解析)
- 全国及31个省级社会消费品(商品)零售总额1981-2023年
- ntpdate centos离线安装三剑客 ntp-4.2.6p5-29.el7.centos.x86-64.rpm
- 免费无需登录api.txt
- 基于Pytorch的数据升维的线性网络模型搭建训练测试显示
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功