Traversaless(traversal less) ViewPager was born as an enhance ViewPager, it's mission was to solve the scroll too much problem for me, but I believe this problem also share with others, so I made this project and release it.
What's the problem
Let's say we have five pages inside the ViewPager, now the first page is shown, after that, we click the corresponding button
of last page intend to switch from first page directly to last page, this time the scroll animation start to play but it go through
the second page and the third page and the fourth page, finally reach to the last page. and if we used the
which you knew it's principle, you'll saw the
third page appear but being destroy after the scrolling done.
what's the point, we just going to last page, you create the innocent page for scroll then destroy it? let's consider this :
"does these irrelevant page(s) would cause unexpected GC or influence the scroll animation smoothly?", the answer is fairly positive.
I'd like to change this behavior, that was why we achieved this component.
Because original ViewPager was complicated and rich-features, so I do it carefully and write enough testcases to prove my customization is unproblematic, also bring some performance improvements, the testcase APK will show you all my job and make you trust it's worth to live in your project.
Please download and install the pre-built testcase APK file to examine in action.
Download the latest JAR or depend it via Maven :
<dependency> <groupId>com.vincestyling</groupId> <artifactId>traversaless-viewpager</artifactId> <version>4.0.1_r1</version> </dependency>
For Gradle projects use :
Note : this widget was depended by
android-support-v4.jar to build,
can't work without it, you should add the support jar into your libraries.
The usage have nothing change, only the package location, enjoy it like you do with ViewPager before.
This widget base on android-support-v4
4.0.1_r1 version, when I try to make clear how it work,
I realize it's bit complicated than I unable to fully get it mind, so I split the source code as two classes,
put those code who weren't doing scroll animation behind, cooperate with the IDE debugger, I make this purpose come true.
If you want to compile this project, you should make the
android-support-v4.jar as library or install it into the maven repository :
mvn install:install-file -Dfile=lib/android-support-v4.jar -DgroupId=com.google.android -DartifactId=support-v4 -Dversion=4.4.2_r1 -DgeneratePom=true -Dpackaging=jar
Copyright (C) 2011 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.