OneBusAway / onebusaway-android

The official Android app for OneBusAway
http://www.onebusaway.org/
Other
474 stars 291 forks source link

Realtime indicator view isn't being recycled properly #818

Open barbeau opened 6 years ago

barbeau commented 6 years ago

Summary:

When you view the list of arrival times, if you scroll down the list the realtime indicator view (to the right of "min") stops animating. If you scroll back up, the color of some views may not match the color of the "min" text.

screenshot_20171125-174745

Steps to reproduce:

  1. Look at list of arrivals (via starred stops or tapping on stop on map) with a long list of arrivals (transit centers are good)
  2. Scroll down until initial list that you saw is offscreen, and then scroll back up to see initial list again

Expected behavior:

Realtime indicator should continue animating and should always match color of "min" text

Observed behavior:

All realtime indicators stop animating, and some don't match the color of the "min" text (intermittent)

Device and Android version:

I first noticed this on LG G5 Android 7.0 update - I don't think this happened on the Android 6 version. Also happens on Samsung Galaxy S8+ with Samsung beta Android 8.0

Screenshots:

See above

barbeau commented 6 years ago

Seems that this is related to the RealtimeIndicatorView.initAnimation() method, as this is where the animation for the concentric circles is kicked off. In the master branch we're instantiating new animations without canceling the old ones. However, I tried adding:

        if (mAnimation1 != null) {
            clearAnimation();
            if (UIUtils.canCancelAnimation()) {
                animate().cancel();
            }
        }

...before adding the new animation but that didn't seem to change anything.

barbeau commented 6 years ago

We're also using a custom org.onebusaway.android.util.ArrayAdapter that extends the platform ArrayAdapter - not sure if this is related.

barbeau commented 6 years ago

So if I comment out the code in ArrayAdapter that recycles the view (without any other changes to master branch), then everything works fine - the animations continue and from some quick testing it seems that the indicator is always the correct color:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;

        //if (convertView == null) {
            view = mInflater.inflate(mLayoutId, parent, false);
//        } else {
//            view = convertView;
//        }

        T item = getItem(position);

So it's definitely an issue with re-using the same View object. I'm assuming the View initialization or animation platform code changed in Android N which has triggered this issue.