diff --git a/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java b/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java index 1fee00a..b7a350e 100644 --- a/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java +++ b/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java @@ -76,16 +76,7 @@ //成功処理 } else { System.out.println("fail"); - switch (response.code()){ - case 404: - //パスワードが違う - error_changePw_LiveData.setValue(404); - break; - case 403: - //認証失敗 - error_changePw_LiveData.setValue(403); - break; - } + error_changePw_LiveData.setValue(404); } } @@ -159,17 +150,7 @@ error_changeAccount_LiveData.setValue(200); }else{ System.out.println("fail"); - switch (response.code()){ - case 404: - //ID・PWが違う - error_changeAccount_LiveData.setValue(404); - break; - case 403: - //承認失敗 - error_changeAccount_LiveData.setValue(403); - break; - } - + error_changeAccount_LiveData.setValue(404); } } diff --git a/app/src/main/java/com/example/citrusclient/views/SettingsFragment.java b/app/src/main/java/com/example/citrusclient/views/SettingsFragment.java index 1ca29e4..e32be30 100644 --- a/app/src/main/java/com/example/citrusclient/views/SettingsFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/SettingsFragment.java @@ -82,7 +82,8 @@ BooksViewModel booksViewModel; FavoritesViewModel favoritesViewModel; - //private String strAccountColor; //色 + private Integer strAccountColor; //色 + private Integer totalamount = 0; @@ -129,10 +130,10 @@ //いいね一覧へ変異 - /*Button FavoriteButton = view.findViewById((R.id.goFavoriteList)); + Button FavoriteButton = view.findViewById((R.id.goFavoriteList)); FavoriteButton.setOnClickListener(v -> { ((MainActivity) getActivity()).showFragment(new FavoritesBooksFragment()); - });*/ + }); //観察部 @@ -142,12 +143,16 @@ public void onChanged(String s) { if (s!=null){ Button iconButton = view.findViewById(R.id.icon); - int parsedColor = Color.parseColor(s); - iconButton.setBackgroundTintList(ColorStateList.valueOf(parsedColor)); + strAccountColor = Color.parseColor(s); + iconButton.setBackgroundTintList(ColorStateList.valueOf(strAccountColor)); } } }); settingsViewModel.loadAccountColor(accountId); + if(strAccountColor != null) { + Button iconButton = view.findViewById(R.id.icon); + iconButton.setBackgroundTintList(ColorStateList.valueOf(strAccountColor)); + } //観察部 //アカウント @@ -159,11 +164,7 @@ TextView textNotes1 = (TextView) view.findViewById(R.id.textNotes1); textNotes1.setText("アカウント名が変更されました"); - } else if (error_changeAccount_LiveData == 404) { - System.out.println("失敗"); - TextView textNotes1 = (TextView) view.findViewById(R.id.textNotes1); - textNotes1.setText("パスワードが違います"); - } else if (error_changeAccount_LiveData == 403 || error_changeAccount_LiveData == 401) { + } else if (error_changeAccount_LiveData == 404 || error_changeAccount_LiveData == 401) { System.out.println("失敗"); TextView textNotes1 = (TextView) view.findViewById(R.id.textNotes1); textNotes1.setText("アカウント名が変更できませんでした"); @@ -204,10 +205,7 @@ //画面遷移処理 Intent intent = (new Intent(getActivity(), SignUpActivity.class)); startActivity(intent); - }else if(integer == 404){ - TextView textNotes3 = (TextView) view.findViewById(R.id.textNotes3); - textNotes3.setText("パスワードが違います"); - }else if(integer == 401){ + }else if(integer == 404 || integer == 401){ TextView textNotes3 = (TextView) view.findViewById(R.id.textNotes3); textNotes3.setText("アカウントが削除できませんでした"); } @@ -218,6 +216,7 @@ //ユーザ(主)が持つ本一覧 List bookList = new ArrayList<>(); List point = new ArrayList<>(); + booksLiveData.observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(HashMap integerBookHashMap) { @@ -227,8 +226,6 @@ }else{ bookList.clear(); - TextView textLikes = (TextView) view.findViewById(R.id.textLikes); - textLikes.setText("0"); } } }); @@ -241,20 +238,19 @@ public void onChanged(List strings) { if(strings != null){ point.add(strings.size()); - int totalamount = point.stream().mapToInt(Integer::intValue).sum(); - TextView textLikes = (TextView) view.findViewById(R.id.textLikes); - textLikes.setText(Integer.toString(totalamount)); - }else{ - + totalamount = point.stream().mapToInt(Integer::intValue).sum(); } } - }); + for(int i=0;i