Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.

Selected state is cleared for selected item #11

Open
Bobrovsky-issart opened this issue Sep 30, 2014 · 0 comments
Open

Selected state is cleared for selected item #11

Bobrovsky-issart opened this issue Sep 30, 2014 · 0 comments

Comments

@Bobrovsky-issart
Copy link

When I use a selector like the following for gallery items I observe the following issue:

Sometimes selected item gets highlighted (as it should) and immediately after that the highlighting is gone. It usually happens with the first item in the gallery.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true">
        <shape>
            <solid android:color="#F14A1D"/>
        </shape>
    </item>
    <item>
        <shape>
            <solid android:color="@android:color/transparent"/>
        </shape>
    </item>
</selector>

I guess the issue is caused by improper handling of selected state for gallery items.

I had a look in the code and I think the error is in the EcoGallery.updateSelectedItemMetadata method. The gallery should not unfocus the old child if the old and the new children are the same. I.e. instead of

if (oldSelectedChild != null)

the condition should be

if (oldSelectedChild != null && oldSelectedChild != mSelectedChild)

Could you please verify mu guess?

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

1 participant