@@ -11,11 +11,11 @@ const SEARCHTEXT = Symbol("searchText");
11
11
const QUERY = Symbol ( "query" ) ;
12
12
13
13
interface QueryTextListener {
14
- new ( owner : SearchBar ) : android . widget . SearchView . OnQueryTextListener ;
14
+ new ( owner : SearchBar ) : android . support . v7 . widget . SearchView . OnQueryTextListener ;
15
15
}
16
16
17
17
interface CloseListener {
18
- new ( owner : SearchBar ) : android . widget . SearchView . OnCloseListener ;
18
+ new ( owner : SearchBar ) : android . support . v7 . widget . SearchView . OnCloseListener ;
19
19
}
20
20
21
21
let QueryTextListener : QueryTextListener ;
@@ -26,8 +26,8 @@ function initializeNativeClasses(): void {
26
26
return ;
27
27
}
28
28
29
- @Interfaces ( [ android . widget . SearchView . OnQueryTextListener ] )
30
- class QueryTextListenerImpl extends java . lang . Object implements android . widget . SearchView . OnQueryTextListener {
29
+ @Interfaces ( [ android . support . v7 . widget . SearchView . OnQueryTextListener ] )
30
+ class CompatQueryTextListenerImpl extends java . lang . Object implements android . support . v7 . widget . SearchView . OnQueryTextListener {
31
31
constructor ( private owner : SearchBar ) {
32
32
super ( ) ;
33
33
return global . __native ( this ) ;
@@ -58,8 +58,8 @@ function initializeNativeClasses(): void {
58
58
}
59
59
}
60
60
61
- @Interfaces ( [ android . widget . SearchView . OnCloseListener ] )
62
- class CloseListenerImpl extends java . lang . Object implements android . widget . SearchView . OnCloseListener {
61
+ @Interfaces ( [ android . support . v7 . widget . SearchView . OnCloseListener ] )
62
+ class CompatCloseListenerImpl extends java . lang . Object implements android . support . v7 . widget . SearchView . OnCloseListener {
63
63
constructor ( private owner : SearchBar ) {
64
64
super ( ) ;
65
65
return global . __native ( this ) ;
@@ -71,12 +71,14 @@ function initializeNativeClasses(): void {
71
71
}
72
72
}
73
73
74
- QueryTextListener = QueryTextListenerImpl ;
75
- CloseListener = CloseListenerImpl ;
74
+ QueryTextListener = CompatQueryTextListenerImpl ;
75
+ CloseListener = CompatCloseListenerImpl ;
76
76
}
77
77
78
78
export class SearchBar extends SearchBarBase {
79
- nativeView : android . widget . SearchView ;
79
+ nativeView : android . support . v7 . widget . SearchView ;
80
+ private _searchTextView : android . widget . TextView ;
81
+ private _searchPlate : android . widget . LinearLayout ;
80
82
81
83
public dismissSoftInput ( ) {
82
84
ad . dismissSoftInput ( this . nativeView ) ;
@@ -93,7 +95,7 @@ export class SearchBar extends SearchBarBase {
93
95
94
96
public createNativeView ( ) {
95
97
initializeNativeClasses ( ) ;
96
- const nativeView = new android . widget . SearchView ( this . _context ) ;
98
+ const nativeView = new android . support . v7 . widget . SearchView ( this . _context )
97
99
nativeView . setIconified ( false ) ;
98
100
99
101
const queryTextListener = new QueryTextListener ( this ) ;
@@ -118,6 +120,8 @@ export class SearchBar extends SearchBarBase {
118
120
const nativeView : any = this . nativeView ;
119
121
nativeView . closeListener . owner = null ;
120
122
nativeView . queryTextListener . owner = null ;
123
+ this . _searchPlate = null ;
124
+ this . _searchTextView = null ;
121
125
super . disposeNativeView ( ) ;
122
126
}
123
127
@@ -208,12 +212,22 @@ export class SearchBar extends SearchBarBase {
208
212
}
209
213
210
214
private _getTextView ( ) : android . widget . TextView {
211
- const id = this . nativeView . getContext ( ) . getResources ( ) . getIdentifier ( "android:id/search_src_text" , null , null ) ;
212
- return < android . widget . TextView > this . nativeView . findViewById ( id ) ;
215
+ if ( ! this . _searchTextView ) {
216
+ const pkgName = this . nativeView . getContext ( ) . getPackageName ( ) ;
217
+ const id = this . nativeView . getContext ( ) . getResources ( ) . getIdentifier ( "search_src_text" , "id" , pkgName ) ;
218
+ this . _searchTextView = < android . widget . TextView > this . nativeView . findViewById ( id ) ;
219
+ }
220
+
221
+ return this . _searchTextView ;
213
222
}
214
223
215
224
private _getSearchPlate ( ) : android . widget . LinearLayout {
216
- const id = this . nativeView . getContext ( ) . getResources ( ) . getIdentifier ( "android:id/search_plate" , null , null ) ;
217
- return < android . widget . LinearLayout > this . nativeView . findViewById ( id ) ;
225
+ if ( ! this . _searchPlate ) {
226
+ const pkgName = this . nativeView . getContext ( ) . getPackageName ( ) ;
227
+ const id = this . nativeView . getContext ( ) . getResources ( ) . getIdentifier ( "search_plate" , "id" , pkgName ) ;
228
+ this . _searchPlate = < android . widget . LinearLayout > this . nativeView . findViewById ( id ) ;
229
+ }
230
+
231
+ return this . _searchPlate ;
218
232
}
219
233
}
0 commit comments