Skip to content
This repository was archived by the owner on Jun 8, 2024. It is now read-only.

Commit 93c83e1

Browse files
committed
SearchActivity: Clear action
Signed-off-by: Fung <fython@163.com>
1 parent 2af3992 commit 93c83e1

6 files changed

Lines changed: 38 additions & 4 deletions

File tree

mobile/src/main/java/info/papdt/express/helper/ui/SearchActivity.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
import android.support.v7.widget.RecyclerView;
1919
import android.text.Editable;
2020
import android.text.TextWatcher;
21-
import android.view.View;
22-
import android.view.ViewAnimationUtils;
23-
import android.view.ViewGroup;
24-
import android.view.ViewTreeObserver;
21+
import android.view.*;
2522
import android.view.inputmethod.EditorInfo;
2623

2724
import java.util.ArrayList;
@@ -206,6 +203,21 @@ public void onAnimationEnd(Animator animator) {
206203
circularReveal.start();
207204
}
208205

206+
@Override
207+
public boolean onCreateOptionsMenu(Menu menu) {
208+
getMenuInflater().inflate(R.menu.menu_search, menu);
209+
return super.onCreateOptionsMenu(menu);
210+
}
211+
212+
@Override
213+
public boolean onOptionsItemSelected(MenuItem item) {
214+
if (item.getItemId() == R.id.action_clear) {
215+
mSearchEdit.setText("");
216+
return true;
217+
}
218+
return super.onOptionsItemSelected(item);
219+
}
220+
209221
private synchronized ArrayList<SearchResultAdapter.ItemType> buildItems() {
210222
ArrayList<SearchResultAdapter.ItemType> items = new ArrayList<>();
211223
items.add(new SearchResultAdapter.ItemType(SearchResultAdapter.ItemType.TYPE_SUBHEADER));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
9+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
5+
<item android:id="@+id/action_clear"
6+
android:title="@string/action_clear"
7+
android:icon="@drawable/ic_clear_black_24dp"
8+
app:showAsAction="always"/>
9+
10+
</menu>

mobile/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161

162162
<!-- Search -->
163163
<string name="activity_search">搜索</string>
164+
<string name="action_clear">清空</string>
164165
<string name="search_hint_common">包裹或公司....</string>
165166
<string name="subheader_package">包裹</string>
166167
<string name="subheader_company">快递公司</string>

mobile/src/main/res/values-zh-rTW/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161

162162
<!-- Search -->
163163
<string name="activity_search">搜尋</string>
164+
<string name="action_clear">清空</string>
164165
<string name="search_hint_common">包裹或公司....</string>
165166
<string name="subheader_package">包裹</string>
166167
<string name="subheader_company">速遞公司</string>

mobile/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168

169169
<!-- Search -->
170170
<string name="activity_search">Search</string>
171+
<string name="action_clear">Clear</string>
171172
<string name="search_hint_common">Package or Company....</string>
172173
<string name="subheader_package">Package</string>
173174
<string name="subheader_company">Company</string>

0 commit comments

Comments
 (0)