오윤석

연결이 안 되는 것과 입력이 잘못된 것 구분

......@@ -103,8 +103,7 @@ public class Api {
static public void auth(String doorId, final Callback callback) {
if("123123123".equals(doorId)) {
// 테스트를 위한 super pass
callback.callbackMethod(true);
Api.accessToken = "superpass";
callback.callbackMethod(new Auth(true, "superpass"));
return;
}
......@@ -118,10 +117,12 @@ public class Api {
JsonObject resp = (JsonObject) apiResult.getData();
if(resp.get("is_available").getAsBoolean()) {
callback.callbackMethod(new Auth(true, resp.get("access_token").getAsString()));
return;
} else {
callback.callbackMethod(new Auth(false));
}
} else {
callback.callbackMethod(null);
}
callback.callbackMethod(new Auth(false));
}
});
}
......
......@@ -81,6 +81,11 @@ public class SplashActivity extends AppCompatActivity {
@Override
public void callbackMethod(Object obj) {
Auth auth = (Auth) obj;
if(auth == null) {
Toast.makeText(getApplicationContext(),"연결 상태가 불안정합니다.",Toast.LENGTH_SHORT).show();
return;
}
if(auth.getIsAvailable()) {
SharedPreferences pref = getSharedPreferences("gateway", MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
......