From 8a69788d1ba7aa0cf9fd76a5af41b0bb1ed53fcf Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 26 Nov 2013 10:52:34 +0100 Subject: Fix not attached exception --- src/de/blinkt/openvpn/fragments/LogFragment.java | 39 ++++++++++++------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/de/blinkt/openvpn/fragments/LogFragment.java b/src/de/blinkt/openvpn/fragments/LogFragment.java index 40f9dfb6..a03d5160 100644 --- a/src/de/blinkt/openvpn/fragments/LogFragment.java +++ b/src/de/blinkt/openvpn/fragments/LogFragment.java @@ -602,25 +602,26 @@ public class LogFragment extends ListFragment implements StateListener, SeekBar. @Override - public void updateState(final String status,final String logMessage, final int resId, final ConnectionStatus level) { - getActivity().runOnUiThread(new Runnable() { - - @Override - public void run() { - String prefix = getString(resId) + ":"; - if (status.equals("BYTECOUNT") || status.equals("NOPROCESS")) - prefix = ""; - if (resId == R.string.unknown_state) - prefix += status; - if (mSpeedView != null) - mSpeedView.setText(prefix + logMessage); - - if (mConnectStatus != null) - mConnectStatus.setText(getString(resId)); - } - }); - - } + public void updateState(final String status, final String logMessage, final int resId, final ConnectionStatus level) { + if (isAdded()) { + getActivity().runOnUiThread(new Runnable() { + + @Override + public void run() { + String prefix = getString(resId) + ":"; + if (status.equals("BYTECOUNT") || status.equals("NOPROCESS")) + prefix = ""; + if (resId == R.string.unknown_state) + prefix += status; + if (mSpeedView != null) + mSpeedView.setText(prefix + logMessage); + + if (mConnectStatus != null) + mConnectStatus.setText(getString(resId)); + } + }); + } + } @Override -- cgit v1.2.3