Mercurial > 510Connectbot
diff src/com/five_ten_sg/connectbot/TerminalView.java @ 419:9045b1af94e5
revert notifyUser() changes
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 29 Oct 2014 15:25:32 -0700 |
parents | 4dcc071e1feb |
children | e5f7c2584296 |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/TerminalView.java Wed Oct 29 13:28:59 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/TerminalView.java Wed Oct 29 15:25:32 2014 -0700 @@ -72,6 +72,7 @@ private Matrix scaleMatrix; private static final Matrix.ScaleToFit scaleType = Matrix.ScaleToFit.FILL; + private Toast notification = null; private String lastNotification = null; private volatile boolean notifications = true; @@ -241,12 +242,24 @@ } public void notifyUser(String message) { - if (!notifications) return; - // Don't keep telling the user the same thing. - if (lastNotification != null && lastNotification.equals(message)) return; - Toast notification = Toast.makeText(context, message, Toast.LENGTH_SHORT); - notification.show(); - lastNotification = message; + try { + // ignore if don't want notifications + if (!notifications) return; + // Don't keep telling the user the same thing. + if (lastNotification != null && lastNotification.equals(message)) return; + // create or use old toast + if (notification == null) { + notification = Toast.makeText(context, message, Toast.LENGTH_SHORT); + } + else { + notification.setText(message); + } + notification.show(); + lastNotification = message; + } + catch (Exception e) { + Log.e(TAG, "Problem while trying to notify user", e); + } } /**