gaugesapp / gauges-android

Gaug.es Android App
https://play.google.com/store/apps/details?id=com.github.mobile.gauges
712 stars 224 forks source link

Rotate Refresh Item While Loading Things #13

Closed EddieRingle closed 12 years ago

EddieRingle commented 12 years ago

As per #8, this adds visual indication that something is happening after pressing the refresh item. It also looks better than swapping it out for a ProgressBar, IMO.

Signed-off-by: Eddie Ringle eddie@eringle.net

rtyley commented 12 years ago

Thanks @eddieringle - much apprecitated!

mattgraham commented 12 years ago

Thanks @eddieringle this was in the thought process you just beat us to it :)

rtyley commented 12 years ago

Unfortunately we can't push this out just yet :( There's a rendering problem: if you go to a gauge, swipe the view pager over to one of the other sides, eg 'Referrers', start a refresh, then swipe back before the reload has completed, you get a nasty rendering glitch - the rotating arrow is rendered over itself:

double-render glitch

This problem then persists until you actually quit the activity and start again. The problem is more noticeable because we use a slightly translucent refresh icon.

My guess is that the some image buffer somewhere is storing what it thinks the actionbar background for that area should be, and it's getting corrupted with an added copy of the refresh icon.

Building against the current head of the 4.0-wip branch of ABS, the behaviour is still there (abs4-post-rc1 branch of gauges-android is updated to deal with the api changes).

Calling menuitem.getActionBarView().invalidate() doesn't seem to help, I'm really not sure how to get the display straightened out. Maybe @JakeWharton can help us :)

EddieRingle commented 12 years ago

I couldn't reproduce this just now on my tablet, but I'll give it a go on my phone (perhaps my internet connection is snappier than my fingers, heh).

I've got a newer implementation of this I've been playing around with that (I think) would help solve this issue. I'll tinker with it and get back to you.

EddieRingle commented 12 years ago

Okay, from the screenshot I'm going to assume you are using Gingerbread. This problem doesn't present itself on Ice Cream Sandwich (tested on both my tablet and phone).

I've got a G1 here with Froyo on it, I'll give that a go and see what turns up.

JakeWharton commented 12 years ago

I was just going to suggest that it's a pre-ICS thing only.

I should be getting internet today (just moved) so I'll take a look as soon as I can.

If you're feeling daft you could create a tiny project that exhibits the bug and cross-post an issue on the ABS project. I have a few dedicated users who've been helpful in resolving bugs before I even get to them. On Mar 3, 2012 9:31 AM, "Eddie Ringle" < reply@reply.github.com> wrote:

Okay, from the screenshot I'm going to assume you are using Gingerbread. This problem doesn't present itself on Ice Cream Sandwich (tested on both my tablet and phone).

I've got a G1 here with Froyo on it, I'll give that a go and see what turns up.


Reply to this email directly or view it on GitHub: https://github.com/github/gauges-android/pull/13#issuecomment-4302885

JakeWharton commented 12 years ago

I observe this on ICS too. Didn't test the app directly, used this:

public class ABSBuggggssActivity extends SherlockActivity {
    boolean mShow = true;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Button b = new Button(this);
        b.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                mShow = !mShow;
                invalidateOptionsMenu();
            }
        });
        setContentView(b);
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        if (mShow) {
            menu.add("Refresh").setIcon(R.drawable.ic_action_refresh).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        return super.onCreateOptionsMenu(menu);
    }

    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        ImageView iv = (ImageView) LayoutInflater.from(this).inflate(R.layout.refresh_action_view, null);
        Animation r = AnimationUtils.loadAnimation(this, R.anim.clockwise_refresh);
        r.setRepeatCount(Animation.INFINITE);
        iv.startAnimation(r);
        item.setActionView(iv);
        return true;
    }
}

edited with better sample. bug can be observed on ICS too by using SherlockFragmentActivity.

JakeWharton commented 12 years ago

Hold the phone! When you convert to a non-ABS, native ICS activity the bug does not present itself... investigating.

rtyley commented 12 years ago

I can't believe @JakeWharton just said 'hold the phone' :)

Just to be more specific about what I've seen:

gauges-android master (48b51dda) & ABS 4.0 RC1 :

ICS Galaxy Nexus - No rendering issue - absolutely fine Gingerbread HTC Sensation - The double-overlay rendering occurs (and additionally, sometimes the button itself is not clickable - if you've gone straight into the gauge and the paged to the side)

gauges-android abs4-post-rc1 (8b26cdfe) & ABS 4.0-wip head @ 03e76649 :

ICS Galaxy Nexus - Double-overlay rendering occurs Gingerbread HTC Sensation - Double-overlay rendering occurs - but at least the button itself is always clickable :-)

So that's actually a regression in the ICS behaviour - I think delegation to native ICS has changed since the ABS RC1?

JakeWharton commented 12 years ago

I've been messing with this for a couple hours with some help from @Sleepybear. It's a very odd issue to say the least.

Currently I'm debugging with the above pasted code except extending from SherlockFragmentActivity running on ICS with the latest from 4.0-wip. This configuration puts the least amount of code from ActionBarSherlock in the mix which was supposed to narrow down where the problem could lie.

It hasn't made anything more obvious yet :(

JakeWharton commented 12 years ago

3.0+ has been fixed with JakeWharton/ActionBarSherlock@72b8d9871cab79b512e5c511939a0e54985a480f. Still working on pre-3.0.

rtyley commented 12 years ago

@JakeWharton I recompiled the gauges-android abs4-post-rc1 branch against ABS 72b8d98 and gave it ago against ICS on a Galaxy Nexus - but unfortunately I still see the double-overlay rendering :(

JakeWharton commented 12 years ago

It seems to respond differently based on whether you're returning true or false. FragmentActivity seems to be the culprit (and its menu handling) and I just need to find a way to work around its behavior. In any case, I'm tracking in an open issue on ABS rather than a closed one here (on which I've cc'd you two).

rtyley commented 12 years ago

Thanks @JakeWharton, I see it at https://github.com/JakeWharton/ActionBarSherlock/issues/331

We pushed out a small bugfix release of the Gauges app today, and decided to leave the animated refresh icon out until the problem's sorted - sorry about that @eddieringle :( We've got the code on a branch and hopefully we'll be able to merge it back into master soon.

EddieRingle commented 12 years ago

Quite alright. Not going to complain or anything since @JakeWharton hates me enough right now for finding this bug. ;)