Example #1
0
 @Override
 public void onBackPressed() {
   Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.container);
   if (fragment != null) {
     if (fragment instanceof SearchFragment) {
       getTracker().track("onSearchCloseBackClick");
       ((SearchFragment) fragment).closeSearch();
     } else if (fragment instanceof PhoneFragment) {
       ((PhoneFragment) fragment).closePhone();
       mAdsProvider.onPhoneClosed(this);
     }
   } else {
     mAdsProvider.onBackPressed(this);
     super.onBackPressed();
   }
 }
Example #2
0
  private void showPhone(final String phoneNumber) {
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.container);
    if (fragment != null && fragment instanceof PhoneFragment) {
      ((PhoneFragment) fragment).updatePhone(phoneNumber);
      return;
    }
    if (isFabClicked) {
      return;
    }
    isFabClicked = true;

    mAdsProvider.onFabClick(this);

    mFloatingActionButton.hide(true);
    mFloatingActionButton.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            PhoneFragment fragment = new PhoneFragment();
            if (phoneNumber != null) {
              Bundle args = new Bundle();
              args.putString(PhoneFragment.EXTRA_PHONE, phoneNumber);
              fragment.setArguments(args);
            }
            if (isFinishing()) {
              return;
            }
            getSupportFragmentManager()
                .beginTransaction()
                .addToBackStack(null)
                .add(R.id.container, fragment)
                .commit();
          }
        },
        200l);
    mFloatingActionButton.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            isFabClicked = false;
          }
        },
        500l);
  }