Showing preview only (858K chars total). Download the full file or copy to clipboard to get everything.
Repository: alibaba/vlayout
Branch: master
Commit: 00d6be0a1fa8
Files: 87
Total size: 818.4 KB
Directory structure:
gitextract_l0k2lwjr/
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README-ch.md
├── README.md
├── build.gradle
├── docs/
│ ├── ATTRIBUTES-ch.md
│ ├── ATTRIBUTES.md
│ └── VLayoutFAQ.md
├── examples/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── alibaba/
│ │ └── android/
│ │ └── vlayout/
│ │ └── ApplicationTest.java
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── alibaba/
│ │ └── android/
│ │ └── vlayout/
│ │ └── example/
│ │ ├── DebugActivity.java
│ │ ├── MainActivity.java
│ │ ├── OnePlusNLayoutActivity.java
│ │ ├── RootActivity.java
│ │ ├── TestActivity.java
│ │ └── VLayoutActivity.java
│ └── res/
│ ├── drawable/
│ │ ├── border_bg.xml
│ │ └── item_background.xml
│ ├── layout/
│ │ ├── card_item.xml
│ │ ├── item.xml
│ │ ├── main_activity.xml
│ │ └── view_pager.xml
│ └── values/
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── jcenterDeploy.gradle
├── jcenterInstall.gradle
├── settings.gradle
└── vlayout/
├── .gitignore
├── DESIGN.md
├── build.gradle
├── jacoco.gradle
├── proguard-rules.pro
└── src/
├── androidTest/
│ └── java/
│ └── com/
│ └── alibaba/
│ └── android/
│ └── vlayout/
│ ├── ViewHolderHelper.java
│ └── VirtualLayoutManagerTest.java
└── main/
├── AndroidManifest.xml
├── java/
│ └── com/
│ └── alibaba/
│ └── android/
│ └── vlayout/
│ ├── Cantor.java
│ ├── DelegateAdapter.java
│ ├── ExposeLinearLayoutManagerEx.java
│ ├── LayoutHelper.java
│ ├── LayoutHelperFinder.java
│ ├── LayoutManagerHelper.java
│ ├── LayoutView.java
│ ├── LayoutViewFactory.java
│ ├── MismatchChildCountException.java
│ ├── OrientationHelperEx.java
│ ├── Range.java
│ ├── RangeLayoutHelperFinder.java
│ ├── RecyclablePagerAdapter.java
│ ├── SortedList.java
│ ├── VirtualLayoutAdapter.java
│ ├── VirtualLayoutManager.java
│ ├── extend/
│ │ ├── InnerRecycledViewPool.java
│ │ ├── LayoutManagerCanScrollListener.java
│ │ ├── PerformanceMonitor.java
│ │ ├── ViewLifeCycleHelper.java
│ │ └── ViewLifeCycleListener.java
│ └── layout/
│ ├── AbstractFullFillLayoutHelper.java
│ ├── BaseLayoutHelper.java
│ ├── ColumnLayoutHelper.java
│ ├── DefaultLayoutHelper.java
│ ├── FixAreaAdjuster.java
│ ├── FixAreaLayoutHelper.java
│ ├── FixLayoutHelper.java
│ ├── FloatLayoutHelper.java
│ ├── GridLayoutHelper.java
│ ├── LayoutChunkResult.java
│ ├── LinearLayoutHelper.java
│ ├── MarginLayoutHelper.java
│ ├── OnePlusNLayoutHelper.java
│ ├── OnePlusNLayoutHelperEx.java
│ ├── RangeGridLayoutHelper.java
│ ├── RangeStyle.java
│ ├── ScrollFixLayoutHelper.java
│ ├── SingleLayoutHelper.java
│ ├── StaggeredGridLayoutHelper.java
│ └── StickyLayoutHelper.java
└── res/
└── values/
└── ids.xml
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
.classpath
.project
.settings/
# Proguard folder generated by Eclipse
proguard/
#Log Files
*.log
# OS X
.DS_Store
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.ear
*.iml
# IDEA Files
.idea/
out/
# MAVEN COMPILE Files
target/
lint.xml
deploy.gradle
#jcenterDeploy.gradle
#jcenterInstall.gradle
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing Guide
Thank you for your attention to this project. Any bug, doc, examples and suggestion is appreciated. Here are some suggestions for you to create Pull Requests or open Issues.
## Branch Management
```
master
↑
develop <--- PR(bugfix/typo/3rd-PR)
↑ PR
{type}/{description}
```
Branches
* `master` branch
* `master` is the latest (pre-)release branch.
* `develop` branch
* `develop` is the stable developing branch. [Github Release](https://help.github.com/articles/creating-releases/) is used to publish a (pre-)release version to `master` branch.
* ***It's RECOMMENDED to commit bugfix or feature PR to `develop`***.
* `{action}/{description}` branch
* The branch for a developing or bugfix
*. **DO NOT commit any PR to such a branch**.
## Branch Name
```
{action}/{description}
```
* `{action}`:
* `feature`: used for developing a new feature.
* `bugfix`: used for fixing bugs.
* for example: `feature/add_flex_layouthelper`
## Commit Log
```
{action} {description}
```
* `{action}`
* `add`
* `update` or `bugfix`
* `remove`
* ...
* `{description}`
* It's ***RECOMMENDED*** to close issue with syntax `#123`, see [the doc](https://help.github.com/articles/closing-issues-via-commit-messages/) for more detail. It's useful for responding issues and release flow.
for example:
* `add new layout helper`
* `fix #123, make compatible to recyclervew 25.2.0`
* `remove abc`
## Issue
* Please apply a proper label to an issue.
* Suggested to use English.
* Provide sufficient instructions to be able to reproduce the issue and make the issues clear. Such as phone model, system version, sdk version, crash logs and screen captures.
## Pull Request And Contributor License Agreement
[Create Pull Requests](https://github.com/alibaba/vlayout/compare) here.
In order to contribute code to vlayout, you (or the legal entity you represent) must sign the Contributor License Agreement (CLA).
You can read and sign the [Alibaba CLA](https://cla-assistant.io/alibaba/vlayout) online.
For CLA assistant service works properly, please make sure you have added email address that your commits linked to GitHub account.
## Code Style Guide
### Java & Android
* Use [Google Java Style](https://google.github.io/styleguide/javaguide.html) as basic guidelines of java code.
* Follow [AOSP Code Style](https://source.android.com/source/code-style.html) for rest of android related code style.
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2016 Alibaba Group
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README-ch.md
================================================
# 注意,该项目停止维护!!!
# vlayout
[English Document](README.md)
## Tangram 相关开源库
### Android
+ [Tangram-Android](https://github.com/alibaba/Tangram-Android)
+ [Virtualview-Android](https://github.com/alibaba/Virtualview-Android)
+ [vlayout](https://github.com/alibaba/vlayout)
+ [UltraViewPager](https://github.com/alibaba/UltraViewPager)
### iOS
+ [Tangram-iOS](https://github.com/alibaba/Tangram-iOS)
+ [Virtualview-iOS](https://github.com/alibaba/VirtualView-iOS)
+ [LazyScrollView](https://github.com/alibaba/lazyscrollview)
VirtualLayout是一个针对RecyclerView的LayoutManager扩展, 主要提供一整套布局方案和布局间的组件复用的问题。
## 设计思路
通过定制化的LayoutManager,接管整个RecyclerView的布局逻辑;LayoutManager管理了一系列LayoutHelper,LayoutHelper负责具体布局逻辑实现的地方;每一个LayoutHelper负责页面某一个范围内的组件布局;不同的LayoutHelper可以做不同的布局逻辑,因此可以在一个RecyclerView页面里提供异构的布局结构,这就能比系统自带的LinearLayoutManager、GridLayoutManager等提供更加丰富的能力。同时支持扩展LayoutHelper来提供更多的布局能力。
## 主要功能
* 默认通用布局实现,解耦所有的View和布局之间的关系: Linear, Grid, 吸顶, 浮动, 固定位置等。
* LinearLayoutHelper: 线性布局
* GridLayoutHelper: Grid布局, 支持横向的colspan
* FixLayoutHelper: 固定布局,始终在屏幕固定位置显示
* ScrollFixLayoutHelper: 固定布局,但之后当页面滑动到该图片区域才显示, 可以用来做返回顶部或其他书签等
* FloatLayoutHelper: 浮动布局,可以固定显示在屏幕上,但用户可以拖拽其位置
* ColumnLayoutHelper: 栏格布局,都布局在一排,可以配置不同列之间的宽度比值
* SingleLayoutHelper: 通栏布局,只会显示一个组件View
* OnePlusNLayoutHelper: 一拖N布局,可以配置1-5个子元素
* StickyLayoutHelper: stikcy布局, 可以配置吸顶或者吸底
* StaggeredGridLayoutHelper: 瀑布流布局,可配置间隔高度/宽度
* 上述默认实现里可以大致分为两类:一是非fix类型布局,像线性、Grid、栏格等,它们的特点是布局在整个页面流里,随页面滚动而滚动;另一类就是fix类型的布局,它们的子节点往往不随页面滚动而滚动。
* 所有除布局外的组件复用,VirtualLayout将用来管理大的模块布局组合,扩展了RecyclerView,使得同一RecyclerView内的组件可以复用,减少View的创建和销毁过程。
## 使用
**虽然 vlayout 布局灵活,然而 API 相对原始,手工维护数据及 LayoutHelper 比较麻烦,强烈建议大家使用 [Tangram-Android](https://github.com/alibaba/Tangram-Android) 来间接使用 vlayout,Tangram 具备 vlayout 里所有的功能,且隐藏了细节,通过数据配置即可搭建页面,能避免绝大多数 Issue 里提到的问题,而且重大更新维护主要基于 Tangram,包括局部刷新、响应式接口等。**
版本请参考 [release 说明](https://github.com/alibaba/vlayout/releases)里的最新版本,最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖:
``` gradle
compile ('com.alibaba.android:vlayout:1.2.8@aar') {
transitive = true
}
```
或者maven:
pom.xml
``` xml
<dependency>
<groupId>com.alibaba.android</groupId>
<artifactId>vlayout</artifactId>
<version>1.2.8</version>
<type>aar</type>
</dependency>
```
初始化```LayoutManager```
``` java
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
```
设置回收复用池大小,(如果一屏内相同类型的 View 个数比较多,需要设置一个合适的大小,防止来回滚动时重新创建 View):
``` java
RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
recyclerView.setRecycledViewPool(viewPool);
viewPool.setMaxRecycledViews(0, 10);
```
**注意:上述示例代码里只针对type=0的item设置了复用池的大小,如果你的页面有多种type,需要为每一种类型的分别调整复用池大小参数。**
加载数据时有两种方式:
* 一种是使用 ```DelegateAdapter```, 可以像平常一样写继承自```DelegateAdapter.Adapter```的Adapter, 只比之前的Adapter需要多重载```onCreateLayoutHelper```方法。
其他的和默认Adapter一样。
``` java
DelegateAdapter delegateAdapter = new DelegateAdapter(layoutManager, hasConsistItemType);
recycler.setAdapter(delegateAdapter);
// 之后可以通过 setAdapters 或 addAdapter方法添加DelegateAdapter.Adapter
delegateAdapter.setAdapters(adapters);
// or
CustomAdapter adapter = new CustomAdapter(data, new GridLayoutHelper());
delegateAdapter.addAdapter(adapter);
// 如果数据有变化,调用自定义 adapter 的 notifyDataSetChanged()
adapter.notifyDataSetChanged();
```
**注意:当hasConsistItemType=true的时候,不论是不是属于同一个子adapter,相同类型的item都能复用。表示它们共享一个类型。
当hasConsistItemType=false的时候,不同子adapter之间的类型不共享**
* 另一种是当业务有自定义的复杂需求的时候, 可以继承自```VirtualLayoutAdapter```, 实现自己的Adapter
``` java
public class MyAdapter extends VirtualLayoutAdapter {
......
}
MyAdapter myAdapter = new MyAdapter(layoutManager);
//构造 layoutHelper 列表
List<LayoutHelper> helpers = new LinkedList<>();
GridLayoutHelper gridLayoutHelper = new GridLayoutHelper(4);
gridLayoutHelper.setItemCount(25);
helpers.add(gridLayoutHelper);
GridLayoutHelper gridLayoutHelper2 = new GridLayoutHelper(2);
gridLayoutHelper2.setItemCount(25);
helpers.add(gridLayoutHelper2);
//将 layoutHelper 列表传递给 adapter
myAdapter.setLayoutHelpers(helpers);
//将 adapter 设置给 recyclerView
recycler.setAdapter(myAdapter);
```
在这种情况下,需要使用者注意在当```LayoutHelpers```的结构或者数据数量等会影响到布局的元素变化时,需要主动调用```setLayoutHelpers```去更新布局模式。
另外如果你的应用有混淆配置,请为vlayout添加一下防混淆配置:
```
-keepattributes InnerClasses
-keep class com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx { *; }
-keep class android.support.v7.widget.RecyclerView$LayoutParams { *; }
-keep class android.support.v7.widget.RecyclerView$ViewHolder { *; }
-keep class android.support.v7.widget.ChildHelper { *; }
-keep class android.support.v7.widget.ChildHelper$Bucket { *; }
-keep class android.support.v7.widget.RecyclerView$LayoutManager { *; }
```
# Demo

[Demo工程](https://github.com/alibaba/vlayout/tree/master/examples)
# FAQ
使用之前或者碰到问题的时候,建议先看看其他[FAQ](docs/VLayoutFAQ.md)。
# 布局属性
每一种layoutHelper都有自己的布局属性来控制布局样式,详情请参考[文档](docs/ATTRIBUTES-ch.md)。
# 贡献代码
在提 Issue 或者 PR 之前,建议先阅读[Contributing Guide](CONTRIBUTING.md)。按照规范提建议。
# 开源许可证
vlayout遵循MIT开源许可证协议。
================================================
FILE: README.md
================================================
# Attention. This project is not maintained any more !!!
# vlayout
[中文文档](README-ch.md)
## Projects of Tangram
### Android
+ [Tangram-Android](https://github.com/alibaba/Tangram-Android)
+ [Virtualview-Android](https://github.com/alibaba/Virtualview-Android)
+ [vlayout](https://github.com/alibaba/vlayout)
+ [UltraViewPager](https://github.com/alibaba/UltraViewPager)
### iOS
+ [Tangram-iOS](https://github.com/alibaba/Tangram-iOS)
+ [Virtualview-iOS](https://github.com/alibaba/VirtualView-iOS)
+ [LazyScrollView](https://github.com/alibaba/lazyscrollview)
Project `vlayout` is a powerful LayoutManager extension for RecyclerView, it provides a group of layouts for RecyclerView. Make it able to handle a complicate situation when grid, list and other layouts in the same recyclerview.
## Design
By providing a custom LayoutManager to RecyclerView, VirtualLayout is able to layout child views with different style at single view elegantly. The custom LayoutManager manages a serial of layoutHelpers where each one implements the specific layout logic for a certain position range items. By the way, implementing your custom layoutHelper and provding it to the framework is also supported.
## Main Feature
* Provide default common layout implementation, decouple the View and Layout. Default layout implementations are:
* LinearLayoutHelper: provide linear layout as LinearLayoutManager.
* GridLayoutHelper: provide grid layout as GridLayoutManager, but with more feature.
* FixLayoutHelper: fix the view at certain position of screen, the view does not scroll with whole page.
* ScrollFixLayoutHelper: fix the view at certain position of screen, but the view does not show until it scrolls to it position.
* FloatLayoutHelper: float the view on top of page, user can drag and drop it.
* ColumnLayoutHelper: perform like GridLayoutHelper but layouts all child views in one line.
* SingleLayoutHelper: contain only one child view.
* OnePlusNLayoutHelper: a custom layout with one child view layouted at left and the others at right, you may not need this.
* StickyLayoutHelper: scroll the view when its position is inside the screen, but fix the view at start or end when its position is outside the screen.
* StaggeredGridLayoutHelper: provide waterfall like layout as StaggeredGridLayoutManager.
* LayoutHelpers provided by default can be generally divided into two categories. One is non-fix LayoutHelper such as LinearLayoutHelper, GridLayoutHelper, etc which means the children of these LayoutHelper will be layouted in the flow of parent container and will be scrolled with the container scrolling. While the other is fix LayoutHelper which means the child of these is always fix in parent container.
## Usage
### Import Library
Please find the latest version in [release notes](https://github.com/alibaba/vlayout/releases). The newest version has been upload to jcenter and MavenCentral, make sure you have added at least one of these repositories. As follow:
For gradle:
``` gradle
compile ('com.alibaba.android:vlayout:1.2.8@aar') {
transitive = true
}
```
Or in maven:
pom.xml
``` xml
<dependency>
<groupId>com.alibaba.android</groupId>
<artifactId>vlayout</artifactId>
<version>1.2.8</version>
<type>aar</type>
</dependency>
```
### Initialize LayoutManager
``` java
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
```
### Initialize recycled pool's size
Provide a reasonable recycled pool's size to your recyclerView, since the default value may not meet your situation and cause re-create views when scrolling.
``` java
RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
recyclerView.setRecycledViewPool(viewPool);
viewPool.setMaxRecycledViews(0, 10);
```
**Attention: the demo code above only modify the recycle pool size of item with type = 0, it you has more than one type in your adapter, you should update recycle pool size for each type.**
### Set Adapters
* You can use `DelegateAdapter` for as a root adapter to make combination of your own adapters. Just make it extend ```DelegateAdapter.Adapter``` and overrides ```onCreateLayoutHelper``` method.
``` java
DelegateAdapter delegateAdapter = new DelegateAdapter(layoutManager, hasConsistItemType);
recycler.setAdapter(delegateAdapter);
// Then you can set sub- adapters
delegateAdapter.setAdapters(adapters);
// or
CustomAdapter adapter = new CustomAdapter(data, new GridLayoutHelper());
delegateAdapter.addAdapter(adapter);
// call notify change when data changes
adapter.notifyDataSetChanged();
```
**Attention: When `hasConsistItemType = true`, items with same type value in different sub-adapters share the same type, their view would be reused during scroll. When `hasConsistItemType = false`, items with same type value in different sub-adapters do not share the same type internally.**
* The other way to set adapter is extending ```VirtualLayoutAdapter``` and implementing it to make deep combination to your business code.
``` java
public class MyAdapter extends VirtualLayoutAdapter {
......
}
MyAdapter myAdapter = new MyAdapter(layoutManager);
//create layoutHelper list
List<LayoutHelper> helpers = new LinkedList<>();
GridLayoutHelper gridLayoutHelper = new GridLayoutHelper(4);
gridLayoutHelper.setItemCount(25);
helpers.add(gridLayoutHelper);
GridLayoutHelper gridLayoutHelper2 = new GridLayoutHelper(2);
gridLayoutHelper2.setItemCount(25);
helpers.add(gridLayoutHelper2);
//set layoutHelper list to adapter
myAdapter.setLayoutHelpers(helpers);
//set adapter to recyclerView
recycler.setAdapter(myAdapter);
```
In this way, one thing you should note is that you should call ```setLayoutHelpers``` when the data of Adapter changes.
### Config proguard
Add following configs in your proguard file if your app is released with proguard.
```
-keepattributes InnerClasses
-keep class com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx { *; }
-keep class android.support.v7.widget.RecyclerView$LayoutParams { *; }
-keep class android.support.v7.widget.RecyclerView$ViewHolder { *; }
-keep class android.support.v7.widget.ChildHelper { *; }
-keep class android.support.v7.widget.ChildHelper$Bucket { *; }
-keep class android.support.v7.widget.RecyclerView$LayoutManager { *; }
```
# Demo

[Demo Project](https://github.com/alibaba/vlayout/tree/master/examples)
# FAQ
Read FAQ(In Chinese language only now) before submitting issue: [FAQ](docs/VLayoutFAQ.md)。
# Layout Attributes
Each layoutHelper has a few attributes to control its layout style. See [this](docs/ATTRIBUTES.md) to read more.
# Contributing
Before you open an issue or create a pull request, please read [Contributing Guide](CONTRIBUTING.md) first.
# LICENSE
Vlayout is available under the MIT license.
================================================
FILE: build.gradle
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://oss.jfrog.org/oss-snapshot-local/" }
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.github.xfumihiro.view-inspector:view-inspector-plugin:0.1.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
allprojects {
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://oss.jfrog.org/oss-snapshot-local/" }
jcenter()
mavenLocal()
}
}
================================================
FILE: docs/ATTRIBUTES-ch.md
================================================
为了提供丰富的布局能力,我们为`LayoutHelper`设计了一系列布局属性,用来控制布局逻辑和样式。这里介绍这些属性的概念和用法。
[Englist Document](ATTRIBUTES.md)
# margin, padding
Margin, padding就是外边距、内边距,概念与Android系统的margin, padding一样,但也有不同的地方:
+ 它不是整个`RecyclerView`页面的margin和padding,它是每一块`LayoutHelper`所负责的区域的margin和padding。
+ 一个页面里可以有多个`LayoutHelper`,意味着不同`LayoutHelper`可以设置不同的margin和padding。
+ `LayoutHelper`的margin和padding与页面`RecyclerView`的margin和padding可以共存。
+ 目前主要针对非fix类型的`LayoutHelper`实现了margin和padding,fix类型`LayoutHelper`内部没有相对位置关系,不处理边距。

### 接口
对于`LayoutHelper`,调用
`public void setPadding(int leftPadding, int topPadding, int rightPadding, int bottomPadding)`
`public void setMargin(int leftMargin, int topMargin, int rightMargin, int bottomMargin)`
# bgColor, bgImg
背景颜色或者背景图,这其实不是布局属性,但是由于在vlayout对视图进行了直接布局,不同区域的视图的父节点都是`RecyclerView`,如果想要针对某一块区域单独绘制背景,就很难做到了。vlayout框架对此做了特殊处理,对于非fix、非float类型的`LayoutHelper`,支持配置背景色或背景图。同样目前主要针对非fix类型的`LayoutHelper`实现这个特性。

### 接口
使用背景色
`public void setBgColor(int bgColor)`
使用背景图
首先为`LayoutManager`提供一个`ImageView`简单工厂
```
this.mLayoutManager.setLayoutViewFactory(new LayoutViewFactory() {
@Override
public opinion generateLayoutView(@NonNull Context context) {
return new XXImageView(context);
}
});
```
再为`LayoutHelper`提设置图片加载的`Listener`
```
baseHelper.setLayoutViewBindListener(new BindListener(imgUrl));
baseHelper.setLayoutViewUnBindListener(new UnbindListener(imgUrl));
private static class BindListener implements BaseLayoutHelper.LayoutViewBindListener {
private String imgUrl;
public BindListener(String imgUrl) {
this.imgUrl = imgUrl;
}
@Override
public void onBind(View layoutView, BaseLayoutHelper baseLayoutHelper) {
//loading image
}
}
private static class UnbindListener implements BaseLayoutHelper.LayoutViewUnBindListener {
private String imgUrl;
public UnbindListener(String imgUrl) {
this. imgUrl = imgUrl;
}
@Override
public void onUnbind(View layoutView, BaseLayoutHelper baseLayoutHelper) {
//cancel loading image
}
}
```
# aspectRatio
为了保证布局过程中视图的高度一致,我们设计了aspectRatio属性,它是宽与高的比例,`LayoutHelper`里有aspectRatio属性,通过vlayout添加的视图的`LayoutParams`也有aspectRatio属性,后者的优先级比前者高,但含义不一样。
+ `LayoutHelper`定义的aspectRatio,指的是一行视图整体的宽度与高度之比,当然整体的宽度是减去了`RecyclerView和`对应的`LayoutHelper`的margin, padding。
+ 视图的`LayoutParams`定义的aspectRatio,指的是在`LayoutHelper`计算出视图宽度之后,用来确定视图高度时使用的,它会覆盖通过`LayoutHelper`的aspectRatio计算出来的视图高度,因此具备更高优先级。

### 接口
对于`LayoutHelper`,调用
`public void setAspectRatio(float aspectRatio)`
对于`LayoutParams`,调用
`((VirutalLayoutManager.LayoutParams) layoutParams).mAspectRatio`
# dividerHeight
`LinearLayoutHelper`的属性,`LinearLayoutHelper`是像`ListView`一样的线性布局,dividerHeight就是每个组件之间的间距。

### 接口
对于`LinearLayoutHelper`,调用
`public void setDividerHeight(int dividerHeight)`
# weights
`ColumnLayoutHelper`, `GridLayoutHelper`的属性,它们都是提供网格状的布局能力,**建议使用`GridLayoutHelper`**,它的能力更加强大,参考下文介绍。默认情况下,每个网格中每一列的宽度是一样的,通过weights属性,可以指定让每一列的宽度成比例分配,就像`LinearLayout`的weight属性一样。
weights属性是一个float数组,每一项代表某一列占父容器宽度的百分比,总和建议是100,否则布局会超出容器宽度;如果布局中有4列,那么weights的长度也应该是4;长度大于4,多出的部分不参与宽度计算;如果小于4,不足的部分默认平分剩余的空间。

### 接口
对于`ColumnLayoutHelper`, `GridLayoutHelper`,调用
`public void setWeights(float[] weights)`
# vGap, hGap
`GridLayoutHelper`与`StaggeredGridLayoutHelper`都有这两个属性,分别控制视图之间的垂直间距和水平间距。

### 接口
对于`GridLayoutHelper`, `StaggeredGridLayoutHelper`,调用
`public void setHGap(int hGap)`
`public void setVGap(int vGap)`
# spanCount, spanSizeLookup
`GridLayoutHelper`的属性,参考于系统的`GridLayoutManager`,spanCount表示网格的列数,默认情况下每一个视图都占用一个网格区域,但通过提供自定义的spanSizeLookUp,可以指定某个位置的视图占用多个网格区域。

### 接口
使用spanCount调用
`public void setSpanCount(int spanCount)`
使用spanSizeLookup
`public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup)`
# autoExpand
`GridLayoutHelper`的属性,当一行里视图的个数少于spanCount值的时候,如果autoExpand为true,视图的总宽度会填满可用区域;否则会在屏幕上留空白区域。

### 接口
调用
`public void setAutoExpand(boolean isAutoExpand)`
# lane
`StaggeredGridLayoutHelper`中有这个属性,与`GridLayoutHelper`里的spanCount类似,控制瀑布流的列数。
### 接口
调用
`public void setLane(int lane)`
# fixAreaAdjuster
fix类型的`LayoutHelper`,在可能需要设置一个相对父容器四个边的偏移量,比如整个页面里有一个固定的标题栏添加在vlayout容器上,vlayout内部的fix类型视图不希望与外部的标题有所重叠,那么就可以设置一个fixAreaAdjuster来做偏移。

### 接口
调用
`public void setAdjuster(FixAreaAdjuster adjuster)`
# alignType, x, y
`FixLayoutHelper`, `ScrollFixLayoutHelper`, `FloatLayoutHelper`的属性,表示吸边时的基准位置,有四个取值,分别是`TOP_LEFT`, `TOP_RIGHT`, `BOTTOM_LEFT`, `BOTTOM_RIGHT`。`x`和`y`是相对这四个位置的偏移量,最终的偏移量还要受上述的fixAreaAdjuster影响。
+ `TOP_LEFT`:基准位置是左上角,`x`是视图左边相对父容器的左边距偏移量,`y`是视图顶边相对父容器的上边距偏移量;
+ `TOP_RIGHT`:基准位置是右上角,`x`是视图右边相对父容器的右边距偏移量,`y`是视图顶边相对父容器的上边距偏移量;
+ `BOTTOM_LEFT`:基准位置是左下角,`x`是视图左边相对父容器的左边距偏移量,`y`是视图底边相对父容器的下边距偏移量;
+ `BOTTOM_RIGHT`:基准位置是右下角,`x`是视图右边相对父容器的右边距偏移量,`y`是视图底边相对父容器的下边距偏移量;

### 接口
设置基准调用
`public void setAlignType(int alignType)`
设置偏移量调用
`public void setX(int x)`
`public void setY(int y)`
# showType
`ScrollFixLayoutHelper`的属性,取值有`SHOW_ALWAYS`, `SHOW_ON_ENTER`, `SHOW_ON_LEAVE`。
+ `SHOW_ALWAYS`:与`FixLayoutHelper`的行为一致,固定在某个位置;
+ `SHOW_ON_ENTER`:默认不显示视图,当页面滚动到这个视图的位置的时候,才显示;
+ `SHOW_ON_LEAVE`:默认不显示视图,当页面滚出这个视图的位置的时候显示;

调用
`public void setShowType(int showType)`
# stickyStart, offset
`StickyLayoutHelper`的属性,当视图的位置在屏幕范围内时,视图会随页面滚动而滚动;当视图的位置滑出屏幕时,`StickyLayoutHelper`会将视图固定在顶部(`stickyStart = true`)或者底部(`stickyStart = false`),固定的位置支持设置偏移量offset。

调用
`public void setStickyStart(boolean stickyStart)`
`public void setOffset(int offset)`
================================================
FILE: docs/ATTRIBUTES.md
================================================
Vlayout provides rich layout features, which are presented in the form of a serial of layout attributes technically. Here we introduce these attributes.
[中文文档](ATTRIBUTES-ch.md)
# margin, padding
Margin, padding have the similar concepts as normal Android system's margin and padding. There are several difference you should know:
+ Here we say margin and padding, specifically mean ```LayoutHelper```'s margin and padding, not the ```RecyclerView```'s.
+ A ```RecyclerView``` could contains more than one layoutHelpers, which means each ```LayoutHelper``` is able to host its own margin and padding value.
+ ```LayoutHelper```'s margin and padding can coexist with ```RecyclerView```'s margin and padding.
+ Margin and padding is mainly supported by non-fix LayoutHelper.

### API
For ```LayoutHelper```,call
```public void setPadding(int leftPadding, int topPadding, int rightPadding, int bottomPadding)```
```public void setMargin(int leftMargin, int topMargin, int rightMargin, int bottomMargin)```
# bgColor, bgImg
Actually, background color or background image has nothing to do with layout logic. But in our framework, all child views has the same parent which is ```RecyclerView```. If you want to fill background to a certain area with a color or image, it's a hard job. Vlayout has done some effort to make it possible for non-fix ```LayoutHelper```, so it's explained here.

### API
Fill background with color, call
```public void setBgColor(int bgColor)```
Fill background with image,
First, provide a simple factory to produce ```ImageView``` to ```LayoutManager```,
```
this.mLayoutManager.setLayoutViewFactory(new LayoutViewFactory() {
@Override
public View generateLayoutView(@NonNull Context context) {
return new XXImageView(context);
}
});
```
Second, set image load listeners to ```LayoutHelper```,
```
baseHelper.setLayoutViewBindListener(new BindListener(imgUrl));
baseHelper.setLayoutViewUnBindListener(new UnbindListener(imgUrl));
private static class BindListener implements BaseLayoutHelper.LayoutViewBindListener {
private String imgUrl;
public BindListener(String imgUrl) {
this.imgUrl = imgUrl;
}
@Override
public void onBind(View layoutView, BaseLayoutHelper baseLayoutHelper) {
//loading image
}
}
private static class UnbindListener implements BaseLayoutHelper.LayoutViewUnBindListener {
private String imgUrl;
public UnbindListener(String imgUrl) {
this. imgUrl = imgUrl;
}
@Override
public void onUnbind(View layoutView, BaseLayoutHelper baseLayoutHelper) {
//cancel loading image
}
}
```
# aspectRatio
In order to uniform child view's height during layout, vlayout introduces aspectRatio. Generally the view's width is decided by ```LayoutHelper``` while its height is decided by the view itself, using aspectRatio allow ```LayoutHelper``` to decide view's height. Both ```LayoutHelper``` and ```LayoutParams``` of the view inside vlayout have this attribute. It generally means width/height ratio, but has slight difference in these two situations. The latter has a higher priority than the former.
+ The aspectRatio defined by ```LayoutHelper``` means the ratio of width of one entire row's view to height of this row's height. Here ```RecyclerView```'s margin padding and ```LayoutHelper```'s margin padding is not included in the width of entire row's view.
+ The aspectRatio defined in ```VirtualLayoutManager.LayoutParams``` means the ratio of width of this view to height of this view. The height calculated by this way will override ```LayoutHelper```'s calculation result, so it has higher priority.

### API
For ```LayoutHelper```, call
```public void setAspectRatio(float aspectRatio)```
For ```LayoutParams```, call
```((VirutalLayoutManager.LayoutParams) layoutParams).mAspectRatio```
# dividerHeight
```LinearLayoutHelper```'s attribute. ```LinearLayoutHelper``` performs like ```ListView```, so as you know, dividerHeight is the gap between items.

### API
For ```LinearLayoutHelper```, call
```public void setDividerHeight(int dividerHeight)```
# weights
```ColumnLayoutHelper``` and ```GridLayoutHelper```'s attribute, they both provide grid layout ability like ```GridLayoutManager```. **You are suggested to use ```GirdLayoutHelper```** since it is more powerful. By default, each column's width is equal and shares the available space. Setting weights allows each column's width occupies a certain percentage of available space. Just sounds like weight in ```LinearLayout```.
This attribute is a float array, each item in array means the percentage of a column width. The sum of item value in array is 100, otherwise child view may be layouted outside the box. If there are four columns in this layout, the suggested length of weights is four, too. If length of weights array is larger than 4, the extra weight provided is ignored. If length of weights array is less than 4, the remaining views with no weight assigned share the remaining available space.

### API
For ```ColumnLayoutHelper```, ```GridLayoutHelper```, call
```public void setWeights(float[] weights)```
# vGap, hGap
```GridLayoutHelper``` and ```StaggeredGridLayoutHelper```'s attribute, vGap defines the vertical gap between child views, hGap defines the horizontal gap between child views.

### API
For ```GridLayoutHelper```, ```StaggeredGridLayoutHelper```, call
```public void setHGap(int hGap)```
```public void setVGap(int vGap)```
# spanCount, spanSizeLookup
```GridLayoutHelper```'s attribute, concept borrowed from system's ```GridLayoutManager```. SpanCount specifies the column count, or grid count each line in other word. By default each item view in ```GridLayoutHelper``` occupies one grid, but with custom spanSizeLookup it allows one item view could occupy more than one grid space.

### API
Setting spanCount call
```public void setSpanCount(int spanCount)```
Setting spanSizeLookup call
```public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup)```
# autoExpand
```GridLayoutHelper```'s attribute. On the occasion of one line view's count is less than spanCount, if autoExpand is set to be true, these view will expand to fill all available space, otherwise they will leave some blank area.

### API
```public void setAutoExpand(boolean isAutoExpand)```
# lane
```StaggeredGridLayoutHelper```'s attribute, performs like spanCount in ```GridLayoutHelper```.
### API
```public void setLane(int lane)```
# fixAreaAdjuster
```LayoutHelper``` with fix behavior may need an offset to four edges of parent container. For example, an activity has a vlayout container with fullscreen size, there's an title bar on top of vlayout's container which is not part of vlayout. While a view inside vlayout wants to be fixed at top of vlayout, so it needs an offset to top edge to avoid overlapping with title bar outside.

### API
```public void setAdjuster(FixAreaAdjuster adjuster)```
# alignType, x, y
```FixLayoutHelper```, ```ScrollFixLayoutHelper```, ```FloatLayoutHelper```'s attributes, alignType defines the base position of fix area, there are four available values: ```TOP_LEFT```, ```TOP_RIGHT```, ```BOTTOM_LEFT```, ```BOTTOM_RIGHT```. ```x``` and ```y``` are the horizontal offset and vertical offset to this base position. The final offset is calculated with fixAreaAdjuster in addition as former mentioned.
+ ```TOP_LEFT```: base position is top left corner of parent container, ```x``` is the offset from child view's left edge to parent's left edge, ```y``` is the offset from child view's top edge to parent's top edge;
+ ```TOP_RIGHT```: base position is top right corner of parent container, ```x``` is the offset from child view's right edge to parent's right edge, ```y``` is the offset from child view's top edge to parent's top edge;
+ ```BOTTOM_LEFT```: base position is bottom left corner of parent container, ```x``` is the offset from child view's left edge to parent's left edge, ```y``` is the offset from child view's bottom edge to parent's bottom edge;
+ ```BOTTOM_RIGHT```: base position is bottom right corner of parent container, ```x``` is the offset from child view's right edge to parent's right edge, ```y``` is the offset from child view's bottom edge to parent's bottom edge;

### API
Setting alignType call
```public void setAlignType(int alignType)```
Setting offset call
```public void setX(int x)```
```public void setY(int y)```
# showType
```ScrollFixLayoutHelper```'s attribute, there are three available values: ```SHOW_ALWAYS```, ```SHOW_ON_ENTER```, ```SHOW_ON_LEAVE```.
+ ```SHOW_ALWAYS```: in this way, ```ScrollFixLayoutHelper``` performs the same as ```FixLayoutHelper```;
+ ```SHOW_ON_ENTER```: in this way, the child view in ```LayoutHelper``` does not show by default. It shows only when the page scroll to its position.
+ ```SHOW_ON_LEAVE```: in this way, the child view in ```LayoutHelper``` does not show by default, either. It shows only when the page scroll over its position.

### API
```public void setShowType(int showType)```
# stickyStart, offset
```StickyLayoutHelper```'s attribute, when child view's position is inside the screen visible area, the child view scrll with whole page; when child view position scrolls outside the screen, this ```LayoutHelper``` will fix the at top(```stickyStart = true```) or bottom(```stickyStart = false```). The fix position is also affected by offset value.

### API
```public void setStickyStart(boolean stickyStart)```
```public void setOffset(int offset)```
================================================
FILE: docs/VLayoutFAQ.md
================================================
# VLayout FAQ
## 组件复用的问题
比如碰到卡顿、类型转换异常等等,都有可能是复用的问题引起的。
在使用 `DelegateAdapter` 的时候,每一个 `LayoutHelper` 都对应于一个 `DelegateAdapter.Adapter`,一般情况下使用方只需要提供自定义的 `DelegateAdapter.Adapter`,然后按照正常的使用方式使用。
但这里有个问题,不同的 `DelegateAdapter.Adapter` 之间,他们的 itemType 是不是一样的?这里有一个选择:在 `DelegateAdapter` 的构造函数里有个 `hasConsistItemType` 参数(默认是 false ):
当 `hasConsistItemType=false` 的时候,即使不同 `DelegateAdapter.Adapter` 里返回的相同的 itemType,对于 `DelegateAdapter` 也会将它转换成不同的值,对于 `RecyclerView` 来说它们是不同的类型。
当 `hasConsistItemType=true` 的时候,不同的 `DelegateAdapter.Adapter` 之间返回相同的 itemType 的时候,他们之间是可以复用的。
因此如果没有处理好这一点,会导致 `ViewHolder` 的类型转换异常等 bug。有一篇更加详细的资料可参考:[PairFunction](http://pingguohe.net/2017/05/03/the-beauty-of-math-in-vlayout.html)
补充:后来发现一个 bug,当 `hasConsistItemType=false`,在同一位置数据变化,前后构造了不一样的 Adapter,它们返回的 itemType 一样,也会导致类型转换出错,详见:[#182](https://github.com/alibaba/vlayout/issues/182),目前采用人工保证返回不同的 itemType 来规避。
## 设置每种类型回收复用池的大小
在 README 里写了这么一段 demo:`viewPool.setMaxRecycledViews(0, 10);`,很多人误以为只要这么设置就可以了,实际上有多少种类型的 itemType,就得为它们分别设置复用池大小。比如:
```
viewPool = new RecyclerView.RecycledViewPool();
recyclerView.setRecycledViewPool(viewPool);
viewPool.setMaxRecycledViews(0, 5);
viewPool.setMaxRecycledViews(1, 5);
viewPool.setMaxRecycledViews(2, 5);
viewPool.setMaxRecycledViews(3, 10);
viewPool.setMaxRecycledViews(4, 10);
viewPool.setMaxRecycledViews(5, 10);
...
```
## 混淆问题
如果碰到release包(混淆过)无法正常运行,debug包(一般未混淆)可正常运行,检查一下混淆配置是否完整:
```
-keepattributes InnerClasses
-keep class com.alibaba.android.vlayout.ExposeLinearLayoutManagerEx { *; }
-keep class android.support.v7.widget.RecyclerView$LayoutParams { *; }
-keep class android.support.v7.widget.RecyclerView$ViewHolder { *; }
-keep class android.support.v7.widget.ChildHelper { *; }
-keep class android.support.v7.widget.ChildHelper$Bucket { *; }
-keep class android.support.v7.widget.RecyclerView$LayoutManager { *; }
```
## 下拉刷新和加载更多
VLayout 只负责布局,下拉刷新和加载更多需要业务方自己处理,当然可能存在和一些下拉刷新控件不兼容的 bug。
下拉刷新,有很多框架是通过判断 `RecyclerView` 的第一个 view 的 top 是否为 0 来触发下拉动作。VLayout 里在处理背景、悬浮态的时候加入了一些对 `LayoutManager` 不可见的 View,但又真实存在与 `RecyclerView` 的视图树里,建议使用 `layoutManager.getChildAt(0)` 来获取第一个 view。
加载更多,可以通过 recyclerView 的滚动状态来触发 load-more 事件,需要使用方注册一个 `OnScrollListener`:
```
RecyclerView.OnScrollListener onScrollListener = new RecyclerView.OnScrollListener() {
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
}
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
//hasMore: status of current page, means if there's more data, you have to maintain this status
if(hasMore) {
VirtualLayoutManager lm = (VirtualLayoutManager)recyclerView.getLayoutManager();
int first=0, last=0, total=0;
first = ((LinearLayoutManager)lm).findFirstVisibleItemPosition();
last = ((LinearLayoutManager)lm).findLastVisibleItemPosition();
total = recyclerView.getAdapter().getItemCount();
if(last > 0
&& last >= total - earlyCountForAutoLoad) {
//earlyCountForAutoLoad: help to trigger load more listener earlier
//TODO trigger loadmore listener
}
}
}
}
```
## 横向滑动
没有实现横向滚动的 `LayoutHelper` ,因为 `LayoutHelper` 目前只能做静态的布局,对于跟数据绑定的动态横向滚动布局,比如 `ViewPager` 或者 `RecyclerView` ,建议使用组件的形式提供。也就是一个 `LinearLayoutHelper` 包一个 Item,这个 Item 是 `ViewPager` 或者横向滚动的 `RecyclerView`,且它们是可以和整个页面的 `RecyclerView` 共用一个回收复用池的,参考 Demo 里的第一个组件的使用方法。
## 设置背景图后触发循环布局
给 `LayoutHelper` 设置背景图的时候,由于这个过程是在布局 view 的阶段,设置了图片会触发一次新的 layout,从而又导致触发一次背景图设置,最终进入死循环,因此需要使用方在设置背景图的时候判断当前图片是否已经加载过一次并且成功,如果绑定过一次就不需要再设置图片了,阻断死循环的路径。
具体做法是:
在 `BaseLayoutHelper.LayoutViewBindListener` 的 `onBind()` 方法里判断是否成功绑定过该背景图。
在 `BaseLayoutHelper.LayoutViewUnBindListener` 的 `onUnbind()` 方法里清楚绑定成功与否的状态。
在使用方的图片加载成功回调函数里设置一下图片加载成功的状态,可以自行维护一个 map 或者给 View 设置一个 tag 标记。
我们提供了一个简单的 `DefaultLayoutViewHelper` 封装了这个逻辑,可以参考使用。
## 在可滚动区域里嵌套使用 vlayout 的 `RecyclerView`
不太建议嵌套滚动,除非手势不冲突;如果要完全展开 vlayout 里的内容,牺牲滚动复用,可以调用 `VirtualLayoutManager` 的 `setNoScrolling(true);` 方法设置一下。
## 为 `GridLayoutHelper` 的设置自定义 `SpanSizeLookup`
在 `SpanSizeLookup` 中,`public int getSpanSize(int position)` 方法参数的 position 是整个页面的 position 信息,需要获取当前 layoutHelper 内的相对位置,需要减去一个偏移量,即 `position - getStartPosition()`。
## 获取 `DelegateAdapter` 里数据的相对位置
在 `DelegateAdapter` 里有 `findOffsetPosition(int absolutePosition)` 方法,传入整个页面的绝对位置,获取相对位置。
或者用
```
public static abstract class Adapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
public abstract LayoutHelper onCreateLayoutHelper();
protected void onBindViewHolderWithOffset(VH holder, int position, int offsetTotal) {
}
}
```
中的 `onBindViewHolderWithOffset()` 方法代替传统的 `onBindViewHolder()` 方法,其中的 `position` 参数也是相对位置。
## `StickyLayoutHelper`里的 item 被其他 item 覆盖
`StickyLayoutHelper`里的 item 在 sticky 状态时是会被添加到 `RecyclerView` 的最顶层,如果它被覆盖,很有可能是其他 item 里设置了一个 z 参数(>= 5.0 系统)或者是被调整了 drawingOrder(`RecyclerView` 有 `setChildDrawingOrderCallback` 接口调整绘制顺序),一个典型的场景是使用了 `CardView`。解决方法是给它设置一个更大的 z 参数(>= 5.0 系统),或者检查一下有没有调整 drawingOrder 的地方。
## 背景图在滑动过程中变形
layoutHelper 根据 item 元素的位置和大小确定整块背景的大小,当 layoutHelper 在有未显示元素时,不清楚自己的区域到底有多大,在可见元素变化时会动态计算区域大小,并调节背景 view 的大小,于是就导致了背景 view 中图片会根据 view 的大小去调整自己的显示。通过把背景 imageview 的 scaleType 设置为 matrix,这样就不会跟随imageview的宽高进行变化,同时根据不同手机的 dpi 提前调整好背景图片的尺寸后,再放入 imageview 中就能解决问题。[#275](https://github.com/alibaba/vlayout/issues/275)
## 判断 `StickyLayoutHelper` 里的 item 是否到达顶部
通过 `virtualLayoutManager.findFirstVisibleItemPosition()`,如果大于 `StickyLayoutHelper` 里的 item 的位置,说明已经到顶部。[#277](https://github.com/alibaba/vlayout/issues/277)
## 滚动到某个 item 位置,并带偏移一个距离
有时候自带的 scrollToPosition 方法或者 smoothScrollToPosition 方法不满足需求,可以尝试自己用动画驱动做一个滚动,下面是一种参考实现,可以基于此调整动画参数;
```
public class RecyclerViewFlinger implements Runnable {
private static final String TAG = "Flinger";
private static final float MILLISECONDS_PER_INCH = 25.0F;
private RecyclerView mRecyclerView;
private int targetPosition;
private int offset;
private int direction = 1;
private ScrollFinishedListener mFinishedListener;
private int lastTop;
private int step;
public RecyclerViewFlinger(RecyclerView recyclerView, int targetPosition, int offset,
ScrollFinishedListener finishedListener) {
this.mRecyclerView = recyclerView;
this.targetPosition = targetPosition; //targetPosition 目标item的位置
this.offset = offset;//offset 是目标 item 距离顶部的偏移量
this.mFinishedListener = finishedListener;//可以设置一个滚动回调
if (mRecyclerView != null) {
int firstVisibleItemPosition = mRecyclerView.getFirstVisiblePosition();
direction = firstVisibleItemPosition < targetPosition ? 1 : -1;
}
this.step = mRecyclerView.getMeasuredHeight() / 2; //滚动步长,时间等都可以细调
}
@Override
public void run() {
if (mRecyclerView != null) {
int firstVisibleItemPosition = mRecyclerView.getFirstVisiblePosition();
int lastVisibleItemPosition = mRecyclerView.getLastVisiblePosition();
boolean inscreen = targetPosition >= firstVisibleItemPosition && targetPosition <= lastVisibleItemPosition;
if (inscreen) {
View targetView = mRecyclerView.getLayoutManager().findViewByPosition(targetPosition);
if (targetView != null) {
int top = targetView.getTop();
int dy = top - offset;
mRecyclerView.smoothScrollBy(0, dy);
if (lastTop == top) {
if (mFinishedListener != null) {
mFinishedListener.onPostExecute(targetView);
}
} else {
lastTop = top;
postOnAnimation();
}
}
} else {
mRecyclerView.smoothScrollBy(0, step * direction);
postOnAnimation();
}
}
}
public void postOnAnimation() {
if (mRecyclerView == null) {
return;
}
ViewCompat.postOnAnimation(mRecyclerView, this);
}
public void stop() {
mFinishedListener = null;
if (mRecyclerView == null) {
return;
}
mRecyclerView.removeCallbacks(this);
}
public interface ScrollFinishedListener {
void onPostExecute(View view);
}
}
```
================================================
FILE: examples/.gitignore
================================================
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
.classpath
.project
.settings/
# Proguard folder generated by Eclipse
proguard/
#Log Files
*.log
# OS X
.DS_Store
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.ear
*.iml
# IDEA Files
.idea/
out/
# MAVEN COMPILE Files
target/
lint.xml
================================================
FILE: examples/build.gradle
================================================
apply plugin: 'com.android.application'
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// apply plugin: 'view-inspector'
android {
compileSdkVersion Integer.parseInt(System.properties['compileSdkVersion'])
buildToolsVersion System.properties['buildToolsVersion']
defaultConfig {
applicationId "com.alibaba.android.vlayout.example"
minSdkVersion 14
targetSdkVersion Integer.parseInt(System.properties['targetSdkVersion'])
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':vlayout')
compile 'com.crittercism.dexmaker:dexmaker:1.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-annotations:21.0.0'
compile 'com.android.support:cardview-v7:23.1.1'
}
================================================
FILE: examples/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/villadora/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepattributes InnerClasses
-keep class android.support.v7.widget.RecyclerView$LayoutParams {
*;
}
-keep class android.support.v7.widget.RecyclerView$ViewHolder {
*;
}
-keep class android.support.v7.widget.ChildHelper {
*;
}
-keep class android.support.v7.widget.RecyclerView$LayoutManager {
*;
}
-dontwarn **
================================================
FILE: examples/src/androidTest/java/com/alibaba/android/vlayout/ApplicationTest.java
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.alibaba.android.vlayout;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: examples/src/main/AndroidManifest.xml
================================================
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<manifest
package="com.alibaba.android.vlayout.example"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".RootActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.alibaba.android.vlayout.example.OnePlusNLayoutActivity">
</activity>
<activity android:name="com.alibaba.android.vlayout.example.MainActivity">
</activity>
<activity android:name="com.alibaba.android.vlayout.example.TestActivity">
</activity>
<activity android:name="com.alibaba.android.vlayout.example.VLayoutActivity">
</activity>
<activity android:name="com.alibaba.android.vlayout.example.DebugActivity">
</activity>
</application>
</manifest>
================================================
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/DebugActivity.java
================================================
package com.alibaba.android.vlayout.example;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.DelegateAdapter.Adapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.alibaba.android.vlayout.layout.FixLayoutHelper;
import com.alibaba.android.vlayout.layout.GridLayoutHelper;
import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
import com.alibaba.android.vlayout.layout.StickyLayoutHelper;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import static com.alibaba.android.vlayout.layout.FixLayoutHelper.TOP_RIGHT;
/**
* Created by longerian on 2017/11/14.
*
* @author longerian
* @date 2017/11/14
*/
public class DebugActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.main_view);
VirtualLayoutManager virtualLayoutManager = new VirtualLayoutManager(this);
DelegateAdapter delegateAdapter = new DelegateAdapter(virtualLayoutManager);
List<Adapter> adapterList = new ArrayList<>();
adapterList.add(new SubAdapter(new LinearLayoutHelper(20), 20));
adapterList.add(new SubAdapter(new StickyLayoutHelper(true), 1));
adapterList.add(new SubAdapter(new LinearLayoutHelper(20), 20));
adapterList.add(new SubAdapter(new GridLayoutHelper(4), 80));
// adapterList.add(new SubAdapter(new FixLayoutHelper(0, 0), 1));
adapterList.add(new SubAdapter(new FixLayoutHelper(TOP_RIGHT, 0, 0), 1));
delegateAdapter.addAdapters(adapterList);
recyclerView.setLayoutManager(virtualLayoutManager);
recyclerView.setAdapter(delegateAdapter);
}
private static class SubAdapter extends DelegateAdapter.Adapter<SubViewHolder> {
private LayoutHelper mLayoutHelper;
private int mItemCount;
private SubAdapter(LayoutHelper layoutHelper, int itemCount) {
mLayoutHelper = layoutHelper;
mItemCount = itemCount;
}
@Override
public LayoutHelper onCreateLayoutHelper() {
return mLayoutHelper;
}
@Override
public SubViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
return new SubViewHolder(inflater.inflate(R.layout.item, parent, false));
}
@Override
public void onBindViewHolder(SubViewHolder holder, int position) {
// do nothing
}
@Override
protected void onBindViewHolderWithOffset(SubViewHolder holder, int position, int offsetTotal) {
super.onBindViewHolderWithOffset(holder, position, offsetTotal);
holder.setText(String.valueOf(offsetTotal));
holder.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
@Override
public int getItemCount() {
return mItemCount;
}
}
private static class SubViewHolder extends RecyclerView.ViewHolder {
public static volatile int existing = 0;
public static int createdTimes = 0;
public SubViewHolder(View itemView) {
super(itemView);
createdTimes++;
existing++;
}
public void setText(String title) {
((TextView) itemView.findViewById(R.id.title)).setText(title);
}
@Override
protected void finalize() throws Throwable {
existing--;
super.finalize();
}
}
}
================================================
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/MainActivity.java
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.alibaba.android.vlayout.example;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.VirtualLayoutAdapter;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.alibaba.android.vlayout.layout.DefaultLayoutHelper;
import com.alibaba.android.vlayout.layout.FixLayoutHelper;
import com.alibaba.android.vlayout.layout.GridLayoutHelper;
import com.alibaba.android.vlayout.layout.ScrollFixLayoutHelper;
import java.util.LinkedList;
import java.util.List;
/**
* Created by villadora on 15/8/3.
*/
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);
VirtualLayoutManager layoutManager = new VirtualLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
//layoutManager.setReverseLayout(true);
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(10, 10, 10, 10);
}
});
final List<LayoutHelper> helpers = new LinkedList<>();
final GridLayoutHelper gridLayoutHelper = new GridLayoutHelper(4);
gridLayoutHelper.setItemCount(25);
final ScrollFixLayoutHelper scrollFixLayoutHelper = new ScrollFixLayoutHelper(FixLayoutHelper.TOP_RIGHT, 100, 100);
helpers.add(DefaultLayoutHelper.newHelper(7));
helpers.add(scrollFixLayoutHelper);
helpers.add(DefaultLayoutHelper.newHelper(2));
helpers.add(gridLayoutHelper);
layoutManager.setLayoutHelpers(helpers);
recyclerView.setAdapter(
new VirtualLayoutAdapter(layoutManager) {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new MainViewHolder(new TextView(MainActivity.this));
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
VirtualLayoutManager.LayoutParams layoutParams = new VirtualLayoutManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, 300);
holder.itemView.setLayoutParams(layoutParams);
((TextView) holder.itemView).setText(Integer.toString(position));
if (position == 7) {
layoutParams.height = 60;
layoutParams.width = 60;
} else if (position > 35) {
layoutParams.height = 200 + (position - 30) * 100;
}
if (position > 35) {
holder.itemView.setBackgroundColor(0x66cc0000 + (position - 30) * 128);
} else if (position % 2 == 0) {
holder.itemView.setBackgroundColor(0xaa00ff00);
} else {
holder.itemView.setBackgroundColor(0xccff00ff);
}
}
@Override
public int getItemCount() {
List<LayoutHelper> helpers = getLayoutHelpers();
if (helpers == null) {
return 0;
}
int count = 0;
for (int i = 0, size = helpers.size(); i < size; i++) {
count += helpers.get(i).getItemCount();
}
return count;
}
});
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
recyclerView.scrollToPosition(7);
recyclerView.getAdapter().notifyDataSetChanged();
}
}, 6000);
}
static class MainViewHolder extends RecyclerView.ViewHolder {
public MainViewHolder(View itemView) {
super(itemView);
}
}
}
================================================
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/OnePlusNLayoutActivity.java
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.alibaba.android.vlayout.example;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.RecyclablePagerAdapter;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams;
import com.alibaba.android.vlayout.layout.FixLayoutHelper;
import com.alibaba.android.vlayout.layout.GridLayoutHelper;
import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
import com.alibaba.android.vlayout.layout.OnePlusNLayoutHelper;
import com.alibaba.android.vlayout.layout.OnePlusNLayoutHelperEx;
import com.alibaba.android.vlayout.layout.ScrollFixLayoutHelper;
import com.alibaba.android.vlayout.layout.StickyLayoutHelper;
import java.util.LinkedList;
import java.util.List;
/**
* @author villadora
*/
public class OnePlusNLayoutActivity extends Activity {
private static final boolean BANNER_LAYOUT = true;
private static final boolean LINEAR_LAYOUT = true;
private static final boolean ONEN_LAYOUT = true;
private static final boolean GRID_LAYOUT = true;
private static final boolean STICKY_LAYOUT = true;
private static final boolean HORIZONTAL_SCROLL_LAYOUT = true;
private static final boolean SCROLL_FIX_LAYOUT = true;
private TextView mFirstText;
private TextView mLastText;
private TextView mCountText;
private TextView mTotalOffsetText;
private Runnable trigger;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
mFirstText = (TextView) findViewById(R.id.first);
mLastText = (TextView) findViewById(R.id.last);
mCountText = (TextView) findViewById(R.id.count);
mTotalOffsetText = (TextView) findViewById(R.id.total_offset);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);
findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText position = (EditText) findViewById(R.id.position);
if (!TextUtils.isEmpty(position.getText())) {
try {
int pos = Integer.parseInt(position.getText().toString());
recyclerView.scrollToPosition(pos);
} catch (Exception e) {
Log.e("VlayoutActivity", e.getMessage(), e);
}
} else {
recyclerView.requestLayout();
}
}
});
final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {
}
@Override
public void onScrolled(RecyclerView recyclerView, int i, int i2) {
mFirstText.setText("First: " + layoutManager.findFirstVisibleItemPosition());
mLastText.setText("Existing: " + MainViewHolder.existing + " Created: " + MainViewHolder.createdTimes);
mCountText.setText("Count: " + recyclerView.getChildCount());
mTotalOffsetText.setText("Total Offset: " + layoutManager.getOffsetToStart());
}
});
recyclerView.setLayoutManager(layoutManager);
// layoutManager.setReverseLayout(true);
RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() {
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = ((LayoutParams) view.getLayoutParams()).getViewPosition();
outRect.set(4, 4, 4, 4);
}
};
final RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
recyclerView.setRecycledViewPool(viewPool);
// recyclerView.addItemDecoration(itemDecoration);
viewPool.setMaxRecycledViews(0, 20);
final DelegateAdapter delegateAdapter = new DelegateAdapter(layoutManager, true);
recyclerView.setAdapter(delegateAdapter);
List<DelegateAdapter.Adapter> adapters = new LinkedList<>();
if (BANNER_LAYOUT) {
adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 1) {
@Override
public void onViewRecycled(MainViewHolder holder) {
if (holder.itemView instanceof ViewPager) {
((ViewPager) holder.itemView).setAdapter(null);
}
}
@Override
public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 1)
return new MainViewHolder(
LayoutInflater.from(OnePlusNLayoutActivity.this).inflate(R.layout.view_pager, parent, false));
return super.onCreateViewHolder(parent, viewType);
}
@Override
public int getItemViewType(int position) {
return 1;
}
@Override
protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) {
}
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
if (holder.itemView instanceof ViewPager) {
ViewPager viewPager = (ViewPager) holder.itemView;
viewPager.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200));
// from position to get adapter
viewPager.setAdapter(new PagerAdapter(this, viewPool));
}
}
});
}
if (GRID_LAYOUT) {
GridLayoutHelper layoutHelper;
layoutHelper = new GridLayoutHelper(4);
layoutHelper.setMargin(0, 10, 0, 10);
layoutHelper.setHGap(3);
layoutHelper.setAspectRatio(4f);
adapters.add(new SubAdapter(this, layoutHelper, 8));
}
if (HORIZONTAL_SCROLL_LAYOUT) {
}
if (GRID_LAYOUT) {
GridLayoutHelper layoutHelper;
layoutHelper = new GridLayoutHelper(2);
layoutHelper.setMargin(0, 10, 0, 10);
layoutHelper.setHGap(3);
layoutHelper.setAspectRatio(3f);
adapters.add(new SubAdapter(this, layoutHelper, 2));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff876384);
helper.setMargin(10, 10, 10, 10);
helper.setPadding(10, 10, 10, 10);
adapters.add(new SubAdapter(this, helper, 3) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
// LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
// layoutParams.leftMargin = 10;
// layoutParams.topMargin = 10;
// layoutParams.rightMargin = 10;
// layoutParams.bottomMargin = 10;
// holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 4));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
helper.setColWeights(new float[]{40f, 45f, 15f, 60f, 0f});
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
helper.setColWeights(new float[]{20f, 80f, 0f, 60f, 20f});
helper.setAspectRatio(4);
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 6));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 7));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
helper.setColWeights(new float[]{40f, 45f, 15f, 60f, 0f, 30f, 30f});
adapters.add(new SubAdapter(this, helper, 7));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xffed7612);
// helper.setMargin(10, 10, 10, 10);
// helper.setPadding(10, 10, 10, 10);
helper.setColWeights(new float[]{30f, 20f, 50f, 40f, 30f, 35f, 35f});
adapters.add(new SubAdapter(this, helper, 7) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
// LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
// layoutParams.leftMargin = 10;
// layoutParams.topMargin = 10;
// layoutParams.rightMargin = 10;
// layoutParams.bottomMargin = 10;
// holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (STICKY_LAYOUT) {
StickyLayoutHelper layoutHelper = new StickyLayoutHelper();
layoutHelper.setAspectRatio(4);
adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
}
if (SCROLL_FIX_LAYOUT) {
ScrollFixLayoutHelper layoutHelper = new ScrollFixLayoutHelper(FixLayoutHelper.BOTTOM_RIGHT, 20, 20);
layoutHelper.setShowType(ScrollFixLayoutHelper.SHOW_ON_LEAVE);
adapters.add(new SubAdapter(this, layoutHelper, 1) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams layoutParams = new LayoutParams(50, 50);
holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (LINEAR_LAYOUT)
adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 100));
delegateAdapter.setAdapters(adapters);
final Handler mainHandler = new Handler(Looper.getMainLooper());
trigger = new Runnable() {
@Override
public void run() {
// recyclerView.scrollToPosition(22);
// recyclerView.getAdapter().notifyDataSetChanged();
recyclerView.requestLayout();
// mainHandler.postDelayed(trigger, 1000);
}
};
mainHandler.postDelayed(trigger, 1000);
}
// RecyclableViewPager
static class PagerAdapter extends RecyclablePagerAdapter<MainViewHolder> {
public PagerAdapter(SubAdapter adapter, RecyclerView.RecycledViewPool pool) {
super(adapter, pool);
}
@Override
public int getCount() {
return 6;
}
@Override
public void onBindViewHolder(MainViewHolder viewHolder, int position) {
// only vertical
viewHolder.itemView.setLayoutParams(
new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((TextView) viewHolder.itemView.findViewById(R.id.title)).setText("Banner: " + position);
}
@Override
public int getItemViewType(int position) {
return 0;
}
}
static class SubAdapter extends DelegateAdapter.Adapter<MainViewHolder> {
private Context mContext;
private LayoutHelper mLayoutHelper;
private LayoutParams mLayoutParams;
private int mCount = 0;
public SubAdapter(Context context, LayoutHelper layoutHelper, int count) {
this(context, layoutHelper, count, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300));
}
public SubAdapter(Context context, LayoutHelper layoutHelper, int count, @NonNull LayoutParams layoutParams) {
this.mContext = context;
this.mLayoutHelper = layoutHelper;
this.mCount = count;
this.mLayoutParams = layoutParams;
}
@Override
public LayoutHelper onCreateLayoutHelper() {
return mLayoutHelper;
}
@Override
public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new MainViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item, parent, false));
}
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
// only vertical
holder.itemView.setLayoutParams(
new LayoutParams(mLayoutParams));
}
@Override
protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) {
((TextView) holder.itemView.findViewById(R.id.title)).setText(Integer.toString(offsetTotal));
}
@Override
public int getItemCount() {
return mCount;
}
}
static class MainViewHolder extends RecyclerView.ViewHolder {
public static volatile int existing = 0;
public static int createdTimes = 0;
public MainViewHolder(View itemView) {
super(itemView);
createdTimes++;
existing++;
}
@Override
protected void finalize() throws Throwable {
existing--;
super.finalize();
}
}
}
================================================
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/RootActivity.java
================================================
package com.alibaba.android.vlayout.example;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
/**
* Created by J!nl!n on 2017/3/9.
*/
public class RootActivity extends ListActivity {
private String[] mTitles = new String[]{
VLayoutActivity.class.getSimpleName(),
MainActivity.class.getSimpleName(),
TestActivity.class.getSimpleName(),
OnePlusNLayoutActivity.class.getSimpleName(),
DebugActivity.class.getSimpleName()
};
private Class[] mActivities = new Class[]{
VLayoutActivity.class,
MainActivity.class,
TestActivity.class,
OnePlusNLayoutActivity.class,
DebugActivity.class
};
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mTitles));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
startActivity(new Intent(this, mActivities[position]));
}
}
================================================
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/TestActivity.java
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.alibaba.android.vlayout.example;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
/**
* Created by villadora on 15/8/3.
*/
public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText position = (EditText) findViewById(R.id.position);
if (!TextUtils.isEmpty(position.getText())) {
try {
int pos = Integer.parseInt(position.getText().toString());
recyclerView.scrollToPosition(pos);
} catch (Exception e) {
Log.e("VlayoutActivity", e.getMessage(), e);
}
}
}
});
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(4, 4, 4, 4);
}
});
recyclerView.setAdapter(
new RecyclerView.Adapter() {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// TextView view = (TextView) LayoutInflater.from(TestActivity.this).inflate(R.layout.item, parent, false);
// FrameLayout frameLayout = new FrameLayout(TestActivity.this);
FrameLayout frameLayout = (FrameLayout) LayoutInflater.from(TestActivity.this).inflate(R.layout.item, parent, false);;
// frameLayout.addView(view);
return new MainViewHolder(frameLayout);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, 300);
layoutParams.height = (int) (200 + (position % 15) * 10);
holder.itemView.findViewById(R.id.title).setLayoutParams(layoutParams);
if (position == 30) {
StaggeredGridLayoutManager.LayoutParams lp = new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
lp.setFullSpan(true);
holder.itemView.setLayoutParams(lp);
} else {
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
if (lp instanceof StaggeredGridLayoutManager.LayoutParams) {
((StaggeredGridLayoutManager.LayoutParams) lp).setFullSpan(false);
}
}
((TextView) holder.itemView.findViewById(R.id.title)).setText(Integer.toString(position));
}
@Override
public int getItemCount() {
return 60;
}
});
}
static class MainViewHolder extends RecyclerView.ViewHolder {
public MainViewHolder(View itemView) {
super(itemView);
}
}
}
================================================
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/VLayoutActivity.java
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.alibaba.android.vlayout.example;
import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.RecyclablePagerAdapter;
import com.alibaba.android.vlayout.VirtualLayoutManager;
import com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams;
import com.alibaba.android.vlayout.extend.LayoutManagerCanScrollListener;
import com.alibaba.android.vlayout.extend.PerformanceMonitor;
import com.alibaba.android.vlayout.extend.ViewLifeCycleListener;
import com.alibaba.android.vlayout.layout.ColumnLayoutHelper;
import com.alibaba.android.vlayout.layout.FixLayoutHelper;
import com.alibaba.android.vlayout.layout.FloatLayoutHelper;
import com.alibaba.android.vlayout.layout.GridLayoutHelper;
import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
import com.alibaba.android.vlayout.layout.OnePlusNLayoutHelper;
import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper;
import com.alibaba.android.vlayout.layout.RangeGridLayoutHelper.GridRangeStyle;
import com.alibaba.android.vlayout.layout.ScrollFixLayoutHelper;
import com.alibaba.android.vlayout.layout.SingleLayoutHelper;
import com.alibaba.android.vlayout.layout.StaggeredGridLayoutHelper;
import com.alibaba.android.vlayout.layout.StickyLayoutHelper;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.EditText;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* @author villadora
*/
public class VLayoutActivity extends Activity {
private static final boolean BANNER_LAYOUT = true;
private static final boolean FIX_LAYOUT = true;
private static final boolean LINEAR_LAYOUT = true;
private static final boolean SINGLE_LAYOUT = true;
private static final boolean FLOAT_LAYOUT = true;
private static final boolean ONEN_LAYOUT = true;
private static final boolean COLUMN_LAYOUT = true;
private static final boolean GRID_LAYOUT = true;
private static final boolean STICKY_LAYOUT = true;
private static final boolean STAGGER_LAYOUT = true;
private SwipeRefreshLayout mSwipeRefreshLayout;
private TextView mFirstText;
private TextView mLastText;
private TextView mCountText;
private TextView mTotalOffsetText;
private Runnable trigger;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
;
mFirstText = (TextView) findViewById(R.id.first);
mLastText = (TextView) findViewById(R.id.last);
mCountText = (TextView) findViewById(R.id.count);
mTotalOffsetText = (TextView) findViewById(R.id.total_offset);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);
final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this);
layoutManager.setPerformanceMonitor(new PerformanceMonitor() {
long start;
long end;
@Override
public void recordStart(String phase, View view) {
start = System.currentTimeMillis();
}
@Override
public void recordEnd(String phase, View view) {
end = System.currentTimeMillis();
Log.d("VLayoutActivity", view.getClass().getName() + " " + (end - start));
}
});
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {
}
@Override
public void onScrolled(RecyclerView recyclerView, int i, int i2) {
mFirstText.setText("First: " + layoutManager.findFirstVisibleItemPosition());
mLastText.setText("Existing: " + MainViewHolder.existing + " Created: " + MainViewHolder.createdTimes);
mCountText.setText("Count: " + recyclerView.getChildCount());
mTotalOffsetText.setText("Total Offset: " + layoutManager.getOffsetToStart());
}
});
recyclerView.setLayoutManager(layoutManager);
// layoutManager.setReverseLayout(true);
RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() {
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = ((LayoutParams) view.getLayoutParams()).getViewPosition();
outRect.set(4, 4, 4, 4);
}
};
final RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
recyclerView.setRecycledViewPool(viewPool);
// recyclerView.addItemDecoration(itemDecoration);
viewPool.setMaxRecycledViews(0, 20);
layoutManager.setRecycleOffset(300);
// viewLifeCycleListener should be used with setRecycleOffset()
layoutManager.setViewLifeCycleListener(new ViewLifeCycleListener() {
@Override
public void onAppearing(View view) {
// Log.e("ViewLifeCycleTest", "onAppearing: " + view);
}
@Override
public void onDisappearing(View view) {
// Log.e("ViewLifeCycleTest", "onDisappearing: " + view);
}
@Override
public void onAppeared(View view) {
// Log.e("ViewLifeCycleTest", "onAppeared: " + view);
}
@Override
public void onDisappeared(View view) {
// Log.e("ViewLifeCycleTest", "onDisappeared: " + view);
}
});
layoutManager.setLayoutManagerCanScrollListener(new LayoutManagerCanScrollListener() {
@Override
public boolean canScrollVertically() {
Log.i("vlayout", "canScrollVertically: ");
return true;
}
@Override
public boolean canScrollHorizontally() {
Log.i("vlayout", "canScrollHorizontally: ");
return true;
}
});
final DelegateAdapter delegateAdapter = new DelegateAdapter(layoutManager, true);
recyclerView.setAdapter(delegateAdapter);
final List<DelegateAdapter.Adapter> adapters = new LinkedList<>();
if (BANNER_LAYOUT) {
adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 1) {
@Override
public void onViewRecycled(MainViewHolder holder) {
if (holder.itemView instanceof ViewPager) {
((ViewPager) holder.itemView).setAdapter(null);
}
}
@Override
public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 1)
return new MainViewHolder(
LayoutInflater.from(VLayoutActivity.this).inflate(R.layout.view_pager, parent, false));
return super.onCreateViewHolder(parent, viewType);
}
@Override
public int getItemViewType(int position) {
return 1;
}
@Override
protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) {
}
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
if (holder.itemView instanceof ViewPager) {
ViewPager viewPager = (ViewPager) holder.itemView;
viewPager.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200));
// from position to get adapter
viewPager.setAdapter(new PagerAdapter(this, viewPool));
}
}
});
}
//{
// GridLayoutHelper helper = new GridLayoutHelper(10);
// helper.setAspectRatio(4f);
// helper.setGap(10);
// adapters.add(new SubAdapter(this, helper, 80));
//}
if (FLOAT_LAYOUT) {
FloatLayoutHelper layoutHelper = new FloatLayoutHelper();
layoutHelper.setAlignType(FixLayoutHelper.BOTTOM_RIGHT);
layoutHelper.setDefaultLocation(100, 400);
LayoutParams layoutParams = new LayoutParams(150, 150);
adapters.add(new SubAdapter(this, layoutHelper, 1, layoutParams));
}
if (LINEAR_LAYOUT) {
LinearLayoutHelper layoutHelper1 = new LinearLayoutHelper();
layoutHelper1.setBgColor(Color.YELLOW);
layoutHelper1.setAspectRatio(2.0f);
layoutHelper1.setMargin(10, 10, 10, 10);
layoutHelper1.setPadding(10, 10, 10, 10);
LinearLayoutHelper layoutHelper2 = new LinearLayoutHelper();
layoutHelper2.setAspectRatio(4.0f);
layoutHelper2.setDividerHeight(10);
layoutHelper2.setMargin(10, 0, 10, 10);
layoutHelper2.setPadding(10, 0, 10, 10);
layoutHelper2.setBgColor(0xFFF5A623);
final Handler mainHandler = new Handler(Looper.getMainLooper());
adapters.add(new SubAdapter(this, layoutHelper1, 1) {
@Override
public void onBindViewHolder(final MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
final SubAdapter subAdapter = this;
//mainHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// //delegateAdapter.removeAdapter(subAdapter);
// //notifyItemRemoved(1);
// holder.itemView.setVisibility(View.GONE);
// notifyItemChanged(1);
// layoutManager.runAdjustLayout();
// }
//}, 2000L);
}
});
adapters.add(new SubAdapter(this, layoutHelper2, 6) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
if (position % 2 == 0) {
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
layoutParams.mAspectRatio = 5;
holder.itemView.setLayoutParams(layoutParams);
}
}
});
}
// {
// RangeGridLayoutHelper layoutHelper = new RangeGridLayoutHelper(4);
// layoutHelper.setBgColor(Color.GREEN);
// layoutHelper.setWeights(new float[]{20f, 26.665f});
// layoutHelper.setPadding(15, 15, 15, 15);
// layoutHelper.setMargin(15, 50, 15, 150);
// layoutHelper.setHGap(10);
// layoutHelper.setVGap(10);
// GridRangeStyle rangeStyle = new GridRangeStyle();
// rangeStyle.setBgColor(Color.RED);
// rangeStyle.setSpanCount(2);
// rangeStyle.setWeights(new float[]{46.665f});
// rangeStyle.setPadding(15, 15, 15, 15);
// rangeStyle.setMargin(15, 15, 15, 15);
// rangeStyle.setHGap(5);
// rangeStyle.setVGap(5);
// layoutHelper.addRangeStyle(0, 7, rangeStyle);
//
// GridRangeStyle rangeStyle1 = new GridRangeStyle();
// rangeStyle1.setBgColor(Color.YELLOW);
// rangeStyle1.setSpanCount(2);
// rangeStyle1.setWeights(new float[]{46.665f});
// rangeStyle1.setPadding(15, 15, 15, 15);
// rangeStyle1.setMargin(15, 15, 15, 15);
// rangeStyle1.setHGap(5);
// rangeStyle1.setVGap(5);
// layoutHelper.addRangeStyle(8, 15, rangeStyle1);
//
// GridRangeStyle rangeStyle2 = new GridRangeStyle();
// rangeStyle2.setBgColor(Color.CYAN);
// rangeStyle2.setSpanCount(2);
// rangeStyle2.setWeights(new float[]{46.665f});
// rangeStyle2.setPadding(15, 15, 15, 15);
// rangeStyle2.setMargin(15, 15, 15, 15);
// rangeStyle2.setHGap(5);
// rangeStyle2.setVGap(5);
// layoutHelper.addRangeStyle(16, 22, rangeStyle2);
// GridRangeStyle rangeStyle3 = new GridRangeStyle();
// rangeStyle3.setBgColor(Color.DKGRAY);
// rangeStyle3.setSpanCount(1);
// rangeStyle3.setWeights(new float[]{46.665f});
// rangeStyle3.setPadding(15, 15, 15, 15);
// rangeStyle3.setMargin(15, 15, 15, 15);
// rangeStyle3.setHGap(5);
// rangeStyle3.setVGap(5);
// rangeStyle2.addChildRangeStyle(0, 2, rangeStyle3);
// GridRangeStyle rangeStyle4 = new GridRangeStyle();
// rangeStyle4.setBgColor(Color.BLUE);
// rangeStyle4.setSpanCount(2);
// rangeStyle4.setWeights(new float[]{46.665f});
// rangeStyle4.setPadding(15, 15, 15, 15);
// rangeStyle4.setMargin(15, 15, 15, 15);
// rangeStyle4.setHGap(5);
// rangeStyle4.setVGap(5);
// rangeStyle2.addChildRangeStyle(3, 6, rangeStyle4);
//
// GridRangeStyle rangeStyle5 = new GridRangeStyle();
// rangeStyle5.setBgColor(Color.RED);
// rangeStyle5.setSpanCount(2);
// rangeStyle5.setPadding(15, 15, 15, 15);
// rangeStyle5.setMargin(15, 15, 15, 15);
// rangeStyle5.setHGap(5);
// rangeStyle5.setVGap(5);
// layoutHelper.addRangeStyle(23, 30, rangeStyle5);
// GridRangeStyle rangeStyle6 = new GridRangeStyle();
// rangeStyle6.setBgColor(Color.MAGENTA);
// rangeStyle6.setSpanCount(2);
// rangeStyle6.setPadding(15, 15, 15, 15);
// rangeStyle6.setMargin(15, 15, 15, 15);
// rangeStyle6.setHGap(5);
// rangeStyle6.setVGap(5);
// rangeStyle5.addChildRangeStyle(0, 7, rangeStyle6);
//
// adapters.add(new SubAdapter(this, layoutHelper, 23));
// }
{
SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
layoutHelper.setBgColor(Color.BLUE);
layoutHelper.setMargin(0, 30, 0, 200);
adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
}
if (STICKY_LAYOUT) {
StickyLayoutHelper layoutHelper = new StickyLayoutHelper();
//layoutHelper.setOffset(100);
layoutHelper.setAspectRatio(4);
adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
}
//{
// final StaggeredGridLayoutHelper helper = new StaggeredGridLayoutHelper(3, 10);
// helper.setBgColor(0xFF86345A);
// adapters.add(new SubAdapter(this, helper, 4) {
//
// @Override
// public void onBindViewHolder(MainViewHolder holder, int position) {
// super.onBindViewHolder(holder, position);
// LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
// if (position % 2 == 0) {
// layoutParams.mAspectRatio = 1.0f;
// } else {
// layoutParams.height = 340 + position % 7 * 20;
// }
// holder.itemView.setLayoutParams(layoutParams);
// }
// });
//}
{
final GridLayoutHelper helper = new GridLayoutHelper(3, 4);
helper.setBgColor(0xFF86345A);
adapters.add(new SubAdapter(this, helper, 4) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
holder.itemView.setLayoutParams(layoutParams);
}
});
}
{
RangeGridLayoutHelper layoutHelper = new RangeGridLayoutHelper(4);
layoutHelper.setBgColor(Color.GREEN);
layoutHelper.setWeights(new float[]{20f, 26.665f});
layoutHelper.setPadding(15, 15, 15, 15);
layoutHelper.setMargin(15, 15, 15, 15);
layoutHelper.setHGap(10);
layoutHelper.setVGap(10);
GridRangeStyle rangeStyle = new GridRangeStyle();
rangeStyle.setBgColor(Color.RED);
rangeStyle.setSpanCount(2);
rangeStyle.setWeights(new float[]{46.665f});
rangeStyle.setPadding(15, 15, 15, 15);
rangeStyle.setMargin(15, 15, 15, 15);
rangeStyle.setHGap(5);
rangeStyle.setVGap(5);
layoutHelper.addRangeStyle(4, 7, rangeStyle);
GridRangeStyle rangeStyle1 = new GridRangeStyle();
rangeStyle1.setBgColor(Color.YELLOW);
rangeStyle1.setSpanCount(2);
rangeStyle1.setWeights(new float[]{46.665f});
rangeStyle1.setPadding(15, 15, 15, 15);
rangeStyle1.setMargin(15, 15, 15, 15);
rangeStyle1.setHGap(5);
rangeStyle1.setVGap(5);
layoutHelper.addRangeStyle(8, 11, rangeStyle1);
adapters.add(new SubAdapter(this, layoutHelper, 16));
}
if (SINGLE_LAYOUT) {
SingleLayoutHelper layoutHelper = new SingleLayoutHelper();
layoutHelper.setBgColor(Color.rgb(135, 225, 90));
layoutHelper.setAspectRatio(4);
layoutHelper.setMargin(10, 20, 10, 20);
layoutHelper.setPadding(10, 10, 10, 10);
adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
}
if (COLUMN_LAYOUT) {
ColumnLayoutHelper layoutHelper = new ColumnLayoutHelper();
layoutHelper.setBgColor(0xff00f0f0);
layoutHelper.setWeights(new float[]{40.0f, Float.NaN, 40});
adapters.add(new SubAdapter(this, layoutHelper, 5) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
if (position == 0) {
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
layoutParams.mAspectRatio = 4;
holder.itemView.setLayoutParams(layoutParams);
} else {
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
layoutParams.mAspectRatio = Float.NaN;
holder.itemView.setLayoutParams(layoutParams);
}
}
});
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff876384);
helper.setAspectRatio(4.0f);
helper.setColWeights(new float[]{40f, 45f});
helper.setMargin(10, 20, 10, 20);
helper.setPadding(10, 10, 10, 10);
adapters.add(new SubAdapter(this, helper, 2));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xffef8ba3);
helper.setAspectRatio(2.0f);
helper.setColWeights(new float[]{40f});
helper.setRowWeight(30f);
helper.setMargin(10, 20, 10, 20);
helper.setPadding(10, 10, 10, 10);
adapters.add(new SubAdapter(this, helper, 4) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams();
if (position == 0) {
lp.rightMargin = 1;
} else if (position == 1) {
} else if (position == 2) {
lp.topMargin = 1;
lp.rightMargin = 1;
}
}
});
}
if (ONEN_LAYOUT) {
adapters.add(new SubAdapter(this, new OnePlusNLayoutHelper(), 0));
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff87e543);
helper.setAspectRatio(1.8f);
helper.setColWeights(new float[]{33.33f, 50f, 40f});
helper.setMargin(10, 20, 10, 20);
helper.setPadding(10, 10, 10, 10);
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
adapters.add(new SubAdapter(this, helper, 3, lp) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams();
if (position == 0) {
lp.rightMargin = 1;
}
}
});
}
if (COLUMN_LAYOUT) {
adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 0));
adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 4));
}
if (FIX_LAYOUT) {
FixLayoutHelper layoutHelper = new FixLayoutHelper(10, 10);
adapters.add(new SubAdapter(this, layoutHelper, 0));
layoutHelper = new FixLayoutHelper(FixLayoutHelper.TOP_RIGHT, 20, 20);
adapters.add(new SubAdapter(this, layoutHelper, 1) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200);
holder.itemView.setLayoutParams(layoutParams);
}
});
}
//if (STICKY_LAYOUT) {
// StickyLayoutHelper layoutHelper = new StickyLayoutHelper(false);
// adapters.add(new SubAdapter(this, layoutHelper, 0));
// layoutHelper = new StickyLayoutHelper(false);
// layoutHelper.setOffset(100);
// adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
//}
if (GRID_LAYOUT) {
GridLayoutHelper layoutHelper = new GridLayoutHelper(2);
layoutHelper.setMargin(7, 0, 7, 0);
layoutHelper.setWeights(new float[]{46.665f});
layoutHelper.setHGap(3);
adapters.add(new SubAdapter(this, layoutHelper, 2));
layoutHelper = new GridLayoutHelper(4);
layoutHelper.setWeights(new float[]{20f, 26.665f});
layoutHelper.setMargin(7, 0, 7, 0);
layoutHelper.setHGap(3);
adapters.add(new SubAdapter(this, layoutHelper, 8));
}
if (GRID_LAYOUT) {
adapters.add(new SubAdapter(this, new GridLayoutHelper(4), 0));
GridLayoutHelper helper = new GridLayoutHelper(4);
helper.setAspectRatio(4f);
//helper.setColWeights(new float[]{40, 20, 30, 30});
// helper.setMargin(0, 10, 0, 10);
helper.setGap(10);
adapters.add(new SubAdapter(this, helper, 80) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams();
// lp.bottomMargin = 1;
// lp.rightMargin = 1;
}
});
}
if (FIX_LAYOUT) {
adapters.add(new SubAdapter(this, new ScrollFixLayoutHelper(20, 20), 1) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams layoutParams = new LayoutParams(200, 200);
holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (LINEAR_LAYOUT)
adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 10));
if (GRID_LAYOUT) {
GridLayoutHelper helper = new GridLayoutHelper(3);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 3));
}
if (STAGGER_LAYOUT) {
// adapters.add(new SubAdapter(this, new StaggeredGridLayoutHelper(2, 0), 0));
final StaggeredGridLayoutHelper helper = new StaggeredGridLayoutHelper(2, 10);
helper.setMargin(20, 10, 10, 10);
helper.setPadding(10, 10, 20, 10);
helper.setBgColor(0xFF86345A);
adapters.add(new SubAdapter(this, helper, 27) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200);
if (position % 2 == 0) {
layoutParams.mAspectRatio = 1.0f;
} else {
layoutParams.height = 340 + position % 7 * 20;
}
holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (COLUMN_LAYOUT) {
// adapters.add(new SubAdapter(this, new ColumnLayoutHelper(), 3));
}
if (GRID_LAYOUT) {
// adapters.add(new SubAdapter(this, new GridLayoutHelper(4), 24));
}
adapters.add(
new FooterAdapter(recyclerView, VLayoutActivity.this, new GridLayoutHelper(1), 1));
delegateAdapter.setAdapters(adapters);
final Handler mainHandler = new Handler(Looper.getMainLooper());
trigger = new Runnable() {
@Override
public void run() {
//recyclerView.scrollToPosition(22);
//recyclerView.getAdapter().notifyDataSetChanged();
//mainHandler.postDelayed(trigger, 1000);
//List<DelegateAdapter.Adapter> newAdapters = new ArrayList<>();
//newAdapters.add((new SubAdapter(VLayoutActivity.this, new ColumnLayoutHelper(), 3)));
//newAdapters.add((new SubAdapter(VLayoutActivity.this, new GridLayoutHelper(4), 24)));
//delegateAdapter.addAdapter(0, new SubAdapter(VLayoutActivity.this, new ColumnLayoutHelper(), 3));
//delegateAdapter.addAdapter(1, new SubAdapter(VLayoutActivity.this, new GridLayoutHelper(4), 24));
//delegateAdapter.notifyDataSetChanged();
}
};
findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText position = (EditText) findViewById(R.id.position);
if (!TextUtils.isEmpty(position.getText())) {
try {
int pos = Integer.parseInt(position.getText().toString());
recyclerView.scrollToPosition(pos);
} catch (Exception e) {
Log.e("VlayoutActivity", e.getMessage(), e);
}
} else {
recyclerView.requestLayout();
}
//FooterAdapter footer = (FooterAdapter)adapters.get(adapters.size() - 1);
//footer.toggleFoot();
}
});
mainHandler.postDelayed(trigger, 1000);
mSwipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
mainHandler.postDelayed(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(false);
}
}, 2000L);
}
});
setListenerToRootView();
}
boolean isOpened = false;
public void setListenerToRootView() {
final View activityRootView = getWindow().getDecorView().findViewById(android.R.id.content);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
if (heightDiff > 100) { // 99% of the time the height diff will be due to a keyboard.
if (isOpened == false) {
//Do two things, make the view top visible and the editText smaller
}
isOpened = true;
} else if (isOpened == true) {
isOpened = false;
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);
recyclerView.getAdapter().notifyDataSetChanged();
}
}
});
}
static class FooterAdapter extends DelegateAdapter.Adapter<MainViewHolder> {
private RecyclerView mRecyclerView;
private Context mContext;
private LayoutHelper mLayoutHelper;
private LayoutParams mLayoutParams;
private int mCount = 0;
private boolean showFooter = false;
public FooterAdapter(RecyclerView recyclerView, Context context, LayoutHelper layoutHelper, int count) {
this(recyclerView, context, layoutHelper, count, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300));
}
public FooterAdapter(RecyclerView recyclerView, Context context, LayoutHelper layoutHelper, int count, @NonNull LayoutParams layoutParams) {
this.mRecyclerView = recyclerView;
this.mContext = context;
this.mLayoutHelper = layoutHelper;
this.mCount = count;
this.mLayoutParams = layoutParams;
}
@Override
public int getItemViewType(int position) {
return 100;
}
@Override
public LayoutHelper onCreateLayoutHelper() {
return mLayoutHelper;
}
@Override
public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new MainViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item, parent, false));
}
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
LayoutParams lp = (LayoutParams) holder.itemView.getLayoutParams();
if (showFooter) {
lp.height = 300;
} else {
lp.height = 0;
}
holder.itemView.setLayoutParams(lp);
}
@Override
protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) {
((TextView) holder.itemView.findViewById(R.id.title)).setText(Integer.toString(offsetTotal));
}
@Override
public int getItemCount() {
return mCount;
}
public void toggleFoot() {
this.showFooter = !this.showFooter;
mRecyclerView.getAdapter().notifyItemChanged(205);
mRecyclerView.post(new Runnable() {
@Override
public void run() {
mRecyclerView.scrollToPosition(205);
mRecyclerView.requestLayout();
}
});
}
}
// RecyclableViewPager
static class PagerAdapter extends RecyclablePagerAdapter<MainViewHolder> {
public PagerAdapter(SubAdapter adapter, RecyclerView.RecycledViewPool pool) {
super(adapter, pool);
}
@Override
public int getCount() {
return 6;
}
@Override
public void onBindViewHolder(MainViewHolder viewHolder, int position) {
// only vertical
viewHolder.itemView.setLayoutParams(
new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((TextView) viewHolder.itemView.findViewById(R.id.title)).setText("Banner: " + position);
}
@Override
public int getItemViewType(int position) {
return 0;
}
}
static class SubAdapter extends DelegateAdapter.Adapter<MainViewHolder> {
private Context mContext;
private LayoutHelper mLayoutHelper;
private LayoutParams mLayoutParams;
private int mCount = 0;
public SubAdapter(Context context, LayoutHelper layoutHelper, int count) {
this(context, layoutHelper, count, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300));
}
public SubAdapter(Context context, LayoutHelper layoutHelper, int count, @NonNull LayoutParams layoutParams) {
this.mContext = context;
this.mLayoutHelper = layoutHelper;
this.mCount = count;
this.mLayoutParams = layoutParams;
}
@Override
public LayoutHelper onCreateLayoutHelper() {
return mLayoutHelper;
}
@Override
public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new MainViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item, parent, false));
}
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
// only vertical
holder.itemView.setLayoutParams(
new LayoutParams(mLayoutParams));
}
@Override
protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) {
((TextView) holder.itemView.findViewById(R.id.title)).setText(Integer.toString(offsetTotal));
}
@Override
public int getItemCount() {
return mCount;
}
}
static class MainViewHolder extends RecyclerView.ViewHolder {
public static volatile int existing = 0;
public static int createdTimes = 0;
public MainViewHolder(View itemView) {
super(itemView);
createdTimes++;
existing++;
}
@Override
protected void finalize() throws Throwable {
existing--;
super.finalize();
}
}
}
================================================
FILE: examples/src/main/res/drawable/border_bg.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp"/>
<stroke
android:width="2px"
android:color="#99000000"/>
</shape>
================================================
FILE: examples/src/main/res/drawable/item_background.xml
================================================
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/item_activated_color"
android:state_activated="true"/>
<item android:drawable="@color/item_pressed_color"
android:state_pressed="true"/>
<item android:drawable="@color/item_default_color"/>
</selector>
================================================
FILE: examples/src/main/res/layout/card_item.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/border_bg">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/item_background"
android:gravity="center"
android:textColor="#999999"
android:textSize="22sp"
android:textStyle="bold"/>
</android.support.v7.widget.CardView>
================================================
FILE: examples/src/main/res/layout/item.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/border_bg">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/item_background"
android:gravity="center"
android:textColor="#999999"
android:textSize="22sp"
android:textStyle="bold"/>
</FrameLayout>
================================================
FILE: examples/src/main/res/layout/main_activity.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#aaaaaa"
android:clipToPadding="true"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:requiresFadingEdge="none"
android:scrollbars="vertical"/>
</android.support.v4.widget.SwipeRefreshLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/first"
style="@style/IndicateText"/>
<TextView
android:id="@+id/last"
style="@style/IndicateText"/>
<TextView
android:id="@+id/count"
style="@style/IndicateText"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#33000000">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jump Position"/>
<EditText
android:id="@+id/position"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:numeric="integer"/>
<Button
android:id="@+id/jump"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Jump"/>
<TextView
android:id="@+id/total_offset"
style="@style/IndicateText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:paddingLeft="20dp"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
================================================
FILE: examples/src/main/res/layout/view_pager.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<android.support.v4.view.ViewPager
android:id="@+id/pager"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="280dp">
</android.support.v4.view.ViewPager>
================================================
FILE: examples/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<resources>
<color name="item_border_color">#666666</color>
<color name="item_default_color">#22EEEEEE</color>
<color name="item_pressed_color">#CCCCCC</color>
<color name="item_activated_color">#77CEEE</color>
</resources>
================================================
FILE: examples/src/main/res/values/strings.xml
================================================
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<resources>
<string name="app_name">Example for VirtualLayout</string>
</resources>
================================================
FILE: examples/src/main/res/values/styles.xml
================================================
<!--
~ MIT License
~
~ Copyright (c) 2016 Alibaba Group
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="IndicateText">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:padding">4dp</item>
<item name="android:gravity">center</item>
<item name="android:textColor">#ffffff</item>
<item name="android:background">#33000000</item>
</style>
</resources>
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#
# MIT License
#
# Copyright (c) 2016 Alibaba Group
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#Tue Nov 29 17:56:32 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
================================================
FILE: gradle.properties
================================================
#
# MIT License
#
# Copyright (c) 2016 Alibaba Group
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
GROUP=com.alibaba.android
ARTIFACT=vlayout
VERSION=1
VERSION_NAME=1.2.39
PACKAGING_TYPE=aar
useNewSupportLibrary=true
systemProp.compileSdkVersion=26
systemProp.targetSdkVersion=26
systemProp.buildToolsVersion=26.0.2
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: jcenterDeploy.gradle
================================================
/*
* MIT License
*
* Copyright (c) 2017 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.jfrog.artifactory'
version = libraryVersion
if (project.hasProperty('deployVersion')) {
version = project.getProperty('deployVersion')
}
if (project.hasProperty("android")) { // Android libraries
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
// task javadoc(type: Javadoc) {
// source = android.sourceSets.main.java.srcDirs
// classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
// android.libraryVariants.all { variant ->
// println variant.javaCompile.classpath.files
// if(variant.name == 'release') { //我们只需 release 的 javadoc
// task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
// // title = ''
// // description = ''
// source = variant.javaCompile.source
// classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())
// options {
// encoding "utf-8"
// links "http://docs.oracle.com/javase/7/docs/api/"
// linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
// }
// exclude '**/BuildConfig.java'
// exclude '**/R.java'
// }
// task("javadoc${variant.name.capitalize()}Jar", type: Jar, dependsOn: "generate${variant.name.capitalize()}Javadoc") {
// classifier = 'javadoc'
// from tasks.getByName("generate${variant.name.capitalize()}Javadoc").destinationDir
// }
// artifacts {
// archives tasks.getByName("javadoc${variant.name.capitalize()}Jar")
// }
// }
// }
//
// }
} else { // Java libraries
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
}
//task javadocJar(type: Jar, dependsOn: javadoc) {
// classifier = 'javadoc'
// from javadoc.destinationDir
//}
artifacts {
// archives javadocJar
archives sourcesJar
}
// Bintray
Properties properties = new Properties()
File localProperties = project.rootProject.file('local.properties')
if (localProperties.exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
if (!user) {
user = project.hasProperty('bintrayUser') ? project.getProperty('bintrayUser') : ""
}
if (!key) {
key = project.hasProperty('bintrayApikey') ? project.getProperty('bintrayApikey') : ""
}
configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = true
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
if (!passphrase) {
passphrase = project.hasProperty('bintrayGPG') ? project.getProperty('bintrayGPG') : ""
}
//Optional. The passphrase for GPG signing'
}
mavenCentralSync {
sync = true
user = properties.getProperty('bintray.oss.user')
if (!user) {
user = project.hasProperty('bintray.oss.user') ? project.getProperty('bintray.oss.user') : ""
}
password = properties.getProperty('bintray.oss.password')
if (!password) {
password = project.hasProperty('bintray.oss.password') ? project.getProperty('bintray.oss.password') : ""
}
close = '1'
}
}
}
}
artifactory {
contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver
resolve {
repository {
repoKey = 'libs-release'
}
}
publish {
repository {
repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
username = bintray.user
password = bintray.key
maven = true
}
defaults {
// the name is the same with that defined in bintray.configurations
publishConfigs('archives')
}
}
}
bintrayUpload.onlyIf {
!version.endsWith("-SNAPSHOT")
}
artifactoryPublish.onlyIf {
version.endsWith("-SNAPSHOT")
}
task deploy(dependsOn: ['install', 'bintrayUpload', 'artifactoryPublish']) << {
println "deploy ...."
}
================================================
FILE: jcenterInstall.gradle
================================================
/*
* MIT License
*
* Copyright (c) 2017 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
apply plugin: 'com.github.dcendents.android-maven'
group = GROUP
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact
// Add your description here
name libraryName
description libraryDescription
url siteUrl
// Set your license
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
================================================
FILE: settings.gradle
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
include ':vlayout'
include ':examples'
================================================
FILE: vlayout/.gitignore
================================================
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
.classpath
.project
.settings/
# Proguard folder generated by Eclipse
proguard/
#Log Files
*.log
# OS X
.DS_Store
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.ear
*.iml
# IDEA Files
.idea/
out/
# MAVEN COMPILE Files
target/
lint.xml
================================================
FILE: vlayout/DESIGN.md
================================================
# VirtualLayout 设计说明
# VirtualLayout Design Note
================================================
FILE: vlayout/build.gradle
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
apply plugin: 'com.android.library'
buildscript {
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://oss.jfrog.org/oss-snapshot-local/" }
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://oss.jfrog.org/oss-snapshot-local/" }
jcenter()
mavenLocal()
}
ext {
bintrayRepo = 'Tangram'
bintrayName = 'vlayout'
publishedGroupId = project.hasProperty('GROUP') ? GROUP : ''
libraryName = project.hasProperty('ARTIFACT') ? ARTIFACT : ''
artifact = project.hasProperty('ARTIFACT') ? ARTIFACT : ''
libraryDescription = 'Project vlayout is a powerfull LayoutManager extension for RecyclerView, it provides a group of layouts for RecyclerView. Make it able to handle a complicate situation when grid, list and other layouts in the same recyclerview.'
siteUrl = 'https://github.com/alibaba/vlayout'
gitUrl = 'https://github.com/alibaba/vlayout.git'
libraryVersion = project.hasProperty('VERSION_NAME') ? VERSION_NAME : ''
developerId = 'longerian'
developerName = 'longerian'
developerEmail = 'xlhongultimate@gmail.com'
licenseName = 'MIT'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
}
def VERSION = System.properties['version'] ?: '10'
def VERSION_NAME = System.properties['versionName'] ?: '0.1.0'
android {
compileSdkVersion Integer.parseInt(System.properties['compileSdkVersion'] ?: '22')
buildToolsVersion System.properties['buildToolsVersion']
defaultConfig {
minSdkVersion 14
targetSdkVersion Integer.parseInt(System.properties['targetSdkVersion'] ?: '14')
versionCode Integer.parseInt(VERSION ?: '10')
versionName VERSION_NAME
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// compile project(':extension')
if (project.hasProperty('useNewSupportLibrary')) {
compile 'com.android.support:recyclerview-v7:25.2.0@aar'
compile('com.android.support:support-v4:25.2.0@aar')
compile 'com.android.support:support-annotations:25.2.0'
compile 'com.android.support:support-compat:25.2.0'
compile 'com.android.support:support-core-ui:25.2.0'
} else {
compile 'com.android.support:recyclerview-v7:23.1.1@aar'
compile('com.android.support:support-v4:23.1.1@aar') {
exclude group: 'com.android.support', module: 'support-annotations'
}
compile 'com.android.support:support-annotations:23.1.1'
}
androidTestCompile "org.robolectric:robolectric:3.0"
}
File deployConfig = rootProject.file('deploy.gradle')
if (deployConfig.exists()) {
apply from: rootProject.file('deploy.gradle')
}
deployConfig = rootProject.file('jcenterInstall.gradle')
if (deployConfig.exists()) {
apply from: rootProject.file('jcenterInstall.gradle')
}
deployConfig = rootProject.file('jcenterDeploy.gradle')
if (deployConfig.exists()) {
apply from: rootProject.file('jcenterDeploy.gradle')
}
================================================
FILE: vlayout/jacoco.gradle
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.1.201405082137"
reportsDir = file("$buildDir/reports/jacoco")
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
android.testOptions.unitTests.all {
// configure the set of classes for JUnit tests
include 'com/alibaba/android/**/*Test.class'
//exclude '**/espresso/**/*.class'
// configure max heap size of the test JVM
maxHeapSize = "2048m"
}
def coverageSourceDirs = [
'../app/src/main/java'
]
task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") {
group = "Reporting"
description = "Generate Jacoco coverage reports"
classDirectories = fileTree(
dir: '../app/build/intermediates/classes/debug',
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files('../app/build/jacoco/testDebug.exec')
reports {
xml.enabled = false
html.enabled = true
}
}
================================================
FILE: vlayout/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/villadora/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keepattributes InnerClasses
-keep class android.support.v7.widget.RecyclerView$LayoutParams {
*;
}
-keep class android.support.v7.widget.RecyclerView$ViewHolder {
*;
}
-keep class android.support.v7.widget.ChildHelper {
*;
}
-keep class android.support.v7.widget.RecyclerView$LayoutManager {
*;
}
-keep class android.support.v7.widget.LinearLayoutManager {
void ensureLayoutState();
void resolveShouldLayoutReverse();
}
================================================
FILE: vlayout/src/androidTest/java/com/alibaba/android/vlayout/ViewHolderHelper.java
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.alibaba.android.vlayout;
import android.support.v7.widget.RecyclerView;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* Created by villadora on 16/2/24.
*/
public class ViewHolderHelper {
private static Field vhField = null;
public static void setField(RecyclerView.ViewHolder holder, String fieldName, Object value) {
try {
Field f = RecyclerView.LayoutParams.class.getDeclaredField(fieldName);
f.setAccessible(true);
f.set(holder, value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
public static RecyclerView.ViewHolder getViewHolder(RecyclerView.LayoutParams params) {
try {
if (vhField == null) {
vhField = RecyclerView.LayoutParams.class.getDeclaredField("mViewHolder");
vhField.setAccessible(true);
}
//vhField.set(params, holder);
return (RecyclerView.ViewHolder) vhField.get(params);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
private static Method vhSetFlags;
public static void addViewHolderFlag(RecyclerView.ViewHolder holder, int flag) {
try {
if (vhSetFlags == null) {
vhSetFlags = RecyclerView.ViewHolder.class.getDeclaredMethod("addFlags", int.class);
vhSetFlags.setAccessible(true);
}
vhSetFlags.invoke(holder, flag);
} catch (Exception e) {
}
}
}
================================================
FILE: vlayout/src/androidTest/java/com/alibaba/android/vlayout/VirtualLayoutManagerTest.java
================================================
/*
* MIT License
*
* Copyright (c) 2016 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.alibaba.android.vlayout;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Looper;
import android.support.v7.widget.RecyclerView;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static com.alibaba.android.vlayout.VirtualLayoutManager.HORIZONTAL;
import static com.alibaba.android.vlayout.VirtualLayoutManager.VERTICAL;
/**
* Created by villadora on 16/2/24.
*/
public class VirtualLayoutManagerTest extends ActivityInstrumentationTestCase2<Activity> {
private static final String TAG = "VLMTest";
private static final boolean DEBUG = false;
protected RecyclerView mRecyclerView;
protected Throwable mainThreadException;
protected WrappedLinearLayoutManager mLayoutManager;
private TestAdapter mTestAdapter;
public VirtualLayoutManagerTest() {
super("com.tmall.wireless.tangram", Activity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
public void testGetFirstLastChildrenTest() throws Throwable {
getFirstLastChildrenTest(new Config().orientation(VERTICAL));
}
public void getFirstLastChildrenTest(final Config config) throws Throwable {
setupByConfig(config, true);
Runnable viewInBoundsTest = new Runnable() {
@Override
public void run() {
VisibleChildren visibleChildren = mLayoutManager.traverseAndFindVisibleChildren();
final String boundsLog = mLayoutManager.getBoundsLog();
assertEquals(config + ":\nfirst visible child should match traversal result\n"
+ boundsLog, visibleChildren.firstVisiblePosition,
mLayoutManager.findFirstVisibleItemPosition()
);
assertEquals(
config + ":\nfirst fully visible child should match traversal result\n"
+ boundsLog, visibleChildren.firstFullyVisiblePosition,
mLayoutManager.findFirstCompletelyVisibleItemPosition()
);
assertEquals(config + ":\nlast visible child should match traversal result\n"
+ boundsLog, visibleChildren.lastVisiblePosition,
mLayoutManager.findLastVisibleItemPosition()
);
assertEquals(
config + ":\nlast fully visible child should match traversal result\n"
+ boundsLog, visibleChildren.lastFullyVisiblePosition,
mLayoutManager.findLastCompletelyVisibleItemPosition()
);
}
};
runTestOnUiThread(viewInBoundsTest);
// smooth scroll to end of the list and keep testing meanwhile. This will test pre-caching
// case
final int scrollPosition = config.mStackFromEnd ? 0 : mTestAdapter.getItemCount();
runTestOnUiThread(new Runnable() {
@Override
public void run() {
mRecyclerView.smoothScrollToPosition(scrollPosition);
}
});
while (mLayoutManager.isSmoothScrolling() ||
mRecyclerView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
runTestOnUiThread(viewInBoundsTest);
Thread.sleep(400);
}
// delete all items
mLayoutManager.expectLayouts(2);
mTestAdapter.deleteAndNotify(0, mTestAdapter.getItemCount());
mLayoutManager.waitForLayout(2);
// test empty case
runTestOnUiThread(viewInBoundsTest);
// set a new adapter with huge items to test full bounds check
mLayoutManager.expectLayouts(1);
final int totalSpace = mLayoutManager.mOrientationHelper.getTotalSpace();
final TestAdapter newAdapter = new TestAdapter(100) {
@Override
public void onBindViewHolder(TestViewHolder holder,
int position) {
super.onBindViewHolder(holder, position);
if (config.mOrientation == HORIZONTAL) {
holder.itemView.setMinimumWidth(totalSpace + 5);
} else {
holder.itemView.setMinimumHeight(totalSpace + 5);
}
}
};
runTestOnUiThread(new Runnable() {
@Override
public void run() {
mRecyclerView.setAdapter(newAdapter);
}
});
mLayoutManager.waitForLayout(2);
runTestOnUiThread(viewInBoundsTest);
}
void setupByConfig(Config config, boolean waitForFirstLayout) throws Throwable {
mRecyclerView = new RecyclerView(getActivity());
mRecyclerView.setHasFixedSize(true);
mTestAdapter = config.mTestAdapter == null ? new TestAdapter(config.mItemCount)
: config.mTestAdapter;
mRecyclerView.setAdapter(mTestAdapter);
mLayoutManager = new WrappedLinearLayoutManager(getActivity(), config.mOrientation,
config.mReverseLayout);
mLayoutManager.setStackFromEnd(config.mStackFromEnd);
mLayoutManager.setRecycleChildrenOnDetach(config.mRecycleChildrenOnDetach);
mRecyclerView.setLayoutManager(mLayoutManager);
if (waitForFirstLayout) {
waitForFirstLayout();
}
}
void postExceptionToInstrumentation(Throwable t) {
if (DEBUG) {
Log.e(TAG, "captured exception on main thread", t);
}
if (mainThreadException != null) {
Log.e(TAG, "receiving another main thread exception. dropping.", t);
} else {
mainThreadException = t;
}
if (mRecyclerView != null && mRecyclerView
.getLayoutManager() instanceof WrappedLinearLayoutManager) {
WrappedLinearLayoutManager lm = (WrappedLinearLayoutManager) mRecyclerView.getLayoutManager();
// finish all layouts so that we get the correct exception
while (lm.layoutLatch.getCount() > 0) {
lm.layoutLatch.countDown();
}
}
}
private void waitForFirstLayout() throws Throwable {
mLayoutManager.expectLayouts(1);
setRecyclerView(mRecyclerView);
mLayoutManager.waitForLayout(2);
}
public void setRecyclerView(final RecyclerView recyclerView) throws Throwable {
setRecyclerView(recyclerView, true);
}
public void setRecyclerView(final RecyclerView recyclerView, boolean assignDummyPool)
throws Throwable {
mRecyclerView = recyclerView;
if (assignDummyPool) {
RecyclerView.RecycledViewPool pool = new RecyclerView.RecycledViewPool() {
@Override
public RecyclerView.ViewHolder getRecycledView(int viewType) {
RecyclerView.ViewHolder viewHolder = super.getRecycledView(viewType);
if (viewHolder == null) {
return null;
}
ViewHolderHelper.addViewHolderFlag(viewHolder, 1); // RecyclerView.ViewHolder.FLAG_BOUND
ViewHolderHelper.setField(viewHolder, "mPosition", 200);
ViewHolderHelper.setField(viewHolder, "mOldPosition", 300);
ViewHolderHelper.setField(viewHolder, "mPreLayoutPosition", 500);
return viewHolder;
}
@Override
public void putRecycledView(RecyclerView.ViewHolder scrap) {
super.putRecycledView(scrap);
}
};
mRecyclerView.setRecycledViewPool(pool);
}
// mAdapterHelper = recyclerView.mAdapterHelper;
runTestOnUiThread(new Runnable() {
@Override
public void run() {
((ViewGroup) getActivity().findViewById(android.R.id.content)).addView(recyclerView);
}
});
}
class TestViewHolder extends RecyclerView.ViewHolder {
Item mBindedItem;
public TestViewHolder(View itemView) {
super(itemView);
itemView.setFocusable(true);
}
@Override
public String toString() {
return super.toString() + " item:" + mBindedItem;
}
}
static class Item {
final static AtomicInteger idCounter = new AtomicInteger(0);
final public int mId = idCounter.incrementAndGet();
int mAdapterIndex;
final String mText;
Item(int adapterIndex, String text) {
mAdapterIndex = adapterIndex;
mText = text;
}
@Override
public String toString() {
return "Item{" +
"mId=" + mId +
", originalIndex=" + mAdapterIndex +
", text='" + mText + '\'' +
'}';
}
}
class WrappedLinearLayoutManager extends VirtualLayoutManager {
CountDownLatch layoutLatch;
OnLayoutListener mOnLayoutListener;
public WrappedLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public void expectLayouts(int count) {
layoutLatch = new CountDownLatch(count);
}
public void waitForLayout(long timeout) throws InterruptedException {
waitForLayout(timeout, TimeUnit.SECONDS);
}
@Override
public void removeAndRecycleView(View child, RecyclerView.Recycler recycler) {
if (DEBUG) {
Log.d(TAG, "recycling view " + mRecyclerView.getChildViewHolder(child));
}
super.removeAndRecycleView(child, recycler);
}
@Override
public void removeAndRecycleViewAt(int index, RecyclerView.Recycler recycler) {
if (DEBUG) {
Log.d(TAG, "recycling view at" + mRecyclerView.getChildViewHolder(getChildAt(index)));
}
super.removeAndRecycleViewAt(index, recycler);
}
private void waitForLayout(long timeout, TimeUnit timeUnit) throws InterruptedException {
layoutLatch.await(timeout * (DEBUG ? 100 : 1), timeUnit);
assertEquals("all expected layouts should be executed at the expected time",
0, layoutLatch.getCount());
getInstrumentation().waitForIdleSync();
}
public String getBoundsLog() {
StringBuilder sb = new StringBuilder();
sb.append("view bounds:[start:").append(mOrientationHelper.getStartAfterPadding())
.append(",").append(" end").append(mOrientationHelper.getEndAfterPadding());
sb.append("\nchildren bounds\n");
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
sb.append("child (ind:").append(i).append(", pos:").append(getPosition(child))
.append("[").append("start:").append(
mOrientationHelper.getDecoratedStart(child)).append(", end:")
.append(mOrientationHelper.getDecoratedEnd(child)).append("]\n");
}
return sb.toString();
}
public void waitForAnimationsToEnd(int timeoutInSeconds) throws InterruptedException {
RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
if (itemAnimator == null) {
return;
}
final CountDownLatch latch = new CountDownLatch(1);
final boolean running = itemAnimator.isRunning(
new RecyclerView.ItemAnimator.ItemAnimatorFinishedListener() {
@Override
public void onAnimationsFinished() {
latch.countDown();
}
}
);
if (running) {
latch.await(timeoutInSeconds, TimeUnit.SECONDS);
}
}
public VisibleChildren traverseAndFindVisibleChildren() {
int childCount = getChildCount();
final VisibleChildren visibleChildren = new VisibleChildren();
final int start = mOrientationHelper.getStartAfterPadding();
final int end = mOrientationHelper.getEndAfterPadding();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
final int childStart = mOrientationHelper.getDecoratedStart(child);
final int childEnd = mOrientationHelper.getDecoratedEnd(child);
final boolean fullyVisible = childStart >= start && childEnd <= end;
final boolean hidden = childEnd <= start || childStart >= end;
if (hidden) {
continue;
}
final int position = getPosition(child);
if (fullyVisible) {
if (position < visibleChildren.firstFullyVisiblePosition ||
visibleChildren.firstFullyVisiblePosition == RecyclerView.NO_POSITION) {
visibleChildren.firstFullyVisiblePosition = position;
}
if (position > visibleChildren.lastFullyVisiblePosition) {
visibleChildren.lastFullyVisiblePosition = position;
}
}
if (position < visibleChildren.firstVisiblePosition ||
visibleChildren.firstVisiblePosition == RecyclerView.NO_POSITION) {
visibleChildren.firstVisiblePosition = position;
}
if (position > visibleChildren.lastVisiblePosition) {
visibleChildren.lastVisiblePosition = position;
}
}
return visibleChildren;
}
Rect getViewBounds(View view) {
if (getOrientation() == HORIZONTAL) {
return new Rect(
mOrientationHelper.getDecoratedStart(view),
mSecondaryOrientationHelper.getDecoratedStart(view),
mOrientationHelper.getDecoratedEnd(view),
mSecondaryOrientationHelper.getDecoratedEnd(view));
} else {
return new Rect(
mSecondaryOrientationHelper.getDecoratedStart(view),
mOrientationHelper.getDecoratedStart(view),
mSecondaryOrientationHelper.getDecoratedEnd(view),
mOrientationHelper.getDecoratedEnd(view));
}
}
Map<Item, Rect> collectChildCoordinates() throws Throwable {
final Map<Item, Rect> items = new LinkedHashMap<Item, Rect>();
runTestOnUiThread(new Runnable() {
@Override
public void run() {
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) child
.getLayoutParams();
TestViewHolder vh = (TestViewHolder) ViewHolderHelper.getViewHolder(lp);
items.put(vh.mBindedItem, getViewBounds(child));
}
}
});
return items;
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
if (mOnLayoutListener != null) {
mOnLayoutListener.before(recycler, state);
}
super.onLayoutChildren(recycler, state);
if (mOnLayoutListener != null) {
mOnLayoutListener.after(recycler, state);
}
} catch (Throwable t) {
postExceptionToInstrumentation(t);
}
layoutLatch.countDown();
}
}
static class OnLayoutListener {
void before(RecyclerView.Recycler recycler, RecyclerView.State state) {
}
void after(RecyclerView.Recycler recycler, RecyclerView.State state) {
}
}
static class VisibleChildren {
int firstVisiblePosition = RecyclerView.NO_POSITION;
int firstFullyVisiblePosition = RecyclerView.NO_POSITION;
int lastVisiblePosition = RecyclerView.NO_POSITION;
int lastFullyVisiblePosition = RecyclerView.NO_POSITION;
@Override
public String toString() {
return "VisibleChildren{" +
"firstVisiblePosition=" + firstVisiblePosition +
", firstFullyVisiblePosition=" + firstFullyVisiblePosition +
", lastVisiblePosition=" + lastVisiblePosition +
", lastFullyVisiblePosition=" + lastFullyVisiblePosition +
'}';
}
}
static class Config implements Cloneable {
private static final int DEFAULT_ITEM_COUNT = 100;
private boolean mStackFromEnd;
TestAdapter mTestAdapter = null;
int mOrientation = VERTICAL;
boolean mReverseLayout = false;
boolean mRecycleChildrenOnDetach = false;
int mItemCount = DEFAULT_ITEM_COUNT;
// TestAdapter mTestAdapter;
Config(int orientation, boolean reverseLayout, boolean stackFromEnd) {
mOrientation = orientation;
mReverseLayout = reverseLayout;
mStackFromEnd = stackFromEnd;
}
public Config() {
}
Config adapter(TestAdapter adapter) {
mTestAdapter = adapter;
return this;
}
Config recycleChildrenOnDetach(boolean recycleChildrenOnDetach) {
mRecycleChildrenOnDetach = recycleChildrenOnDetach;
return this;
}
Config orientation(int orientation) {
mOrientation = orientation;
return this;
}
Config stackFromBottom(boolean stackFromBottom) {
mStackFromEnd = stackFromBottom;
return this;
}
Config reverseLayout(boolean reverseLayout) {
mReverseLayout = reverseLayout;
return this;
}
public Config itemCount(int itemCount) {
mItemCount = itemCount;
return this;
}
// required by convention
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public String toString() {
return "Config{" +
"mStackFromEnd=" + mStackFromEnd +
", mOrientation=" + mOrientation +
", mReverseLayout=" + mReverseLayout +
", mRecycleChildrenOnDetach=" + mRecycleChildrenOnDetach +
", mItemCount=" + mItemCount +
'}';
}
}
class TestAdapter extends RecyclerView.Adapter<TestViewHolder> {
List<Item> mItems;
TestAdapter(int count) {
mItems = new ArrayList<Item>(count);
for (int i = 0; i < count; i++) {
mItems.add(new Item(i, "Item " + i));
}
}
@Override
public TestViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
return new TestViewHolder(new TextView(parent.getContext()));
}
@Override
public void onBindViewHolder(TestViewHolder holder, int position) {
final Item item = mItems.get(position);
((TextView) (holder.itemView)).setText(item.mText + "(" + item.mAdapterIndex + ")");
holder.mBindedItem = item;
}
public void deleteAndNotify(final int start, final int count) throws Throwable {
deleteAndNotify(new int[]{start, count});
}
/**
* Deletes items in the given ranges.
* <p>
* Note that each operation affects the one after so you should offset them properly.
* <p>
* For example, if adapter has 5 items (A,B,C,D,E), and then you call this method with
* <code>[1, 2],[2, 1]</code>, it will first delete items B,C and the new adapter will be
* A D E. Then it will delete 2,1 which means it will delete E.
*/
public void deleteAndNotify(final int[]... startCountTuples) throws Throwable {
for (int[] tuple : startCountTuples) {
tuple[1] = -tuple[1];
}
new AddRemoveRunnable(startCountTuples).runOnMainThread();
}
@Override
public long getItemId(int position) {
return hasStableIds() ? mItems.get(position).mId : super.getItemId(position);
}
public void offsetOriginalIndices(int start, int offset) {
for (int i = start; i < mItems.size(); i++) {
mItems.get(i).mAdapterIndex += offset;
}
}
/**
* @param start inclusive
* @param end exclusive
* @param offset
*/
public void offsetOriginalIndicesBetween(int start, int end, int offset) {
for (int i = start; i < end && i < mItems.size(); i++) {
mItems.get(i).mAdapterIndex += offset;
}
}
public void addAndNotify(final int start, final int count) throws Throwable {
addAndNotify(new int[]{start, count});
}
public void addAndNotify(final int[]... startCountTuples) throws Throwable {
new AddRemoveRunnable(startCountTuples).runOnMainThread();
}
public void dispatchDataSetChanged() throws Throwable {
runTestOnUiThread(new Runnable() {
@Override
gitextract_l0k2lwjr/
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README-ch.md
├── README.md
├── build.gradle
├── docs/
│ ├── ATTRIBUTES-ch.md
│ ├── ATTRIBUTES.md
│ └── VLayoutFAQ.md
├── examples/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── alibaba/
│ │ └── android/
│ │ └── vlayout/
│ │ └── ApplicationTest.java
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── alibaba/
│ │ └── android/
│ │ └── vlayout/
│ │ └── example/
│ │ ├── DebugActivity.java
│ │ ├── MainActivity.java
│ │ ├── OnePlusNLayoutActivity.java
│ │ ├── RootActivity.java
│ │ ├── TestActivity.java
│ │ └── VLayoutActivity.java
│ └── res/
│ ├── drawable/
│ │ ├── border_bg.xml
│ │ └── item_background.xml
│ ├── layout/
│ │ ├── card_item.xml
│ │ ├── item.xml
│ │ ├── main_activity.xml
│ │ └── view_pager.xml
│ └── values/
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── jcenterDeploy.gradle
├── jcenterInstall.gradle
├── settings.gradle
└── vlayout/
├── .gitignore
├── DESIGN.md
├── build.gradle
├── jacoco.gradle
├── proguard-rules.pro
└── src/
├── androidTest/
│ └── java/
│ └── com/
│ └── alibaba/
│ └── android/
│ └── vlayout/
│ ├── ViewHolderHelper.java
│ └── VirtualLayoutManagerTest.java
└── main/
├── AndroidManifest.xml
├── java/
│ └── com/
│ └── alibaba/
│ └── android/
│ └── vlayout/
│ ├── Cantor.java
│ ├── DelegateAdapter.java
│ ├── ExposeLinearLayoutManagerEx.java
│ ├── LayoutHelper.java
│ ├── LayoutHelperFinder.java
│ ├── LayoutManagerHelper.java
│ ├── LayoutView.java
│ ├── LayoutViewFactory.java
│ ├── MismatchChildCountException.java
│ ├── OrientationHelperEx.java
│ ├── Range.java
│ ├── RangeLayoutHelperFinder.java
│ ├── RecyclablePagerAdapter.java
│ ├── SortedList.java
│ ├── VirtualLayoutAdapter.java
│ ├── VirtualLayoutManager.java
│ ├── extend/
│ │ ├── InnerRecycledViewPool.java
│ │ ├── LayoutManagerCanScrollListener.java
│ │ ├── PerformanceMonitor.java
│ │ ├── ViewLifeCycleHelper.java
│ │ └── ViewLifeCycleListener.java
│ └── layout/
│ ├── AbstractFullFillLayoutHelper.java
│ ├── BaseLayoutHelper.java
│ ├── ColumnLayoutHelper.java
│ ├── DefaultLayoutHelper.java
│ ├── FixAreaAdjuster.java
│ ├── FixAreaLayoutHelper.java
│ ├── FixLayoutHelper.java
│ ├── FloatLayoutHelper.java
│ ├── GridLayoutHelper.java
│ ├── LayoutChunkResult.java
│ ├── LinearLayoutHelper.java
│ ├── MarginLayoutHelper.java
│ ├── OnePlusNLayoutHelper.java
│ ├── OnePlusNLayoutHelperEx.java
│ ├── RangeGridLayoutHelper.java
│ ├── RangeStyle.java
│ ├── ScrollFixLayoutHelper.java
│ ├── SingleLayoutHelper.java
│ ├── StaggeredGridLayoutHelper.java
│ └── StickyLayoutHelper.java
└── res/
└── values/
└── ids.xml
SYMBOL INDEX (1154 symbols across 50 files)
FILE: examples/src/androidTest/java/com/alibaba/android/vlayout/ApplicationTest.java
class ApplicationTest (line 33) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 34) | public ApplicationTest() {
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/DebugActivity.java
class DebugActivity (line 33) | public class DebugActivity extends Activity {
method onCreate (line 35) | @Override
class SubAdapter (line 54) | private static class SubAdapter extends DelegateAdapter.Adapter<SubVie...
method SubAdapter (line 59) | private SubAdapter(LayoutHelper layoutHelper, int itemCount) {
method onCreateLayoutHelper (line 64) | @Override
method onCreateViewHolder (line 69) | @Override
method onBindViewHolder (line 75) | @Override
method onBindViewHolderWithOffset (line 80) | @Override
method getItemCount (line 87) | @Override
class SubViewHolder (line 94) | private static class SubViewHolder extends RecyclerView.ViewHolder {
method SubViewHolder (line 99) | public SubViewHolder(View itemView) {
method setText (line 105) | public void setText(String title) {
method finalize (line 109) | @Override
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/MainActivity.java
class MainActivity (line 51) | public class MainActivity extends Activity {
method onCreate (line 53) | @Override
class MainViewHolder (line 142) | static class MainViewHolder extends RecyclerView.ViewHolder {
method MainViewHolder (line 144) | public MainViewHolder(View itemView) {
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/OnePlusNLayoutActivity.java
class OnePlusNLayoutActivity (line 63) | public class OnePlusNLayoutActivity extends Activity {
method onCreate (line 88) | @Override
class PagerAdapter (line 369) | static class PagerAdapter extends RecyclablePagerAdapter<MainViewHolde...
method PagerAdapter (line 370) | public PagerAdapter(SubAdapter adapter, RecyclerView.RecycledViewPoo...
method getCount (line 374) | @Override
method onBindViewHolder (line 379) | @Override
method getItemViewType (line 387) | @Override
class SubAdapter (line 394) | static class SubAdapter extends DelegateAdapter.Adapter<MainViewHolder> {
method SubAdapter (line 405) | public SubAdapter(Context context, LayoutHelper layoutHelper, int co...
method SubAdapter (line 409) | public SubAdapter(Context context, LayoutHelper layoutHelper, int co...
method onCreateLayoutHelper (line 416) | @Override
method onCreateViewHolder (line 421) | @Override
method onBindViewHolder (line 426) | @Override
method onBindViewHolderWithOffset (line 434) | @Override
method getItemCount (line 439) | @Override
class MainViewHolder (line 446) | static class MainViewHolder extends RecyclerView.ViewHolder {
method MainViewHolder (line 451) | public MainViewHolder(View itemView) {
method finalize (line 457) | @Override
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/RootActivity.java
class RootActivity (line 14) | public class RootActivity extends ListActivity {
method onCreate (line 32) | @Override
method onListItemClick (line 38) | @Override
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/TestActivity.java
class TestActivity (line 44) | public class TestActivity extends Activity {
method onCreate (line 46) | @Override
class MainViewHolder (line 119) | static class MainViewHolder extends RecyclerView.ViewHolder {
method MainViewHolder (line 121) | public MainViewHolder(View itemView) {
FILE: examples/src/main/java/com/alibaba/android/vlayout/example/VLayoutActivity.java
class VLayoutActivity (line 77) | public class VLayoutActivity extends Activity {
method onCreate (line 110) | @Override
method setListenerToRootView (line 734) | public void setListenerToRootView() {
class FooterAdapter (line 755) | static class FooterAdapter extends DelegateAdapter.Adapter<MainViewHol...
method FooterAdapter (line 768) | public FooterAdapter(RecyclerView recyclerView, Context context, Lay...
method FooterAdapter (line 772) | public FooterAdapter(RecyclerView recyclerView, Context context, Lay...
method getItemViewType (line 780) | @Override
method onCreateLayoutHelper (line 785) | @Override
method onCreateViewHolder (line 790) | @Override
method onBindViewHolder (line 795) | @Override
method onBindViewHolderWithOffset (line 807) | @Override
method getItemCount (line 812) | @Override
method toggleFoot (line 817) | public void toggleFoot() {
class PagerAdapter (line 833) | static class PagerAdapter extends RecyclablePagerAdapter<MainViewHolde...
method PagerAdapter (line 834) | public PagerAdapter(SubAdapter adapter, RecyclerView.RecycledViewPoo...
method getCount (line 838) | @Override
method onBindViewHolder (line 843) | @Override
method getItemViewType (line 851) | @Override
class SubAdapter (line 858) | static class SubAdapter extends DelegateAdapter.Adapter<MainViewHolder> {
method SubAdapter (line 869) | public SubAdapter(Context context, LayoutHelper layoutHelper, int co...
method SubAdapter (line 873) | public SubAdapter(Context context, LayoutHelper layoutHelper, int co...
method onCreateLayoutHelper (line 880) | @Override
method onCreateViewHolder (line 885) | @Override
method onBindViewHolder (line 890) | @Override
method onBindViewHolderWithOffset (line 898) | @Override
method getItemCount (line 903) | @Override
class MainViewHolder (line 910) | static class MainViewHolder extends RecyclerView.ViewHolder {
method MainViewHolder (line 915) | public MainViewHolder(View itemView) {
method finalize (line 921) | @Override
FILE: vlayout/src/androidTest/java/com/alibaba/android/vlayout/ViewHolderHelper.java
class ViewHolderHelper (line 35) | public class ViewHolderHelper {
method setField (line 40) | public static void setField(RecyclerView.ViewHolder holder, String fie...
method getViewHolder (line 53) | public static RecyclerView.ViewHolder getViewHolder(RecyclerView.Layou...
method addViewHolderFlag (line 75) | public static void addViewHolderFlag(RecyclerView.ViewHolder holder, i...
FILE: vlayout/src/androidTest/java/com/alibaba/android/vlayout/VirtualLayoutManagerTest.java
class VirtualLayoutManagerTest (line 52) | public class VirtualLayoutManagerTest extends ActivityInstrumentationTes...
method VirtualLayoutManagerTest (line 66) | public VirtualLayoutManagerTest() {
method setUp (line 71) | @Override
method testGetFirstLastChildrenTest (line 77) | public void testGetFirstLastChildrenTest() throws Throwable {
method getFirstLastChildrenTest (line 82) | public void getFirstLastChildrenTest(final Config config) throws Throw...
method setupByConfig (line 157) | void setupByConfig(Config config, boolean waitForFirstLayout) throws T...
method postExceptionToInstrumentation (line 174) | void postExceptionToInstrumentation(Throwable t) {
method waitForFirstLayout (line 195) | private void waitForFirstLayout() throws Throwable {
method setRecyclerView (line 202) | public void setRecyclerView(final RecyclerView recyclerView) throws Th...
method setRecyclerView (line 206) | public void setRecyclerView(final RecyclerView recyclerView, boolean a...
class TestViewHolder (line 242) | class TestViewHolder extends RecyclerView.ViewHolder {
method TestViewHolder (line 246) | public TestViewHolder(View itemView) {
method toString (line 251) | @Override
class Item (line 257) | static class Item {
method Item (line 265) | Item(int adapterIndex, String text) {
method toString (line 270) | @Override
class WrappedLinearLayoutManager (line 281) | class WrappedLinearLayoutManager extends VirtualLayoutManager {
method WrappedLinearLayoutManager (line 287) | public WrappedLinearLayoutManager(Context context, int orientation, ...
method expectLayouts (line 291) | public void expectLayouts(int count) {
method waitForLayout (line 295) | public void waitForLayout(long timeout) throws InterruptedException {
method removeAndRecycleView (line 299) | @Override
method removeAndRecycleViewAt (line 307) | @Override
method waitForLayout (line 315) | private void waitForLayout(long timeout, TimeUnit timeUnit) throws I...
method getBoundsLog (line 322) | public String getBoundsLog() {
method waitForAnimationsToEnd (line 338) | public void waitForAnimationsToEnd(int timeoutInSeconds) throws Inte...
method traverseAndFindVisibleChildren (line 357) | public VisibleChildren traverseAndFindVisibleChildren() {
method getViewBounds (line 396) | Rect getViewBounds(View view) {
method collectChildCoordinates (line 413) | Map<Item, Rect> collectChildCoordinates() throws Throwable {
method onLayoutChildren (line 431) | @Override
class OnLayoutListener (line 451) | static class OnLayoutListener {
method before (line 452) | void before(RecyclerView.Recycler recycler, RecyclerView.State state) {
method after (line 455) | void after(RecyclerView.Recycler recycler, RecyclerView.State state) {
class VisibleChildren (line 460) | static class VisibleChildren {
method toString (line 470) | @Override
class Config (line 482) | static class Config implements Cloneable {
method Config (line 500) | Config(int orientation, boolean reverseLayout, boolean stackFromEnd) {
method Config (line 506) | public Config() {
method adapter (line 511) | Config adapter(TestAdapter adapter) {
method recycleChildrenOnDetach (line 517) | Config recycleChildrenOnDetach(boolean recycleChildrenOnDetach) {
method orientation (line 522) | Config orientation(int orientation) {
method stackFromBottom (line 527) | Config stackFromBottom(boolean stackFromBottom) {
method reverseLayout (line 532) | Config reverseLayout(boolean reverseLayout) {
method itemCount (line 537) | public Config itemCount(int itemCount) {
method clone (line 543) | @Override
method toString (line 548) | @Override
class TestAdapter (line 561) | class TestAdapter extends RecyclerView.Adapter<TestViewHolder> {
method TestAdapter (line 565) | TestAdapter(int count) {
method onCreateViewHolder (line 572) | @Override
method onBindViewHolder (line 578) | @Override
method deleteAndNotify (line 585) | public void deleteAndNotify(final int start, final int count) throws...
method deleteAndNotify (line 598) | public void deleteAndNotify(final int[]... startCountTuples) throws ...
method getItemId (line 605) | @Override
method offsetOriginalIndices (line 610) | public void offsetOriginalIndices(int start, int offset) {
method offsetOriginalIndicesBetween (line 621) | public void offsetOriginalIndicesBetween(int start, int end, int off...
method addAndNotify (line 627) | public void addAndNotify(final int start, final int count) throws Th...
method addAndNotify (line 631) | public void addAndNotify(final int[]... startCountTuples) throws Thr...
method dispatchDataSetChanged (line 635) | public void dispatchDataSetChanged() throws Throwable {
method changeAndNotify (line 644) | public void changeAndNotify(final int start, final int count) throws...
method changePositionsAndNotify (line 653) | public void changePositionsAndNotify(final int... positions) throws ...
method addDeleteAndNotify (line 670) | public void addDeleteAndNotify(final int[]... startCountTuples) thro...
method getItemCount (line 674) | @Override
method moveItems (line 679) | public void moveItems(boolean notifyChange, int[]... fromToTuples) t...
method moveItem (line 689) | public void moveItem(final int from, final int to, final boolean not...
class AddRemoveRunnable (line 706) | private class AddRemoveRunnable implements Runnable {
method AddRemoveRunnable (line 709) | public AddRemoveRunnable(int[][] startCountTuples) {
method runOnMainThread (line 713) | public void runOnMainThread() throws Throwable {
method run (line 721) | @Override
method add (line 732) | private void add(int[] tuple) {
method delete (line 741) | private void delete(int[] tuple) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/Cantor.java
class Cantor (line 10) | public class Cantor {
method getCantor (line 17) | public static long getCantor(long k1, long k2) {
method reverseCantor (line 26) | public static void reverseCantor(long cantor, long[] result) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/DelegateAdapter.java
class DelegateAdapter (line 52) | public class DelegateAdapter extends VirtualLayoutAdapter<RecyclerView.V...
method DelegateAdapter (line 77) | public DelegateAdapter(VirtualLayoutManager layoutManager) {
method DelegateAdapter (line 85) | public DelegateAdapter(VirtualLayoutManager layoutManager, boolean has...
method DelegateAdapter (line 94) | DelegateAdapter(VirtualLayoutManager layoutManager, boolean hasConsist...
method onCreateViewHolder (line 104) | @Override
method onBindViewHolder (line 131) | @SuppressWarnings("unchecked")
method onBindViewHolder (line 143) | @SuppressWarnings("unchecked")
method getItemCount (line 155) | @Override
method getItemViewType (line 166) | @Override
method getItemId (line 192) | @Override
method setHasStableIds (line 213) | @Override
method onViewRecycled (line 218) | @SuppressWarnings("unchecked")
method onViewAttachedToWindow (line 233) | @SuppressWarnings("unchecked")
method onViewDetachedFromWindow (line 246) | @SuppressWarnings("unchecked")
method setLayoutHelpers (line 263) | @Deprecated
method setAdapters (line 270) | public void setAdapters(@Nullable List<Adapter> adapters) {
method addAdapters (line 310) | public void addAdapters(int position, @Nullable List<Adapter> adapters) {
method addAdapters (line 341) | public void addAdapters(@Nullable List<Adapter> adapters) {
method addAdapter (line 345) | public void addAdapter(int position, @Nullable Adapter adapter) {
method addAdapter (line 349) | public void addAdapter(@Nullable Adapter adapter) {
method removeFirstAdapter (line 353) | public void removeFirstAdapter() {
method removeLastAdapter (line 360) | public void removeLastAdapter() {
method removeAdapter (line 367) | public void removeAdapter(int adapterIndex) {
method removeAdapter (line 374) | public void removeAdapter(@Nullable Adapter targetAdapter) {
method removeAdapters (line 381) | public void removeAdapters(@Nullable List<Adapter> targetAdapters) {
method clear (line 412) | public void clear() {
method getAdaptersCount (line 430) | public int getAdaptersCount() {
method findOffsetPosition (line 438) | public int findOffsetPosition(int absoultePosition) {
method findAdapterByPosition (line 447) | @Nullable
method findAdapterPositionByIndex (line 478) | public int findAdapterPositionByIndex(int index) {
method findAdapterByIndex (line 483) | public Adapter findAdapterByIndex(int index) {
class AdapterDataObserver (line 488) | protected class AdapterDataObserver extends RecyclerView.AdapterDataOb...
method AdapterDataObserver (line 493) | public AdapterDataObserver(int startPosition, int index) {
method updateStartPositionAndIndex (line 498) | public void updateStartPositionAndIndex(int startPosition, int index) {
method getStartPosition (line 503) | public int getStartPosition() {
method getIndex (line 507) | public int getIndex() {
method updateLayoutHelper (line 511) | private boolean updateLayoutHelper() {
method onChanged (line 544) | @Override
method onItemRangeRemoved (line 552) | @Override
method onItemRangeInserted (line 560) | @Override
method onItemRangeMoved (line 568) | @Override
method onItemRangeChanged (line 576) | @Override
method onItemRangeChanged (line 584) | @Override
method simpleAdapter (line 599) | public static Adapter<? extends RecyclerView.ViewHolder> simpleAdapter...
method simpleAdapter (line 610) | public static Adapter<? extends RecyclerView.ViewHolder> simpleAdapter...
class SimpleViewHolder (line 615) | static class SimpleViewHolder extends RecyclerView.ViewHolder {
method SimpleViewHolder (line 617) | public SimpleViewHolder(View view) {
class SimpleViewAdapter (line 622) | static class SimpleViewAdapter extends Adapter<RecyclerView.ViewHolder> {
method SimpleViewAdapter (line 628) | public SimpleViewAdapter(@NonNull View view, @NonNull LayoutHelper l...
method SimpleViewAdapter (line 633) | public SimpleViewAdapter(@NonNull View view) {
method onCreateLayoutHelper (line 637) | @Override
method onCreateViewHolder (line 642) | @Override
method onBindViewHolder (line 647) | @Override
method getItemCount (line 652) | @Override
class Adapter (line 659) | public static abstract class Adapter<VH extends RecyclerView.ViewHolde...
method onCreateLayoutHelper (line 660) | public abstract LayoutHelper onCreateLayoutHelper();
method onBindViewHolderWithOffset (line 662) | protected void onBindViewHolderWithOffset(VH holder, int position, i...
method onBindViewHolderWithOffset (line 666) | protected void onBindViewHolderWithOffset(VH holder, int position, i...
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/ExposeLinearLayoutManagerEx.java
class ExposeLinearLayoutManagerEx (line 59) | class ExposeLinearLayoutManagerEx extends LinearLayoutManager {
method ExposeLinearLayoutManagerEx (line 139) | public ExposeLinearLayoutManagerEx(Context context) {
method ExposeLinearLayoutManagerEx (line 150) | public ExposeLinearLayoutManagerEx(Context context, int orientation, b...
method onSaveInstanceState (line 183) | @Override
method onRestoreInstanceState (line 209) | @Override
method setOrientation (line 228) | public void setOrientation(int orientation) {
method setRecycleOffset (line 233) | public void setRecycleOffset(int recycleOffset) {
method myResolveShouldLayoutReverse (line 242) | private void myResolveShouldLayoutReverse() {
method computeScrollVectorForPosition (line 252) | public PointF computeScrollVectorForPosition(int targetPosition) {
method onLayoutChildren (line 268) | @Override
method onAnchorReady (line 421) | public void onAnchorReady(RecyclerView.State state, AnchorInfo anchorI...
method onAttachedToWindow (line 427) | @Override
method onDetachedFromWindow (line 433) | @Override
method findFirstVisibleItemPosition (line 439) | @Override
method findLastVisibleItemPosition (line 446) | @Override
method myFindReferenceChildClosestToEnd (line 461) | private View myFindReferenceChildClosestToEnd(RecyclerView.State state) {
method myFindReferenceChildClosestToStart (line 465) | private View myFindReferenceChildClosestToStart(RecyclerView.State sta...
method myFindFirstReferenceChild (line 470) | private View myFindFirstReferenceChild(int itemCount) {
method myFindLastReferenceChild (line 474) | private View myFindLastReferenceChild(int itemCount) {
method findReferenceChildInternal (line 479) | private View findReferenceChildInternal(int start, int end, int itemCo...
method layoutForPredictiveAnimationsExpose (line 513) | private void layoutForPredictiveAnimationsExpose(RecyclerView.Recycler...
method updateAnchorInfoForLayoutExpose (line 568) | private void updateAnchorInfoForLayoutExpose(RecyclerView.State state,...
method updateAnchorFromChildrenExpose (line 595) | private boolean updateAnchorFromChildrenExpose(RecyclerView.State stat...
method updateAnchorFromPendingDataExpose (line 643) | private boolean updateAnchorFromPendingDataExpose(RecyclerView.State s...
method fixLayoutEndGapExpose (line 727) | private int fixLayoutEndGapExpose(int endOffset, RecyclerView.Recycler...
method fixLayoutStartGapExpose (line 752) | private int fixLayoutStartGapExpose(int startOffset, RecyclerView.Recy...
method updateLayoutStateToFillEndExpose (line 774) | private void updateLayoutStateToFillEndExpose(AnchorInfo anchorInfo) {
method updateLayoutStateToFillEndExpose (line 778) | private void updateLayoutStateToFillEndExpose(int itemPosition, int of...
method updateLayoutStateToFillStartExpose (line 788) | private void updateLayoutStateToFillStartExpose(AnchorInfo anchorInfo) {
method updateLayoutStateToFillStartExpose (line 792) | private void updateLayoutStateToFillStartExpose(int itemPosition, int ...
method ensureLayoutStateExpose (line 805) | protected void ensureLayoutStateExpose() {
method scrollToPosition (line 837) | @Override
method scrollToPositionWithOffset (line 867) | public void scrollToPositionWithOffset(int position, int offset) {
method updateLayoutStateExpose (line 876) | protected void updateLayoutStateExpose(int layoutDirection, int requir...
method computeAlignOffset (line 919) | protected int computeAlignOffset(View child, boolean isLayoutEnd, bool...
method computeAlignOffset (line 930) | protected int computeAlignOffset(int position, boolean isLayoutEnd, bo...
method isEnableMarginOverLap (line 934) | public boolean isEnableMarginOverLap() {
method scrollHorizontallyBy (line 941) | @Override
method scrollVerticallyBy (line 953) | @Override
method scrollInternalBy (line 970) | protected int scrollInternalBy(int dy, RecyclerView.Recycler recycler,...
method assertNotInLayoutOrScroll (line 1002) | @Override
method recycleChildren (line 1015) | protected void recycleChildren(RecyclerView.Recycler recycler, int sta...
method recycleViewsFromStartExpose (line 1042) | private void recycleViewsFromStartExpose(RecyclerView.Recycler recycle...
method recycleViewsFromEndExpose (line 1081) | private void recycleViewsFromEndExpose(RecyclerView.Recycler recycler,...
method recycleByLayoutStateExpose (line 1122) | private void recycleByLayoutStateExpose(RecyclerView.Recycler recycler...
method fill (line 1147) | protected int fill(RecyclerView.Recycler recycler, LayoutState layoutS...
method layoutChunk (line 1196) | protected void layoutChunk(RecyclerView.Recycler recycler, RecyclerVie...
method convertFocusDirectionToLayoutDirectionExpose (line 1283) | private int convertFocusDirectionToLayoutDirectionExpose(int focusDire...
method getChildClosestToStartExpose (line 1317) | private View getChildClosestToStartExpose() {
method getChildClosestToEndExpose (line 1327) | private View getChildClosestToEndExpose() {
method onFocusSearchFailed (line 1331) | @Override
method logChildren (line 1382) | private void logChildren() {
method validateChildOrderExpose (line 1402) | private void validateChildOrderExpose() {
method supportsPredictiveItemAnimations (line 1442) | @Override
method addHiddenView (line 1450) | protected void addHiddenView(View view, boolean head) {
method hideView (line 1456) | protected void hideView(View view) {
method showView (line 1460) | protected void showView(View view) {
method findHiddenView (line 1464) | protected View findHiddenView(int position) {
method isHidden (line 1468) | protected boolean isHidden(View view) {
method isViewHolderUpdated (line 1479) | protected static boolean isViewHolderUpdated(RecyclerView.ViewHolder h...
method attachViewHolder (line 1483) | protected static void attachViewHolder(RecyclerView.LayoutParams param...
class LayoutState (line 1515) | public static class LayoutState {
method LayoutState (line 1600) | public LayoutState() {
method hasMore (line 1614) | public boolean hasMore(RecyclerView.State state) {
method next (line 1624) | public View next(RecyclerView.Recycler recycler) {
method nextFromLimitedList (line 1640) | @SuppressLint("LongLogTag")
method log (line 1683) | @SuppressLint("LongLogTag")
class AnchorInfo (line 1693) | protected class AnchorInfo {
method reset (line 1698) | void reset() {
method assignCoordinateFromPadding (line 1708) | void assignCoordinateFromPadding() {
method toString (line 1714) | @Override
method assignFromViewIfValid (line 1727) | public boolean assignFromViewIfValid(View child, RecyclerView.State ...
method assignFromView (line 1737) | public void assignFromView(View child) {
class ViewHolderWrapper (line 1761) | static class ViewHolderWrapper {
method setFlags (line 1796) | public static void setFlags(RecyclerView.ViewHolder viewHolder, int ...
method ViewHolderWrapper (line 1806) | public ViewHolderWrapper(RecyclerView.ViewHolder holder) {
method isInvalid (line 1811) | boolean isInvalid() {
method isRemoved (line 1823) | boolean isRemoved() {
method isChanged (line 1835) | boolean isChanged() {
method setFlags (line 1847) | void setFlags(int flags, int mask) {
method requireUpdated (line 1858) | public boolean requireUpdated() {
class ChildHelperWrapper (line 1865) | class ChildHelperWrapper {
method ensureChildHelper (line 1891) | void ensureChildHelper() {
method ChildHelperWrapper (line 1927) | ChildHelperWrapper(RecyclerView.LayoutManager layoutManager) {
method hide (line 1938) | void hide(View view) {
method show (line 1950) | void show(View view) {
method findHiddenNonRemovedView (line 1963) | View findHiddenNonRemovedView(int position, int type) {
method isHidden (line 1982) | boolean isHidden(View view) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/LayoutHelper.java
class LayoutHelper (line 49) | public abstract class LayoutHelper {
method isOutOfRange (line 69) | public boolean isOutOfRange(int position) {
method setRange (line 83) | public void setRange(int start, int end) {
method onRangeChange (line 113) | public void onRangeChange(final int start, final int end) {
method getRange (line 122) | @NonNull
method checkAnchorInfo (line 135) | public void checkAnchorInfo(RecyclerView.State state, VirtualLayoutMan...
method onScrollStateChanged (line 146) | public void onScrollStateChanged(int state, int startPosition, int end...
method onOffsetChildrenHorizontal (line 157) | public void onOffsetChildrenHorizontal(int dx, LayoutManagerHelper hel...
method onOffsetChildrenVertical (line 167) | public void onOffsetChildrenVertical(int dy, LayoutManagerHelper helpe...
method getZIndex (line 176) | public int getZIndex() {
method setZIndex (line 185) | public void setZIndex(int zIndex) {
method getFixedView (line 194) | @Nullable
method getOffFlowViews (line 208) | @NonNull
method isRecyclable (line 223) | public boolean isRecyclable(int childPos, int startIndex, int endIndex...
method getItemCount (line 232) | public abstract int getItemCount();
method setItemCount (line 239) | public abstract void setItemCount(int itemCount);
method doLayout (line 241) | public abstract void doLayout(RecyclerView.Recycler recycler, Recycler...
method onRefreshLayout (line 245) | public void onRefreshLayout(RecyclerView.State state, VirtualLayoutMan...
method beforeLayout (line 256) | public abstract void beforeLayout(RecyclerView.Recycler recycler, Recy...
method afterLayout (line 269) | public abstract void afterLayout(RecyclerView.Recycler recycler, Recyc...
method adjustLayout (line 279) | public abstract void adjustLayout(int startPosition, int endPosition, ...
method onItemsChanged (line 281) | public void onItemsChanged(LayoutManagerHelper helper) {
method clear (line 290) | public abstract void clear(LayoutManagerHelper helper);
method requireLayoutView (line 297) | public abstract boolean requireLayoutView();
method bindLayoutView (line 304) | public abstract void bindLayoutView(View layoutView);
method isFixLayout (line 306) | public abstract boolean isFixLayout();
method computeAlignOffset (line 318) | public abstract int computeAlignOffset(int offset, boolean isLayoutEnd...
method computeMarginStart (line 321) | public abstract int computeMarginStart(int offset, boolean isLayoutEnd...
method computeMarginEnd (line 324) | public abstract int computeMarginEnd(int offset, boolean isLayoutEnd, ...
method computePaddingStart (line 327) | public abstract int computePaddingStart(int offset, boolean isLayoutEn...
method computePaddingEnd (line 330) | public abstract int computePaddingEnd(int offset, boolean isLayoutEnd,...
method onSaveState (line 333) | public void onSaveState(final Bundle bundle) {
method onRestoreInstanceState (line 337) | public void onRestoreInstanceState(final Bundle bundle) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/LayoutHelperFinder.java
class LayoutHelperFinder (line 35) | public abstract class LayoutHelperFinder {
method setLayouts (line 40) | abstract void setLayouts(@Nullable List<LayoutHelper> layouts);
method getLayoutHelper (line 48) | @Nullable
method getLayoutHelpers (line 56) | @NonNull
method reverse (line 64) | protected abstract List<LayoutHelper> reverse();
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/LayoutManagerHelper.java
type LayoutManagerHelper (line 35) | public interface LayoutManagerHelper {
method generateLayoutView (line 47) | View generateLayoutView();
method getChildCount (line 54) | int getChildCount();
method getChildAt (line 62) | @Nullable
method addChildView (line 71) | void addChildView(View view, int index);
method addChildView (line 80) | void addChildView(VirtualLayoutManager.LayoutStateWrapper layoutState,...
method addChildView (line 88) | void addChildView(VirtualLayoutManager.LayoutStateWrapper layoutState,...
method removeChildView (line 95) | void removeChildView(View view);
method isViewHolderUpdated (line 103) | boolean isViewHolderUpdated(View view);
method addOffFlowView (line 112) | void addOffFlowView(View view, boolean head);
method addBackgroundView (line 121) | void addBackgroundView(View view, boolean head);
method addFixedView (line 130) | void addFixedView(View view);
method hideView (line 138) | void hideView(View view);
method showView (line 145) | void showView(View view);
method getChildViewHolder (line 153) | RecyclerView.ViewHolder getChildViewHolder(View child);
method getRecyclerView (line 160) | RecyclerView getRecyclerView();
method findViewByPosition (line 168) | @Nullable
method getMainOrientationHelper (line 181) | OrientationHelperEx getMainOrientationHelper();
method getSecondaryOrientationHelper (line 188) | OrientationHelperEx getSecondaryOrientationHelper();
method measureChild (line 197) | void measureChild(View view, int widthSpec, int heightSpec);
method measureChildWithMargins (line 206) | void measureChildWithMargins(View child, int widthUsed, int heightUsed);
method layoutChildWithMargins (line 218) | void layoutChildWithMargins(View view, int left, int top, int right, i...
method layoutChild (line 229) | void layoutChild(View view, int left, int top, int right, int bottom);
method getChildMeasureSpec (line 239) | int getChildMeasureSpec(int parentSize, int size, boolean canScroll);
method getPosition (line 251) | int getPosition(View view);
method getOrientation (line 253) | int getOrientation();
method getPaddingTop (line 255) | int getPaddingTop();
method getPaddingBottom (line 257) | int getPaddingBottom();
method getPaddingRight (line 259) | int getPaddingRight();
method getPaddingLeft (line 261) | int getPaddingLeft();
method getContentWidth (line 263) | int getContentWidth();
method getContentHeight (line 265) | int getContentHeight();
method isDoLayoutRTL (line 267) | boolean isDoLayoutRTL();
method getReverseLayout (line 269) | boolean getReverseLayout();
method recycleView (line 276) | void recycleView(View child);
method findLayoutHelperByPosition (line 283) | LayoutHelper findLayoutHelperByPosition(int position);
method findFirstVisibleItemPosition (line 289) | int findFirstVisibleItemPosition();
method findLastVisibleItemPosition (line 296) | int findLastVisibleItemPosition();
method isEnableMarginOverLap (line 301) | boolean isEnableMarginOverLap();
method getDecoratedLeft (line 303) | int getDecoratedLeft(View child);
method getDecoratedTop (line 305) | int getDecoratedTop(View child);
method getDecoratedRight (line 307) | int getDecoratedRight(View child);
method getDecoratedBottom (line 309) | int getDecoratedBottom(View child);
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/LayoutView.java
class LayoutView (line 38) | public final class LayoutView extends View {
method LayoutView (line 40) | public LayoutView(Context context) {
method LayoutView (line 44) | public LayoutView(Context context, AttributeSet attrs) {
method LayoutView (line 48) | public LayoutView(Context context, AttributeSet attrs, int defStyleAtt...
method LayoutView (line 52) | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/LayoutViewFactory.java
type LayoutViewFactory (line 34) | public interface LayoutViewFactory {
method generateLayoutView (line 36) | View generateLayoutView(@NonNull final Context context);
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/MismatchChildCountException.java
class MismatchChildCountException (line 30) | public class MismatchChildCountException extends RuntimeException {
method MismatchChildCountException (line 33) | public MismatchChildCountException(String msg) {
method MismatchChildCountException (line 37) | public MismatchChildCountException(String msg, Throwable cause) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/OrientationHelperEx.java
class OrientationHelperEx (line 14) | abstract public class OrientationHelperEx {
method OrientationHelperEx (line 26) | private OrientationHelperEx(ExposeLinearLayoutManagerEx layoutManager) {
method onLayoutComplete (line 35) | public void onLayoutComplete() {
method getTotalSpaceChange (line 49) | public int getTotalSpaceChange() {
method getDecoratedStart (line 63) | public abstract int getDecoratedStart(View view);
method getDecoratedEnd (line 75) | public abstract int getDecoratedEnd(View view);
method getDecoratedMeasurement (line 85) | public abstract int getDecoratedMeasurement(View view);
method getDecoratedMeasurementInOther (line 95) | public abstract int getDecoratedMeasurementInOther(View view);
method getStartAfterPadding (line 102) | public abstract int getStartAfterPadding();
method getEndAfterPadding (line 109) | public abstract int getEndAfterPadding();
method getEnd (line 116) | public abstract int getEnd();
method offsetChildren (line 123) | public abstract void offsetChildren(int amount);
method getTotalSpace (line 131) | public abstract int getTotalSpace();
method offsetChild (line 139) | public abstract void offsetChild(View view, int offset);
method getEndPadding (line 148) | public abstract int getEndPadding();
method createOrientationHelper (line 157) | public static OrientationHelperEx createOrientationHelper(
method createHorizontalHelper (line 174) | public static OrientationHelperEx createHorizontalHelper(
method createVerticalHelper (line 252) | public static OrientationHelperEx createVerticalHelper(ExposeLinearLay...
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/Range.java
class Range (line 36) | public final class Range<T extends Comparable<? super T>> {
method Range (line 51) | public Range(@NonNull final T lower, @NonNull final T upper) {
method create (line 79) | public static <T extends Comparable<? super T>> Range<T> create(final ...
method getLower (line 88) | public T getLower() {
method getUpper (line 97) | public T getUpper() {
method contains (line 112) | public boolean contains(@NonNull T value) {
method contains (line 132) | public boolean contains(@NonNull Range<T> range) {
method equals (line 150) | @Override
method clamp (line 175) | public T clamp(T value) {
method intersect (line 206) | public Range<T> intersect(Range<T> range) {
method intersect (line 238) | public Range<T> intersect(T lower, T upper) {
method extend (line 276) | public Range<T> extend(Range<T> range) {
method extend (line 308) | public Range<T> extend(T lower, T upper) {
method extend (line 339) | public Range<T> extend(T value) {
method toString (line 350) | @Override
method hashCode (line 358) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/RangeLayoutHelperFinder.java
class RangeLayoutHelperFinder (line 41) | public class RangeLayoutHelperFinder extends LayoutHelperFinder {
method compare (line 56) | @Override
method reverse (line 62) | @Override
method setLayouts (line 70) | @Override
method getLayoutHelpers (line 94) | @NonNull
method getLayoutHelper (line 100) | @Nullable
class LayoutHelperItem (line 128) | static class LayoutHelperItem {
method LayoutHelperItem (line 130) | LayoutHelperItem(LayoutHelper helper) {
method getStartPosition (line 136) | public int getStartPosition() {
method getEndPosition (line 140) | public int getEndPosition() {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/RecyclablePagerAdapter.java
class RecyclablePagerAdapter (line 38) | public abstract class RecyclablePagerAdapter<VH extends RecyclerView.Vie...
method RecyclablePagerAdapter (line 45) | public RecyclablePagerAdapter(RecyclerView.Adapter<VH> adapter, Recycl...
method getCount (line 54) | @Override
method isViewFromObject (line 57) | @Override
method instantiateItem (line 69) | @Override
method destroyItem (line 96) | @Override
method onBindViewHolder (line 106) | public abstract void onBindViewHolder(VH viewHolder, int position);
method getItemViewType (line 108) | public abstract int getItemViewType(int position);
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/SortedList.java
class SortedList (line 42) | @SuppressWarnings("unchecked")
method SortedList (line 74) | public SortedList(Class<T> klass, Callback<T> callback) {
method SortedList (line 85) | public SortedList(Class<T> klass, Callback<T> callback, int initialCap...
method size (line 97) | public int size() {
method add (line 125) | public int add(T item) {
method beginBatchedUpdates (line 161) | public void beginBatchedUpdates() {
method endBatchedUpdates (line 174) | public void endBatchedUpdates() {
method add (line 183) | private int add(T item, boolean notify) {
method remove (line 214) | public boolean remove(T item) {
method removeItemAt (line 224) | public T removeItemAt(int index) {
method remove (line 230) | private boolean remove(T item, boolean notify) {
method removeItemAtIndex (line 239) | private void removeItemAtIndex(int index, boolean notify) {
method updateItemAt (line 268) | public void updateItemAt(int index, T item) {
method recalculatePositionOfItemAt (line 321) | public void recalculatePositionOfItemAt(int index) {
method get (line 339) | public T get(int index) throws IndexOutOfBoundsException {
method indexOf (line 354) | public int indexOf(T item) {
method findIndexOf (line 358) | private int findIndexOf(T item, int reason) {
method linearEqualitySearch (line 385) | private int linearEqualitySearch(T item, int middle, int left, int rig...
method addToData (line 410) | private void addToData(int index, T item) {
class Callback (line 438) | public static abstract class Callback<T2> {
method compare (line 450) | abstract public int compare(T2 o1, T2 o2);
method onInserted (line 458) | abstract public void onInserted(int position, int count);
method onRemoved (line 466) | abstract public void onRemoved(int position, int count);
method onMoved (line 474) | abstract public void onMoved(int fromPosition, int toPosition);
method onChanged (line 482) | abstract public void onChanged(int position, int count);
method areContentsTheSame (line 501) | abstract public boolean areContentsTheSame(T2 oldItem, T2 newItem);
method areItemsTheSame (line 512) | abstract public boolean areItemsTheSame(T2 item1, T2 item2);
class BatchedCallback (line 531) | public static class BatchedCallback<T2> extends Callback<T2> {
method BatchedCallback (line 551) | public BatchedCallback(Callback<T2> wrappedCallback) {
method compare (line 555) | @Override
method onInserted (line 560) | @Override
method onRemoved (line 574) | @Override
method onMoved (line 586) | @Override
method onChanged (line 592) | @Override
method areContentsTheSame (line 609) | @Override
method areItemsTheSame (line 614) | @Override
method dispatchLastEvent (line 624) | public void dispatchLastEvent() {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/VirtualLayoutAdapter.java
class VirtualLayoutAdapter (line 35) | public abstract class VirtualLayoutAdapter<VH extends RecyclerView.ViewH...
method VirtualLayoutAdapter (line 40) | public VirtualLayoutAdapter(@NonNull VirtualLayoutManager layoutManage...
method setLayoutHelpers (line 44) | public void setLayoutHelpers(List<LayoutHelper> helpers) {
method getLayoutHelpers (line 48) | @NonNull
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/VirtualLayoutManager.java
class VirtualLayoutManager (line 72) | public class VirtualLayoutManager extends ExposeLinearLayoutManagerEx im...
method enableDebugging (line 82) | public static void enableDebugging(boolean isDebug) {
method compare (line 115) | @Override
method VirtualLayoutManager (line 128) | public VirtualLayoutManager(@NonNull final Context context) {
method VirtualLayoutManager (line 137) | public VirtualLayoutManager(@NonNull final Context context, int orient...
method VirtualLayoutManager (line 147) | public VirtualLayoutManager(@NonNull final Context context, int orient...
method setPerformanceMonitor (line 156) | public void setPerformanceMonitor(PerformanceMonitor performanceMonito...
method setNoScrolling (line 160) | public void setNoScrolling(boolean noScrolling) {
method setCanScrollVertically (line 167) | public void setCanScrollVertically(boolean canScrollVertically) {
method setCanScrollHorizontally (line 171) | public void setCanScrollHorizontally(boolean canScrollHorizontally) {
method setLayoutManagerCanScrollListener (line 175) | public void setLayoutManagerCanScrollListener(LayoutManagerCanScrollLi...
method setNestedScrolling (line 179) | public void setNestedScrolling(boolean nestedScrolling) {
method setNestedScrolling (line 183) | public void setNestedScrolling(boolean nestedScrolling, int maxMeasure...
method setHelperFinder (line 191) | public void setHelperFinder(@NonNull final LayoutHelperFinder finder) {
method setFixOffset (line 219) | public void setFixOffset(int left, int top, int right, int bottom) {
method setLayoutHelpers (line 237) | public void setLayoutHelpers(@Nullable List<LayoutHelper> helpers) {
method getLayoutHelpers (line 303) | @NonNull
method setEnableMarginOverlapping (line 308) | public void setEnableMarginOverlapping(boolean enableMarginOverlapping) {
method isEnableMarginOverLap (line 315) | @Override
method getOrientation (line 325) | @Override
method setOrientation (line 330) | @Override
method setReverseLayout (line 339) | @Override
method setStackFromEnd (line 353) | @Override
method onAnchorReady (line 365) | @Override
method findNeighbourNonfixLayoutHelper (line 401) | public LayoutHelper findNeighbourNonfixLayoutHelper(LayoutHelper layou...
method computeAlignOffset (line 427) | @Override
method computeAlignOffset (line 432) | @Override
method obtainExtraMargin (line 446) | public int obtainExtraMargin(View child, boolean isLayoutEnd) {
method obtainExtraMargin (line 450) | public int obtainExtraMargin(View child, boolean isLayoutEnd, boolean ...
method runPreLayout (line 461) | private void runPreLayout(RecyclerView.Recycler recycler, RecyclerView...
method runPostLayout (line 476) | private void runPostLayout(RecyclerView.Recycler recycler, RecyclerVie...
method runAdjustLayout (line 502) | public void runAdjustLayout() {
method onLayoutChildren (line 521) | @Override
method scrollInternalBy (line 590) | @Override
method onScrollStateChanged (line 636) | @Override
method offsetChildrenHorizontal (line 651) | @Override
method offsetChildrenVertical (line 665) | @Override
method setViewLifeCycleListener (line 681) | public void setViewLifeCycleListener(@NonNull ViewLifeCycleListener vi...
method getVirtualLayoutDirection (line 689) | public int getVirtualLayoutDirection() {
method findRangeLength (line 697) | @Nullable
method layoutChunk (line 733) | @Override
method getOffsetToStart (line 782) | public int getOffsetToStart() {
method setDefaultLayoutHelper (line 819) | private void setDefaultLayoutHelper(@NonNull final LayoutHelper layout...
method scrollToPosition (line 827) | @Override
method scrollToPositionWithOffset (line 833) | @Override
method smoothScrollToPosition (line 838) | @Override
method supportsPredictiveItemAnimations (line 844) | @Override
method onItemsAdded (line 857) | @Override
method onItemsRemoved (line 862) | @Override
method onItemsUpdated (line 867) | @Override
method onItemsMoved (line 872) | @Override
method onItemsChanged (line 877) | @Override
method checkLayoutParams (line 891) | @Override
method generateDefaultLayoutParams (line 896) | @Override
method generateLayoutParams (line 902) | @Override
method generateLayoutParams (line 915) | @Override
method onAdapterChanged (line 920) | @Override
method onAttachedToWindow (line 926) | @Override
method onDetachedFromWindow (line 932) | @Override
class LayoutParams (line 948) | @SuppressWarnings("unused")
method storeOriginWidth (line 961) | public void storeOriginWidth() {
method storeOriginHeight (line 967) | public void storeOriginHeight() {
method restoreOriginWidth (line 973) | public void restoreOriginWidth() {
method restoreOriginHeight (line 979) | public void restoreOriginHeight() {
method LayoutParams (line 985) | public LayoutParams(Context c, AttributeSet attrs) {
method LayoutParams (line 989) | public LayoutParams(int width, int height) {
method LayoutParams (line 993) | public LayoutParams(ViewGroup.MarginLayoutParams source) {
method LayoutParams (line 997) | public LayoutParams(ViewGroup.LayoutParams source) {
method LayoutParams (line 1001) | public LayoutParams(RecyclerView.LayoutParams source) {
class InflateLayoutParams (line 1007) | public static class InflateLayoutParams extends LayoutParams {
method InflateLayoutParams (line 1009) | public InflateLayoutParams(Context c, AttributeSet attrs) {
class AnchorInfoWrapper (line 1015) | public static class AnchorInfoWrapper {
method AnchorInfoWrapper (line 1023) | AnchorInfoWrapper() {
class LayoutStateWrapper (line 1030) | @SuppressWarnings({"JavaDoc", "unused"})
method LayoutStateWrapper (line 1046) | LayoutStateWrapper() {
method LayoutStateWrapper (line 1050) | LayoutStateWrapper(LayoutState layoutState) {
method getOffset (line 1055) | public int getOffset() {
method getCurrentPosition (line 1059) | public int getCurrentPosition() {
method hasScrapList (line 1063) | public boolean hasScrapList() {
method skipCurrentPosition (line 1067) | public void skipCurrentPosition() {
method isRecycle (line 1074) | public boolean isRecycle() {
method isRefreshLayout (line 1082) | public boolean isRefreshLayout() {
method getAvailable (line 1089) | public int getAvailable() {
method getItemDirection (line 1098) | public int getItemDirection() {
method getLayoutDirection (line 1106) | public int getLayoutDirection() {
method getScrollingOffset (line 1115) | public int getScrollingOffset() {
method getExtra (line 1124) | public int getExtra() {
method isPreLayout (line 1133) | public boolean isPreLayout() {
method hasMore (line 1138) | public boolean hasMore(RecyclerView.State state) {
method next (line 1142) | public View next(RecyclerView.Recycler recycler) {
method retrieve (line 1148) | public View retrieve(RecyclerView.Recycler recycler, int position) {
class LayoutViewHolder (line 1158) | private static class LayoutViewHolder extends RecyclerView.ViewHolder {
method LayoutViewHolder (line 1160) | public LayoutViewHolder(View itemView) {
method getFixedViews (line 1167) | public List<View> getFixedViews() {
method generateLayoutView (line 1188) | @Override
method setLayoutViewFactory (line 1199) | public void setLayoutViewFactory(@NonNull final LayoutViewFactory fact...
method generateLayoutView (line 1205) | @Override
method addChildView (line 1218) | @Override
method moveView (line 1224) | @Override
method addChildView (line 1229) | @Override
method addChildView (line 1235) | @Override
method addOffFlowView (line 1250) | @Override
method addBackgroundView (line 1257) | @Override
method addFixedView (line 1264) | @Override
method hideView (line 1271) | @Override
method showView (line 1276) | @Override
method getRecyclerView (line 1281) | @Override
method getChildViewHolder (line 1286) | @Override
method isViewHolderUpdated (line 1297) | @Override
method removeChildView (line 1304) | @Override
method getMainOrientationHelper (line 1309) | @Override
method getSecondaryOrientationHelper (line 1314) | @Override
method measureChild (line 1319) | @Override
method measureChildWithMargins (line 1324) | @Override
method getChildMeasureSpec (line 1329) | @Override
method canScrollHorizontally (line 1335) | @Override
method canScrollVertically (line 1344) | @Override
method layoutChildWithMargins (line 1353) | @Override
method layoutChild (line 1366) | @Override
method recycleChildren (line 1378) | @Override
method detachAndScrapAttachedViews (line 1434) | @Override
method detachAndScrapViewAt (line 1451) | @Override
method detachAndScrapView (line 1463) | @Override
type CacheViewHolder (line 1468) | public interface CacheViewHolder {
method needCached (line 1469) | boolean needCached();
method getContentWidth (line 1472) | @Override
method getContentHeight (line 1477) | @Override
method isDoLayoutRTL (line 1482) | @Override
method measureChildWithDecorations (line 1489) | private void measureChildWithDecorations(View child, int widthSpec, in...
method measureChildWithDecorationsAndMargin (line 1502) | private void measureChildWithDecorationsAndMargin(View child, int widt...
method updateSpecWithExtra (line 1531) | private int updateSpecWithExtra(int spec, int startInset, int endInset) {
method findViewByPosition (line 1549) | @Override
method recycleView (line 1566) | @Override
method findLayoutHelperByPosition (line 1577) | @Override
method onMeasure (line 1600) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/extend/InnerRecycledViewPool.java
class InnerRecycledViewPool (line 40) | public final class InnerRecycledViewPool extends RecyclerView.RecycledVi...
method InnerRecycledViewPool (line 60) | public InnerRecycledViewPool(RecyclerView.RecycledViewPool pool) {
method InnerRecycledViewPool (line 65) | public InnerRecycledViewPool() {
method clear (line 69) | @Override
method setMaxRecycledViews (line 84) | @Override
method getRecycledView (line 100) | @Override
method size (line 118) | public int size() {
method putRecycledView (line 134) | @SuppressWarnings("unchecked")
method destroyViewHolder (line 158) | private void destroyViewHolder(RecyclerView.ViewHolder holder) {
method setDefaultMaxSize (line 178) | public void setDefaultMaxSize(int maxSize) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/extend/LayoutManagerCanScrollListener.java
type LayoutManagerCanScrollListener (line 3) | public interface LayoutManagerCanScrollListener {
method canScrollVertically (line 4) | boolean canScrollVertically();
method canScrollHorizontally (line 6) | boolean canScrollHorizontally();
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/extend/PerformanceMonitor.java
class PerformanceMonitor (line 15) | public class PerformanceMonitor {
method recordStart (line 22) | @Keep
method recordEnd (line 32) | @Keep
method recordStart (line 42) | @Keep
method recordEnd (line 52) | @Keep
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/extend/ViewLifeCycleHelper.java
class ViewLifeCycleHelper (line 11) | public class ViewLifeCycleHelper {
type STATUS (line 12) | public enum STATUS {
method ViewLifeCycleHelper (line 27) | public ViewLifeCycleHelper(VirtualLayoutManager virtualLayoutManager, ...
method checkViewStatusInScreen (line 32) | public void checkViewStatusInScreen() {
method getViewStatus (line 75) | private STATUS getViewStatus(View view) {
method setViewstatus (line 83) | private void setViewstatus(View view, STATUS status) {
method isViewReadyAppearing (line 87) | private boolean isViewReadyAppearing(View view) {
method setViewAppearing (line 91) | private void setViewAppearing(View view) {
method isViewReadyAppeared (line 102) | private boolean isViewReadyAppeared(View view) {
method setViewAppeared (line 106) | private void setViewAppeared(View view) {
method isViewReadyDisAppearing (line 116) | private boolean isViewReadyDisAppearing(View view) {
method setViewDisappearing (line 120) | private void setViewDisappearing(View view) {
method isViewReadyDisAppeared (line 131) | private boolean isViewReadyDisAppeared(View view) {
method setViewDisappeared (line 135) | private void setViewDisappeared(View view) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/extend/ViewLifeCycleListener.java
type ViewLifeCycleListener (line 5) | public interface ViewLifeCycleListener {
method onAppearing (line 6) | void onAppearing(View view);
method onDisappearing (line 8) | void onDisappearing(View view);
method onAppeared (line 10) | void onAppeared(View view);
method onDisappeared (line 12) | void onDisappeared(View view);
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/AbstractFullFillLayoutHelper.java
class AbstractFullFillLayoutHelper (line 47) | public abstract class AbstractFullFillLayoutHelper extends BaseLayoutHel...
method getAllChildren (line 57) | protected int getAllChildren(View[] toFill,
method layoutViews (line 111) | @Override
method doLayoutView (line 121) | protected void doLayoutView(RecyclerView.Recycler recycler, RecyclerVi...
method onMeasure (line 127) | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
method onLayout (line 131) | protected void onLayout(boolean changed, int l, int t, int r, int b) {
method setMeasuredDimension (line 135) | protected final void setMeasuredDimension(int measuredWidth, int measu...
method checkAnchorInfo (line 139) | @Override
method afterLayout (line 157) | @Override
method computeAlignOffset (line 164) | @Override
method checkLayoutParams (line 182) | protected boolean checkLayoutParams(LayoutParams p) {
method generateDefaultLayoutParams (line 186) | protected LayoutParams generateDefaultLayoutParams() {
method generateLayoutParams (line 190) | protected LayoutParams generateLayoutParams(LayoutParams p) {
method isRecyclable (line 195) | @Override
method setHasHeader (line 214) | public void setHasHeader(boolean hasHeader) {
method setHasFooter (line 218) | public void setHasFooter(boolean hasFooter) {
method calculateRect (line 222) | protected void calculateRect(int mainAxisSize, Rect areaRect, LayoutSt...
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/BaseLayoutHelper.java
class BaseLayoutHelper (line 44) | public abstract class BaseLayoutHelper extends MarginLayoutHelper {
method BaseLayoutHelper (line 58) | public BaseLayoutHelper() {
method isFixLayout (line 62) | @Override
method getBgColor (line 67) | public int getBgColor() {
method setBgColor (line 76) | public void setBgColor(int bgColor) {
method setAspectRatio (line 80) | public void setAspectRatio(float aspectRatio) {
method getAspectRatio (line 84) | public float getAspectRatio() {
method getItemCount (line 95) | @Override
method setItemCount (line 100) | @Override
method nextView (line 114) | @Nullable
method beforeLayout (line 133) | @Override
method isValidScrolled (line 164) | protected boolean isValidScrolled(int scrolled) {
method afterLayout (line 169) | @Override
method adjustLayout (line 233) | @Override
method clear (line 279) | @Override
method onClear (line 299) | protected void onClear(LayoutManagerHelper helper) {
method requireLayoutView (line 306) | @Override
method layoutViews (line 311) | public abstract void layoutViews(RecyclerView.Recycler recycler, Recyc...
method doLayout (line 316) | @Override
method layoutChildWithMargin (line 332) | protected void layoutChildWithMargin(final View child, int left, int t...
method layoutChildWithMargin (line 336) | protected void layoutChildWithMargin(final View child, int left, int t...
method layoutChild (line 361) | protected void layoutChild(final View child, int left, int top, int ri...
method layoutChild (line 365) | protected void layoutChild(final View child, int left, int top, int ri...
type LayoutViewBindListener (line 383) | public interface LayoutViewBindListener {
method onBind (line 384) | void onBind(View layoutView, BaseLayoutHelper baseLayoutHelper);
type LayoutViewUnBindListener (line 390) | public interface LayoutViewUnBindListener {
method onUnbind (line 391) | void onUnbind(View layoutView, BaseLayoutHelper baseLayoutHelper);
type LayoutViewHelper (line 395) | public interface LayoutViewHelper {
method onBindViewSuccess (line 402) | void onBindViewSuccess(View layoutView, String id);
class DefaultLayoutViewHelper (line 418) | public static class DefaultLayoutViewHelper implements LayoutViewBindL...
method DefaultLayoutViewHelper (line 424) | public DefaultLayoutViewHelper(
method onBindViewSuccess (line 431) | @Override
method onBind (line 436) | @Override
method onUnbind (line 445) | @Override
method setLayoutViewHelper (line 454) | public void setLayoutViewHelper(DefaultLayoutViewHelper layoutViewHelp...
method setLayoutViewBindListener (line 463) | public void setLayoutViewBindListener(LayoutViewBindListener bindListe...
method setLayoutViewUnBindListener (line 471) | public void setLayoutViewUnBindListener(
method bindLayoutView (line 476) | @Override
method handleStateOnResult (line 491) | protected void handleStateOnResult(LayoutChunkResult result, View view) {
method handleStateOnResult (line 513) | protected void handleStateOnResult(LayoutChunkResult result, View[] vi...
method computeStartSpace (line 537) | protected int computeStartSpace(LayoutManagerHelper helper, boolean la...
method computeEndSpace (line 573) | protected int computeEndSpace(LayoutManagerHelper helper, boolean layo...
method calGap (line 581) | private int calGap(int gap, int currGap) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/ColumnLayoutHelper.java
class ColumnLayoutHelper (line 74) | public class ColumnLayoutHelper extends AbstractFullFillLayoutHelper {
method setWeights (line 84) | public void setWeights(float[] weights) {
method layoutViews (line 92) | @Override
method checkAnchorInfo (line 246) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/DefaultLayoutHelper.java
class DefaultLayoutHelper (line 32) | public class DefaultLayoutHelper extends LinearLayoutHelper {
method newHelper (line 34) | public static LayoutHelper newHelper(int itemCount) {
method isOutOfRange (line 40) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/FixAreaAdjuster.java
class FixAreaAdjuster (line 30) | public class FixAreaAdjuster {
method FixAreaAdjuster (line 39) | public FixAreaAdjuster(int left, int top, int right, int bottom) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/FixAreaLayoutHelper.java
class FixAreaLayoutHelper (line 35) | public abstract class FixAreaLayoutHelper extends BaseLayoutHelper {
method setAdjuster (line 40) | public void setAdjuster(FixAreaAdjuster adjuster) {
method setFixViewAnimatorHelper (line 44) | public void setFixViewAnimatorHelper(
method adjustLayout (line 49) | @Override
method isFixLayout (line 54) | public boolean isFixLayout() {
type FixViewAnimatorHelper (line 58) | public interface FixViewAnimatorHelper {
method onGetFixViewAppearAnimator (line 60) | ViewPropertyAnimator onGetFixViewAppearAnimator(View fixView);
method onGetFixViewDisappearAnimator (line 62) | ViewPropertyAnimator onGetFixViewDisappearAnimator(View fixView);
method computeMarginStart (line 66) | @Override
method computeMarginEnd (line 71) | @Override
method computePaddingStart (line 76) | @Override
method computePaddingEnd (line 81) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/FixLayoutHelper.java
class FixLayoutHelper (line 68) | public class FixLayoutHelper extends FixAreaLayoutHelper {
method FixLayoutHelper (line 106) | public FixLayoutHelper(int x, int y) {
method FixLayoutHelper (line 110) | public FixLayoutHelper(int alignType, int x, int y) {
method setItemCount (line 117) | @Override
method setMargin (line 130) | @Override
method setX (line 135) | public void setX(int x) {
method setY (line 139) | public void setY(int y) {
method setAlignType (line 143) | public void setAlignType(int alignType) {
method setSketchMeasure (line 148) | public void setSketchMeasure(boolean sketchMeasure) {
method onRangeChange (line 160) | @Override
method layoutViews (line 165) | @Override
method requireLayoutView (line 210) | @Override
method beforeLayout (line 215) | @Override
method afterLayout (line 231) | @Override
method addFixViewWithAnimator (line 297) | private void addFixViewWithAnimator(LayoutManagerHelper layoutManagerH...
method removeFixViewWithAnimator (line 315) | private void removeFixViewWithAnimator(RecyclerView.Recycler recycler,
method shouldBeDraw (line 348) | protected boolean shouldBeDraw(LayoutManagerHelper helper, int startPo...
method getFixedView (line 352) | @Override
method onClear (line 357) | @Override
method doMeasureAndLayout (line 369) | private void doMeasureAndLayout(View view, LayoutManagerHelper helper) {
class FixViewAppearAnimatorListener (line 475) | private static class FixViewAppearAnimatorListener extends AnimatorLis...
method bindAction (line 481) | public void bindAction(LayoutManagerHelper layoutManagerHelper, View...
method onAnimationStart (line 486) | @Override
method onAnimationEnd (line 491) | @Override
class FixViewDisappearAnimatorListener (line 496) | private static class FixViewDisappearAnimatorListener extends Animator...
method bindAction (line 508) | public void bindAction(RecyclerView.Recycler recycler,
method onAnimationStart (line 516) | @Override
method onAnimationEnd (line 520) | @Override
method isAnimating (line 531) | public boolean isAnimating() {
method withEndAction (line 535) | public void withEndAction(Runnable action) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/FloatLayoutHelper.java
class FloatLayoutHelper (line 50) | public class FloatLayoutHelper extends FixAreaLayoutHelper {
method FloatLayoutHelper (line 58) | public FloatLayoutHelper() {
method setDefaultLocation (line 75) | public void setDefaultLocation(int x, int y) {
method setX (line 80) | public void setX(int x) {
method setY (line 84) | public void setY(int y) {
method setAlignType (line 88) | public void setAlignType(int alignType) {
method setItemCount (line 92) | @Override
method onRangeChange (line 109) | @Override
method layoutViews (line 114) | @Override
method setBgColor (line 159) | @Override
method requireLayoutView (line 164) | @Override
method beforeLayout (line 169) | @Override
method afterLayout (line 184) | @Override
method shouldBeDraw (line 234) | protected boolean shouldBeDraw(int startPosition, int endPosition) {
method getFixedView (line 239) | @Nullable
method onClear (line 245) | @Override
method doMeasureAndLayout (line 256) | private void doMeasureAndLayout(View view, LayoutManagerHelper helper) {
method onTouch (line 373) | @Override
method doPullOverAnimation (line 440) | private void doPullOverAnimation(final View v) {
method setDragEnable (line 459) | public void setDragEnable(boolean dragEnable) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/GridLayoutHelper.java
class GridLayoutHelper (line 52) | public class GridLayoutHelper extends BaseLayoutHelper {
method GridLayoutHelper (line 95) | public GridLayoutHelper(int spanCount) {
method GridLayoutHelper (line 103) | public GridLayoutHelper(int spanCount, int itemCount) {
method GridLayoutHelper (line 107) | public GridLayoutHelper(int spanCount, int itemCount, int gap) {
method GridLayoutHelper (line 117) | public GridLayoutHelper(int spanCount, int itemCount, int vGap, int hG...
method setWeights (line 127) | public void setWeights(float[] weights) {
method setSpanSizeLookup (line 135) | public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) {
method setAutoExpand (line 144) | public void setAutoExpand(boolean isAutoExpand) {
method setIgnoreExtra (line 148) | public void setIgnoreExtra(boolean ignoreExtra) {
method setSpanCount (line 160) | public void setSpanCount(int spanCount) {
method getVGap (line 174) | public int getVGap() {
method getHGap (line 178) | public int getHGap() {
method getSpanCount (line 182) | public int getSpanCount() {
method onRangeChange (line 192) | @Override
method setGap (line 199) | public void setGap(int gap) {
method setVGap (line 204) | public void setVGap(int vGap) {
method setHGap (line 209) | public void setHGap(int hGap) {
method layoutViews (line 214) | @Override
method computeAlignOffset (line 569) | @Override
method onClear (line 586) | @Override
method onItemsChanged (line 592) | @Override
method getMainDirSpec (line 601) | private int getMainDirSpec(int dim, int otherSize, int viewSize, float...
method ensureSpanCount (line 614) | private void ensureSpanCount() {
method checkAnchorInfo (line 632) | @Override
method getSpanIndex (line 667) | private int getSpanIndex(RecyclerView.Recycler recycler, RecyclerView....
method getSpanSize (line 680) | private int getSpanSize(RecyclerView.Recycler recycler, RecyclerView.S...
method assignSpans (line 693) | private void assignSpans(RecyclerView.Recycler recycler, RecyclerView....
class DefaultSpanSizeLookup (line 728) | static final class DefaultSpanSizeLookup extends SpanSizeLookup {
method getSpanSize (line 730) | @Override
method getSpanIndex (line 735) | @Override
class SpanSizeLookup (line 742) | public static abstract class SpanSizeLookup {
method getSpanSize (line 756) | abstract public int getSpanSize(int position);
method setSpanIndexCacheEnabled (line 765) | public void setSpanIndexCacheEnabled(boolean cacheSpanIndices) {
method setStartPosition (line 769) | public void setStartPosition(int startPosition) {
method getStartPosition (line 773) | public int getStartPosition() {
method invalidateSpanIndexCache (line 781) | public void invalidateSpanIndexCache() {
method isSpanIndexCacheEnabled (line 790) | public boolean isSpanIndexCacheEnabled() {
method getCachedSpanIndex (line 794) | int getCachedSpanIndex(int position, int spanCount) {
method getSpanIndex (line 830) | public int getSpanIndex(int position, int spanCount) {
method findReferenceIndexFromCache (line 861) | int findReferenceIndexFromCache(int position) {
method getSpanGroupIndex (line 891) | public int getSpanGroupIndex(int adapterPosition, int spanCount) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/LayoutChunkResult.java
class LayoutChunkResult (line 30) | public class LayoutChunkResult {
method resetInternal (line 36) | public void resetInternal() {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/LinearLayoutHelper.java
class LinearLayoutHelper (line 44) | public class LinearLayoutHelper extends BaseLayoutHelper {
method LinearLayoutHelper (line 54) | public LinearLayoutHelper() {
method LinearLayoutHelper (line 58) | public LinearLayoutHelper(int dividerHeight) {
method LinearLayoutHelper (line 64) | public LinearLayoutHelper(int dividerHeight, int itemCount) {
method setDividerHeight (line 70) | public void setDividerHeight(int dividerHeight) {
method layoutViews (line 81) | @Override
method checkAnchorInfo (line 220) | @Override
method computeAlignOffset (line 226) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/MarginLayoutHelper.java
class MarginLayoutHelper (line 35) | public abstract class MarginLayoutHelper extends LayoutHelper {
method setPadding (line 55) | public void setPadding(int leftPadding, int topPadding, int rightPaddi...
method setMargin (line 70) | public void setMargin(int leftMargin, int topMargin, int rightMargin, ...
method computeAlignOffset (line 86) | @Override
method computeMarginStart (line 91) | @Override
method computeMarginEnd (line 101) | @Override
method computePaddingStart (line 111) | @Override
method computePaddingEnd (line 121) | @Override
method getHorizontalMargin (line 136) | public int getHorizontalMargin() {
method getVerticalMargin (line 145) | public int getVerticalMargin() {
method getHorizontalPadding (line 153) | public int getHorizontalPadding() {
method getVerticalPadding (line 161) | public int getVerticalPadding() {
method getPaddingLeft (line 165) | public int getPaddingLeft() {
method getPaddingRight (line 169) | public int getPaddingRight() {
method getPaddingTop (line 173) | public int getPaddingTop() {
method getPaddingBottom (line 177) | public int getPaddingBottom() {
method getMarginLeft (line 181) | public int getMarginLeft() {
method getMarginRight (line 185) | public int getMarginRight() {
method getMarginTop (line 189) | public int getMarginTop() {
method getMarginBottom (line 193) | public int getMarginBottom() {
method setPaddingLeft (line 197) | public void setPaddingLeft(int paddingLeft) {
method setPaddingRight (line 201) | public void setPaddingRight(int paddingRight) {
method setPaddingTop (line 205) | public void setPaddingTop(int paddingTop) {
method setPaddingBottom (line 209) | public void setPaddingBottom(int paddingBottom) {
method setMarginLeft (line 213) | public void setMarginLeft(int marginLeft) {
method setMarginRight (line 217) | public void setMarginRight(int marginRight) {
method setMarginTop (line 221) | public void setMarginTop(int marginTop) {
method setMarginBottom (line 225) | public void setMarginBottom(int marginBottom) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/OnePlusNLayoutHelper.java
class OnePlusNLayoutHelper (line 107) | public class OnePlusNLayoutHelper extends AbstractFullFillLayoutHelper {
method OnePlusNLayoutHelper (line 120) | public OnePlusNLayoutHelper() {
method OnePlusNLayoutHelper (line 124) | public OnePlusNLayoutHelper(int itemCount) {
method OnePlusNLayoutHelper (line 128) | public OnePlusNLayoutHelper(int itemCount, int leftMargin, int topMarg...
method onRangeChange (line 144) | @Override
method setColWeights (line 154) | public void setColWeights(float[] weights) {
method setRowWeight (line 162) | public void setRowWeight(float weight) {
method layoutViews (line 166) | @Override
method getViewMainWeight (line 272) | private float getViewMainWeight(int index) {
method onClear (line 280) | @Override
method checkAnchorInfo (line 285) | @Override
method computeAlignOffset (line 291) | @Override
method handleHeader (line 314) | private int handleHeader(View header, LayoutStateWrapper layoutState, ...
method handleFooter (line 333) | private int handleFooter(View footer, LayoutStateWrapper layoutState, ...
method handleOne (line 352) | private int handleOne(LayoutStateWrapper layoutState, LayoutChunkResul...
method handleTwo (line 391) | private int handleTwo(LayoutStateWrapper layoutState, LayoutChunkResul...
method handleThree (line 490) | private int handleThree(LayoutStateWrapper layoutState, LayoutChunkRes...
method handleFour (line 580) | private int handleFour(LayoutStateWrapper layoutState, LayoutChunkResu...
method handleFive (line 688) | private int handleFive(LayoutStateWrapper layoutState, LayoutChunkResu...
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/OnePlusNLayoutHelperEx.java
class OnePlusNLayoutHelperEx (line 81) | public class OnePlusNLayoutHelperEx extends AbstractFullFillLayoutHelper {
method OnePlusNLayoutHelperEx (line 93) | public OnePlusNLayoutHelperEx() {
method OnePlusNLayoutHelperEx (line 97) | public OnePlusNLayoutHelperEx(int itemCount) {
method OnePlusNLayoutHelperEx (line 101) | public OnePlusNLayoutHelperEx(int itemCount, int leftMargin, int topMa...
method onRangeChange (line 117) | @Override
method setColWeights (line 129) | public void setColWeights(float[] weights) {
method setRowWeight (line 137) | public void setRowWeight(float weight) {
method layoutViews (line 141) | @Override
method getViewMainWeight (line 188) | private float getViewMainWeight(int index) {
method computeAlignOffset (line 196) | @Override
method handleFive (line 225) | private int handleFive(LayoutStateWrapper layoutState, LayoutChunkResu...
method handSix (line 352) | private int handSix(LayoutStateWrapper layoutState, LayoutChunkResult ...
method handSeven (line 508) | private int handSeven(LayoutStateWrapper layoutState, LayoutChunkResul...
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/RangeGridLayoutHelper.java
class RangeGridLayoutHelper (line 56) | public class RangeGridLayoutHelper extends BaseLayoutHelper {
method RangeGridLayoutHelper (line 69) | public RangeGridLayoutHelper(int spanCount) {
method RangeGridLayoutHelper (line 77) | public RangeGridLayoutHelper(int spanCount, int itemCount) {
method RangeGridLayoutHelper (line 81) | public RangeGridLayoutHelper(int spanCount, int itemCount, int gap) {
method RangeGridLayoutHelper (line 91) | public RangeGridLayoutHelper(int spanCount, int itemCount, int vGap, i...
method addRangeStyle (line 105) | public void addRangeStyle(int start, int end, GridRangeStyle rangeStyl...
method getRootRangeStyle (line 109) | public GridRangeStyle getRootRangeStyle() {
method setMargin (line 113) | @Override
method setPadding (line 119) | @Override
method setWeights (line 125) | public void setWeights(float[] weights) {
method setSpanSizeLookup (line 129) | public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) {
method setAutoExpand (line 133) | public void setAutoExpand(boolean isAutoExpand) {
method setIgnoreExtra (line 137) | public void setIgnoreExtra(boolean ignoreExtra) {
method setSpanCount (line 149) | public void setSpanCount(int spanCount) {
method getSpanCount (line 153) | public int getSpanCount() {
method onRangeChange (line 163) | @Override
method setGap (line 168) | public void setGap(int gap) {
method setVGap (line 173) | public void setVGap(int vGap) {
method setHGap (line 177) | public void setHGap(int hGap) {
method setAspectRatio (line 181) | @Override
method getAspectRatio (line 186) | @Override
method setBgColor (line 191) | @Override
method setLayoutViewHelper (line 196) | @Override
method setLayoutViewBindListener (line 201) | @Override
method setLayoutViewUnBindListener (line 206) | @Override
method requireLayoutView (line 211) | @Override
method beforeLayout (line 216) | @Override
method layoutViews (line 223) | @Override
method afterLayout (line 697) | @Override
method adjustLayout (line 703) | @Override
method computeAlignOffset (line 708) | @Override
method onClear (line 724) | @Override
method onItemsChanged (line 731) | @Override
method getMainDirSpec (line 740) | private int getMainDirSpec(GridRangeStyle rangeStyle, int dim, int oth...
method checkAnchorInfo (line 754) | @Override
method getSpanIndex (line 790) | private int getSpanIndex(SpanSizeLookup spanSizeLookup, int spanCount,...
method getSpanSize (line 803) | private int getSpanSize(SpanSizeLookup spanSizeLookup, RecyclerView.Re...
method assignSpans (line 816) | private void assignSpans(GridRangeStyle rangeStyle, RecyclerView.Recyc...
method getBorderStartSpace (line 850) | public int getBorderStartSpace(LayoutManagerHelper helper) {
method getBorderEndSpace (line 860) | public int getBorderEndSpace(LayoutManagerHelper helper) {
class GridRangeStyle (line 870) | public static class GridRangeStyle extends RangeStyle<GridRangeStyle> {
method GridRangeStyle (line 906) | public GridRangeStyle(RangeGridLayoutHelper layoutHelper) {
method GridRangeStyle (line 911) | public GridRangeStyle() {
method findRangeStyleByPosition (line 917) | public GridRangeStyle findRangeStyleByPosition(int position) {
method findRangeStyle (line 921) | private GridRangeStyle findRangeStyle(GridRangeStyle rangeStyle, int...
method findSiblingStyleByPosition (line 934) | public GridRangeStyle findSiblingStyleByPosition(int position) {
method onInvalidateSpanIndexCache (line 952) | public void onInvalidateSpanIndexCache() {
method computeEndAlignOffset (line 960) | public static int computeEndAlignOffset(GridRangeStyle rangeStyle, b...
method computeStartAlignOffset (line 976) | public static int computeStartAlignOffset(GridRangeStyle rangeStyle,...
method setAspectRatio (line 993) | public void setAspectRatio(float aspectRatio) {
method getAspectRatio (line 997) | public float getAspectRatio() {
method setRange (line 1002) | @Override
method setGap (line 1009) | public void setGap(int gap) {
method setVGap (line 1014) | public void setVGap(int vGap) {
method setHGap (line 1021) | public void setHGap(int hGap) {
method setWeights (line 1028) | public void setWeights(float[] weights) {
method setSpanSizeLookup (line 1036) | public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) {
method setAutoExpand (line 1045) | public void setAutoExpand(boolean isAutoExpand) {
method setIgnoreExtra (line 1049) | public void setIgnoreExtra(boolean ignoreExtra) {
method setSpanCount (line 1061) | public void setSpanCount(int spanCount) {
method getSpanCount (line 1075) | public int getSpanCount() {
method ensureSpanCount (line 1079) | private void ensureSpanCount() {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/RangeStyle.java
class RangeStyle (line 31) | public class RangeStyle<T extends RangeStyle> {
method RangeStyle (line 76) | public RangeStyle(BaseLayoutHelper layoutHelper) {
method RangeStyle (line 80) | public RangeStyle() {
method addChildRangeStyle (line 83) | public void addChildRangeStyle(int start, int end, T rangeStyle) {
method setParent (line 93) | public void setParent(T rangeStyle) {
method setPadding (line 104) | public void setPadding(int leftPadding, int topPadding, int rightPaddi...
method setMargin (line 119) | public void setMargin(int leftMargin, int topMargin, int rightMargin, ...
method getHorizontalMargin (line 131) | protected int getHorizontalMargin() {
method getVerticalMargin (line 140) | protected int getVerticalMargin() {
method getHorizontalPadding (line 148) | protected int getHorizontalPadding() {
method getVerticalPadding (line 156) | protected int getVerticalPadding() {
method getPaddingLeft (line 160) | public int getPaddingLeft() {
method getPaddingRight (line 164) | public int getPaddingRight() {
method getPaddingTop (line 168) | public int getPaddingTop() {
method getPaddingBottom (line 172) | public int getPaddingBottom() {
method getMarginLeft (line 176) | public int getMarginLeft() {
method getMarginRight (line 180) | public int getMarginRight() {
method getMarginTop (line 184) | public int getMarginTop() {
method getMarginBottom (line 188) | public int getMarginBottom() {
method setPaddingLeft (line 192) | public void setPaddingLeft(int paddingLeft) {
method setPaddingRight (line 196) | public void setPaddingRight(int paddingRight) {
method setPaddingTop (line 200) | public void setPaddingTop(int paddingTop) {
method setPaddingBottom (line 204) | public void setPaddingBottom(int paddingBottom) {
method setMarginLeft (line 208) | public void setMarginLeft(int marginLeft) {
method setMarginRight (line 212) | public void setMarginRight(int marginRight) {
method setMarginTop (line 216) | public void setMarginTop(int marginTop) {
method setMarginBottom (line 220) | public void setMarginBottom(int marginBottom) {
method getFamilyHorizontalMargin (line 228) | public int getFamilyHorizontalMargin() {
method getFamilyVerticalMargin (line 236) | public int getFamilyVerticalMargin() {
method getFamilyHorizontalPadding (line 244) | public int getFamilyHorizontalPadding() {
method getFamilyVerticalPadding (line 252) | public int getFamilyVerticalPadding() {
method getFamilyPaddingLeft (line 256) | public int getFamilyPaddingLeft() {
method getFamilyPaddingRight (line 260) | public int getFamilyPaddingRight() {
method getFamilyPaddingTop (line 264) | public int getFamilyPaddingTop() {
method getFamilyPaddingBottom (line 268) | public int getFamilyPaddingBottom() {
method getFamilyMarginLeft (line 272) | public int getFamilyMarginLeft() {
method getFamilyMarginRight (line 276) | public int getFamilyMarginRight() {
method getFamilyMarginTop (line 280) | public int getFamilyMarginTop() {
method getFamilyMarginBottom (line 284) | public int getFamilyMarginBottom() {
method getAncestorHorizontalMargin (line 292) | public int getAncestorHorizontalMargin() {
method getAncestorVerticalMargin (line 300) | public int getAncestorVerticalMargin() {
method getAncestorHorizontalPadding (line 308) | public int getAncestorHorizontalPadding() {
method getAncestorVerticalPadding (line 316) | public int getAncestorVerticalPadding() {
method getAncestorPaddingLeft (line 320) | public int getAncestorPaddingLeft() {
method getAncestorPaddingRight (line 324) | public int getAncestorPaddingRight() {
method getAncestorPaddingTop (line 328) | public int getAncestorPaddingTop() {
method getAncestorPaddingBottom (line 332) | public int getAncestorPaddingBottom() {
method getAncestorMarginLeft (line 336) | public int getAncestorMarginLeft() {
method getAncestorMarginRight (line 340) | public int getAncestorMarginRight() {
method getAncestorMarginTop (line 344) | public int getAncestorMarginTop() {
method getAncestorMarginBottom (line 348) | public int getAncestorMarginBottom() {
method getOriginStartOffset (line 352) | public int getOriginStartOffset() {
method getOriginEndOffset (line 356) | public int getOriginEndOffset() {
method setOriginStartOffset (line 360) | public void setOriginStartOffset(int originStartOffset) {
method setOriginEndOffset (line 364) | public void setOriginEndOffset(int originEndOffset) {
method getRange (line 368) | public Range<Integer> getRange() {
method getLayoutHelper (line 372) | public BaseLayoutHelper getLayoutHelper() {
method isChildrenEmpty (line 382) | public boolean isChildrenEmpty() {
method isRoot (line 386) | public boolean isRoot() {
method isOutOfRange (line 390) | public boolean isOutOfRange(int position) {
method isFirstPosition (line 394) | public boolean isFirstPosition(int position) {
method isLastPosition (line 398) | public boolean isLastPosition(int position) {
method setRange (line 406) | public void setRange(int start, int end) {
method beforeLayout (line 423) | public void beforeLayout(RecyclerView.Recycler recycler, RecyclerView....
method isValidScrolled (line 448) | private boolean isValidScrolled(int scrolled) {
method afterLayout (line 452) | public void afterLayout(RecyclerView.Recycler recycler, RecyclerView.S...
method unionChildRegion (line 524) | private void unionChildRegion(RangeStyle<T> rangeStyle) {
method removeChildViews (line 537) | private void removeChildViews(LayoutManagerHelper helper, RangeStyle<T...
method adjustLayout (line 554) | public void adjustLayout(int startPosition, int endPosition, LayoutMan...
method hideLayoutViews (line 599) | private void hideLayoutViews(LayoutManagerHelper helper) {
method hideChildLayoutViews (line 609) | private void hideChildLayoutViews(LayoutManagerHelper helper, RangeSty...
method requireLayoutView (line 622) | public boolean requireLayoutView() {
method requireChildLayoutView (line 630) | private boolean requireChildLayoutView(RangeStyle<T> rangeStyle) {
method bindLayoutView (line 644) | public void bindLayoutView(@NonNull final View layoutView) {
method setLayoutViewHelper (line 658) | public void setLayoutViewHelper(DefaultLayoutViewHelper layoutViewHelp...
method setLayoutViewBindListener (line 663) | public void setLayoutViewBindListener(LayoutViewBindListener bindListe...
method setLayoutViewUnBindListener (line 667) | public void setLayoutViewUnBindListener(
method setBgColor (line 672) | public void setBgColor(int bgColor) {
method onClear (line 676) | public void onClear(LayoutManagerHelper helper) {
method clearChild (line 680) | private void clearChild(LayoutManagerHelper helper, RangeStyle<T> rang...
method onClearChildMap (line 699) | public void onClearChildMap() {
method layoutChild (line 703) | public void layoutChild(final View child, int left, int top, int right...
method fillLayoutRegion (line 708) | protected void fillLayoutRegion(int left, int top, int right, int bott...
class RangeMap (line 724) | private static class RangeMap<T> {
method RangeMap (line 736) | public RangeMap(Class<T> type) {
method addChild (line 740) | public void addChild(int startOffset, int endOffset, T t) {
method getChild (line 763) | public T getChild(int offset) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/ScrollFixLayoutHelper.java
class ScrollFixLayoutHelper (line 36) | public class ScrollFixLayoutHelper extends FixLayoutHelper {
method ScrollFixLayoutHelper (line 48) | public ScrollFixLayoutHelper(int x, int y) {
method ScrollFixLayoutHelper (line 52) | public ScrollFixLayoutHelper(int alignType, int x, int y) {
method setShowType (line 56) | public void setShowType(int showType) {
method getShowType (line 60) | public int getShowType() {
method shouldBeDraw (line 64) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/SingleLayoutHelper.java
class SingleLayoutHelper (line 39) | public class SingleLayoutHelper extends ColumnLayoutHelper {
method SingleLayoutHelper (line 45) | public SingleLayoutHelper() {
method setItemCount (line 50) | @Override
method onRangeChange (line 66) | @Override
method layoutViews (line 71) | @Override
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/StaggeredGridLayoutHelper.java
class StaggeredGridLayoutHelper (line 61) | public class StaggeredGridLayoutHelper extends BaseLayoutHelper {
method run (line 98) | @Override
method StaggeredGridLayoutHelper (line 104) | public StaggeredGridLayoutHelper() {
method StaggeredGridLayoutHelper (line 108) | public StaggeredGridLayoutHelper(int lanes) {
method StaggeredGridLayoutHelper (line 112) | public StaggeredGridLayoutHelper(int lanes, int gap) {
method setGap (line 117) | public void setGap(int gap) {
method setHGap (line 122) | public void setHGap(int hGap) {
method getHGap (line 126) | public int getHGap() {
method setVGap (line 130) | public void setVGap(int vGap) {
method getVGap (line 134) | public int getVGap() {
method setLane (line 138) | public void setLane(int lane) {
method getLane (line 143) | public int getLane() {
method getColLength (line 150) | public int getColLength() {
method ensureLanes (line 154) | private void ensureLanes() {
method beforeLayout (line 164) | @Override
method afterLayout (line 193) | @Override
method layoutViews (line 208) | @Override
method recycleForPreLayout (line 399) | private void recycleForPreLayout(RecyclerView.Recycler recycler, Layou...
method onScrollStateChanged (line 426) | @Override
method computeAlignOffset (line 439) | @Override
method onClear (line 480) | @Override
method checkForGaps (line 492) | private void checkForGaps() {
method hasGapsToFix (line 616) | private View hasGapsToFix(VirtualLayoutManager layoutManager, final in...
method checkSpanForGap (line 641) | private boolean checkSpanForGap(Span span, VirtualLayoutManager layout...
method recycle (line 654) | private void recycle(RecyclerView.Recycler recycler, LayoutStateWrappe...
method recycleFromStart (line 670) | private void recycleFromStart(RecyclerView.Recycler recycler, int line...
method recycleFromEnd (line 692) | private void recycleFromEnd(RecyclerView.Recycler recycler, int line, ...
method findSpan (line 714) | private Span findSpan(int position, View child, boolean isStart) {
method isRecyclable (line 744) | @Override
method updateAllRemainingSpans (line 792) | private void updateAllRemainingSpans(int layoutDir, int targetLine, Or...
method updateRemainingSpans (line 801) | private void updateRemainingSpans(Span span, int layoutDir, int target...
method getNextSpan (line 819) | private Span getNextSpan(int defaultLine, LayoutStateWrapper layoutSta...
method getMaxStart (line 886) | private int getMaxStart(int defaultValue, OrientationHelperEx helper) {
method getMinStart (line 897) | private int getMinStart(int defaultValue, OrientationHelperEx helper) {
method getMaxEnd (line 908) | private int getMaxEnd(int defaultValue, OrientationHelperEx helper) {
method getMinEnd (line 919) | private int getMinEnd(int defaultValue, OrientationHelperEx helper) {
method onRefreshLayout (line 931) | @Override
method checkAnchorInfo (line 949) | @Override
method onItemsChanged (line 1050) | @Override
method onSaveState (line 1055) | @Override
method onRestoreInstanceState (line 1062) | @Override
method onOffsetChildrenVertical (line 1069) | @Override
method onOffsetChildrenHorizontal (line 1080) | @Override
class Span (line 1093) | static class Span {
method Span (line 1104) | private Span(int index) {
method calculateCachedStart (line 1108) | void calculateCachedStart(@NonNull OrientationHelperEx helper) {
method getStartLine (line 1117) | int getStartLine(OrientationHelperEx helper) {
method getStartLine (line 1122) | int getStartLine(int defaultValue, OrientationHelperEx helper) {
method calculateCachedEnd (line 1138) | void calculateCachedEnd(OrientationHelperEx helper) {
method getEndLine (line 1147) | int getEndLine(OrientationHelperEx helper) {
method getEndLine (line 1152) | int getEndLine(int defaultValue, OrientationHelperEx helper) {
method prependToSpan (line 1168) | void prependToSpan(View view, OrientationHelperEx helper) {
method appendToSpan (line 1180) | void appendToSpan(View view, OrientationHelperEx helper) {
method cacheReferenceLineAndClear (line 1193) | void cacheReferenceLineAndClear(boolean reverseLayout, int offset, O...
method clear (line 1215) | void clear() {
method invalidateCache (line 1221) | void invalidateCache() {
method setLine (line 1228) | void setLine(int line) {
method popEnd (line 1233) | void popEnd(OrientationHelperEx helper) {
method findEnd (line 1246) | boolean findEnd(View view) {
method popStart (line 1255) | void popStart(OrientationHelperEx helper) {
method findStart (line 1268) | boolean findStart(View view) {
method getDeletedSize (line 1277) | public int getDeletedSize() {
method getLayoutParams (line 1281) | LayoutParams getLayoutParams(View view) {
method onOffset (line 1285) | void onOffset(int dt) {
method getNormalizedOffset (line 1304) | int getNormalizedOffset(int dt, int targetStart, int targetEnd, Orie...
method isEmpty (line 1330) | boolean isEmpty(int start, int end, OrientationHelperEx orientationH...
class LazySpanLookup (line 1348) | static class LazySpanLookup {
method invalidateAfter (line 1356) | int invalidateAfter(int position) {
method getSpan (line 1368) | int getSpan(int position) {
method setSpan (line 1376) | void setSpan(int position, Span span) {
method sizeForPosition (line 1381) | int sizeForPosition(int position) {
method ensureSize (line 1389) | void ensureSize(int position) {
method clear (line 1401) | void clear() {
method offsetForRemoval (line 1407) | void offsetForRemoval(int positionStart, int itemCount) {
method offsetForAddition (line 1419) | void offsetForAddition(int positionStart, int itemCount) {
FILE: vlayout/src/main/java/com/alibaba/android/vlayout/layout/StickyLayoutHelper.java
class StickyLayoutHelper (line 49) | public class StickyLayoutHelper extends FixAreaLayoutHelper {
type StickyListener (line 50) | public interface StickyListener {
method onSticky (line 51) | void onSticky(int pos, View view);
method onUnSticky (line 53) | void onUnSticky(int pos, View view);
type Stackable (line 56) | public interface Stackable {
method enable (line 57) | boolean enable();
method StickyLayoutHelper (line 77) | public StickyLayoutHelper() {
method StickyLayoutHelper (line 81) | public StickyLayoutHelper(boolean stickyStart) {
method setStickyStart (line 86) | public void setStickyStart(boolean stickyStart) {
method setOffset (line 90) | public void setOffset(int offset) {
method isStickyNow (line 94) | public boolean isStickyNow() {
method setItemCount (line 98) | @Override
method onRangeChange (line 107) | @Override
method layoutViews (line 112) | @Override
method beforeLayout (line 246) | @Override
method requireLayoutView (line 262) | @Override
method afterLayout (line 267) | @Override
method fixLayoutStateFromAbnormal2Normal (line 322) | private void fixLayoutStateFromAbnormal2Normal(OrientationHelperEx ori...
method fixLayoutStateInCase1 (line 375) | private void fixLayoutStateInCase1(OrientationHelperEx orientationHelp...
method fixLayoutStateInCase2 (line 521) | private void fixLayoutStateInCase2(OrientationHelperEx orientationHelp...
method getFixedView (line 711) | @Nullable
method onClear (line 717) | @Override
method doMeasure (line 727) | private void doMeasure(View view, LayoutManagerHelper helper) {
method setStickyListener (line 763) | public void setStickyListener(StickyListener stickyListener) {
method setStackable (line 767) | public void setStackable(Stackable stackable) {
method getExtraTopOffset (line 778) | private int getExtraTopOffset(LayoutManagerHelper helper) {
Condensed preview — 87 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (869K chars).
[
{
"path": ".gitignore",
"chars": 542,
"preview": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbi"
},
{
"path": "CONTRIBUTING.md",
"chars": 2470,
"preview": "# Contributing Guide\n\nThank you for your attention to this project. Any bug, doc, examples and suggestion is appreciated"
},
{
"path": "LICENSE",
"chars": 1070,
"preview": "MIT License\n\nCopyright (c) 2016 Alibaba Group\n\nPermission is hereby granted, free of charge, to any person obtaining a c"
},
{
"path": "README-ch.md",
"chars": 5189,
"preview": "# 注意,该项目停止维护!!!\n\n# vlayout\n\n[English Document](README.md)\n\n## Tangram 相关开源库\n\n### Android\n\n+ [Tangram-Android](https://gi"
},
{
"path": "README.md",
"chars": 6990,
"preview": "# Attention. This project is not maintained any more !!!\n\n# vlayout\n\n[中文文档](README-ch.md)\n\n## Projects of Tangram\n\n### A"
},
{
"path": "build.gradle",
"chars": 2077,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "docs/ATTRIBUTES-ch.md",
"chars": 6005,
"preview": "为了提供丰富的布局能力,我们为`LayoutHelper`设计了一系列布局属性,用来控制布局逻辑和样式。这里介绍这些属性的概念和用法。\n\n[Englist Document](ATTRIBUTES.md)\n\n# margin, paddin"
},
{
"path": "docs/ATTRIBUTES.md",
"chars": 10176,
"preview": "Vlayout provides rich layout features, which are presented in the form of a serial of layout attributes technically. Her"
},
{
"path": "docs/VLayoutFAQ.md",
"chars": 8614,
"preview": "# VLayout FAQ\n\n## 组件复用的问题\n比如碰到卡顿、类型转换异常等等,都有可能是复用的问题引起的。\n\n在使用 `DelegateAdapter` 的时候,每一个 `LayoutHelper` 都对应于一个 `DelegateA"
},
{
"path": "examples/.gitignore",
"chars": 483,
"preview": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbi"
},
{
"path": "examples/build.gradle",
"chars": 2184,
"preview": "apply plugin: 'com.android.application'\n\n/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is he"
},
{
"path": "examples/proguard-rules.pro",
"chars": 998,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "examples/src/androidTest/java/com/alibaba/android/vlayout/ApplicationTest.java",
"chars": 1496,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "examples/src/main/AndroidManifest.xml",
"chars": 2306,
"preview": "<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission is hereby granted, free of charge, to a"
},
{
"path": "examples/src/main/java/com/alibaba/android/vlayout/example/DebugActivity.java",
"chars": 4084,
"preview": "package com.alibaba.android.vlayout.example;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.alibaba.and"
},
{
"path": "examples/src/main/java/com/alibaba/android/vlayout/example/MainActivity.java",
"chars": 5812,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "examples/src/main/java/com/alibaba/android/vlayout/example/OnePlusNLayoutActivity.java",
"chars": 17128,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "examples/src/main/java/com/alibaba/android/vlayout/example/RootActivity.java",
"chars": 1296,
"preview": "package com.alibaba.android.vlayout.example;\n\nimport android.app.ListActivity;\nimport android.content.Intent;\nimport and"
},
{
"path": "examples/src/main/java/com/alibaba/android/vlayout/example/TestActivity.java",
"chars": 5406,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "examples/src/main/java/com/alibaba/android/vlayout/example/VLayoutActivity.java",
"chars": 37268,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "examples/src/main/res/drawable/border_bg.xml",
"chars": 1510,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission "
},
{
"path": "examples/src/main/res/drawable/item_background.xml",
"chars": 1498,
"preview": "<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission is hereby granted, free of charge, to a"
},
{
"path": "examples/src/main/res/layout/card_item.xml",
"chars": 1791,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission "
},
{
"path": "examples/src/main/res/layout/item.xml",
"chars": 1745,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission "
},
{
"path": "examples/src/main/res/layout/main_activity.xml",
"chars": 3858,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission "
},
{
"path": "examples/src/main/res/layout/view_pager.xml",
"chars": 1440,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission "
},
{
"path": "examples/src/main/res/values/colors.xml",
"chars": 1446,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission"
},
{
"path": "examples/src/main/res/values/strings.xml",
"chars": 1250,
"preview": "<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission is hereby granted, free of charge, to a"
},
{
"path": "examples/src/main/res/values/styles.xml",
"chars": 1781,
"preview": "<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission is hereby granted, free of charge, to a"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 1343,
"preview": "#\n# MIT License\n#\n# Copyright (c) 2016 Alibaba Group\n#\n# Permission is hereby granted, free of charge, to any person obt"
},
{
"path": "gradle.properties",
"chars": 2187,
"preview": "#\n# MIT License\n#\n# Copyright (c) 2016 Alibaba Group\n#\n# Permission is hereby granted, free of charge, to any person obt"
},
{
"path": "gradlew",
"chars": 5080,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "jcenterDeploy.gradle",
"chars": 6227,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2017 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "jcenterInstall.gradle",
"chars": 2235,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2017 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "settings.gradle",
"chars": 1176,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/.gitignore",
"chars": 483,
"preview": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbi"
},
{
"path": "vlayout/DESIGN.md",
"chars": 49,
"preview": "# VirtualLayout 设计说明\n\n# VirtualLayout Design Note"
},
{
"path": "vlayout/build.gradle",
"chars": 4722,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/jacoco.gradle",
"chars": 2423,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/proguard-rules.pro",
"chars": 1116,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "vlayout/src/androidTest/java/com/alibaba/android/vlayout/ViewHolderHelper.java",
"chars": 2877,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/androidTest/java/com/alibaba/android/vlayout/VirtualLayoutManagerTest.java",
"chars": 27612,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/AndroidManifest.xml",
"chars": 1224,
"preview": "<!--\n ~ MIT License\n ~\n ~ Copyright (c) 2016 Alibaba Group\n ~\n ~ Permission is hereby granted, free of charge, to a"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/Cantor.java",
"chars": 1001,
"preview": "package com.alibaba.android.vlayout;\n\n/**\n * Created by longerian on 2017/12/10.\n *\n * @author longerian\n * @date 2017/1"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/DelegateAdapter.java",
"chars": 21207,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/ExposeLinearLayoutManagerEx.java",
"chars": 80531,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/LayoutHelper.java",
"chars": 11156,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/LayoutHelperFinder.java",
"chars": 1987,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/LayoutManagerHelper.java",
"chars": 8597,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/LayoutView.java",
"chars": 1992,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/LayoutViewFactory.java",
"chars": 1421,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/MismatchChildCountException.java",
"chars": 1503,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/OrientationHelperEx.java",
"chars": 11794,
"preview": "package com.alibaba.android.vlayout;\n\nimport android.support.v7.widget.RecyclerView;\nimport android.view.View;\nimport an"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/Range.java",
"chars": 13051,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/RangeLayoutHelperFinder.java",
"chars": 4714,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/RecyclablePagerAdapter.java",
"chars": 4117,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/SortedList.java",
"chars": 25249,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/VirtualLayoutAdapter.java",
"chars": 1902,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/VirtualLayoutManager.java",
"chars": 54983,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/extend/InnerRecycledViewPool.java",
"chars": 5885,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/extend/LayoutManagerCanScrollListener.java",
"chars": 170,
"preview": "package com.alibaba.android.vlayout.extend;\n\npublic interface LayoutManagerCanScrollListener {\n boolean canScrollVert"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/extend/PerformanceMonitor.java",
"chars": 1058,
"preview": "package com.alibaba.android.vlayout.extend;\n\nimport android.support.annotation.Keep;\nimport android.view.View;\n\n/**\n * A"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/extend/ViewLifeCycleHelper.java",
"chars": 4715,
"preview": "package com.alibaba.android.vlayout.extend;\n\nimport android.support.annotation.NonNull;\nimport android.support.v4.util.A"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/extend/ViewLifeCycleListener.java",
"chars": 254,
"preview": "package com.alibaba.android.vlayout.extend;\n\nimport android.view.View;\n\npublic interface ViewLifeCycleListener {\n voi"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/AbstractFullFillLayoutHelper.java",
"chars": 9584,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/BaseLayoutHelper.java",
"chars": 23020,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/ColumnLayoutHelper.java",
"chars": 9874,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/DefaultLayoutHelper.java",
"chars": 1623,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/FixAreaAdjuster.java",
"chars": 1655,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/FixAreaLayoutHelper.java",
"chars": 2837,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/FixLayoutHelper.java",
"chars": 19699,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/FloatLayoutHelper.java",
"chars": 19285,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/GridLayoutHelper.java",
"chars": 33728,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/LayoutChunkResult.java",
"chars": 1536,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/LinearLayoutHelper.java",
"chars": 10698,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/MarginLayoutHelper.java",
"chars": 6718,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/OnePlusNLayoutHelper.java",
"chars": 38931,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/OnePlusNLayoutHelperEx.java",
"chars": 31332,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/RangeGridLayoutHelper.java",
"chars": 45182,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/RangeStyle.java",
"chars": 26245,
"preview": "package com.alibaba.android.vlayout.layout;\n\nimport java.lang.reflect.Array;\nimport java.util.HashMap;\nimport java.util."
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/ScrollFixLayoutHelper.java",
"chars": 2727,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/SingleLayoutHelper.java",
"chars": 7172,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/StaggeredGridLayoutHelper.java",
"chars": 55538,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/java/com/alibaba/android/vlayout/layout/StickyLayoutHelper.java",
"chars": 34320,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2016 Alibaba Group\n *\n * Permission is hereby granted, free of charge, to any pers"
},
{
"path": "vlayout/src/main/res/values/ids.xml",
"chars": 114,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <item name=\"tag_layout_helper_bg\" type=\"id\" />\n</resources>"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the alibaba/vlayout GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 87 files (818.4 KB), approximately 183.9k tokens, and a symbol index with 1154 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.