Ejemplo n.º 1
0
 @Override
 public void onAttachFragment(Fragment fragment) {
   if (fragment instanceof DialpadFragment) {
     mDialpadFragment = (DialpadFragment) fragment;
     final FragmentTransaction transaction = getFragmentManager().beginTransaction();
     transaction.hide(mDialpadFragment);
     transaction.commit();
   } else if (fragment instanceof SmartDialSearchFragment) {
     mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
     mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(
         mPhoneNumberPickerActionListener);
   } else if (fragment instanceof SearchFragment) {
     mRegularSearchFragment = (RegularSearchFragment) fragment;
     mRegularSearchFragment.setOnPhoneNumberPickerActionListener(mPhoneNumberPickerActionListener);
   } else if (fragment instanceof PhoneFavoriteFragment) {
     mPhoneFavoriteFragment = (PhoneFavoriteFragment) fragment;
     mPhoneFavoriteFragment.setListener(mPhoneFavoriteListener);
   }
 }
Ejemplo n.º 2
0
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
          final String newText = s.toString();
          if (newText.equals(mSearchQuery)) {
            // If the query hasn't changed (perhaps due to activity being destroyed
            // and restored, or user launching the same DIAL intent twice), then there is
            // no need to do anything here.
            return;
          }
          mSearchQuery = newText;
          if (DEBUG) {
            Log.d(TAG, "onTextChange for mSearchView called with new query: " + s);
          }
          final boolean dialpadSearch = isDialpadShowing();

          // Show search result with non-empty text. Show a bare list otherwise.
          if (TextUtils.isEmpty(newText) && getInSearchUi()) {
            exitSearchUi();
            mSearchViewCloseButton.setVisibility(View.GONE);
            mVoiceSearchButton.setVisibility(View.VISIBLE);
            return;
          } else if (!TextUtils.isEmpty(newText)) {
            final boolean sameSearchMode =
                (dialpadSearch && mInDialpadSearch) || (!dialpadSearch && mInRegularSearch);
            if (!sameSearchMode) {
              // call enterSearchUi only if we are switching search modes, or entering
              // search ui for the first time
              enterSearchUi(dialpadSearch, newText);
            }

            if (dialpadSearch && mSmartDialSearchFragment != null) {
              mSmartDialSearchFragment.setQueryString(newText, false);
            } else if (mRegularSearchFragment != null) {
              mRegularSearchFragment.setQueryString(newText, false);
            }
            mSearchViewCloseButton.setVisibility(View.VISIBLE);
            mVoiceSearchButton.setVisibility(View.GONE);
            return;
          }
        }