From 834bc353182d7a0b03cabecafbc0cce912f76022 Mon Sep 17 00:00:00 2001 From: Fuchimoto1234 Date: Fri, 19 Jan 2024 12:30:17 +0900 Subject: [PATCH] search UI --- .../feature/search/SearchTopFragment.java | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/feature/search/src/main/java/one/nem/lacerta/feature/search/SearchTopFragment.java b/feature/search/src/main/java/one/nem/lacerta/feature/search/SearchTopFragment.java index 17ee05c0..a42d7a01 100644 --- a/feature/search/src/main/java/one/nem/lacerta/feature/search/SearchTopFragment.java +++ b/feature/search/src/main/java/one/nem/lacerta/feature/search/SearchTopFragment.java @@ -86,58 +86,52 @@ public class SearchTopFragment extends Fragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - // Menuの設定 - - // ActionViewの取得 - - - // 虫眼鏡アイコンを最初表示するかの設定 this.searchView.setIconifiedByDefault(true); - // Submitボタンを表示するかどうか + this.searchView.setSubmitButtonEnabled(false); if (!this.searchWord.equals("")) { - // TextView.setTextみたいなもの + this.searchView.setQuery(this.searchWord, false); } else { String queryHint = self.getResources().getString(R.string.hello_blank_fragment); - // placeholderみたいなもの + this.searchView.setQueryHint(queryHint); } this.searchView.setOnQueryTextListener(self.onQueryTextListener); } - private SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() { + private final SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() { @Override - public boolean onQueryTextSubmit(String searchWord) { - // SubmitボタンorEnterKeyを押されたら呼び出されるメソッド + public boolean onQueryTextSubmit(String query) { + return self.setSearchWord(searchWord); } @Override - public boolean onQueryTextChange(String newText) { - // 入力される度に呼び出される + public boolean onQueryTextChange(String query) { + return false; } }; - private boolean setSearchWord(String searchWord) { + private boolean setSearchWord(String query) { if (searchWord != null && !searchWord.equals("")) { - // searchWordがあることを確認 + this.searchWord = searchWord; } - // 虫眼鏡アイコンを隠す + this.searchView.setIconified(false); - // SearchViewを隠す + this.searchView.onActionViewCollapsed(); - // Focusを外す + this.searchView.clearFocus(); return false; }