mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
search UI
This commit is contained in:
parent
8a57331d32
commit
1e3a3262a4
|
@ -4,6 +4,7 @@
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
package one.nem.lacerta.feature.search;
|
package one.nem.lacerta.feature.search;
|
||||||
|
|
||||||
|
import android.app.ActionBar;
|
||||||
|
import android.app.LauncherActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.core.view.MenuItemCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.SearchView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
|
@ -16,8 +26,17 @@ import android.view.ViewGroup;
|
||||||
public class SearchTopFragment extends Fragment {
|
public class SearchTopFragment extends Fragment {
|
||||||
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
// TODO: Rename parameter arguments, choose names that match
|
||||||
|
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||||
|
private static final String TAG = SearchTopFragment.class.getSimpleName();
|
||||||
|
private final SearchTopFragment self = this;
|
||||||
|
|
||||||
|
private SearchView searchView;
|
||||||
|
private String searchWord;
|
||||||
|
|
||||||
|
|
||||||
private static final String ARG_PARAM1 = "param1";
|
private static final String ARG_PARAM1 = "param1";
|
||||||
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
private static final String ARG_PARAM2 = "param2";
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
// TODO: Rename and change types of parameters
|
||||||
|
@ -37,6 +56,8 @@ public class SearchTopFragment extends Fragment {
|
||||||
* @return A new instance of fragment SearchTopFragment.
|
* @return A new instance of fragment SearchTopFragment.
|
||||||
*/
|
*/
|
||||||
// TODO: Rename and change types and number of parameters
|
// TODO: Rename and change types and number of parameters
|
||||||
|
|
||||||
|
|
||||||
public static SearchTopFragment newInstance(String param1, String param2) {
|
public static SearchTopFragment newInstance(String param1, String param2) {
|
||||||
SearchTopFragment fragment = new SearchTopFragment();
|
SearchTopFragment fragment = new SearchTopFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
@ -60,5 +81,76 @@ public class SearchTopFragment extends Fragment {
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
return inflater.inflate(R.layout.fragment_search_top, container, false);
|
return inflater.inflate(R.layout.fragment_search_top, container, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
@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() {
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextSubmit(String searchWord) {
|
||||||
|
// SubmitボタンorEnterKeyを押されたら呼び出されるメソッド
|
||||||
|
return self.setSearchWord(searchWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextChange(String newText) {
|
||||||
|
// 入力される度に呼び出される
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private boolean setSearchWord(String searchWord) {
|
||||||
|
|
||||||
|
|
||||||
|
if (searchWord != null && !searchWord.equals("")) {
|
||||||
|
// searchWordがあることを確認
|
||||||
|
this.searchWord = searchWord;
|
||||||
|
}
|
||||||
|
// 虫眼鏡アイコンを隠す
|
||||||
|
this.searchView.setIconified(false);
|
||||||
|
// SearchViewを隠す
|
||||||
|
this.searchView.onActionViewCollapsed();
|
||||||
|
// Focusを外す
|
||||||
|
this.searchView.clearFocus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface LacertaSearch {
|
||||||
|
ArrayList<LauncherActivity.ListItem> autoSearch(String query, int limit);
|
||||||
|
|
||||||
|
ArrayList<LauncherActivity.ListItem> autoSearch(String query, int limit, int offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
tools:context=".SearchTopFragment">
|
tools:context=".SearchTopFragment">
|
||||||
|
|
||||||
<!-- TODO: Update blank fragment layout -->
|
<!-- TODO: Update blank fragment layout -->
|
||||||
<TextView
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/Search_tool_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="69dp"
|
||||||
android:text="@string/hello_blank_fragment" />
|
android:background="#E4E8EA"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
android:theme="?attr/actionBarTheme"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:title="" />
|
||||||
|
|
||||||
|
<SearchView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user