本文整理匯總了Java中android.support.v4.app.Fragment.getUserVisibleHint方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.getUserVisibleHint方法的具體用法?Java Fragment.getUserVisibleHint怎麽用?Java Fragment.getUserVisibleHint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.getUserVisibleHint方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dispatchBackPress
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 處理fragment回退鍵
* <p>如果fragment實現了OnBackClickListener接口,返回{@code true}: 表示已消費回退鍵事件,反之則沒消費</p>
* <p>具體示例見FragmentActivity</p>
*
* @param fragmentManager fragment管理器
* @return 是否消費回退事件
*/
public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) return false;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null
&& fragment.isResumed()
&& fragment.isVisible()
&& fragment.getUserVisibleHint()
&& fragment instanceof OnBackClickListener
&& ((OnBackClickListener) fragment).onBackClick()) {
return true;
}
}
return false;
}
示例2: getTopShowFragmentIsInStack
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 根據棧參數獲取頂層可見fragment
*
* @param fragmentManager fragment管理器
* @param parentFragment 父fragment
* @param isInStack 是否是棧中的
* @return 棧中頂層可見fragment
*/
private static Fragment getTopShowFragmentIsInStack(@NonNull final FragmentManager fragmentManager,
final Fragment parentFragment,
final boolean isInStack) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return parentFragment;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) {
if (isInStack) {
if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true);
}
} else {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false);
}
}
}
return parentFragment;
}
示例3: dispatchBackPress
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 處理fragment回退鍵
* <p>如果fragment實現了OnBackClickListener接口,返回{@code true}: 表示已消費回退鍵事件,反之則沒消費</p>
* <p>具體示例見FragmentActivity</p>
*
* @param fragmentManager fragment管理器
* @return 是否消費回退事件
*/
public static boolean dispatchBackPress(@NonNull final FragmentManager fragmentManager) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments == null || fragments.isEmpty()) return false;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null
&& fragment.isResumed()
&& fragment.isVisible()
&& fragment.getUserVisibleHint()
&& fragment instanceof OnBackClickListener
&& ((OnBackClickListener) fragment).onBackClick()) {
return true;
}
}
return false;
}
示例4: getTopShowFragmentIsInStack
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 根據棧參數獲取頂層可見fragment
*
* @param fragmentManager fragment管理器
* @param parentFragment 父fragment
* @param isInStack 是否是棧中的
* @return 棧中頂層可見fragment
*/
private static Fragment getTopShowFragmentIsInStack(@NonNull FragmentManager fragmentManager,
Fragment parentFragment,
boolean isInStack) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return parentFragment;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) {
if (isInStack) {
if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true);
}
} else {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false);
}
}
}
return parentFragment;
}
示例5: getTopShowFragmentIsInStack
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 根據棧參數獲取頂層可見fragment
*
* @param fragmentManager fragment管理器
* @param parentFragment 父fragment
* @param isInStack 是否是棧中的
* @return 棧中頂層可見fragment
*/
private static Fragment getTopShowFragmentIsInStack(@NonNull FragmentManager fragmentManager,
Fragment parentFragment,
boolean isInStack) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty())
return parentFragment;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) {
if (isInStack) {
if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true);
}
} else {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false);
}
}
}
return parentFragment;
}
示例6: dispatchBackPress
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 處理fragment回退鍵
* <p>如果fragment實現了OnBackClickListener接口,返回{@code true}: 表示已消費回退鍵事件,反之則沒消費</p>
* <p>具體示例見FragmentActivity</p>
*
* @param fragmentManager fragment管理器
* @return 是否消費回退事件
*/
public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) {
return false;
}
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null
&& fragment.isResumed()
&& fragment.isVisible()
&& fragment.getUserVisibleHint()
&& fragment instanceof OnBackClickListener
&& ((OnBackClickListener) fragment).onBackClick()) {
return true;
}
}
return false;
}
示例7: getTopShowFragmentIsInStack
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 根據棧參數獲取頂層可見fragment
*
* @param fragmentManager fragment管理器
* @param parentFragment 父fragment
* @param isInStack 是否是棧中的
* @return 棧中頂層可見fragment
*/
private static Fragment getTopShowFragmentIsInStack(@NonNull FragmentManager fragmentManager,
Fragment parentFragment,
boolean isInStack) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) {
return parentFragment;
}
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) {
if (isInStack) {
if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true);
}
} else {
return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false);
}
}
}
return parentFragment;
}
示例8: dispatchBackPress
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 處理fragment回退鍵
* <p>如果fragment實現了OnBackClickListener接口,返回{@code true}: 表示已消費回退鍵事件,反之則沒消費</p>
* <p>具體示例見FragmentActivity</p>
*
* @param fragmentManager fragment管理器
* @return 是否消費回退事件
*/
public static boolean dispatchBackPress(@NonNull final FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) return false;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null
&& fragment.isResumed()
&& fragment.isVisible()
&& fragment.getUserVisibleHint()
&& fragment instanceof OnBackClickListener
&& ((OnBackClickListener) fragment).onBackClick()) {
return true;
}
}
return false;
}
示例9: dispatchBackPress
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* Handle the fragment back key
* <p>If fragment implements the OnBackClickListener interface, returns {@code true}: indicates that the consumer has returned the key event, otherwise it is not consumed</p>
* <p>See FragmentActivity for specific examples</p>
*
* @param fragmentManager fragment manager
* @return Whether to consume back events
*/
public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty())
return false;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null
&& fragment.isResumed()
&& fragment.isVisible()
&& fragment.getUserVisibleHint()
&& fragment instanceof OnBackClickListener
&& ((OnBackClickListener) fragment).onBackClick()) {
return true;
}
}
return false;
}
示例10: activityCreated
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public void activityCreated(){
// 如果自己是顯示狀態,但父Fragment卻是隱藏狀態,就把自己也改為隱藏狀態,並且設置一個等待顯示的標記
if(fragment.getUserVisibleHint()){
Fragment parentFragment = fragment.getParentFragment();
if(parentFragment != null && !parentFragment.getUserVisibleHint()){
if(DEBUG){
LogUtils.info(TAG, fragmentName + ": activityCreated, parent " + parentFragment.getClass().getSimpleName() + "is hidden, therefore hidden self");
}
userVisibleCallback.setWaitingShowToUser(true);
userVisibleCallback.callSuperSetUserVisibleHint(false);
}
}
}
示例11: compatChildFragmentExitAnim
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Nullable
public Animation compatChildFragmentExitAnim(Fragment fragment) {
if ((fragment.getTag() != null && fragment.getTag().startsWith("android:switcher:") && fragment.getUserVisibleHint()) ||
(fragment.getParentFragment() != null && fragment.getParentFragment().isRemoving() && !fragment.isHidden())) {
Animation animation = new Animation() {
};
animation.setDuration(exitAnim.getDuration());
return animation;
}
return null;
}
示例12: dispatchSupportVisible
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void dispatchSupportVisible(boolean visible) {
if (mIsSupportVisible == visible) {
mNeedDispatch = true;
return;
}
mIsSupportVisible = visible;
if (!mNeedDispatch) {
mNeedDispatch = true;
} else {
if (checkAddState()) return;
FragmentManager fragmentManager = mFragment.getChildFragmentManager();
if (fragmentManager != null) {
List<Fragment> childFragments = FragmentationHack.getActiveFragments(fragmentManager);
if (childFragments != null) {
for (Fragment child : childFragments) {
if (child instanceof ISupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
((ISupportFragment) child).getSupportDelegate().getVisibleDelegate().dispatchSupportVisible(visible);
}
}
}
}
}
if (visible) {
if (checkAddState()) return;
mSupportF.onSupportVisible();
if (mIsFirstVisible) {
mIsFirstVisible = false;
mSupportF.onLazyInitView(mSaveInstanceState);
}
} else {
mSupportF.onSupportInvisible();
}
}
示例13: dispatchSupportVisible
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void dispatchSupportVisible(boolean visible) {
mIsSupportVisible = visible;
if (!mNeedDispatch) {
mNeedDispatch = true;
} else {
FragmentManager fragmentManager = mSupportFragment.getChildFragmentManager();
if (fragmentManager != null) {
List<Fragment> childFragments = fragmentManager.getFragments();
if (childFragments != null) {
for (Fragment child : childFragments) {
if (child instanceof SupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
((SupportFragment) child).getVisibleDelegate().dispatchSupportVisible(visible);
}
}
}
}
}
if (visible) {
mSupportFragment.onSupportVisible();
if (mIsFirstVisible) {
mIsFirstVisible = false;
mSupportFragment.onLazyInitView(mSaveInstanceState);
}
} else {
mSupportFragment.onSupportInvisible();
}
}
示例14: getActiveFragment
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private static ISupportFragment getActiveFragment(FragmentManager fragmentManager, ISupportFragment parentFragment) {
List<Fragment> fragmentList = FragmentationHack.getActiveFragments(fragmentManager);
if (fragmentList == null) {
return parentFragment;
}
for (int i = fragmentList.size() - 1; i >= 0; i--) {
Fragment fragment = fragmentList.get(i);
if (fragment instanceof ISupportFragment) {
if (fragment.isResumed() && !fragment.isHidden() && fragment.getUserVisibleHint()) {
return getActiveFragment(fragment.getChildFragmentManager(), (ISupportFragment) fragment);
}
}
}
return parentFragment;
}
示例15: isFragmentBackHandled
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
* 判斷Fragment是否處理了Back鍵
* @return 如果處理了back鍵則返回 <b>true</b>
*/
private static boolean isFragmentBackHandled(Fragment fragment) {
return fragment != null
&& fragment.isVisible()
&& fragment.getUserVisibleHint() //for ViewPager
&& fragment instanceof FragmentBackHandler
&& ((FragmentBackHandler) fragment).onBackPressed();
}