androidx.fragment.app.Fragment.setUserVisibleHint()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中androidx.fragment.app.Fragment.setUserVisibleHint()方法的一些代码示例,展示了Fragment.setUserVisibleHint()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fragment.setUserVisibleHint()方法的具体详情如下:
包路径:androidx.fragment.app.Fragment
类名称:Fragment
方法名:setUserVisibleHint

Fragment.setUserVisibleHint介绍

暂无

代码示例

代码示例来源:origin: offensive-security/nethunter-app

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
  if (isVisibleToUser) {
    //Log.d("ISORNOT", isVisibleToUser + prwText);
    readFileForPreview();
  }
  super.setUserVisibleHint(isVisibleToUser);
}

代码示例来源:origin: cbeyls/fosdem-companion-android

@NonNull
  @Override
  public Object instantiateItem(@NonNull ViewGroup container, int position) {
    // Allow the non-primary fragments to start as soon as they are visible
    Fragment f = (Fragment) super.instantiateItem(container, position);
    f.setUserVisibleHint(true);
    return f;
  }
}

代码示例来源:origin: cbeyls/fosdem-companion-android

@NonNull
  @Override
  public Object instantiateItem(@NonNull ViewGroup container, int position) {
    // Allow the non-primary fragments to start as soon as they are visible
    Fragment f = (Fragment) super.instantiateItem(container, position);
    f.setUserVisibleHint(true);
    return f;
  }
}

代码示例来源:origin: AlexMofer/ProjectX

@Override
public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
  Fragment fragment = (Fragment) object;
  if (fragment != mCurrentPrimaryItem) {
    if (mCurrentPrimaryItem != null) {
      mCurrentPrimaryItem.setMenuVisibility(false);
      mCurrentPrimaryItem.setUserVisibleHint(false);
    }
    fragment.setMenuVisibility(true);
    fragment.setUserVisibleHint(true);
    mCurrentPrimaryItem = fragment;
  }
}

代码示例来源:origin: proninyaroslav/libretorrent

@Override
public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object)
{
  Fragment f = (Fragment)object;
  if (f == currentPrimaryItem)
    return;
  if (currentPrimaryItem != null) {
    currentPrimaryItem.setMenuVisibility(false);
    currentPrimaryItem.setUserVisibleHint(false);
  }
  f.setMenuVisibility(true);
  f.setUserVisibleHint(true);
  currentPrimaryItem = f;
}

代码示例来源:origin: luhaoaimama1/zone-sdk

/**
 * 与ViewPager一起使用,ViewPager的FragmentPagerAdapter会调用的是setUserVisibleHint
 * 注意:如果页面过多 则会从新 new 因为默认缓存是一个页面
 * setUserVisibleHint->onCreateView
 *
 * @param isVisibleToUser 是否显示出来了
 */
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
  super.setUserVisibleHint(isVisibleToUser);
  mlastIsVisibleToUser = isVisibleToUser;
  if (!setUserVisibleHintUsed) {
    setUserVisibleHintUsed = true;
  }
  if (inflateView != null) {
    setUserVisibleCompat(isVisibleToUser);
  }
}

代码示例来源:origin: AlexMofer/ProjectX

fragment.setUserVisibleHint(false);

代码示例来源:origin: proninyaroslav/libretorrent

@NonNull
@Override
public Object instantiateItem(ViewGroup container, int position)
{
  if (position < 0 || position >= getCount())
    return null;
  if (curTransaction == null)
    curTransaction = fm.beginTransaction();
  String name = makeFragmentName(container.getId(), position);
  Fragment f = fm.findFragmentByTag(name);
  if (f != null) {
    curTransaction.attach(f);
  } else {
    f = getItem(position);
    curTransaction.add(container.getId(), f,
        makeFragmentName(container.getId(), position));
  }
  if (f != currentPrimaryItem) {
    f.setMenuVisibility(false);
    f.setUserVisibleHint(false);
  }
  registeredFragments.put(position, f);
  return f;
}

代码示例来源:origin: MCMrARM/revolution-irc

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
  super.setUserVisibleHint(isVisibleToUser);
  if (isVisibleToUser && getParentFragment() != null)
    updateParentCurrentChannel();
  if (isVisibleToUser && getParentFragment() != null)
    ((ChatFragment) getParentFragment()).getSendMessageHelper()
        .setCurrentChannel(mChannelName);
  if (!isVisibleToUser) {
    hideMessagesActionMenu();
  }
  if (mConnection != null && mChannelName != null) {
    mConnection.getNotificationManager().getChannelManager(mChannelName, true).setOpened(getContext(), isVisibleToUser);
    if (isVisibleToUser) {
      updateUnreadCounter();
      mConnection.getNotificationManager().addUnreadMessageCountCallback(this);
    } else {
      mConnection.getNotificationManager().removeUnreadMessageCountCallback(this);
    }
  }
  if (mConnection != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    if (isVisibleToUser)
      IRCChooserTargetService.setChannel(mConnection.getUUID(), mChannelName);
    else
      IRCChooserTargetService.unsetChannel(mConnection.getUUID(), mChannelName);
  }
}

相关文章