davidpacioianu / inkpageindicator Goto Github PK
View Code? Open in Web Editor NEWInkPageIndicator created by @nickbutcher for Plaid https://github.com/nickbutcher/plaid and backported by me for API 14+ (4.0+)
License: Apache License 2.0
InkPageIndicator created by @nickbutcher for Plaid https://github.com/nickbutcher/plaid and backported by me for API 14+ (4.0+)
License: Apache License 2.0
Basically, just add
@Override
public void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState)state;
super.onRestoreInstanceState(savedState.getSuperState());
currentPage = savedState.currentPage;
requestLayout();
}
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState savedState = new SavedState(superState);
savedState.currentPage = currentPage;
return savedState;
}
static class SavedState extends BaseSavedState {
int currentPage;
public SavedState(Parcelable superState) {
super(superState);
}
private SavedState(Parcel in) {
super(in);
currentPage = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(currentPage);
}
@SuppressWarnings("UnusedDeclaration")
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}
Not exactly an issue.
But most of the new apps in India are targeting API 15 or above.
And this can be made compatible with API 14 and above by replacing:
postInvalidateOnAnimation()
with
'ViewCompat.postInvalidateOnAnimation(InkPageIndicator.this)'
I was working on dynamic view pager. Since the library is listening to the adapter changes, i notice that there is a function called reset state where the pageCount - 1 should handle properly as the page count could go to zero.
Hi can you add support for recyclerview
D/PageIndicator: dot 1 fraction: 0.01759255
Hi There,
The test app does not work if coun of items in the Adapter is slightly increase. Make it more then 30.
The log I am seeing is like
19 | 08-24 | 16:01:42.345 | F | 23570 | 23570 | DEBUG | : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** | |
---|---|---|---|---|---|---|---|---|
20 | 08-24 | 16:01:42.345 | F | 23570 | 23570 | DEBUG | : Build fingerprint: google/shamu/shamu:7.1.1/N6F27I/4118426:user/release-keys | |
21 | 08-24 | 16:01:42.345 | F | 23570 | 23570 | DEBUG | : Revision: 0 | |
22 | 08-24 | 16:01:42.345 | F | 23570 | 23570 | DEBUG | : ABI: arm | |
23 | 08-24 | 16:01:42.345 | F | 23570 | 23570 | DEBUG | : pid: 22397, tid: 22440, name: hwuiTask1 >>> com.pixelcan.ipidemo <<< | |
24 | 08-24 | 16:01:42.346 | F | 23570 | 23570 | DEBUG | : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- | |
25 | 08-24 | 16:01:42.349 | F | 23570 | 23570 | DEBUG | : r0 00000000 r1 000057a8 r2 00000006 r3 00000008 | |
26 | 08-24 | 16:01:42.349 | F | 23570 | 23570 | DEBUG | : r4 8e16f978 r5 00000006 r6 8e16f920 r7 0000010c | |
27 | 08-24 | 16:01:42.349 | F | 23570 | 23570 | DEBUG | : r8 8e16d6d8 r9 8e16d490 sl 8e16d628 fp 8e16d7b0 | |
28 | 08-24 | 16:01:42.349 | F | 23570 | 23570 | DEBUG | : ip 0000000c sp 8e16d358 lr b067a5c7 pc b067ce30 cpsr 600f0010 | |
29 | 08-24 | 16:01:42.372 | F | 23570 | 23570 | DEBUG | : | |
30 | 08-24 | 16:01:42.372 | F | 23570 | 23570 | DEBUG | : backtrace: | |
31 | 08-24 | 16:01:42.372 | F | 23570 | 23570 | DEBUG | : #00 pc 00049e30 /system/lib/libc.so (tgkill+12) | |
32 | 08-24 | 16:01:42.372 | F | 23570 | 23570 | DEBUG | : #1 pc 000475c3 /system/lib/libc.so (pthread_kill+34) | |
33 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #2 pc 0001d635 /system/lib/libc.so (raise+10) | |
34 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #3 pc 00019181 /system/lib/libc.so (__libc_android_abort+34) | |
35 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #4 pc 00017048 /system/lib/libc.so (abort+4) | |
36 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #5 pc 002afccd /system/lib/libskia.so (_Z15sk_malloc_flagsjj+28) | |
37 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #6 pc 0013c6d7 /system/lib/libskia.so (_ZN12SkChunkAlloc8newBlockEjNS_13AllocFailTypeE+26) | |
38 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #7 pc 0013c707 /system/lib/libskia.so (_ZN12SkChunkAlloc19addBlockIfNecessaryEjNS_13AllocFailTypeE+18) | |
39 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #8 pc 0013c727 /system/lib/libskia.so (_ZN12SkChunkAlloc5allocEjNS_13AllocFailTypeE+14) | |
40 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #9 pc 00149eb7 /system/lib/libskia.so (_ZN13SkEdgeBuilder7addQuadEPK7SkPoint+10) | |
41 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #10 pc 0014a667 /system/lib/libskia.so | |
42 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #11 pc 0014a557 /system/lib/libskia.so (_ZN13SkEdgeBuilder5buildERK6SkPathPK7SkIRectib+406) | |
43 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #12 pc 0019139b /system/lib/libskia.so (_Z12sk_fill_pathRK6SkPathPK7SkIRectP9SkBlitteriiiRK8SkRegion+62) | |
44 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #13 pc 0018e03b /system/lib/libskia.so (_ZN6SkScan12AntiFillPathERK6SkPathRK8SkRegionP9SkBlitterb+682) | |
45 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #14 pc 0014679b /system/lib/libskia.so (_ZNK6SkDraw8drawPathERK6SkPathRK7SkPaintPK8SkMatrixbbP9SkBlitter+678) | |
46 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #15 pc 001275cf /system/lib/libskia.so (_ZN14SkBitmapDevice8drawPathERK6SkDrawRK6SkPathRK7SkPaintPK8SkMatrixb+30) | |
47 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #16 pc 0013956b /system/lib/libskia.so (_ZN8SkCanvas10onDrawPathERK6SkPathRK7SkPaint+370) | |
48 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #17 pc 000485c3 /system/lib/libhwui.so | |
49 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #18 pc 000488bb /system/lib/libhwui.so | |
50 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #19 pc 00025087 /system/lib/libhwui.so | |
51 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #20 pc 000299d1 /system/lib/libhwui.so | |
52 | 08-24 | 16:01:42.373 | F | 23570 | 23570 | DEBUG | : #21 pc 0000e3a3 /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+270) | |
53 | 08-24 | 16:01:42.374 | F | 23570 | 23570 | DEBUG | : #22 pc 00067d21 /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+80) | |
54 | 08-24 | 16:01:42.374 | F | 23570 | 23570 | DEBUG | : #23 pc 00047093 /system/lib/libc.so (_ZL15__pthread_startPv+22) | |
55 | 08-24 | 16:01:42.374 | F | 23570 | 23570 | DEBUG | : #24 pc 00019bdd /system/lib/libc.so (__start_thread+6) |
Hi,
Thank you so much for this wonderful library. It is very useful and has helped me immensely.
But I found an issue with using setCurrentItem on my viewPager.
Here is the flow :
I have initialized the ViewPager, PagerAdapter and InkPageIndicator
testAdapter = new SimplePagerAdapter(testList);
testPager.setAdapter(testAdapter);
testIndicator.setViewPager(testPager);
Then I add few views to testList and call notifyDataSetChanged on testAdapter.
(Which internally calls setPageCount and pageCount gets initialized correctly, which internally calls requestLayout , which would be called on next idle cycle)
testList.add(newView);
testPager.getAdapter().notifyDataSetChanged();
Then I immediately call setCurrentItem(newViewIndex, false);
which calls setPageSelected inline which calls setSelectedPage. setSelectedPage tries to call
createMoveSelectedAnimator but dotCenterX doesn't contain newly added view's dot's X value. This is because calculateDotPositions isn't called as yet since onMeasure is not called as yet and is waiting to be called in idle cycle.
Could you please give me a suggestion on how can I fix this. I would create the patch and create pull request for the same.
Would be nice to be able to set the gravity to bottom too.
In my project, I have to support the view pager being updated such that any page in it can be deleted.
The InkPageIndicator library crashes when I delete the final page with an ArrayIndexOutOfBoundsException
It looks like maybe dotsToHide
isn't being updated at the right time and is always expecting 1 more than it has access to after deleting.
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 at com.pixelcan.inkpageindicator.InkPageIndicator.setDotRevealFraction(InkPageIndicator.java:655) at com.pixelcan.inkpageindicator.InkPageIndicator.access$1600(InkPageIndicator.java:47) at com.pixelcan.inkpageindicator.InkPageIndicator$PendingRetreatAnimator$3.onAnimationStart(InkPageIndicator.java:765) at android.animation.ValueAnimator.notifyStartListeners(ValueAnimator.java:981) at android.animation.ValueAnimator.start(ValueAnimator.java:1043) at android.animation.ValueAnimator.start(ValueAnimator.java:1050) at com.pixelcan.inkpageindicator.InkPageIndicator$PendingStartAnimator.startIfNecessary(InkPageIndicator.java:681) at com.pixelcan.inkpageindicator.InkPageIndicator$3.onAnimationUpdate(InkPageIndicator.java:610) at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1374) at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1298) at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1339) at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:715) at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:549) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I have vertical card slider and I would like show a vertical inkpage indicator beside the slider. Could you enhance it or give me suggestion what to change to make it vertical?
Like below
.
.
.
.
In some cases, names of own attributes or attributes in other libraries can be equal with your library attributes. That's why resource merger could exit with an error while building. Like this:
Attribute "animationDuration" has already been defined
I propose you to add tags like pi_animationDuration
to your attributes. That's might be helpful.
Is there a way to change the pageIndicatorColor
and the currentPageIndicatorColor
programmatically?
Thanks
Hello,
please do the size of the current indicator of different sizes with unselected indicators
The JCenter repository is now deprecated and will stop service on February 1, 2022. For more information, see https://developer.android.com/studio/build/jcenter-migration
In sample app, when I add 20 pages, it become very very slow and completely unusable.
I found it's caused by a line code in InkPageIndicator.drawUnselected(Canvas canvas).
......
// draw any settled, revealing or joining dots
for (int page = 0; page < pageCount; page++) {
int nextXIndex = page == pageCount - 1 ? page : page + 1;
Path unselectedPath = getUnselectedPath(page,
dotCenterX[page],
dotCenterX[nextXIndex],
page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
dotRevealFractions[page]);
unselectedPath.addPath(combinedUnselectedPath);
combinedUnselectedPath.addPath(unselectedPath);
}
......
I don't known why the bold line is need there? but when I delete it, this issue disappeared.
the bold line and the under line, seem will add some circle paths to the final draw path very much times, so it cause this issue.
Please pardon my poor english!
There's an animation bug with this on pre-lollipop where the dot to the right side disappears during the transition.
See: http://webmshare.com/dLEEL
I think it's due to the change to addPath
, which I don't think it a like-for-like equivelant to Path.Op.UNION
.
UPDATE: This seems to be an issue when using a custom ViewPager. When using a generic ViewPager it does not happen.
Hi, I have noticed this issue both on Lollipop and Nougat devices. When scrolling a viewpager backwards, eg. when scrolling from page 6 to page 5, I notice that as soon as the animations complete, dot 4 flashes. This happens on all page scrolls from right to left, but not the other way around. So, scrolling from page 5 to page 6 doesn't have this issue.
Maybe this is a simple fix of not including that dot in the ones to be redrawn, but I'm not sure what part of the code I need to touch for this.
Hi,
I have many reports of NPE on devices running Android 4. I couldn't figure out the origin of the problem since I cannot reproduce it. Below the stack trace. Any idea?
java.lang.NullPointerException:
at com.pixelcan.inkpageindicator.InkPageIndicator.a (InkPageIndicator.java:338)
at com.pixelcan.inkpageindicator.InkPageIndicator.onDraw (InkPageIndicator.java:327)
at android.view.View.draw (View.java:14629)
at android.view.View.getDisplayList (View.java:13523)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.View.draw (View.java:14343)
at android.view.ViewGroup.drawChild (ViewGroup.java:3228)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3084)
at android.view.View.draw (View.java:14632)
at android.view.View.getDisplayList (View.java:13523)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:3202)
at android.view.View.getDisplayList (View.java:13460)
at android.view.View.getDisplayList (View.java:13565)
at android.view.HardwareRenderer$GlRenderer.buildDisplayList (HardwareRenderer.java:1577)
at android.view.HardwareRenderer$GlRenderer.draw (HardwareRenderer.java:1451)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:2398)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:2264)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:1892)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1006)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:5652)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:761)
at android.view.Choreographer.doCallbacks (Choreographer.java:574)
at android.view.Choreographer.doFrame (Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:747)
at android.os.Handler.handleCallback (Handler.java:733)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:136)
at android.app.ActivityThread.main (ActivityThread.java:5426)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1084)
at dalvik.system.NativeStart.main (Native Method
My app Touch for Facebook will use InkPageIndicator with the next update, already implemented it. Please add it to the list:)
http://play.google.com/store/apps/details?id=com.fa.touch.free
Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute application@label value=(Kapt Issue) from AndroidManifest.xml:6:9-35
is also present at [com.pacioianu.david:ink-page-indicator:1.2.0] AndroidManifest.xml:12:9-41 value=(@string/app_name).
Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:4:5-14:19 to override.
This value should be defined in the app using the lib, not in the library.
I have just migrated to AndroidX and I can't compile my app because InkPageIndicator uses ViewPager from android design support library
Step to reproduce:
Create a ViewPager with 3 pages.
Go to the second page.
Begin to scroll to the first page, but stop the movement so that you actually stay on the second.
The first dot disappears.
The bug doesn't show when you slide to right.
i work on a gallery app to show products, when i show 12 pictures or less it works great, but when there are more than 15 pictures it blocks the app
It is very hard to notice, but it gives a bad overall impression:
When animating from position 1 to position 2, the dot is supposed to move (i.e. animate) from position 1 to position 2. But if you look carefully, for a split second a dot (with the selected color) appears at position 2 and then vanishes; and then the animation takes place as expected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.