14
14
import android .view .inputmethod .EditorInfo ;
15
15
import android .view .inputmethod .InputMethodManager ;
16
16
import android .widget .AdapterView ;
17
- import android .widget .Button ;
18
17
import android .widget .EditText ;
19
18
import android .widget .ListView ;
20
19
import android .widget .TextView ;
21
20
22
21
import net .coding .program .R ;
23
- import net .coding .program .common .Global ;
24
22
import net .coding .program .common .SearchProjectCache ;
25
23
import net .coding .program .common .adapter .SearchHistoryListAdapter ;
26
- import net .coding .program .common .ui .BaseActivity ;
24
+ import net .coding .program .common .ui .BackActivity ;
27
25
import net .coding .program .common .util .DensityUtil ;
28
26
import net .coding .program .third .PagerSlidingTabStrip ;
29
27
35
33
import java .util .List ;
36
34
37
35
@ EActivity (R .layout .activity_search_project )
38
- public class SearchProjectActivity extends BaseActivity implements TextView .OnEditorActionListener , TextWatcher , AdapterView .OnItemClickListener {
36
+ public class SearchProjectActivity extends BackActivity implements TextView .OnEditorActionListener , TextWatcher , AdapterView .OnItemClickListener {
39
37
40
38
private static final String TAG = SearchProjectActivity .class .getSimpleName ();
41
39
@ ViewById
@@ -60,19 +58,22 @@ public class SearchProjectActivity extends BaseActivity implements TextView.OnEd
60
58
// 历史搜索的记录
61
59
private List <String > mSearchHistoryList = new ArrayList <String >();
62
60
private String mSearchData = "" ;
63
- private Button btnCancel ;
64
61
private EditText editText ;
62
+ private View btnCancel ;
65
63
66
64
@ AfterViews
67
65
void init () {
66
+ View actionBar = getLayoutInflater ().inflate (R .layout .activity_search_project_actionbar , null );
67
+ getSupportActionBar ().setCustomView (actionBar );
68
+ getSupportActionBar ().setDisplayShowCustomEnabled (true );
69
+
68
70
imm = (InputMethodManager ) getSystemService (Context .INPUT_METHOD_SERVICE );
69
- btnCancel = ( Button ) this .findViewById (R .id .btnCancel );
71
+ btnCancel = actionBar .findViewById (R .id .btnCancel );
70
72
btnCancel .setOnClickListener (v -> {
71
- Global .popSoftkeyboard (this , editText , false );
72
- onBackPressed ();
73
+ editText .setText ("" );
73
74
});
74
75
75
- editText = (EditText ) this .findViewById (R .id .editText );
76
+ editText = (EditText ) actionBar .findViewById (R .id .editText );
76
77
final int pageMargin = (int ) TypedValue .applyDimension (TypedValue .COMPLEX_UNIT_DIP , 4 , getResources ()
77
78
.getDisplayMetrics ());
78
79
pager .setPageMargin (pageMargin );
@@ -96,6 +97,46 @@ void init() {
96
97
97
98
}
98
99
100
+ // @Override
101
+ // public boolean onCreateOptionsMenu(Menu menu) {
102
+ // MenuInflater menuInflater = getMenuInflater();
103
+ // menuInflater.inflate(R.menu.add_follow_activity, menu);
104
+ //
105
+ // MenuItem menuItem = menu.findItem(R.id.action_search);
106
+ // menuItem.expandActionView();
107
+ // SearchView searchView = (SearchView) menuItem.getActionView();
108
+ // searchView.onActionViewExpanded();
109
+ // searchView.setIconified(false);
110
+ // searchView.setQueryHint("用户名,邮箱,昵称");
111
+ // searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
112
+ // @Override
113
+ // public boolean onQueryTextSubmit(String s) {
114
+ // return true;
115
+ // }
116
+ //
117
+ // @Override
118
+ // public boolean onQueryTextChange(String s) {
119
+ // search(s);
120
+ // return true;
121
+ // }
122
+ // });
123
+ //
124
+ // MenuItemCompat.setOnActionExpandListener(menuItem, new MenuItemCompat.OnActionExpandListener() {
125
+ // @Override
126
+ // public boolean onMenuItemActionExpand(MenuItem item) {
127
+ // return true;
128
+ // }
129
+ //
130
+ // @Override
131
+ // public boolean onMenuItemActionCollapse(MenuItem item) {
132
+ // onBackPressed();
133
+ // return false;
134
+ // }
135
+ // });
136
+ //
137
+ // return true;
138
+ // }
139
+
99
140
private void setTabsValue () {
100
141
DisplayMetrics dm = getResources ().getDisplayMetrics ();
101
142
// 设置Tab是自动填充满屏幕的
@@ -187,7 +228,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
187
228
public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
188
229
if (actionId == EditorInfo .IME_ACTION_SEARCH ) {
189
230
String tmp = editText .getText ().toString ();
190
- if (tmp == null || TextUtils .isEmpty (tmp )) {
231
+ if (TextUtils .isEmpty (tmp )) {
191
232
emptyListView .setVisibility (View .VISIBLE );
192
233
pager .setVisibility (View .GONE );
193
234
tabs .setVisibility (View .GONE );
0 commit comments