Commit 226d8cd770d8931b5593f27c4f3db0504efe07f6
1 parent
b7d05233
- skip login if login was completed at login activity
Showing
3 changed files
with
22 additions
and
4 deletions
app/src/main/java/net/devfac/userstory/ActivityLogin.java
1 | 1 | package net.devfac.userstory; |
2 | 2 | |
3 | +import android.app.AlertDialog; | |
3 | 4 | import android.content.Intent; |
4 | 5 | import android.net.Uri; |
5 | 6 | import android.os.Bundle; |
... | ... | @@ -34,6 +35,8 @@ public class ActivityLogin extends AppCompatActivity implements View.OnClickList |
34 | 35 | private ImageButton mImgBtnLogin; |
35 | 36 | private TextView mTextHomepageLink; |
36 | 37 | |
38 | + private AlertDialog mAlertDialog; | |
39 | + | |
37 | 40 | @Override |
38 | 41 | protected void onCreate(Bundle savedInstanceState) { |
39 | 42 | super.onCreate(savedInstanceState); |
... | ... | @@ -62,6 +65,8 @@ public class ActivityLogin extends AppCompatActivity implements View.OnClickList |
62 | 65 | mTextHomepageLink.setOnClickListener(this); |
63 | 66 | |
64 | 67 | StateContext.getInstance(this).setStateEventListener(this); |
68 | + | |
69 | + mAlertDialog = new AlertDialog.Builder(this).create(); | |
65 | 70 | } |
66 | 71 | |
67 | 72 | @Override |
... | ... | @@ -115,13 +120,17 @@ public class ActivityLogin extends AppCompatActivity implements View.OnClickList |
115 | 120 | @Override |
116 | 121 | public void onEntry(Class stateClass, Object input) { |
117 | 122 | if( stateClass.equals(StateLoginRequested.class)){ |
118 | - Toast.makeText(this, "로그인 중입니다...", Toast.LENGTH_LONG).show(); | |
123 | +// Toast.makeText(this, "로그인 중입니다...", Toast.LENGTH_LONG).show(); | |
124 | + mAlertDialog.setTitle("로그인 중입니다..."); | |
125 | + mAlertDialog.setMessage("잠시만 기다려 주세요."); | |
126 | + mAlertDialog.show(); | |
119 | 127 | } |
120 | 128 | } |
121 | 129 | |
122 | 130 | @Override |
123 | 131 | public void onExit(Class stateClass, Object output, StateContext.STATE_RESULT stateResult) { |
124 | 132 | if( stateClass.equals(StateLoginRequested.class)){ |
133 | + mAlertDialog.dismiss(); | |
125 | 134 | switch( stateResult ){ |
126 | 135 | case LOGIN_FAIL: |
127 | 136 | PreferenceUtil.getInstance(this).putIsLoggedInState(false); |
... | ... | @@ -129,8 +138,10 @@ public class ActivityLogin extends AppCompatActivity implements View.OnClickList |
129 | 138 | break; |
130 | 139 | case LOGIN_SUCCESS: |
131 | 140 | PreferenceUtil.getInstance(this).putIsLoggedInState(true); |
132 | - Toast.makeText(this, "Login Success", Toast.LENGTH_LONG).show(); | |
133 | - startActivity(new Intent(this, MainActivity.class)); | |
141 | +// Toast.makeText(this, "Login Success", Toast.LENGTH_LONG).show(); | |
142 | + Intent mainActivityIntent = new Intent(this, MainActivity.class); | |
143 | + mainActivityIntent.putExtra(Constants.EXTRA_LOGIN_COMPLETED, true); | |
144 | + startActivity(mainActivityIntent); | |
134 | 145 | finish(); |
135 | 146 | break; |
136 | 147 | } | ... | ... |
app/src/main/java/net/devfac/userstory/Constants.java
app/src/main/java/net/devfac/userstory/MainActivity.java
... | ... | @@ -60,8 +60,12 @@ public class MainActivity extends AppCompatActivity |
60 | 60 | } |
61 | 61 | setContentView(R.layout.activity_main); |
62 | 62 | |
63 | + Intent intentFrom = getIntent(); | |
64 | + | |
63 | 65 | initWidget(); |
64 | - initLogin(); | |
66 | + if( !intentFrom.getBooleanExtra(Constants.EXTRA_LOGIN_COMPLETED, false) ){ | |
67 | + initLogin(); | |
68 | + } | |
65 | 69 | |
66 | 70 | StateContext.getInstance(this).setStateEventListener(this); |
67 | 71 | } | ... | ... |