Merge pull request 'feature/child_mode' (#156) from feature/child_mode into main

Reviewed-on: #156
This commit is contained in:
Fujimatsu 2024-07-08 17:10:15 +00:00
commit e98cbefcad

View File

@ -15,6 +15,8 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
@ -78,21 +80,24 @@ public class ChildLoginActivity extends AppCompatActivity {
findViewById(R.id.childLoginButton).setOnClickListener(v -> {
logger.debug("ログインボタンが押されました");
Call<ChildAuthResponse> call = kidShiftApiService.childLogin(new ChildAuthRequest(getLoginCode()));
try {
ChildAuthResponse childAuthResponse = call.execute().body();
if (childAuthResponse == null || childAuthResponse.getAccessToken() == null) {
// エラー処理
logger.error("ChildAuthResponseがnullまたはAccessTokenがnullです");
return;
CompletableFuture.runAsync(() -> {
try {
ChildAuthResponse childAuthResponse = call.execute().body();
if (childAuthResponse == null || childAuthResponse.getAccessToken() == null) {
// エラー処理
logger.error("ChildAuthResponseがnullまたはAccessTokenがnullです");
return;
}
UserSettings.AppCommonSetting appCommonSetting = userSettings.getAppCommonSetting();
appCommonSetting.setLoggedIn(true);
appCommonSetting.setAccessToken(childAuthResponse.getAccessToken());
appCommonSetting.setChildMode(true);
finish();
} catch (Exception e) {
logger.error("リクエストに失敗しました");
Toast.makeText(this, "ログインに失敗しました", Toast.LENGTH_SHORT).show();
}
UserSettings.AppCommonSetting appCommonSetting = userSettings.getAppCommonSetting();
appCommonSetting.setLoggedIn(true);
appCommonSetting.setAccessToken(childAuthResponse.getAccessToken());
appCommonSetting.setChildMode(true);
} catch (Exception e) {
logger.error("リクエストに失敗しました");
Toast.makeText(this, "ログインに失敗しました", Toast.LENGTH_SHORT).show();
}
});
});
}