rectangle-dbmi / Realtime-Port-Authority

Realtime transit tracker of Pittsburgh's Port Authority buses using the realtime PAT API using Google Maps to Display the Maps
GNU General Public License v3.0
60 stars 33 forks source link

Error messages remain after closing app, obscuring other apps #233

Open mikeantonacci opened 8 years ago

mikeantonacci commented 8 years ago

Steps to reproduce: select several buses that will give an error, then immediately close the app or switch to another app before all messages have appeared on screen.

What happens: error messages remain on screen, obscuring other apps.

What should happen: error messages disappear immediately.

epicstar commented 8 years ago

So... This is actually not a bug.

Apparently for toasts, they're made for system messages (phone-wide)... hence if you exit and stuff, the toast messages show up through the whole phone.

The solution? We should use a SnackBar instead of the toast! Here is the code below:


    /**
     * General way to make a snackbar
     *
     * @since 46
     * @param string - the string to add to on the
     * @param showLength - how long to show the snackbar
     */
    private void makeSnackbar(String string, int showLength) {
        if(string != null && string.length() > 0) {

            Snackbar.make(mainLayout,
                    string, showLength
            ).show();
        }

    }

So then, if you have this sort of code, why not abide by Material Design and show these errors in a Snackbar? Contrary to what the Snackbar documentation says... Snackbars are not transient at all........

There is a bug that exactly explains the issue.

http://stackoverflow.com/questions/33264764/when-is-snackbar-isqueued-used-how-to-queue-the-snackbar

In other words, the Snackbar seems to be bugged......

Solutions that I -- someone who can't deal with UI well -- can think of:

  1. Waste 5 hours of time to fix something that seems to be a Design Library Bug
  2. Move to Dialogs -> no.......
  3. Make an indefinite length Snackbar until fixed -> Possibly
  4. Increase the length of time snackbars appear but have an X button -> could have bad consequences
  5. Improve transient messages (doing) and use Toasts until fixed -> Current Solution

@VincentIII - what do you think T_T

I'll make a task for Snackbars at some point.

epicstar commented 8 years ago

Please star... assuming this is a real issue:

https://code.google.com/p/android/issues/detail?id=193752&thanks=193752&ts=1447177236

mikeantonacci commented 8 years ago

The core issue still exists, but as of 6.4rc all toasts are LENGTH_SHORT which should mitigate this somewhat.

epicstar commented 8 years ago

I talked to @TheAndroidMaster about this, and we seem to have some sort of plan to go forward for this. He'll be working on changing toasts to snackbars. He told me that the snackbars should just close and then open a new one instead of stacking on each other so he'll investigate why our snackbars aren't doing that.

fennifith commented 8 years ago

This is mostly fixed with pull request #284. The issue here was that the Snackbars were being attached to a DrawerLayout instead of a CoordinatorLayout. I've added one to temporarily contain the fragment, this will probably be used for later improvements as well if we want to define the action bar in the layout file or something.

There is a small issue that snackbars made from the nav drawer aren't visible, but we were thinking of replacing it anyway so it shouldn't matter. Otherwise, we could always just replace the calls in the navigation drawer with toasts.