android.support.v4.app.Fragment#getId ( )源码实例Demo

下面列出了android.support.v4.app.Fragment#getId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private String getStateId() {
    if (stateId != null) {
        return stateId;
    }

    Fragment parentFragment = getParentFragment();
    stateId = parentFragment.getTag();
    if (stateId == null) {
        int id = parentFragment.getId();
        if (id > 0) {
            stateId = Integer.toString(id);
        }
    }

    if (stateId == null) {
        throw new IllegalStateException("Fragment dose not have a valid id");
    }

    return stateId;
}
 
源代码2 项目: identity-samples   文件: MainActivity.java
public void setFragment(boolean isVerifying) {
    Fragment current = getCurrentFragment();
    Fragment frag = statusFrag;
    if (isVerifying) {
        frag = validationFrag;
    }
    if (current == null || frag.getId() != current.getId()) {
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(container.getId(), frag);
        transaction.commitAllowingStateLoss();
    }
}
 
@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (currTransaction == null) {
        currTransaction = fm.beginTransaction();
    }

    Fragment fragment = getExistingFragment(position);

    if (fragment != null) {
        if (fragment.getId() == container.getId()) {
            retentionStrategy.attach(fragment, currTransaction);
        } else {
            fm.beginTransaction().remove(fragment).commit();
            fm.executePendingTransactions();

            currTransaction.add(container.getId(), fragment,
                    getFragmentTag(position));
        }
    } else {
        fragment = createFragment(entries.get(position).getDescriptor());
        currTransaction.add(container.getId(), fragment,
                getFragmentTag(position));
    }

    if (fragment != currPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}
 
源代码4 项目: android-credentials   文件: MainActivity.java
public void setFragment(boolean isVerifying) {
    Fragment current = getCurrentFragment();
    Fragment frag = statusFrag;
    if (isVerifying) {
        frag = validationFrag;
    }
    if (current == null || frag.getId() != current.getId()) {
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(container.getId(), frag);
        transaction.commitAllowingStateLoss();
    }
}
 
源代码5 项目: android-task   文件: FragmentIdHelper.java
public static String getFragmentId(Fragment fragment) {
    String index = getIndex(fragment);
    int id = fragment.getId();

    String tag = fragment.getTag();
    if (tag == null) {
        tag = "null";
    }

    return index + '/' + id + '/' + tag;
}
 
源代码6 项目: cwac-pager   文件: ArrayPagerAdapter.java
@Override
public Object instantiateItem(ViewGroup container, int position) {
  if (currTransaction == null) {
    currTransaction=fm.beginTransaction();
  }

  Fragment fragment=getExistingFragment(position);

  if (fragment != null) {
    if (fragment.getId() == container.getId()) {
      retentionStrategy.attach(fragment, currTransaction);
    }
    else {
      fm.beginTransaction().remove(fragment).commit();
      fm.executePendingTransactions();

      currTransaction.add(container.getId(), fragment,
                          getFragmentTag(position));
    }
  }
  else {
    fragment=createFragment(entries.get(position).getDescriptor());
    currTransaction.add(container.getId(), fragment,
                        getFragmentTag(position));
  }

  if (fragment != currPrimaryItem) {
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
  }

  return fragment;
}
 
源代码7 项目: aMuleRemote   文件: DlQueueActivity.java
@Override
public void onAttachFragment(Fragment fragment) {
    super.onAttachFragment(fragment);
    if (fragment.getId() == R.id.fragment_dlqueue) mDlQueueFragment = (DlQueueFragment) fragment;
}
 
源代码8 项目: weex   文件: FragmentCompatSupportLib.java
@Override
public int getId(Fragment fragment) {
  return fragment.getId();
}
 
源代码9 项目: stetho   文件: FragmentCompatSupportLib.java
@Override
public int getId(Fragment fragment) {
  return fragment.getId();
}