Пример #1
0
  private void showSearchSuggestions() {
    BusProvider.getInstance().post(new ShowSearchSuggestionsEvent(getQuery()));

    mSuggestionsAdapter.setOnItemClickListener(this);
    mSuggestionsAdapter.setOnItemLongClickListener(this);
    mSuggestionsAdapter.setOnSearchSuggestionCompleteClickListener(this);

    CustomLinearLayoutManager layoutManager = new CustomLinearLayoutManager(getContext());
    //        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    mRecyclerView.setLayoutManager(layoutManager);

    mDividerItemDecoration =
        new DividerItemDecoration(ContextCompat.getDrawable(getContext(), R.drawable.divider));
    mRecyclerView.addItemDecoration(mDividerItemDecoration);
    //        mRecyclerView.setItemAnimator(new SlideInUpAnimator());
    mRecyclerView.setAdapter(mSuggestionsAdapter);

    if (mSuggestionsAdapter.getItemCount() > 0) {
      mRecyclerView.setVisibility(View.VISIBLE);
      mDividerView.setVisibility(View.VISIBLE);
    } else {
      mRecyclerView.setVisibility(View.GONE);
      mDividerView.setVisibility(View.GONE);
    }

    mBackgroundCoverFrameLayout.setVisibility(View.VISIBLE);

    setUpLeftDrawable(true);

    mAreSearchSuggestionsVisible = true;
  }
Пример #2
0
  // region SuggestionsAdapter.OnItemClickListener Methods
  @Override
  public void onItemClick(int position, View view) {
    TextView suggestionTextView = (TextView) view.findViewById(R.id.suggestion_tv);
    String suggestion = suggestionTextView.getText().toString();

    hideSearchSuggestions();
    BusProvider.getInstance().post(new SearchPerformedEvent(suggestion));
  }
Пример #3
0
  @OnTextChanged(R.id.search_et)
  public void onSearchEditTextTextChanged(CharSequence text) {
    if (text.length() > 0) {
      mMicrophoneImageView.setVisibility(View.GONE);
      mClearImageView.setVisibility(View.VISIBLE);
    } else {
      mClearImageView.setVisibility(View.GONE);
      mMicrophoneImageView.setVisibility(View.VISIBLE);
    }

    if (mIsSearchEditTextFocused) {
      mSuggestionsAdapter.setCurrentQuery(text.toString());
      BusProvider.getInstance().post(new ShowSearchSuggestionsEvent(text.toString()));
    }

    mFilterImageView.setVisibility(View.GONE);
  }
Пример #4
0
  @OnClick(R.id.left_drawable_iv)
  public void leftDrawableImageViewClicked() {
    if (mAreSearchSuggestionsVisible) {
      hideSearchSuggestions();
    } else {
      LeftDrawableClickedEvent.Type type = null;
      switch (mLeftDrawableType) {
        case 0:
          type = LeftDrawableClickedEvent.Type.MENU;
          break;
        case 1:
          type = LeftDrawableClickedEvent.Type.BACK;
          break;
        case 2:
          type = LeftDrawableClickedEvent.Type.SEARCH;
          mSearchEditText.requestFocus();
        default:
          break;
      }

      BusProvider.getInstance().post(new LeftDrawableClickedEvent(type));
    }
  }
Пример #5
0
 @Override
 public void onClick(View v) {
   BusProvider.getInstance().post(new FilterClickedEvent());
 }
Пример #6
0
 @Override
 public void onPause() {
   super.onPause();
   BusProvider.getInstance().unregister(this);
 }
Пример #7
0
 @Override
 public void onResume() {
   super.onResume();
   BusProvider.getInstance().register(this);
 }