Bug 34376 - [Android Samples] Pull to refresh in "Cheese Square" Xamarin sample causes tapped listview items to open multiple pages
Summary: [Android Samples] Pull to refresh in "Cheese Square" Xamarin sample causes ta...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Samples ()
Version: 5.1
Hardware: Macintosh Mac OS
: Highest normal
Target Milestone: ---
Assignee: Jon Dick
URL:
Depends on:
Blocks:
 
Reported: 2015-09-28 20:36 UTC by Kent Green [MSFT]
Modified: 2015-10-13 14:32 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Logs from my repo of the issue (194.36 KB, application/zip)
2015-09-28 20:36 UTC, Kent Green [MSFT]
Details
An example that causes the opening of multiple views with just one tap (3.08 MB, application/octet-stream)
2015-10-11 16:29 UTC, bagimene
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Kent Green [MSFT] 2015-09-28 20:36:39 UTC
Created attachment 13113 [details]
Logs from my repo of the issue

## Overview
From this enterprise desk case:
https://kb.xamarin.com/agent/case/216997

Customer reports that using the "Chesse Square" sample, scrolling down or up (pull to refresh) and selecting one of the listview list items will cause multiple pages to be stacked, requiring several taps to back out of entries to the main list.

## Sample Link
https://github.com/xamarin/monodroid-samples/tree/master/android5.0/Cheesesquare

## Steps to Reproduce
1. Compile and launch app
2. Scroll down or up all the way (pull to refresh)
3. Click a view
4. Hit back
5. Instead of going “back” to the list, additional random entries will appear.

## Additional Observations
Note: In my tests I was able to reproduce the issue with these steps frequently, but not always 100% of the time. It seems to generate a random number of pages to "back out" from to get back to the list, usually between about 1 & 5. I did notice there were some Random variables within the source code which I initially suspected of being the cause, however; these Random variables seem to only apply to the names and images for each "cheese"; and commenting them out seemed to have no impact on the reproducibility of the bug. 

I'm also not sure if this issue is a bug with the sample *itself* or if it's a Xamarin.Android bug.

## Build Information
=== Xamarin Studio ===

Version 5.9.7 (build 9)
Installation UUID: 8ef63a7c-1b18-40de-a334-7f78777fcb55
Runtime:
	Mono 4.0.4 ((detached/cb6d6b2)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400040002

=== Apple Developer Tools ===

Xcode 7.0 (8227)
Build 7A220

=== Xamarin.iOS ===

Version: 9.0.1.20 (Business Edition)
Hash: d8e9592
Branch: master
Build date: 2015-09-18 23:22:05-0400

=== Xamarin.Android ===

Version: 5.1.6.7 (Business Edition)
Android SDK: /Users/kentgreen/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
Java SDK: /usr
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.2.111 (Business Edition)

=== Build Information ===

Release ID: 509070009
Git revision: 31fa64709030b3edb971237780a452a4c69943c4
Build date: 2015-09-17 11:44:37-04
Xamarin addins: b105d33d8cd72911ff2cf3ee0b7715d37e5f19a6

=== Operating System ===

Mac OS X 10.10.5
Darwin Kents-MBP 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 3 bagimene 2015-10-11 16:29:10 UTC
Created attachment 13279 [details]
An example that causes the opening of multiple views with just one tap

We have a similar problem with an application that shows products. We think that our example could help to solve this bug.

When running the application follow these steps:
1) slide the screen down to the product 14
2) select the product 14 with just one tap
3) press the return button to go back to the previous view. Here others screens appear. Specifically, you will see product 9 and then product 4 two times.
4) Once in the hoome screen, if you pick another product and go back, the error occurs again in a similar sequence (for instance, selecting product 13 generates the sequence 13>8>3>3).

Note: This error also occurs in other scenarios that seem random.

Some thougths:

Why does the sequence 14>9>4>4 occur?
Does it have something to do with the tabs used in the code?

In the example of "Cheesesquare" it is similar, but with views with the same name. However, when testing the officil Java version of "Cheesesquare" in Android Studio, the application does not have this problem. 

This seems like a Xamarin.Android bug.
Comment 4 Jon Dick 2015-10-13 14:32:41 UTC
In the case of Cheesesquare sample what's happening is the Click event handler for the ViewHolder's view is being subscribed to each time the view holder is bound.  This means that as the viewholder is recycled, more and more event handlers are added to the same view's click event, causing multiple details pages to open.

I've fixed the sample in the public monodroid-samples repo on github.

As for the Catalog example, Benjamim, I believe the same thing is happening... You are using the convertView in the GetView of your adapter, and always adding a new button click event handler... so each time the view is recycled, the click handler gets another subscriber.