@@ -329,17 +329,7 @@ protected void onCreate(Bundle savedInstanceState) {
329
329
@ Override
330
330
public void onClick (View v ) {
331
331
//set default people list
332
- try {
333
- peopleAdapter .changeCursor (getPeopleCursorGenerator ().call ());
334
- } catch (Exception e ) {
335
- ZLog .logException (e );
336
- }
337
- //set search editText text empty
338
- etSearchPeople .setText ("" );
339
- //hide soft keyboard
340
- hideSoftKeyBoard ();
341
- //remove focus
342
- etSearchPeople .clearFocus ();
332
+ resetPeopleSearch ();
343
333
}
344
334
});
345
335
etSearchStream = (EditText )findViewById (R .id .stream_drawer_search );
@@ -349,16 +339,7 @@ public void onClick(View v) {
349
339
@ Override
350
340
public void onClick (View v ) {
351
341
//set default stream list
352
- try {
353
- streamsDrawerAdapter .changeCursor (getSteamCursorGenerator ().call ());
354
- } catch (Exception e ) {
355
- ZLog .logException (e );
356
- }
357
- etSearchStream .setText ("" );
358
- //hide soft keyboard
359
- hideSoftKeyBoard ();
360
- //remove focus
361
- etSearchStream .clearFocus ();
342
+ resetStreamSearch ();
362
343
}
363
344
});
364
345
app .setZulipActivity (this );
@@ -398,6 +379,7 @@ public void onDrawerOpened(View drawerView) {
398
379
@ Override
399
380
public void onItemClick (AdapterView <?> parent , View view ,
400
381
int position , long id ) {
382
+ resetPeopleSearch ();
401
383
if (id == allPeopleId ) {
402
384
doNarrow (new NarrowFilterAllPMs (app .getYou ()));
403
385
} else {
@@ -544,6 +526,28 @@ public Cursor runQuery(CharSequence charSequence) {
544
526
}
545
527
}
546
528
529
+ /**
530
+ * Change peopleAdapter cursor to default
531
+ * Clear text of etSearchPeople
532
+ * Remove focus of etSearchPeople
533
+ */
534
+ private void resetPeopleSearch () {
535
+ try {
536
+ peopleAdapter .changeCursor (getPeopleCursorGenerator ().call ());
537
+ } catch (Exception e ) {
538
+ ZLog .logException (e );
539
+ }
540
+ //set search editText text empty
541
+ etSearchPeople .setText ("" );
542
+ //hide soft keyboard
543
+ hideSoftKeyBoard ();
544
+ //remove focus
545
+ etSearchPeople .clearFocus ();
546
+ }
547
+
548
+ /**
549
+ * Hide soft keyboard
550
+ */
547
551
private void hideSoftKeyBoard () {
548
552
// Check if no view has focus:
549
553
View view = this .getCurrentFocus ();
@@ -1026,6 +1030,7 @@ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition
1026
1030
1027
1031
@ Override
1028
1032
public boolean onGroupClick (ExpandableListView expandableListView , View view , int position , long l ) {
1033
+ resetStreamSearch ();
1029
1034
String streamName = ((TextView ) view .findViewById (R .id .name )).getText ().toString ();
1030
1035
doNarrow (new NarrowFilterStream (streamName , null ));
1031
1036
drawerLayout .openDrawer (GravityCompat .START );
@@ -1054,6 +1059,7 @@ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
1054
1059
view .setOnClickListener (new View .OnClickListener () {
1055
1060
@ Override
1056
1061
public void onClick (View v ) {
1062
+ resetStreamSearch ();
1057
1063
onNarrow (new NarrowFilterStream (streamName , null ));
1058
1064
onNarrowFillSendBoxStream (streamName , "" , false );
1059
1065
}
@@ -1099,6 +1105,24 @@ public void onClick(View v) {
1099
1105
streamsDrawer .setAdapter (streamsDrawerAdapter );
1100
1106
}
1101
1107
1108
+ /**
1109
+ * Change streamsDrawerAdapter cursor to default
1110
+ * Clear text of etSearchStream
1111
+ * Remove focus of etSearchStream
1112
+ */
1113
+ private void resetStreamSearch () {
1114
+ try {
1115
+ streamsDrawerAdapter .changeCursor (getSteamCursorGenerator ().call ());
1116
+ } catch (Exception e ) {
1117
+ ZLog .logException (e );
1118
+ }
1119
+ etSearchStream .setText ("" );
1120
+ //hide soft keyboard
1121
+ hideSoftKeyBoard ();
1122
+ //remove focus
1123
+ etSearchStream .clearFocus ();
1124
+ }
1125
+
1102
1126
/**
1103
1127
* Initiates the streams Drawer if the streams in the drawer is 0.
1104
1128
*/
0 commit comments