/*
* Copyright (C) 2011 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.itlanbao.app.tabhost;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.support.v4.os.ParcelableCompat;
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
import android.support.v4.view.AccessibilityDelegateCompat;
import android.support.v4.view.KeyEventCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewConfigurationCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.support.v4.view.accessibility.AccessibilityRecordCompat;
import android.support.v4.widget.EdgeEffectCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.FocusFinder;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.Interpolator;
import android.widget.Scroller;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/**
* Layout manager that allows the user to flip left and right
* through pages of data. You supply an implementation of a
* {@link PagerAdapter} to generate the pages that the view shows.
*
* <p>Note this class is currently under early design and
* development. The API will likely change in later updates of
* the compatibility library, requiring changes to the source code
* of apps when they are compiled against the newer version.</p>
*
* <p>ViewPager is most often used in conjunction with {@link android.app.Fragment},
* which is a convenient way to supply and manage the lifecycle of each page.
* There are standard adapters implemented for using fragments with the ViewPager,
* which cover the most common use cases. These are
* {@link android.support.v4.app.FragmentPagerAdapter} and
* {@link android.support.v4.app.FragmentStatePagerAdapter}; each of these
* classes have simple code showing how to build a full user interface
* with them.
*
* <p>Here is a more complicated example of ViewPager, using it in conjuction
* with {@link android.app.ActionBar} tabs. You can find other examples of using
* ViewPager in the API 4+ Support Demos and API 13+ Support Demos sample code.
*
* {@sample development/samples/Support13Demos/src/com/example/android/supportv13/app/ActionBarTabsPager.java
* complete}
*/
public class CustomViewPager extends ViewGroup {
private static final String TAG = "ViewPager";
private static final boolean DEBUG = false;
private static final boolean USE_CACHE = false;
private boolean isCanScroll = true;
private static final int DEFAULT_OFFSCREEN_PAGES = 0;
private static final int MAX_SETTLE_DURATION = 600; // ms
private static final int MIN_DISTANCE_FOR_FLING = 25; // dips
private static final int DEFAULT_GUTTER_SIZE = 16; // dips
private static final int MIN_FLING_VELOCITY = 400; // dips
private static final int[] LAYOUT_ATTRS = new int[] {
android.R.attr.layout_gravity
};
/**
* Used to track what the expected number of items in the adapter should be.
* If the app changes this when we don't expect it, we'll throw a big obnoxious exception.
*/
private int mExpectedAdapterCount;
static class ItemInfo {
Object object;
int position;
boolean scrolling;
float widthFactor;
float offset;
}
private static final Comparator<ItemInfo> COMPARATOR = new Comparator<ItemInfo>(){
@Override
public int compare(ItemInfo lhs, ItemInfo rhs) {
return lhs.position - rhs.position;
}
};
private static final Interpolator sInterpolator = new Interpolator() {
public float getInterpolation(float t) {
t -= 1.0f;
return t * t * t * t * t + 1.0f;
}
};
private final ArrayList<ItemInfo> mItems = new ArrayList<ItemInfo>();
private final ItemInfo mTempItem = new ItemInfo();
private final Rect mTempRect = new Rect();
private PagerAdapter mAdapter;
private int mCurItem; // Index of currently displayed page.
private int mRestoredCurItem = -1;
private Parcelable mRestoredAdapterState = null;
private ClassLoader mRestoredClassLoader = null;
private Scroller mScroller;
private PagerObserver mObserver;
private int mPageMargin;
private Drawable mMarginDrawable;
private int mTopPageBounds;
private int mBottomPageBounds;
// Offsets of the first and last items, if known.
// Set during population, used to determine if we are at the beginning
// or end of the pager data set during touch scrolling.
private float mFirstOffset = -Float.MAX_VALUE;
private float mLastOffset = Float.MAX_VALUE;
private int mChildWidthMeasureSpec;
private int mChildHeightMeasureSpec;
private boolean mInLayout;
private boolean mScrollingCacheEnabled;
private boolean mPopulatePending;
private int mOffscreenPageLimit = DEFAULT_OFFSCREEN_PAGES;
private boolean mIsBeingDragged;
private boolean mIsUnableToDrag;
private boolean mIgnoreGutter;
private int mDefaultGutterSize;
private int mGutterSize;
private int mTouchSlop;
/**
* Position of the last motion event.
*/
private float mLastMotionX;
private float mLastMotionY;
private float mInitialMotionX;
private float mInitialMotionY;
/**
* ID of the active pointer. This is used to retain consistency during
* drags/flings if multiple pointers are used.
*/
private int mActivePointerId = INVALID_POINTER;
/**
* Sentinel value for no current active pointer.
* Used by {@link #mActivePointerId}.
*/
private static final int INVALID_POINTER = -1;
/**
* Determines speed during touch scrolling
*/
private VelocityTracker mVelocityTracker;
private int mMinimumVelocity;
private int mMaximumVelocity;
private int mFlingDistance;
private int mCloseEnough;
// If the pager is at least this close to its final position, complete the scroll
// on touch down and let the user interact with the content inside instead of
// "catching" the flinging pager.
private static final int CLOSE_ENOUGH = 2; // dp
private boolean mFakeDragging;
private long mFa
没有合适的资源?快使用搜索试试~ 我知道了~
Android 主流侧滑菜单框架 源码
共297个文件
png:124个
class:87个
xml:35个
4星 · 超过85%的资源 需积分: 50 149 下载量 59 浏览量
2015-10-19
15:32:45
上传
评论
收藏 3.88MB RAR 举报
温馨提示
android市面主流侧滑框架,本架构主要实现侧滑出现底部view和首页实现tabhost效果,并且每一个fragment支持使用多个viewpager,很好的处理viewpager一次全部加载问题,可以根据viewpager出现的时候调用初始化页面,提高性能。这是一个不错的架构,欢迎android小伙伴们一起学习。 本项目主要底部TabFragment和左边侧滑DragLayout 以及CustomViewPager 实现,并且提供退出应用的一种关闭所有acitiviy的方式。
资源推荐
资源详情
资源评论
收起资源包目录
Android 主流侧滑菜单框架 源码 (297个子文件)
resources.ap_ 215KB
HomeActivity.apk 754KB
jarlist.cache 120B
CustomViewPager.class 50KB
TabFragment.class 15KB
TabPageIndicator.class 10KB
BadgeView.class 9KB
DragLayout.class 9KB
TabFragment$TabsAdapter.class 7KB
HomeActivity.class 7KB
R$color.class 6KB
MyRadioGroup.class 6KB
IconPageIndicator.class 5KB
IcsLinearLayout.class 5KB
HomeFragment.class 4KB
TabMode.class 4KB
CustomViewPager$MyAccessibilityDelegate.class 3KB
DragLayout$2.class 3KB
CustomViewPager$SavedState.class 3KB
R$drawable.class 3KB
MyRadioGroup$PassThroughHierarchyChangeListener.class 2KB
R$styleable.class 2KB
TabFragment$1.class 2KB
MyFragment.class 2KB
RecommendedFragment.class 2KB
MyRadioGroup$LayoutParams.class 2KB
DragLayout$1.class 2KB
PersonalLetterTabFragmentAdapter.class 2KB
TabFragment$2.class 2KB
TabPageIndicator$1.class 2KB
R$id.class 2KB
TabFragment$ZoomOutPageTransformer.class 2KB
MyRadioGroup$CheckedStateTracker.class 2KB
R$string.class 2KB
MyRelativeLayout.class 1KB
CustomViewPager$SavedState$1.class 1KB
ArticleFragment.class 1KB
TabPageIndicator$TabView.class 1KB
TabFragment$DepthPageTransformer.class 1KB
TabFragment$TabsAdapter$TabInfo.class 1KB
SearchFriendFragment.class 1KB
CustomViewPager$ViewPositionComparator.class 1KB
SpecialFragment.class 1KB
HomeActivity$5.class 1KB
R$attr.class 1KB
TabFragment$TabsAdapter$DummyTabFactory.class 1KB
CustomViewPager$LayoutParams.class 1KB
HomeFragment$1.class 1KB
DragLayout$Status.class 1KB
InfomationFragment.class 1KB
R$dimen.class 1KB
IconPageIndicator$1.class 1KB
CustomViewPager$1.class 1KB
TabPageIndicator$2.class 1KB
MyBitmapEntity.class 1KB
BaseActivity.class 1004B
TabFragment$1$1.class 989B
R$style.class 956B
CustomViewPager$SimpleOnPageChangeListener.class 945B
CustomViewPager$PagerObserver.class 939B
HomeActivity$2.class 930B
HomeActivity$6.class 920B
SoftApplication.class 889B
R.class 841B
HomeActivity$1.class 830B
HomeActivity$3.class 789B
HomeActivity$4.class 789B
R$layout.class 762B
CustomViewPager$3.class 761B
R$array.class 745B
MangerActivitys.class 727B
TabPageIndicator$NumView.class 714B
CustomViewPager$2.class 596B
PageIndicator.class 568B
CustomViewPager$ItemInfo.class 554B
Constant.class 420B
R$menu.class 382B
R$raw.class 379B
CustomViewPager$OnAdapterChangeListener.class 372B
CustomViewPager$OnPageChangeListener.class 358B
BuildConfig.class 341B
MyRadioGroup$OnCheckedChangeListener.class 327B
DragLayout$OnLayoutDragingListener.class 310B
TabPageIndicator$OnTabReselectedListener.class 303B
CustomViewPager$PageTransformer.class 297B
TabFragment$ITabOnDoubleClickListener.class 286B
TabFragment$IFocusChangeListener.class 277B
CustomViewPager$Decor.class 227B
IconPagerAdapter.class 195B
FragmentInterface.class 170B
.classpath 609B
classes.dex 2.1MB
android-support-v4.jar 1.13MB
android-support-v4-02d8fb3e981d565353ec05b7d6ba74ea.jar 400KB
android-support-v4-9b454539cb92e4732c713bdb5429b2ef.jar 400KB
android_api_3.7.0.jar 111KB
nineoldandroids-2.4.0.jar 108KB
android_api_3.7.0-4916f4f6b15b30123a059dc2e7406ab1.jar 57KB
android_api_3.7.0-6a50b905a28cf028c988ea8feac49730.jar 57KB
nineoldandroids-2.4.0-10a8174d841489ccee1e8183fbff30e0.jar 45KB
共 297 条
- 1
- 2
- 3
资源评论
- yaomingbo2016-12-28为什么 我的下载下来用不了啊
- xiaoxiao_892015-10-30为什么 我的下载下来用不了啊
- mylihaihui2017-11-20这个都是 ecplise 的项目 现在都基本没人用了,博主以后更新可能Android studio 方便一些
LeBron_Six
- 粉丝: 802
- 资源: 208
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功