private void handlerBackKey() { if (mCurrentFragment == fragment_phone) { mCurrentFragment = fragment_main; if (mPickContactPhoneFragment != null && !mPickContactPhoneFragment.isHidden()) { mFragmentManager.beginTransaction().hide(mPickContactPhoneFragment).commit(); } mPickFriendsFragment = (PickFriendsFragment) mFragmentManager.findFragmentByTag(PICK_MAIN_TAG); if (mPickFriendsFragment == null) { mPickFriendsFragment = new PickFriendsFragment(); mFragmentManager .beginTransaction() .add(R.id.request_container, mPickFriendsFragment, PICK_MAIN_TAG) .commit(); } else { mFragmentManager.beginTransaction().show(mPickFriendsFragment).commit(); mPickFriendsFragment.setAddress(); } } else if (mCurrentFragment == fragment_email) { mCurrentFragment = fragment_main; if (mPickContactEmailFragment != null && !mPickContactEmailFragment.isHidden()) { mFragmentManager.beginTransaction().hide(mPickContactEmailFragment).commit(); } mPickFriendsFragment = (PickFriendsFragment) mFragmentManager.findFragmentByTag(PICK_MAIN_TAG); if (mPickFriendsFragment == null) { mPickFriendsFragment = new PickFriendsFragment(); mFragmentManager .beginTransaction() .add(R.id.request_container, mPickFriendsFragment, PICK_MAIN_TAG) .commit(); } else { mFragmentManager.beginTransaction().show(mPickFriendsFragment).commit(); mPickFriendsFragment.setAddress(); } } else { if (mCurrentFragment == fragment_main) { if (mPickFriendsFragment != null) { if (mPickFriendsFragment.isBackSearch()) { Log.d(TAG, "is back from search mode"); } else { setResult(Activity.RESULT_CANCELED); super.onBackPressed(); } } else { setResult(Activity.RESULT_CANCELED); super.onBackPressed(); } } else { setResult(Activity.RESULT_CANCELED); super.onBackPressed(); } } }
@Override public void gotoPickContactFragment(int type) { Log.d(TAG, "gotoPickContactFragment: " + type); if (type == PickAudienceBaseFragment.PICK_TYPE_PHONE) { if (mCurrentFragment != fragment_phone) { showSlideToggle(overrideSlideToggleClickListener); mCurrentFragment = fragment_phone; if (mPickFriendsFragment != null && !mPickFriendsFragment.isHidden()) { mFragmentManager.beginTransaction().hide(mPickFriendsFragment).commit(); } mPickContactPhoneFragment = (PickAudiencePhoneFragment) mFragmentManager.findFragmentByTag(PICK_PHONE_TAG); if (mPickContactPhoneFragment == null) { mPickContactPhoneFragment = new PickAudiencePhoneFragment(); mFragmentManager .beginTransaction() .add(R.id.request_container, mPickContactPhoneFragment, PICK_PHONE_TAG) .commit(); } else { mFragmentManager.beginTransaction().show(mPickContactPhoneFragment).commit(); mPickContactPhoneFragment.setAddress(); } } } else if (type == PickAudienceBaseFragment.PICK_TYPE_EMAIL) { if (mCurrentFragment != fragment_email) { showSlideToggle(overrideSlideToggleClickListener); mCurrentFragment = fragment_email; if (mPickFriendsFragment != null && !mPickFriendsFragment.isHidden()) { mFragmentManager.beginTransaction().hide(mPickFriendsFragment).commit(); } mPickContactEmailFragment = (PickAudienceEmailFragment) mFragmentManager.findFragmentByTag(PICK_EMAIL_TAG); if (mPickContactEmailFragment == null) { mPickContactEmailFragment = new PickAudienceEmailFragment(); mFragmentManager .beginTransaction() .add(R.id.request_container, mPickContactEmailFragment, PICK_EMAIL_TAG) .commit(); } else { mFragmentManager.beginTransaction().show(mPickContactEmailFragment).commit(); mPickContactEmailFragment.setAddress(); } } } }