/*
* 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 android.support.v7.widget;
import android.content.Context;
import android.database.Observable;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v4.os.TraceCompat;
import android.support.v4.util.ArrayMap;
import android.support.v4.view.InputDeviceCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ScrollingView;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewConfigurationCompat;
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.support.v4.widget.ScrollerCompat;
import static android.support.v7.widget.AdapterHelper.UpdateOp;
import static android.support.v7.widget.AdapterHelper.Callback;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.TypedValue;
import android.view.FocusFinder;
import android.view.MotionEvent;
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.accessibility.AccessibilityManager;
import android.view.animation.Interpolator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* A flexible view for providing a limited window into a large data set.
*
* <h3>Glossary of terms:</h3>
*
* <ul>
* <li><em>Adapter:</em> A subclass of {@link Adapter} responsible for providing views
* that represent items in a data set.</li>
* <li><em>Position:</em> The position of a data item within an <em>Adapter</em>.</li>
* <li><em>Index:</em> The index of an attached child view as used in a call to
* {@link ViewGroup#getChildAt}. Contrast with <em>Position.</em></li>
* <li><em>Binding:</em> The process of preparing a child view to display data corresponding
* to a <em>position</em> within the adapter.</li>
* <li><em>Recycle (view):</em> A view previously used to display data for a specific adapter
* position may be placed in a cache for later reuse to display the same type of data again
* later. This can drastically improve performance by skipping initial layout inflation
* or construction.</li>
* <li><em>Scrap (view):</em> A child view that has entered into a temporarily detached
* state during layout. Scrap views may be reused without becoming fully detached
* from the parent RecyclerView, either unmodified if no rebinding is required or modified
* by the adapter if the view was considered <em>dirty</em>.</li>
* <li><em>Dirty (view):</em> A child view that must be rebound by the adapter before
* being displayed.</li>
* </ul>
*
* <h4>Positions in RecyclerView:</h4>
* <p>
* RecyclerView introduces an additional level of abstraction between the {@link Adapter} and
* {@link LayoutManager} to be able to detect data set changes in batches during a layout
* calculation. This saves LayoutManager from tracking adapter changes to calculate animations.
* It also helps with performance because all view bindings happen at the same time and unnecessary
* bindings are avoided.
* <p>
* For this reason, there are two types of <code>position</code> related methods in RecyclerView:
* <ul>
* <li>layout position: Position of an item in the latest layout calculation. This is the
* position from the LayoutManager's perspective.</li>
* <li>adapter position: Position of an item in the adapter. This is the position from
* the Adapter's perspective.</li>
* </ul>
* <p>
* These two positions are the same except the time between dispatching <code>adapter.notify*
* </code> events and calculating the updated layout.
* <p>
* Methods that return or receive <code>*LayoutPosition*</code> use position as of the latest
* layout calculation (e.g. {@link ViewHolder#getLayoutPosition()},
* {@link #findViewHolderForLayoutPosition(int)}). These positions include all changes until the
* last layout calculation. You can rely on these positions to be consistent with what user is
* currently seeing on the screen. For example, if you have a list of items on the screen and user
* asks for the 5<sup>th</sup> element, you should use these methods as they'll match what user
* is seeing.
* <p>
* The other set of position related methods are in the form of
* <code>*AdapterPosition*</code>. (e.g. {@link ViewHolder#getAdapterPosition()},
* {@link #findViewHolderForAdapterPosition(int)}) You should use these methods when you need to
* work with up-to-date adapter positions even if they may not have been reflected to layout yet.
* For example, if you want to access the item in the adapter on a ViewHolder click, you should use
* {@link ViewHolder#getAdapterPosition()}. Beware that these methods may not be able to calculate
* adapter positions if {@link Adapter#notifyDataSetChanged()} has been called and new layout has
* not yet been calculated. For this reasons, you should carefully handle {@link #NO_POSITION} or
* <code>null</code> results from these methods.
* <p>
* When writing a {@link LayoutManager} you almost always want to use layout positions whereas when
* writing an {@link Adapter}, you probably want to use adapter positions.
*/
public class RecyclerView extends ViewGroup implements ScrollingView {
private static final String TAG = "RecyclerView";
private static final boolean DEBUG = false;
/**
* On Kitkat and JB MR2, there is a bug which prevents DisplayList from being invalidated if
* a View is two levels deep(wrt to ViewHolder.itemView). DisplayList can be invalidated by
* setting View's visibility to INVISIBLE when View is detached. On Kitkat and JB MR2, Recycler
* recursively traverses itemView and invalidates display list for each ViewGroup that matches
* this criteria.
*/
private static final boolean FORCE_INVALIDATE_DISPLAY_LIST = Build.VERSION.SDK_INT == 18
|| Build.VERSION.SDK_INT == 19 || Build.VERSION.SDK_INT == 20;
private static final boolean DISPATCH_TEMP_DETACH = false;
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
public static final int NO_POSITION = -1;
public static final long NO_ID = -1;
public static final int INVALID_TYPE = -1;
/**
* Constant for use with {@link #setScrollingTouchSlop(int)}. Indicates
* that the RecyclerView should use the standard touch slop for smooth,
* continuous scrolling.
*/
public static final int TOUCH_SLOP_DEFAULT = 0;
/**
* Constant for use with {@link #setScrollingTouchSlop(int)}. Indicates
* that the RecyclerView should use the standard touch slop for scrolling
* widgets that snap to a page or other coarse-grained barrier.
*/
public stat
没有合适的资源?快使用搜索试试~ 我知道了~
RecyclerView实现关于listview,Gridview,水平Gridview和瀑布流功能
共1443个文件
class:997个
java:370个
aidl:24个
需积分: 10 13 下载量 106 浏览量
2016-05-25
14:24:16
上传
评论
收藏 3.23MB RAR 举报
温馨提示
用Android5.0新控件RecyclerView实现替代listview,Gridview ,水平Gridview和瀑布流功能,功能实现简单,易用.
资源推荐
资源详情
资源评论
收起资源包目录
RecyclerView实现关于listview,Gridview,水平Gridview和瀑布流功能 (1443个子文件)
IMediaSession.aidl 3KB
IMediaSession.aidl 3KB
IMediaSession.aidl 3KB
IMediaControllerCallback.aidl 2KB
IMediaControllerCallback.aidl 2KB
IMediaControllerCallback.aidl 2KB
INotificationSideChannel.aidl 1KB
INotificationSideChannel.aidl 1KB
INotificationSideChannel.aidl 1KB
MediaSessionCompat.aidl 787B
MediaSessionCompat.aidl 787B
MediaSessionCompat.aidl 787B
ParcelableVolumeInfo.aidl 689B
ParcelableVolumeInfo.aidl 689B
ParcelableVolumeInfo.aidl 689B
PlaybackStateCompat.aidl 688B
PlaybackStateCompat.aidl 688B
PlaybackStateCompat.aidl 688B
MediaMetadataCompat.aidl 680B
MediaMetadataCompat.aidl 680B
MediaMetadataCompat.aidl 680B
RatingCompat.aidl 673B
RatingCompat.aidl 673B
RatingCompat.aidl 673B
resources.ap_ 44KB
TestRecyclerView.apk 531KB
RecyclerView.class 65KB
ViewPager.class 49KB
FragmentManagerImpl.class 43KB
StaggeredGridLayoutManager.class 40KB
BackStackRecord.class 34KB
NestedScrollView.class 31KB
LinearLayoutManager.class 31KB
RecyclerView$LayoutManager.class 31KB
DrawerLayout.class 28KB
Fragment.class 27KB
SlidingPaneLayout.class 27KB
ViewDragHelper.class 21KB
RecyclerView$Recycler.class 20KB
SwipeRefreshLayout.class 20KB
AccessibilityNodeInfoCompat.class 19KB
MediaSessionCompat$MediaSessionImplBase.class 19KB
FragmentActivity.class 18KB
GridLayoutManager.class 18KB
ViewCompat.class 16KB
ViewCompat$BaseViewCompatImpl.class 16KB
DefaultItemAnimator.class 15KB
NotificationCompatJellybean.class 14KB
IMediaSession$Stub$Proxy.class 13KB
PagerTitleStrip.class 12KB
MediaMetadataCompat.class 12KB
NotificationCompat$WearableExtender.class 11KB
FragmentTransitionCompat21.class 11KB
AdapterHelper.class 11KB
AccessibilityNodeInfoCompat$AccessibilityNodeInfoStubImpl.class 11KB
ExploreByTouchHelper.class 11KB
NotificationManagerCompat$SideChannelManager.class 11KB
NotificationCompat$Builder.class 11KB
LoaderManagerImpl.class 10KB
NotificationCompat.class 10KB
GestureDetectorCompat$GestureDetectorCompatImplBase.class 10KB
MaterialProgressDrawable.class 9KB
AutoScrollHelper.class 9KB
IMediaSession$Stub.class 9KB
ViewPropertyAnimatorCompat.class 9KB
MediaSessionCompat$MediaSessionImplBase$MediaSessionStub.class 9KB
SimpleArrayMap.class 9KB
FileProvider.class 9KB
FragmentTabHost.class 9KB
RecyclerView$ViewFlinger.class 9KB
LoaderManagerImpl$LoaderInfo.class 8KB
MediaControllerCompat$MediaControllerImplBase.class 8KB
ModernAsyncTask.class 8KB
AccessibilityRecordCompat.class 8KB
RecyclerView$ViewHolder.class 8KB
PrintHelperKitkat.class 8KB
DialogFragment.class 8KB
LocalBroadcastManager.class 8KB
MediaSessionCompat.class 8KB
ActionBarDrawerToggle.class 8KB
StaggeredGridLayoutManager$Span.class 8KB
ViewPropertyAnimatorCompat$BaseViewPropertyAnimatorCompatImpl.class 8KB
NotificationCompatKitKat$Builder.class 7KB
MaterialProgressDrawable$Ring.class 7KB
ShareCompat$IntentBuilder.class 7KB
MediaControllerCompat$MediaControllerImplApi21.class 7KB
PositionMap.class 7KB
LinearSmoothScroller.class 7KB
PrintHelperKitkat$2.class 7KB
TransportMediatorJellybeanMR2.class 7KB
ListFragment.class 7KB
TransportMediator.class 7KB
SortedList.class 7KB
NotificationCompatJellybean$Builder.class 7KB
CursorAdapter.class 7KB
NotificationCompatApi21.class 7KB
PagerTabStrip.class 7KB
NotificationCompatApi21$Builder.class 7KB
TaskStackBuilder.class 7KB
PlaybackStateCompat.class 7KB
共 1443 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
qq_35111473
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功