janishar / PlaceHolderView

This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->
http://janishar.com/PlaceHolderView
Apache License 2.0
2.11k stars 369 forks source link

@Click behavior bug for SwipePlaceHolderView #14

Closed rsaksida closed 7 years ago

rsaksida commented 7 years ago

Hey,

First of all, thanks for the awesome work on PlaceHolderView! It's by far the best and most professional Android library of its kind. :clap:

I've noticed an odd behavior while using SwipePlaceHolderView. This is the context of the bug:

1) I have a stack of 3 cards: A, B and C added in this order. 2) Each card has a few buttons on it. I'm setting click handlers for the buttons with @Click. 3) When I click a button on the first card of the deck (A), the last card of the deck (C) is triggered instead. C is not visible at all to the user as it's below in the deck.

I've created a repository demonstrating this: PlaceHolderView bug. If you run it and click the buttons, you'll notice in the debug log that the wrong button is being triggered.

Let me know if I'm doing something wrong - maybe this is not the proper way to do what I'm trying to achieve...

In addition, if this is really a bug and you don't have time to tackle it in the library, perhaps I could help with a PR if you give me some pointers as to where the issue might be.

Thanks again!

janishar commented 7 years ago

@rmsaksida Thank you so much for your kind words. I looked into your project repo but when I tested the card is showing the correct click events. see this log.

com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION1. The answer is: ANSWER1. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION1. The answer is: ANSWER2. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION1. The answer is: ANSWER3. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION2. The answer is: ANSWER1. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION2. The answer is: ANSWER2. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION2. The answer is: ANSWER3. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER1. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER2. com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 0 com.example.placeholderviewbug D/ViewRootImpl: ViewPostImeInputStage processPointer 1 com.example.placeholderviewbug I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER3.

Provide some log of your so I can look into this bug

rsaksida commented 7 years ago

Hmm, then it must be an API level issue. I didn't think to test on different API levels, sorry about that. I tested now on API level 21 and indeed it works.

However, the error still happens on API level 16.

rsaksida commented 7 years ago

Emulator Profile:

Name: Nexus_5_API_16
CPU/ABI: Google APIs Intel Atom (x86)
Path: 
Target: google_apis [Google APIs] (API level 16)
Skin: nexus_5
SD Card: 100M
hw.dPad: no
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: Nexus 5
vm.heapSize: 64
skin.dynamic: yes
hw.device.manufacturer: Google
hw.gps: yes
hw.initialOrientation: Portrait
image.androidVersion.api: 16
hw.audioInput: yes
image.sysdir.1: system-images/android-16/google_apis/x86/
tag.id: google_apis
showDeviceFrame: yes
hw.camera.back: emulated
hw.mainKeys: no
AvdId: Nexus_5_API_16
hw.camera.front: emulated
hw.lcd.density: 480
avd.ini.displayname: Nexus 5 API 16
hw.gpu.mode: auto
hw.device.hash2: MD5:2fa0e16c8cceb7d385183284107c0c88
hw.ramSize: 1536
hw.trackBall: no
hw.battery: yes
hw.cpu.ncore: 2
hw.sdCard: yes
tag.display: Google APIs
runtime.network.latency: none
hw.keyboard: yes
hw.sensors.proximity: yes
disk.dataPartition.size: 800M
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes

Debug log:

$ adb shell am start -n "com.example.placeholderviewbug/com.example.placeholderviewbug.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.example.placeholderviewbug.test | com.example.placeholderviewbug
Waiting for application to come online: com.example.placeholderviewbug.test | com.example.placeholderviewbug
Waiting for application to come online: com.example.placeholderviewbug.test | com.example.placeholderviewbug
Connecting to com.example.placeholderviewbug
I/dalvikvm: Debugger is active
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8728', transport: 'socket'
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1306)
I/dalvikvm: Could not find method android.app.Application.registerOnProvideAssistDataListener, referenced from method com.android.tools.fd.runtime.BootstrapApplication.registerOnProvideAssistDataListener
W/dalvikvm: VFY: unable to resolve virtual method 236: Landroid/app/Application;.registerOnProvideAssistDataListener (Landroid/app/Application$OnProvideAssistDataListener;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/dalvikvm: Could not find method android.app.Application.unregisterOnProvideAssistDataListener, referenced from method com.android.tools.fd.runtime.BootstrapApplication.unregisterOnProvideAssistDataListener
W/dalvikvm: VFY: unable to resolve virtual method 239: Landroid/app/Application;.unregisterOnProvideAssistDataListener (Landroid/app/Application$OnProvideAssistDataListener;)V
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/InstantRun: Instant Run Runtime started. Android package is com.example.placeholderviewbug, real application class is null.
W/InstantRun: No instant run dex files added to classpath
E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources
W/dalvikvm: VFY: unable to resolve check-cast 2060 (Landroid/util/ArrayMap;) in Lcom/android/tools/fd/runtime/MonkeyPatcher;
D/dalvikvm: VFY: replacing opcode 0x1f at 0x025e
E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.pruneResourceCache
W/dalvikvm: VFY: unable to resolve const-class 2060 (Landroid/util/ArrayMap;) in Lcom/android/tools/fd/runtime/MonkeyPatcher;
D/dalvikvm: VFY: replacing opcode 0x1c at 0x0060
I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
W/dalvikvm: VFY: unable to resolve interface method 18123: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
W/dalvikvm: VFY: unable to resolve interface method 18125: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
W/dalvikvm: VFY: unable to resolve interface method 18129: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
W/dalvikvm: VFY: unable to resolve virtual method 674: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
W/dalvikvm: VFY: unable to resolve virtual method 696: Landroid/content/res/TypedArray;.getType (I)I
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008
I/dalvikvm: Could not find method android.widget.FrameLayout.startActionModeForChild, referenced from method android.support.v7.widget.ActionBarContainer.startActionModeForChild
W/dalvikvm: VFY: unable to resolve virtual method 18580: Landroid/widget/FrameLayout;.startActionModeForChild (Landroid/view/View;Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002
I/dalvikvm: Could not find method android.view.ViewGroup.onRtlPropertiesChanged, referenced from method android.support.v7.widget.Toolbar.onRtlPropertiesChanged
W/dalvikvm: VFY: unable to resolve virtual method 18019: Landroid/view/ViewGroup;.onRtlPropertiesChanged (I)V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0007
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
W/dalvikvm: VFY: unable to resolve virtual method 419: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
W/dalvikvm: VFY: unable to resolve virtual method 637: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
W/dalvikvm: VFY: unable to resolve virtual method 639: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
W/dalvikvm: VFY: unable to resolve instanceof 151 (Landroid/graphics/drawable/RippleDrawable;) in Landroid/support/v7/widget/AppCompatImageHelper;
D/dalvikvm: VFY: replacing opcode 0x20 at 0x000c
D/dalvikvm: GC_CONCURRENT freed 219K, 2% free 18842K/19207K, paused 1ms+1ms, total 5ms
I/dalvikvm: Could not find method android.widget.FrameLayout.<init>, referenced from method com.mindorks.placeholderview.SwipePlaceHolderView.<init>
W/dalvikvm: VFY: unable to resolve direct method 18518: Landroid/widget/FrameLayout;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;II)V
D/dalvikvm: VFY: replacing opcode 0x70 at 0x0003
D/libEGL: loaded /system/lib/egl/libEGL_emulation.so
D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so

          [ 10-11 10:13:50.926  2179: 2179 D/         ]
          HostConnection::get() New Host Connection established 0xb85d5f60, tid 2179
W/gralloc_ranchu: Gralloc pipe failed
D/OpenGLRenderer: Enabling debug mode 0
I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER1.
I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER2.
I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER3.
I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER1.
I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER2.
I/PlaceholderView: The question is: QUESTION3. The answer is: ANSWER3.
rsaksida commented 7 years ago

Hey, curious as to why this was closed - isn't API level 16 supported? Thanks.

janishar commented 7 years ago

Let me do a testing on 16 api and will post the finding.. thanks

janishar commented 7 years ago

@rmsaksida The issue is with the emulator. The emulator with api 16 does not respond quickly when the buttons are clicked via touch pad. Try using arrow keys and enter button for the button click. It will work. If you test on real device I am confident it will work. But have not tested on real device with api 16 though.

Also I have released new version 0.2.8. This version activate the @Click only when the card is top most.

rsaksida commented 7 years ago

Understood, thank you for looking into this! Congrats for the library.