Skip to content

Commit

Permalink
发现搜索
Browse files Browse the repository at this point in the history
  • Loading branch information
Invinciblelee committed Jul 2, 2019
1 parent 4fc6784 commit 6ad4939
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class FindBookFragment extends BaseFragment<FindBookContract.Presenter> i
private FindBookAdapter mAdapter;

private boolean mSubmit = true;
private String mKeyword;

private KeyboardHeightProvider mHeightProvider;
private boolean mKeyboardShown;
Expand Down Expand Up @@ -107,7 +108,8 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
@Override
public void afterTextChanged(Editable s) {
if (mSubmit) {
mAdapter.getFilter().filter(s == null ? null : s.toString());
mKeyword = s == null ? null : s.toString();
mAdapter.getFilter().filter(mKeyword);
} else {
mSubmit = true;
}
Expand All @@ -130,6 +132,9 @@ private void animShow(boolean show) {
mSubmit = false;
searchEdit.setText(null);
searchEdit.clearFocus();
}else {
searchEdit.setText(mKeyword);
searchEdit.setSelection(searchEdit.length());
}

final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) searchField.getLayoutParams();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_find_book.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
Expand Down Expand Up @@ -61,6 +60,7 @@
android:layout_marginStart="21dp"
android:background="@color/transparent"
android:gravity="center_vertical"
android:includeFontPadding="false"
android:hint="@string/search"
android:paddingStart="24dp"
android:paddingEnd="24dp"
Expand Down

0 comments on commit 6ad4939

Please sign in to comment.