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

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

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

FragmentTransaction.setTransition介绍

暂无

代码示例

代码示例来源:origin: linkedin/shaky-android

/**
 * Attaches this intent's extras to the fragment and transitions to the next fragment.
 *
 * @param fragment Fragment the fragment to swap to
 */
private void changeToFragment(@NonNull Fragment fragment) {
  getSupportFragmentManager().beginTransaction()
    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
    .replace(R.id.shaky_fragment_container, fragment)
    .addToBackStack(null)
    .commit();
}

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

public void setFragment(Fragment fragment) {
  getSupportFragmentManager().beginTransaction()
      .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
      .replace(R.id.content_frame, fragment)
      .addToBackStack(null)
      .commit();
}

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

private <F extends PreferenceFragmentCompat> void setFragment(F fragment, String title)
{
  if (Utils.isLargeScreenDevice(activity)) {
    if (callback != null)
      callback.onDetailTitleChanged(title);
    activity.getSupportFragmentManager().beginTransaction()
        .replace(R.id.detail_fragment_container, fragment)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
        .commit();
  }
}

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

private void showDetailTorrent(String id)
{
  if (Utils.isTwoPane(activity)) {
    FragmentManager fm = getFragmentManager();
    if (fm == null)
      return;
    DetailTorrentFragment detail = DetailTorrentFragment.newInstance(id);
    Fragment fragment = fm.findFragmentById(R.id.detail_torrent_fragmentContainer);
    if (fragment != null && fragment instanceof DetailTorrentFragment) {
      String oldId = ((DetailTorrentFragment) fragment).getTorrentId();
      if (oldId != null && id.equals(oldId))
        return;
    }
    fm.beginTransaction()
        .replace(R.id.detail_torrent_fragmentContainer, detail)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
        .commit();
  } else {
    Intent i = new Intent(activity, DetailTorrentActivity.class);
    i.putExtra(DetailTorrentActivity.TAG_TORRENT_ID, id);
    startActivity(i);
  }
}

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

private void showBlankFragment()
{
  if (Utils.isTwoPane(activity)) {
    FragmentManager fm = getFragmentManager();
    BlankFragment blank = BlankFragment.newInstance(getString(R.string.select_or_add_feed_channel));
    if (fm != null)
      fm.beginTransaction()
        .replace(R.id.feed_items_fragmentContainer, blank)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
        .commitAllowingStateLoss();
  }
}

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

private void showBlankFragment()
{
  if (Utils.isTwoPane(activity)) {
    FragmentManager fm = getFragmentManager();
    if (fm == null)
      return;
    BlankFragment blank = BlankFragment.newInstance(getString(R.string.select_or_add_torrent));
    fm.beginTransaction()
        .replace(R.id.detail_torrent_fragmentContainer, blank)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
        .commitAllowingStateLoss();
  }
}

代码示例来源:origin: WireGuard/wireguard-android

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
  switch (item.getItemId()) {
    case android.R.id.home:
      // The back arrow in the action bar should act the same as the back button.
      onBackPressed();
      return true;
    case R.id.menu_action_edit:
      getSupportFragmentManager().beginTransaction()
          .replace(R.id.detail_container, new TunnelEditorFragment())
          .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
          .addToBackStack(null)
          .commit();
      return true;
    case R.id.menu_action_save:
      // This menu item is handled by the editor fragment.
      return false;
    case R.id.menu_settings:
      startActivity(new Intent(this, SettingsActivity.class));
      return true;
    default:
      return super.onOptionsItemSelected(item);
  }
}

代码示例来源:origin: WireGuard/wireguard-android

@Override
  protected void onSelectedTunnelChanged(@Nullable final Tunnel oldTunnel,
                      @Nullable final Tunnel newTunnel) {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final int backStackEntries = fragmentManager.getBackStackEntryCount();
    if (newTunnel == null) {
      // Clear everything off the back stack (all editors and detail fragments).
      fragmentManager.popBackStackImmediate(0, FragmentManager.POP_BACK_STACK_INCLUSIVE);
      return;
    }
    if (backStackEntries == 2) {
      // Pop the editor off the back stack to reveal the detail fragment. Use the immediate
      // method to avoid the editor picking up the new tunnel while it is still visible.
      fragmentManager.popBackStackImmediate();
    } else if (backStackEntries == 0) {
      // Create and show a new detail fragment.
      fragmentManager.beginTransaction()
          .add(R.id.detail_container, new TunnelDetailFragment())
          .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
          .addToBackStack(null)
          .commit();
    }
  }
}

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

private void showFeedItems(FeedChannel channel)
{
  if (channel == null)
    return;
  if (Utils.isTwoPane(activity)) {
    FragmentManager fm = getFragmentManager();
    if (fm == null)
      return;
    FeedItemsFragment feedItems = FeedItemsFragment.newInstance(channel.getUrl());
    Fragment fragment = fm.findFragmentById(R.id.detail_torrent_fragmentContainer);
    if (fragment != null && fragment instanceof FeedItemsFragment) {
      String oldFeedUrl = ((FeedItemsFragment)fragment).getFeedUrl();
      if (oldFeedUrl != null && channel.getUrl().equals(oldFeedUrl))
        return;
    }
    fm.beginTransaction()
        .replace(R.id.feed_items_fragmentContainer, feedItems)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
        .commit();
  } else {
    Intent i = new Intent(activity, FeedItemsActivity.class);
    i.putExtra(FeedItemsActivity.TAG_FEED_URL, channel.getUrl());
    startActivity(i);
  }
}

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

private <F extends PreferenceFragmentCompat> void setFragment(F fragment, String title)
{
  if (Utils.isLargeScreenDevice(getActivity())) {
    if (callback != null)
      callback.onDetailTitleChanged(title);
    getActivity().getSupportFragmentManager().beginTransaction()
        .replace(R.id.detail_fragment_container, fragment)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
        .commit();
  }
}

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

Fragment f = EventDetailsFragment.newInstance(event);
fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).replace(R.id.event, f).commitAllowingStateLoss();

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

public void openManageServers() {
  dismissFragmentDialog();
  setChannelInfoDrawerVisible(false);
  getSupportFragmentManager().beginTransaction()
      .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
      .replace(R.id.content_frame, ServerListFragment.newInstance())
      .commit();
  mDrawerHelper.setSelectedMenuItem(mDrawerHelper.getManageServersItem());
  mBackReturnToServerList = false;
}

代码示例来源:origin: michael-rapp/AndroidPreferenceActivity

transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.commit();
this.preferenceFragment = fragment;

代码示例来源:origin: michael-rapp/AndroidPreferenceActivity

/**
 * Removes the currently preference fragment, regardless of whether the split screen layout is
 * used, or not.
 */
private void removePreferenceFragmentUnconditionally() {
  if (isPreferenceFragmentShown()) {
    resetTitle();
    hideToolbarNavigationIcon();
    adaptBreadCrumbVisibility();
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.remove(preferenceFragment);
    if (!isSplitScreen()) {
      transaction.show(navigationFragment);
    }
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
    transaction.commit();
    notifyOnPreferenceFragmentHidden(preferenceFragment);
    preferenceFragment = null;
  }
}

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

public ChatFragment openServer(ServerConnectionInfo server, String channel, String messageId,
                boolean fromServerList) {
  dismissFragmentDialog();
  setChannelInfoDrawerVisible(false);
  ChatFragment fragment;
  if (getCurrentFragment() instanceof ChatFragment &&
      ((ChatFragment) getCurrentFragment()).getConnectionInfo() == server) {
    fragment = (ChatFragment) getCurrentFragment();
    fragment.setCurrentChannel(channel, messageId);
    setChannelInfoDrawerVisible(false);
  } else {
    fragment = ChatFragment.newInstance(server, channel, messageId);
    getSupportFragmentManager().beginTransaction()
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
        .replace(R.id.content_frame, fragment)
        .commit();
  }
  mDrawerHelper.setSelectedChannel(server, channel);
  if (fromServerList)
    mBackReturnToServerList = true;
  return fragment;
}

相关文章