Commit db41d854f27847e9e8b7f769ce4682b764fdf61a
1 parent
a99d6682
- add exception handler to ActivityLogin
Showing
1 changed file
with
28 additions
and
14 deletions
app/src/main/java/net/devfac/userstory/ActivityLogin.java
... | ... | @@ -10,6 +10,7 @@ import android.view.Menu; |
10 | 10 | import android.view.MenuInflater; |
11 | 11 | import android.view.MenuItem; |
12 | 12 | import android.view.View; |
13 | +import android.view.WindowManager; | |
13 | 14 | import android.widget.EditText; |
14 | 15 | import android.widget.ImageButton; |
15 | 16 | import android.widget.TextView; |
... | ... | @@ -24,6 +25,7 @@ import net.devfac.userstory.Utils.PreferenceUtil; |
24 | 25 | |
25 | 26 | /** |
26 | 27 | * Created by Onether on 15. 11. 10.. |
28 | + * Handling Login | |
27 | 29 | */ |
28 | 30 | public class ActivityLogin extends AppCompatActivity implements View.OnClickListener, StateEventListener { |
29 | 31 | private Toolbar mToolbarLogin; |
... | ... | @@ -100,7 +102,7 @@ public class ActivityLogin extends AppCompatActivity implements View.OnClickList |
100 | 102 | // WebView wv = (WebView)getActivity().findViewById(R.id.webView); |
101 | 103 | // StateContext.getInstance(getActivity()).setWebView(wv); |
102 | 104 | StateContext.getInstance(this).processEvent(Action.REQ_LOGIN, null); |
103 | - } | |
105 | + } | |
104 | 106 | else{ //Log off handling |
105 | 107 | |
106 | 108 | } |
... | ... | @@ -116,26 +118,38 @@ public class ActivityLogin extends AppCompatActivity implements View.OnClickList |
116 | 118 | public void onEntry(Class stateClass, Object input) { |
117 | 119 | if( stateClass.equals(StateLoginRequested.class)){ |
118 | 120 | // Toast.makeText(this, "로그인 중입니다...", Toast.LENGTH_LONG).show(); |
119 | - runOnUiThread(new Runnable() { | |
120 | - @Override | |
121 | - public void run() { | |
122 | - mProgressDialog = ProgressDialog.show(ActivityLogin.this, "로그인 중입니다", "잠시만 기다려주세요.."); | |
123 | - } | |
124 | - }); | |
121 | + try { | |
122 | + runOnUiThread(new Runnable() { | |
123 | + @Override | |
124 | + public void run() { | |
125 | + mProgressDialog = ProgressDialog.show(ActivityLogin.this, "로그인 중입니다", "잠시만 기다려주세요.."); | |
126 | + } | |
127 | + }); | |
128 | + } | |
129 | + catch(WindowManager.BadTokenException e){ | |
130 | + Logger.i("Windows closed very shortly"); | |
131 | + } | |
132 | + | |
125 | 133 | } |
126 | 134 | } |
127 | 135 | |
128 | 136 | @Override |
129 | 137 | public void onExit(Class stateClass, Object output, StateContext.STATE_RESULT stateResult) { |
130 | 138 | if( stateClass.equals(StateLoginRequested.class)){ |
131 | - runOnUiThread(new Runnable() { | |
132 | - @Override | |
133 | - public void run() { | |
134 | - if( mProgressDialog != null){ | |
135 | - mProgressDialog.dismiss(); | |
139 | + try { | |
140 | + runOnUiThread(new Runnable() { | |
141 | + @Override | |
142 | + public void run() { | |
143 | + if (mProgressDialog != null) { | |
144 | + mProgressDialog.dismiss(); | |
145 | + } | |
136 | 146 | } |
137 | - } | |
138 | - }); | |
147 | + }); | |
148 | + } | |
149 | + catch(WindowManager.BadTokenException e){ | |
150 | + Logger.i("Windows closed very shortly"); | |
151 | + } | |
152 | + | |
139 | 153 | |
140 | 154 | switch( stateResult ){ |
141 | 155 | case LOGIN_FAIL: | ... | ... |