Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Clicked item view is not redrawn if the swipe to dismiss is enabled. #9

Closed
hsanson opened this issue Sep 30, 2013 · 3 comments
Closed

Comments

@hsanson
Copy link

hsanson commented Sep 30, 2013

I have implemented a list, using EnhancedListView, that allows users to remove items from it by swiping. But also I would like to allow users to select one item from the list by clicking on it.

For some reason when the I enable swipeToDismiss on the list and click on a item, all other items in the list get redrawn except the one I clicked. For this reason the clicked item view is not updated and never changes to the selected state.

You can see this my modifying the EnhancedListViewDemo application so it prints the list items that are redrawn in the getView() method and call the notifyDataSetChanged() on the adapter in the onItemClick callback.

When swipeToDismiss is disabled and you click on an item the notifyDataSetChanged() is called and you can see in the log that all items in the list are redrawn by calls to the getView() method.

When I enable the swipeToDismiss on the list and you click on an item you will notice on the logs that all items are redrawn (via getView()) except for the item you clicked.

You may use this patch to see what I am saying:

From c60e5b95add865fd3f5ba3efa2ee86fefbaf1ce1 Mon Sep 17 00:00:00 2001
From: Horacio Sanson <horacio@skillupjapan.co.jp>
Date: Mon, 30 Sep 2013 20:23:33 +0900
Subject: [PATCH] Simple test for testing a bug.

---
 .../src/main/java/de/timroes/android/listviewdemo/MainActivity.java     | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/EnhancedListViewDemo/src/main/java/de/timroes/android/listviewdemo/MainActivity.java b/EnhancedListViewDemo/src/main/java/de/timroes/android/listviewdemo/MainActivity.java
index 03268ce..b29d884 100644
--- a/EnhancedListViewDemo/src/main/java/de/timroes/android/listviewdemo/MainActivity.java
+++ b/EnhancedListViewDemo/src/main/java/de/timroes/android/listviewdemo/MainActivity.java
@@ -140,6 +140,7 @@ public class MainActivity extends ActionBarActivity {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                 Toast.makeText(MainActivity.this, "Clicked on item " + mAdapter.getItem(position), Toast.LENGTH_SHORT).show();
+                mAdapter.notifyDataSetChanged();
             }
         });
         mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@@ -368,6 +369,7 @@ public class MainActivity extends ActionBarActivity {
             }

             holder.position = position;
+            Log.d("XXX", "Get view " + mItems.get(position));
             holder.mTextView.setText(mItems.get(position));

             return convertView;
-- 
1.8.1.2
@timroes
Copy link
Owner

timroes commented Sep 30, 2013

Hi,

I am sorry, but I cannot reproduce this. I applied your patch, and pressing e.g. Item 2 gives me:

5201               REDRAW  D  View Item 1
5201               REDRAW  D  View Item 2
5201               REDRAW  D  View Item 3
5201               REDRAW  D  View Item 4
5201               REDRAW  D  View Item 5
5201               REDRAW  D  View Item 6
5201               REDRAW  D  View Item 7
5201               REDRAW  D  View Item 8
5201               REDRAW  D  View Item 9
5201               REDRAW  D  View Item 10
5201               REDRAW  D  View Item 11

Is this really the only thing you changed in the demo app, to cause the described behavior?

@hsanson
Copy link
Author

hsanson commented Oct 1, 2013

Yes that is all I changed in the demo app. I used git format-patch to generate it.

Make sure you enable the swipe-to-dismiss option in the settings and click several items.

And just in case I am using a real device (motorola M201) with android 4.1.2 for testing.

This is my output:

# Press the reset items in the settings
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 1
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 2
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 3
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 4
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 5
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 6
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 7
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 8
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 9
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 10
10-01 09:03:37.115 15587 15587 D XXX     : Get view Item 11

# Ensure swipe to dismiss in the settings is disabled and click item 5
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 1
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 2
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 3
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 4
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 5
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 6
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 7
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 8
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 9
10-01 09:03:37.105 15587 15587 D XXX     : Get view Item 10
10-01 09:03:37.115 15587 15587 D XXX     : Get view Item 11


# Ensure swipe to dismiss is enabled and click item 5
10-01 09:06:41.972 15587 15587 D XXX     : Get view Item 1
10-01 09:06:41.972 15587 15587 D XXX     : Get view Item 2
10-01 09:06:41.972 15587 15587 D XXX     : Get view Item 3
10-01 09:06:41.972 15587 15587 D XXX     : Get view Item 4   <- item 5 is missing
10-01 09:06:41.972 15587 15587 D XXX     : Get view Item 6
10-01 09:06:41.982 15587 15587 D XXX     : Get view Item 7
10-01 09:06:41.982 15587 15587 D XXX     : Get view Item 8
10-01 09:06:41.982 15587 15587 D XXX     : Get view Item 9
10-01 09:06:41.982 15587 15587 D XXX     : Get view Item 10
10-01 09:06:41.982 15587 15587 D XXX     : Get view Item 11

@timroes timroes closed this as completed in ea6bed9 Oct 1, 2013
@timroes
Copy link
Owner

timroes commented Oct 1, 2013

Fixed and published version 0.1.1 to maven central. Within the next 2 hours it should be synced, so it will be available via dependency resolution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants