当前位置: 首页>>代码示例>>Java>>正文


Java Fragment.isVisible方法代码示例

本文整理汇总了Java中android.support.v4.app.Fragment.isVisible方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.isVisible方法的具体用法?Java Fragment.isVisible怎么用?Java Fragment.isVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.Fragment的用法示例。


在下文中一共展示了Fragment.isVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:FragmentUtils.java

示例2: 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;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:25,代码来源:FragmentUtils.java

示例3: 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;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:28,代码来源:FragmentUtils.java

示例4: changeView

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void changeView(int position) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    Fragment fragment = mFragments.get(position);
    if (fragment.isAdded()) {
        transaction.show(fragment);
    } else {
        transaction.add(R.id.sticky_container, fragment);
        mVisibleFragments.add(fragment);
    }
    for (Fragment fragment1 : mVisibleFragments) {
        if (fragment1 != fragment) {
            if (fragment1.isVisible()) {
                transaction.hide(fragment1);
                transaction.addToBackStack(null);
            }
        }
    }
    transaction.commit();
}
 
开发者ID:yedashen,项目名称:UltimateRecyclerView,代码行数:21,代码来源:LikeStickListViewActivity.java

示例5: 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;
}
 
开发者ID:yangxp108,项目名称:MVPArms_Fragment-fragment,代码行数:26,代码来源:FragmentUtils.java

示例6: 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;
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:26,代码来源:FragmentUtils.java

示例7: onBackPressed

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static boolean onBackPressed(@NonNull final FragmentManager fm) {
    List<Fragment> fragments = getFragments(fm);
    if (fragments == null || fragments.isEmpty()) {
        return false;
    }
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        //@formatter:off
        if (fragment != null &&
                fragment.isResumed() &&
                fragment.isVisible() &&
                fragment.getUserVisibleHint() &&
                fragment instanceof OnBackClickListener &&
                ((OnBackClickListener) fragment)
                .onBackClick())
        {
            return true;
        }
        //@formatter:on
    }
    return false;
}
 
开发者ID:interactiveservices,项目名称:utils-android,代码行数:23,代码来源:FragmentUtils.java

示例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 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;
}
 
开发者ID:HStanN,项目名称:TakeRest,代码行数:25,代码来源:FragmentUtils.java

示例9: onBackPressed

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG);

    /* Close drawer if opened. */
    if (mDrawerLayout != null) {
        if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
            mDrawerLayout.closeDrawer(GravityCompat.START);
            mIsDrawerOpen = false;
            return;
        }
    }

    /* Handle back press when editing note - check for changes */
    Fragment fragment = getSupportFragmentManager().findFragmentByTag(NoteFragment.FRAGMENT_TAG);
    if (fragment != null && fragment instanceof NoteFragment && fragment.isVisible()) {
        final NoteFragment noteFragment = (NoteFragment) fragment;
        if (noteFragment.isAskingForConfirmationForModifiedNote()) {
            return;
        }
    }

    super.onBackPressed();
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:25,代码来源:MainActivity.java

示例10: unHighlightAyah

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void unHighlightAyah(int sura, int ayah, HighlightType type) {
  int position = viewPager.getCurrentItem();
  Fragment f = pagerAdapter.getFragmentIfExists(position);
  if (f instanceof QuranPage && f.isVisible()) {
    ((QuranPage) f).getAyahTracker().unHighlightAyah(sura, ayah, type);
  }
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:8,代码来源:PagerActivity.java

示例11: getVisibleFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public Fragment getVisibleFragment() {
    List<Fragment> fragments = getSupportFragmentManager().getFragments();
    for (Fragment fragment : fragments) {
        if (fragment != null && fragment.isVisible()) {
            return fragment;
        }
    }
    return null;
}
 
开发者ID:ITBlackDog,项目名称:XiaoHuaCharge,代码行数:10,代码来源:HomeActivity.java

示例12: 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();
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:12,代码来源:BackHandlerHelper.java

示例13: updateToolbar

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void updateToolbar() {
    if(getSupportActionBar() != null) {
        Fragment account = getSupportFragmentManager().findFragmentByTag("settingsAccountOverviewFragment");
        Fragment update = getSupportFragmentManager().findFragmentByTag("settingsAccountUpdateFragment");
        Fragment licenses = getSupportFragmentManager().findFragmentByTag("settingsLicensesFragment");

        if((account != null && account.isVisible()) || (update != null && update.isVisible())) {
            showMenuItems(false);

            User displayed = null;
            if(lastUserID != null && !lastUserID.equals("")) {
                displayed = DBHelper.getInstance(this).getUserByID(lastUserID);
            }
            if(displayed != null) {
                getSupportActionBar().setTitle(displayed.getName());
            } else {
                getSupportActionBar().setTitle(R.string.settings);
            }
        } else if(licenses != null && licenses.isVisible()) {
            showMenuItems(false);
            getSupportActionBar().setTitle(R.string.settings_licenses);
        } else {
            showMenuItems(true);
            getSupportActionBar().setTitle(R.string.settings);
        }
    }
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:28,代码来源:SettingsActivity.java

示例14: onBackPressed

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG_TIME_CONTROL_FRAGMENT);
    if (frag != null && frag.isVisible()) {
        ((TimeControlFragment) frag).showConfirmGoBackDialog();
    } else {
        finish();
        overridePendingTransition(R.anim.left_to_right_in, R.anim.left_to_right_full);
    }
}
 
开发者ID:ChessCom,项目名称:android-chessclock,代码行数:11,代码来源:SettingsActivity.java

示例15: getActiveFragmentBook

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private Book getActiveFragmentBook() {
    Fragment f = getSupportFragmentManager().findFragmentByTag(BookFragment.FRAGMENT_TAG);

    if (f != null && f.isVisible()) {
        BookFragment bookFragment = (BookFragment) f;
        return bookFragment.getBook();
    }

    return null;
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:11,代码来源:MainActivity.java


注:本文中的android.support.v4.app.Fragment.isVisible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。