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


Java Fragment.isDetached方法代码示例

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


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

示例1: switchFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void switchFragment(@NonNull Fragment fragment, String tag) {
    if (fragment.isAdded()) {
        return;
    }

    final FragmentManager manager = getSupportFragmentManager();
    final FragmentTransaction fragmentTransaction = manager.beginTransaction();

    final Fragment currentFragment = manager.findFragmentById(R.id.container);
    if (currentFragment != null) {
        fragmentTransaction.detach(currentFragment);
    }

    if (fragment.isDetached()) {
        fragmentTransaction.attach(fragment);
    } else {
        fragmentTransaction.add(R.id.container, fragment, tag);
    }
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
            .commit();
}
 
开发者ID:soramitsu,项目名称:iroha-demo-android,代码行数:22,代码来源:MainActivity.java

示例2: getItemPosition

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public int getItemPosition(Object object) {
    if (object instanceof Fragment) {
        final Fragment fragment = (Fragment) object;
        final String tag = fragment.getTag();
        if (fragment.isDetached() || tag == null) {
            return POSITION_NONE;
        }

        int position = 0;
        for (T data : mList) {
            if (tag.equals(makeFragmentTag(mContainerId, getItemId(data)))) {
                return position;
            }
            position++;
        }

        return POSITION_NONE;
    }

    return super.getItemPosition(object);
}
 
开发者ID:nekocode,项目名称:Hubs,代码行数:23,代码来源:ExFragmentPagerAdapter.java

示例3: showDirectoryWithSelectedTab

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void showDirectoryWithSelectedTab(FileInfo fileInfo) {
    Preconditions.checkNotNull(fileInfo, "fileInfo == null");
    Preconditions.checkNotNull(mSelectedDirectory, "mSelectedDirectory == null");
    Log.d(TAG, "showDirectoryWithSelectedTab: " + fileInfo.getName());
    if (mSelectedDirectory != fileInfo) {
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        Fragment f = mFragmentManager.findFragmentByTag(mSelectedDirectory.getAbsolutePath());
        if (f != null && !f.isDetached()) {
            ft.detach(f);
        }

        mSelectedDirectory = fileInfo;

        f = mFragmentManager.findFragmentByTag(fileInfo.getAbsolutePath());
        if (f == null) {
            f = FileInfosFragment.newInstance(fileInfo.getAbsolutePath());
            ft.add(R.id.contentFrame, f, fileInfo.getAbsolutePath());
        } else {
            ft.attach(f);
        }
        ft.commit();
    }
}
 
开发者ID:JulianAndroid,项目名称:AppChooser,代码行数:24,代码来源:FileInfosActivity.java

示例4: onBackPressed

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onBackPressed()
{
    if (mFragmentManager.findFragmentByTag("home").isDetached())
    {
        fragStuff.setFragmentByTag("home");
        for (Fragment fragment : mFragmentManager.getFragments())
        {
            if (fragment != null && !fragment.isDetached() && fragment instanceof ChatFragment)
            {
                if (((ChatFragment) fragment).getmSlidingMenu().isMenuShowing())
                {
                    ((ChatFragment) fragment).getmSlidingMenu().hideMenu(true);
                }
            }
        }
        if (mChatroomSlidingMenu.isMenuShowing())
        {
            mChatroomSlidingMenu.hideMenu(true);
        }
    }
    else if (mChatroomSlidingMenu.isMenuShowing())
    {
        mChatroomSlidingMenu.hideMenu(true);
    }
    else
    {
        super.onBackPressed();
    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:31,代码来源:MainActivity.java

示例5: reattachRemovedFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void reattachRemovedFragment(Fragment fragment, FragmentTransaction fragmentTransaction, Path key, int containerId) {
    if(fragment == null) {
        fragment = key.createFragment();
    }
    if(!fragment.isAdded() || (fragment.isDetached() || fragment.getView() == null)) {
        fragmentTransaction.add(containerId, fragment, key.getFragmentTag());
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:9,代码来源:MasterDetailFragmentStateChanger.java

示例6: removeToDetachFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private Fragment removeToDetachFragment(StateChange stateChange, Path key) {
    Fragment fragment = fragmentManager.findFragmentByTag(key.getFragmentTag());
    if(fragment != null && (fragment.isDetached() || fragment.getView() == null)) {
        FragmentTransaction fragmentTransaction = beginFragmentTransaction(stateChange);
        Fragment.SavedState savedState = fragmentManager.saveFragmentInstanceState(fragment);
        fragmentTransaction.remove(fragment);
        fragmentTransaction.commitNow();
        fragment.setInitialSavedState(savedState);
    }
    return fragment;
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:12,代码来源:MasterDetailFragmentStateChanger.java

示例7: showDirectoryWithBackPressed

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void showDirectoryWithBackPressed() {
    Preconditions.checkNotNull(mSelectedDirectory, "mSelectedDirectory == null");
    Preconditions.checkArgument(mDirectories.contains(mSelectedDirectory),
            "mDirectories not contain:" + mSelectedDirectory.getAbsolutePath());
    final int selectedPosition = mDirectories.indexOf(mSelectedDirectory);
    if (selectedPosition == 0) {
        finish();
    } else {
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        Fragment f = mFragmentManager.findFragmentByTag(mSelectedDirectory.getAbsolutePath());
        if (f != null && !f.isDetached()) {
            ft.detach(f);
        }
        int previousPosition = selectedPosition - 1;
        FileInfo previous = mSelectedDirectory = mDirectories.get(previousPosition);
        f = mFragmentManager.findFragmentByTag(previous.getAbsolutePath());
        if (f == null) {
            f = FileInfosFragment.newInstance(previous.getAbsolutePath());
            ft.add(R.id.contentFrame, f, previous.getAbsolutePath());
        } else {
            ft.attach(f);
        }
        ft.commit();

        Message msg = mMyHandler.obtainMessage();
        msg.arg1 = previousPosition;
        mMyHandler.sendMessageDelayed(msg, 100L);
    }
}
 
开发者ID:JulianAndroid,项目名称:AppChooser,代码行数:30,代码来源:FileInfosActivity.java

示例8: showChart

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void showChart() {
    Fragment fragment = getSupportFragmentManager().findFragmentByTag(CHART_FRAGMENT);
    if (fragment != null && !fragment.isDetached() && fragment.getId() != R.id.chart_dual) {
        return;
    }
    openSinglePaneChartFragment();
}
 
开发者ID:rjaros87,项目名称:pm-home-station,代码行数:8,代码来源:MainActivity.java

示例9: setFragmentByTag

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * Open a chat using its tag
 *
 * @param tag the chat's fragment tag (should be its URL)
 */

public void setFragmentByTag(String tag)
{
    Log.e("TAG", tag);
    if (mainActivity.mFragmentManager.getFragments() != null)
    {
        for (Fragment fragment : mainActivity.mFragmentManager.getFragments())
        {
            if (fragment != null && !fragment.isDetached())
            {
                mainActivity.mFragmentManager.beginTransaction().detach(fragment).commit();
            }
        }
        Fragment fragToAttach = mainActivity.mFragmentManager.findFragmentByTag(tag);

        if (fragToAttach != null)
        {

            if (tag.equals("home"))
            {
                mainActivity.mFragmentManager.beginTransaction().setCustomAnimations(R.anim.fade_in, R.anim.fade_out).attach(fragToAttach).commit();
                mainActivity.mCurrentUsers_SlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
                ((HomeFragment) fragToAttach).hueTest();
            }
            else
            {
                if (mainActivity.mFragmentManager.findFragmentByTag("home").isDetached())
                {
                    mainActivity.mFragmentManager.beginTransaction().attach(fragToAttach).commit();
                }
                else
                {
                    mainActivity.mFragmentManager.beginTransaction().setCustomAnimations(R.anim.fade_in, R.anim.fade_out).attach(fragToAttach).commit();
                }
                mainActivity.mCurrentUsers_SlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
            }
        }
        else
        {
            Log.e("TAG", tag);
        }

    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:50,代码来源:FragStuff.java


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