MrEngineer13 / SnackBar

toast-like alert pattern for Android inspired by the Google Material Design Spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not shown from Preference Fragment

jpshelley opened this issue · comments

If I'm using a standard activity that hosts a PreferenceFragment, the snackbar is not shown.

  1. Creating the Snackbar in the activity, not the fragment.
  2. Showing the Snackbar from the activity, after fragment issues the command.

Thoughts?

Update:
I'm calling the Snackbar from a nested Preference Screen, if I click back soon enough the Snackbar is shown from the initial Preference Fragment.

I'm guessing it has to do with the nested preference fragment. (Which I've seen many issues with from the Android Project in general, so there might be no hope)

There is a way around this. I haven't fully tested it yet but you should try SnackBars other constructor. There is one that takes an Activity and another one that takes a context and a view. That view must contain whats in sb__snack.xml so after you add its contents to your fragment then you can use it like so: SnackBar mSnackBar = new SnackBar(getActivity(), root); Let me know how it works out for you

I see what you mean @MrEngineer13. Just looked at the other constructor. However I'm not sure how to do that. See, I'm using a nested PreferenceScreen inside my initial PreferenceScreen. (On Pre-L devices the action bar doesn't show up, and now the Toolbar won't show up either) I've seen bugs with this before and think its deep in the PreferenceFragment's source code.
I'd say I'd try it out, but there is not way for me to add the sb__snack.xml code to a preference.xml file

After you updated to v0.5.0 does this issue still persist?

Just updated to v0.5.0 and the issue still persists. Like I said. I think its an issue with android's deep nested preference fragment maybe? The toolbar isn't showing up either.
I'm following android's guides for "Using Subscreens" here: http://developer.android.com/guide/topics/ui/settings.html#DefiningPrefs if that helps at all. If you have a test unit around this, maybe test a basic subscreen and a double subscreen.

Are you using the Fragment or Activity to build the SnackBar?

@MrEngineer13 In the Activity that is hosting a PreferenceFragment.

I'm going to close this as there haven't been any updates however if you do feel free to explain how you got it working.