Showing
2 changed files
with
10 additions
and
4 deletions
... | @@ -103,8 +103,7 @@ public class Api { | ... | @@ -103,8 +103,7 @@ public class Api { |
103 | static public void auth(String doorId, final Callback callback) { | 103 | static public void auth(String doorId, final Callback callback) { |
104 | if("123123123".equals(doorId)) { | 104 | if("123123123".equals(doorId)) { |
105 | // 테스트를 위한 super pass | 105 | // 테스트를 위한 super pass |
106 | - callback.callbackMethod(true); | 106 | + callback.callbackMethod(new Auth(true, "superpass")); |
107 | - Api.accessToken = "superpass"; | ||
108 | return; | 107 | return; |
109 | } | 108 | } |
110 | 109 | ||
... | @@ -118,10 +117,12 @@ public class Api { | ... | @@ -118,10 +117,12 @@ public class Api { |
118 | JsonObject resp = (JsonObject) apiResult.getData(); | 117 | JsonObject resp = (JsonObject) apiResult.getData(); |
119 | if(resp.get("is_available").getAsBoolean()) { | 118 | if(resp.get("is_available").getAsBoolean()) { |
120 | callback.callbackMethod(new Auth(true, resp.get("access_token").getAsString())); | 119 | callback.callbackMethod(new Auth(true, resp.get("access_token").getAsString())); |
121 | - return; | 120 | + } else { |
121 | + callback.callbackMethod(new Auth(false)); | ||
122 | } | 122 | } |
123 | + } else { | ||
124 | + callback.callbackMethod(null); | ||
123 | } | 125 | } |
124 | - callback.callbackMethod(new Auth(false)); | ||
125 | } | 126 | } |
126 | }); | 127 | }); |
127 | } | 128 | } | ... | ... |
... | @@ -81,6 +81,11 @@ public class SplashActivity extends AppCompatActivity { | ... | @@ -81,6 +81,11 @@ public class SplashActivity extends AppCompatActivity { |
81 | @Override | 81 | @Override |
82 | public void callbackMethod(Object obj) { | 82 | public void callbackMethod(Object obj) { |
83 | Auth auth = (Auth) obj; | 83 | Auth auth = (Auth) obj; |
84 | + if(auth == null) { | ||
85 | + Toast.makeText(getApplicationContext(),"연결 상태가 불안정합니다.",Toast.LENGTH_SHORT).show(); | ||
86 | + return; | ||
87 | + } | ||
88 | + | ||
84 | if(auth.getIsAvailable()) { | 89 | if(auth.getIsAvailable()) { |
85 | SharedPreferences pref = getSharedPreferences("gateway", MODE_PRIVATE); | 90 | SharedPreferences pref = getSharedPreferences("gateway", MODE_PRIVATE); |
86 | SharedPreferences.Editor editor = pref.edit(); | 91 | SharedPreferences.Editor editor = pref.edit(); | ... | ... |
-
Please register or login to post a comment