當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentManager.getBackStackEntryCount方法代碼示例

本文整理匯總了Java中android.app.FragmentManager.getBackStackEntryCount方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentManager.getBackStackEntryCount方法的具體用法?Java FragmentManager.getBackStackEntryCount怎麽用?Java FragmentManager.getBackStackEntryCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.FragmentManager的用法示例。


在下文中一共展示了FragmentManager.getBackStackEntryCount方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: goBack

import android.app.FragmentManager; //導入方法依賴的package包/類
@Override
public void goBack() {
    FragmentManager fragmentManager = getFragmentManager();
    if (mDisplayMode == DisplayMode.MESSAGE_VIEW) {
        showMessageList();
    } else if (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStack();
    } else if (mMessageListFragment.isManualSearch()) {
        finish();
    } else if (!mSingleFolderMode) {
        onAccounts();
    } else {
        onShowFolderList();
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:16,代碼來源:MessageList.java

示例2: changeFragment

import android.app.FragmentManager; //導入方法依賴的package包/類
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	FragmentManager fm = getFragmentManager();
	FragmentTransaction transaction = fm.beginTransaction();

	/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
		if (newFragmentType.isRightOf(currentFragment)) {
			transaction.setCustomAnimations(R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left,
					R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right);
		} else {
			transaction.setCustomAnimations(R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right,
					R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left);
		}
	}*/

	if (newFragmentType != FragmentsAvailable.DIALER
			&& newFragmentType != FragmentsAvailable.CONTACTS_LIST
			&& newFragmentType != FragmentsAvailable.CHAT_LIST
			&& newFragmentType != FragmentsAvailable.HISTORY_LIST) {
		transaction.addToBackStack(newFragmentType.toString());
	} else {
		while (fm.getBackStackEntryCount() > 0) {
			fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
		}
	}

	transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
	transaction.commitAllowingStateLoss();
	fm.executePendingTransactions();

	currentFragment = newFragmentType;
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:36,代碼來源:LinphoneActivity.java

示例3: onBackPressed

import android.app.FragmentManager; //導入方法依賴的package包/類
@Override
public void onBackPressed() {
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        // 백스택이 존재할 떄까지
        if (fm.getBackStackEntryCount() > 0)
        {
            fm.popBackStack();
            ft.commit();
        }
        // 백스택이 없는 경우
        else
        {
            super.onBackPressed();
        }
    }
}
 
開發者ID:JoMingyu,項目名稱:Daejeon-People,代碼行數:22,代碼來源:Main.java

示例4: onBackPressed

import android.app.FragmentManager; //導入方法依賴的package包/類
@Override
public void onBackPressed() {
    FragmentManager fm = getFragmentManager();
    if (fm.getBackStackEntryCount() > 0) {
        fm.popBackStack();
    } else {
        new AlertDialog.Builder(this)
                .setTitle("Exit")
                .setMessage("Are you sure you want to exit?")
                .setNegativeButton(android.R.string.no, null)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).create().show();
    }
}
 
開發者ID:BranchMetrics,項目名稱:Branch-Monster-Factory-Example-Android-Instant-Apps,代碼行數:19,代碼來源:MonsterViewerActivity.java

示例5: onOptionsItemSelected

import android.app.FragmentManager; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            FragmentManager fm = getFragmentManager();
            if (fm.getBackStackEntryCount() > 0) {
                fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
            } else {
                finish();
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:BaseActivity.java

示例6: onBackPressed

import android.app.FragmentManager; //導入方法依賴的package包/類
@Override
public void onBackPressed() {
    FragmentManager fm = getFragmentManager();

    if (fm.getBackStackEntryCount() > 0) {
        fm.popBackStack();
        mCurrentPath = FileUtils.cutLastSegmentOfPath(mCurrentPath);
        updateTitle();
    } else {
        setResult(RESULT_CANCELED);
        super.onBackPressed();
    }
}
 
開發者ID:qq1198,項目名稱:mtoolbox,代碼行數:14,代碼來源:FilePickerActivity.java

示例7: replaceFragment

import android.app.FragmentManager; //導入方法依賴的package包/類
/**
 *
 *
 * @param position is the new fragment
 */
private void replaceFragment(int position) {
    FragmentManager fragmentManager = getFragmentManager();
    Fragment fragment = null;
    String fragment_tag = "";

    //Delete not initialized state
    if (position == -1) {
        position = 0;
    }

    switch (position) {
        case POSITION_MAIN:
            fragment_tag = MainFragment.class.getName();
            fragment = fragmentManager.findFragmentByTag(fragment_tag);
            if (fragment == null) {
                fragment = new MainFragment();
            }
            break;
        case POSITION_MAP:
            fragment_tag = MyMapFragment.class.getName();
            fragment = fragmentManager.findFragmentByTag(fragment_tag);
            if (fragment == null) {
                fragment = new MyMapFragment();
            }
            break;
        case POSITION_PREDICTION:
            fragment_tag = PredictionFragment.class.getName();
            fragment = fragmentManager.findFragmentByTag(fragment_tag);
            if (fragment == null) {
                fragment = new PredictionFragment();
            }
            break;
        case POSITION_PROTOCOLO:
            fragment_tag = ProtocolosFragment.class.getName();
            fragment = fragmentManager.findFragmentByTag(fragment_tag);
            if (fragment == null) {
                fragment = new ProtocolosFragment();
            }
            break;
        case POSITION_LAST_AVISO:
            DownloadFilesUtils.downloadPdf(this,this, DownloadFilesUtils.EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE_BOLETIN_DIARIO);
            return;
        case POSITION_INFO:
            fragment_tag = InfoFragment.class.getName();
            fragment = fragmentManager.findFragmentByTag(fragment_tag);
            if (fragment == null) {
                fragment = new InfoFragment();
            }
            break;
        case POSITION_FEEDBACK:
            fragment_tag = FeedbackFragment.class.getName();
            fragment = fragmentManager.findFragmentByTag(fragment_tag);
            if (fragment == null) {
                fragment = new FeedbackFragment();
            }
            break;
    }

    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.content_frame, fragment, fragment_tag);
    if (position != 0 && fragmentManager.getBackStackEntryCount() == 0) {
        transaction.addToBackStack(null);
    }
    transaction.commit();
    mCurrentDrawerItem = position;

}
 
開發者ID:medialab-prado,項目名稱:puremadrid,代碼行數:73,代碼來源:MainActivity.java

示例8: onBackPressed

import android.app.FragmentManager; //導入方法依賴的package包/類
@Override
public void onBackPressed() {
    if (isSearchViewExpanded()) {
        hideSearchView();
    } else {
        final FragmentManager fm = getFragmentManager();
        mBackStackEntryPopped = fm.popBackStackImmediate();
        final int entryCnt = fm.getBackStackEntryCount();

        if (entryCnt > 0) {
            final FragmentManager.BackStackEntry entry = fm.getBackStackEntryAt(entryCnt - 1);
            final Fragment fragment = fm.findFragmentByTag(entry.getName());

            if (fragment instanceof CurrentFeedFragment) {
                mBottomNavigationView.setSelectedItemId(R.id.action_view_current_feed);
            } else if (fragment instanceof FeedSubscriptionsFragment) {
                mBottomNavigationView.setSelectedItemId(R.id.action_view_feed_subscriptions);
            } else if (fragment instanceof SavedEntriesFragment) {
                mBottomNavigationView.setSelectedItemId(R.id.action_view_saved_entries);
            } else {
                mBackStackEntryPopped = fm.popBackStackImmediate();
                mBottomNavigationView.setSelectedItemId(R.id.action_view_feed_subscriptions);
            }

            mBackStackEntryPopped = false;
        } else {
            super.onBackPressed();
        }
    }
}
 
開發者ID:Applications-Development,項目名稱:SimpleRssReader,代碼行數:31,代碼來源:MainActivity.java

示例9: clearBackStack

import android.app.FragmentManager; //導入方法依賴的package包/類
private void clearBackStack(FragmentManager fragmentManager ){
    while (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStackImmediate();
    }
}
 
開發者ID:medialab-prado,項目名稱:puremadrid,代碼行數:6,代碼來源:MainActivity.java


注:本文中的android.app.FragmentManager.getBackStackEntryCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。