本文整理汇总了Java中android.support.v4.app.FragmentManager.BackStackEntry方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.BackStackEntry方法的具体用法?Java FragmentManager.BackStackEntry怎么用?Java FragmentManager.BackStackEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.BackStackEntry方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBackPressed
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
if (backButtonDisabled) {
Log.w(TAG, "Going back at this step is not possible.");
return;
}
final int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount();
if (backStackEntryCount == 0) {
super.onBackPressed();
} else {
FragmentManager.BackStackEntry backEntry = getSupportFragmentManager().getBackStackEntryAt(backStackEntryCount - 1);
String tag = backEntry.getName();
if (PaymentMethodSelectionFragment.class.getName().equals(tag) || LoadingScreenFragment.class.getName().equals(tag)) {
final Intent cancellationIntent = new Intent(Constants.PaymentRequest.PAYMENT_REQUEST_CANCELLED_INTENT);
LocalBroadcastManager.getInstance(this).sendBroadcast(cancellationIntent);
finish();
} else if (backStackEntryCount == 1) {
finish();
} else {
getSupportFragmentManager().popBackStackImmediate();
}
}
}
示例2: configureToolbar
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void configureToolbar() {
super.configureToolbar();
int stackEntryCount = getChildFragmentManager().getBackStackEntryCount();
if (stackEntryCount > 0) {
FragmentManager.BackStackEntry stackEntry = getChildFragmentManager().getBackStackEntryAt(stackEntryCount - 1);
//Get the name that was supplied to FragmentTransaction.addToBackStack(String) when creating this entry
String fragmentTab = stackEntry.getName();
BasicToolbarFragment fragmentByTag = (BasicToolbarFragment) getChildFragmentManager().findFragmentByTag(fragmentTab);
if (fragmentByTag != null) {
fragmentByTag.setupToolbar();
}
} else {
setupToolbar();
}
}
示例3: navigateBack
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void navigateBack() {
activity.hideKeyboard();
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager.getBackStackEntryCount() > 0) {
Log.i(TAG, "Popping back stack");
int fragmentPosition = fragmentManager.getBackStackEntryCount() - 1;
FragmentManager.BackStackEntry backEntry = fragmentManager.getBackStackEntryAt(fragmentPosition);
String fragmentName = backEntry.getName();
fragmentManager.popBackStackImmediate(fragmentName, FragmentManager.POP_BACK_STACK_INCLUSIVE);
navigationManager.removeFragmentsFromStack(fragmentPosition);
} else {
Log.i(TAG, "Nothing on back stack");
if (activity.isTaskRoot()) {
if (doublePressToExit) {
activity.finish();
return;
}
doublePressToExit = true;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
doublePressToExit = false;
}
}, TIME_INTERVAL);
} else {
activity.finish();
}
}
}
示例4: getStackNum
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 获取堆栈淋面的
*
* @return
*/
public void getStackNum() {
int num = getSupportFragmentManager().getBackStackEntryCount();
String numString = "++++++++++++++++++++++++++++++++++Fragment回退栈数量:" + num;
LogUtil.d("Fragment", numString);
for (int i = 0; i < num; i++) {
FragmentManager.BackStackEntry backstatck = getSupportFragmentManager().getBackStackEntryAt(i);
// Log.d("Fragment=name", backstatck.getName());
}
}
示例5: onCreate
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
int backStackEntryCount = fragmentManager.getBackStackEntryCount();
for (int i = backStackEntryCount - 1; i >= 0; i--) {
FragmentManager.BackStackEntry entry = fragmentManager.getBackStackEntryAt(i);
if (getClass().getSimpleName().equals(entry.getName())) {
mBackStackIndex = i;
break;
}
}
}
}
示例6: onClick
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void onClick(View v) {
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
switch (v.getId()) {
case R.id.fragment_exit_yes:
MainActivity.syncDataFromExitScreen = true;
fragment = new DataFragment();
bundle = getActivity().getIntent().getExtras();
fragment.setArguments(bundle);
fragmentTransaction = getActivity().getSupportFragmentManager()
.beginTransaction();
fragmentTransaction.replace(R.id.container_fragment, fragment).addToBackStack(ValueHelper.DATA_FRAGMENT).commit();
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentManager.BackStackEntry first = manager.getBackStackEntryAt(0);
manager.popBackStack(first.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
break;
case R.id.fragment_exit_no:
getActivity().finish();
break;
}
}