Fix snackbar not showing when alarms are created on 21+
This commit is contained in:
parent
3bbee9a641
commit
f13897cc8e
@ -219,10 +219,21 @@ public final class AlarmController {
|
|||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSnackbar(String message) {
|
private void showSnackbar(final String message) {
|
||||||
// Is the window containing this anchor currently focused?
|
// Is the window containing this anchor currently focused?
|
||||||
if (mSnackbarAnchor != null && mSnackbarAnchor.hasWindowFocus()) {
|
// Log.d(TAG, "Anchor has window focus? " + mSnackbarAnchor.hasWindowFocus());
|
||||||
|
if (mSnackbarAnchor != null /*&& mSnackbarAnchor.hasWindowFocus()*/) {
|
||||||
|
// Queue the message on the view's message loop, so the message
|
||||||
|
// gets processed once the view gets attached to the window.
|
||||||
|
// This executes on the UI thread, just like not queueing it will,
|
||||||
|
// but the difference here is we wait for the view to be attached
|
||||||
|
// to the window (if not already) before executing the runnable code.
|
||||||
|
mSnackbarAnchor.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
Snackbar.make(mSnackbarAnchor, message, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(mSnackbarAnchor, message, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user