Merge pull request #293 from nitta-lab-2022/GameView1110
おk
commit 8e313b8a6acad098fe4b8b1eaead9c1cbf20ddab
2 parents 00bc63d + 57680a2
Okada Kenshin authored on 10 Nov 2022
Showing 1 changed file
View
89
app/src/main/java/org/ntlab/irisclient/viewmodels/GameViewModel.java
 
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()){
if(hintPreData == null){
try {
hintMutableLiveData.setValue(response.body().string());
 
hintPreData = hintMutableLiveData.getValue();
System.out.println("今回のヒントは" + hintPreData + "です(初回)"+hintMutableLiveData.getValue());
} catch (IOException e) {
e.printStackTrace();
if (response.isSuccessful()) {
if (response.body() != null) {
if (hintPreData == null) {
try {
hintMutableLiveData.setValue(response.body().string());
 
hintPreData = hintMutableLiveData.getValue();
System.out.println("今回のヒントは" + hintPreData + "です(初回)" + hintMutableLiveData.getValue());
} catch (IOException e) {
e.printStackTrace();
}
} else if (hintMutableLiveData.getValue().equals(hintPreData)) {
//値が一緒なら書き換えない
} else {
try {
hintMutableLiveData.setValue(response.body().string());
hintPreData = hintMutableLiveData.getValue();
} catch (IOException e) {
e.printStackTrace();
}
 
System.out.println("今回のヒントは" + hintPreData + "です");
}
}else if(hintMutableLiveData.getValue().equals(hintPreData)){
//値が一緒なら書き換えない
}else{
try {
hintMutableLiveData.setValue(response.body().string());
hintPreData = hintMutableLiveData.getValue();
} catch (IOException e) {
e.printStackTrace();
}
 
System.out.println("今回のヒントは" + hintPreData + "です");
}
}
}
 
call.enqueue(new Callback<Integer>() {
@Override
public void onResponse(Call<Integer> call, Response<Integer> response) {
if (response.isSuccessful()){
if(maxPreData == null){
//初回代入
maxMutableLiveData.setValue(response.body());
maxPreData = response.body();
}else if(response.body().equals(maxPreData)){
//値が一緒なら書き換えない
}else{
//値が異なるときのみライブデータを上書き
maxMutableLiveData.setValue(response.body());
maxPreData = response.body();
if (response.body() != null) {
if (maxPreData == null) {
//初回代入
maxMutableLiveData.setValue(response.body());
maxPreData = response.body();
} else if (response.body().equals(maxPreData)) {
//値が一緒なら書き換えない
} else {
//値が異なるときのみライブデータを上書き
maxMutableLiveData.setValue(response.body());
maxPreData = response.body();
}
}
}
}
 
 
call.enqueue(new Callback<Integer>() {
@Override
public void onResponse(Call<Integer> call, Response<Integer> response) {
if (response.isSuccessful()){
if(turnNumberPreData == null){
if (response.isSuccessful()) {
if (turnNumberPreData == null) {
//初回代入
turnNumberMutableLiveData.setValue(response.body());
turnNumberPreData = response.body();
tno = response.body();
System.out.println("TurnNumberは" + turnNumberPreData + "です");
}else if(response.body().equals(turnNumberPreData)){
//値が一緒なら書き換えない
}else{
} else if (response.body().equals(turnNumberPreData)) {
//値が一緒なら書き換えない
} else {
//値が異なるときのみライブデータを上書き
turnNumberMutableLiveData.setValue(response.body());
turnNumberPreData = response.body();
tno = response.body();