Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListViewDraggingAnimation broken on Android 5 Lollipop

I'm using ListViewDraggingAnimation by DevBytes, but it seems broken on Android Lollipop developer preview 2 (LPX13D). When I drag a row over other rows, those rows will disappear and become no longer clickable (see below). I tried disabling hardware acceleration for the listview but it didn't have any effect.

Example

Has anyone experienced the same issue? Any hints? Thanks :)

like image 538
Venator85 Avatar asked Oct 30 '14 09:10

Venator85


2 Answers

I found the problem. It came from this flag. StableArrayAdapter.hasStableId.

It fix all problem from this view on Lollipop.

@Override public boolean hasStableIds() {     return android.os.Build.VERSION.SDK_INT < 20; } 
like image 166
Jeremie Petitjean Avatar answered Oct 05 '22 03:10

Jeremie Petitjean


To be honest, I don't what causes the problem, but this fix makes no visual errors anymore on any version. And because all that was changed is just visibility of view, I believe it shouldn't create any new functional problems.


Replace this code in function handleCellSwitch() in class DynamicListView:

mobileView.setVisibility(View.VISIBLE); switchView.setVisibility(View.INVISIBLE); 

for

if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.KITKAT){     mobileView.setVisibility(View.VISIBLE);     switchView.setVisibility(View.INVISIBLE); } else{     mobileView.setVisibility(View.INVISIBLE);     switchView.setVisibility(View.VISIBLE); } 

I tried tinkering with the code and in the end I found a way how to make it display as it was before. But fixing the problem for Lollipop made the same problem appear on KitKat and previous versions instead. So I applied the fix only for android versions higher than KitKat.

My guess is that these two views gets exchanged in the process for some reason on the new Lollipop version. In effect, one of the views gets always displayed while the other one gets always hidden. Would be nice to know where and what was changed in the lollipop android code though...

like image 36
Antimonit Avatar answered Oct 05 '22 04:10

Antimonit