示例#1
0
  @Override
  protected void onStop() {
    super.onStop();
    CommonUtils.hideKeyboard(mSearchEditText);
    setResultContainerVisible(false);
    setSearchBoxVisible(false);

    ((IDrawerView) mMapsFragment).enableDrawer(true);
  }
示例#2
0
  @Override
  protected void onStart() {
    super.onStart();
    if (hasResult()) {
      finish();
      return;
    }

    hidePoiWithoutLoc = getHidePoiWithoutLoc();
    if (getOnlySearchBox()) {
      setSearchBoxVisible(true);
      mSearchEditText.setCursorVisible(false);
      mMapsFragment.setMapViewVisibility(View.VISIBLE);
    } else {
      mMapsFragment.setMapViewVisibility(View.INVISIBLE);
      setSearchBoxVisible(true);
      setResultContainerVisible(true);
      mSearchEditText.setCursorVisible(true);

      ((IDrawerView) mMapsFragment).enableDrawer(false);
    }
    if (getBackBtnAsDrawer()) {
      isBackBtnAsDrawer = true;
      mBackBtn.setImageDrawable(getContext().getDrawable(R.drawable.ic_menu));
    } else {
      isBackBtnAsDrawer = false;
      mBackBtn.setImageDrawable(getContext().getDrawable(R.drawable.ic_arrow_back));
    }
    if (getChooseOnMap()) {
      mChooseOnMapBtn.setVisibility(View.VISIBLE);
    } else {
      mChooseOnMapBtn.setVisibility(View.GONE);
    }
    if (getChooseFromFav()) {
      mChooseFromFavBtn.setVisibility(View.VISIBLE);
    } else {
      mChooseFromFavBtn.setVisibility(View.GONE);
    }
  }
示例#3
0
  @Override
  protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
    super.onCreateView(inflater, container);
    ViewGroup searchBox = (ViewGroup) inflater.inflate(R.layout.search_box, container, false);
    mSearchBox = searchBox;

    ImageButton btn = (ImageButton) searchBox.findViewById(R.id.opendrawer_or_back);
    mBackBtn = btn;
    btn.setOnClickListener(this);

    final ImageButton editTextClearBtn = (ImageButton) searchBox.findViewById(R.id.edit_text_clear);
    editTextClearBtn.setOnClickListener(this);

    EditText searchEditText = (EditText) searchBox.findViewById(R.id.search_edittext);
    mSearchEditText = searchEditText;
    searchEditText.setCursorVisible(false);
    searchEditText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void afterTextChanged(Editable s) {
            if (s.length() > 0) {
              editTextClearBtn.setVisibility(View.VISIBLE);
            } else {
              editTextClearBtn.setVisibility(View.INVISIBLE);
            }
            if (enableTextTip) {
              String str = s.toString().trim();
              mSearchBoxPresenter.requestInputTips(str, "");
            }
          }
        });
    searchEditText.setOnClickListener(this);
    searchEditText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String s = v.getText().toString();
            if (CommonUtils.isStringEmpty(s)) {
              return false;
            }
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
              Tip tip = getTipFromKeyword(s);
              tip.setID(""); // prevent null value
              returnResult(tip);
              return true;
            }
            return false;
          }
        });

    ViewGroup searchResultContainer =
        (ViewGroup) inflater.inflate(R.layout.search_result, container, false);
    mSearchResultContainer = searchResultContainer;

    ViewGroup chooseOnMapBtn =
        (ViewGroup) searchResultContainer.findViewById(R.id.search_choose_on_map);
    mChooseOnMapBtn = chooseOnMapBtn;
    chooseOnMapBtn.setOnClickListener(this);
    ViewGroup chooseFromFavBtn =
        (ViewGroup) searchResultContainer.findViewById(R.id.choose_from_favorites);
    mChooseFromFavBtn = chooseFromFavBtn;
    chooseFromFavBtn.setOnClickListener(this);

    RecyclerView resultListView =
        (RecyclerView) searchResultContainer.findViewById(R.id.result_listview);
    SearchTipsAdapter searchTipsAdapter = new SearchTipsAdapter(getContext());
    mResultAdapter = searchTipsAdapter;
    resultListView.setAdapter(searchTipsAdapter);
    searchTipsAdapter.setOnViewClickListener(
        new OnViewClickListener() {
          @Override
          public void onClick(View v, Object data) {
            final Tip tip = (Tip) data;
            if (getOnlySearchBox()) {
              enableTextTip = false;
              mSearchEditText.setText(tip.getName());
              enableTextTip = true;
            }
            returnResult(tip);
          }
        });
    setOnStartAnimation(R.animator.slide_in_top);
    setOnStopAnimation(R.animator.slide_out_top);
    setViewToAnimate(searchBox);
  }
示例#4
0
 @Override
 protected void onCreate() {
   super.onCreate();
   mSearchBoxPresenter = new SearchBoxPresenter(getContext(), this, mMapsFragment.getMapsModule());
 }