use of android.support.v4.app.FragmentManager.BackStackEntry in project HoloEverywhere by Prototik.
the class FragmentBreadCrumbs method updateCrumbs.
void updateCrumbs() {
FragmentManager fm = mActivity.getSupportFragmentManager();
int numEntries = fm.getBackStackEntryCount();
int numPreEntries = getPreEntryCount();
int numViews = mContainer.getChildCount();
for (int i = 0; i < numEntries + numPreEntries; i++) {
BackStackEntry bse = i < numPreEntries ? getPreEntry(i) : fm.getBackStackEntryAt(i - numPreEntries);
if (i < numViews) {
View v = mContainer.getChildAt(i);
Object tag = v.getTag();
if (tag != bse) {
for (int j = i; j < numViews; j++) {
mContainer.removeViewAt(i);
}
numViews = i;
}
}
if (i >= numViews) {
final View item = mInflater.inflate(R.layout.fragment_bread_crumb_item, this, false);
final TextView text = (TextView) item.findViewById(R.id.title);
text.setText(bse.getBreadCrumbTitle());
text.setTag(bse);
if (i == 0) {
item.findViewById(R.id.left_icon).setVisibility(View.GONE);
}
mContainer.addView(item);
text.setOnClickListener(mOnClickListener);
}
}
int viewI = numEntries + numPreEntries;
numViews = mContainer.getChildCount();
while (numViews > viewI) {
mContainer.removeViewAt(numViews - 1);
numViews--;
}
for (int i = 0; i < numViews; i++) {
final View child = mContainer.getChildAt(i);
child.findViewById(R.id.title).setEnabled(i < numViews - 1);
if (mMaxVisible > 0) {
child.setVisibility(i < numViews - mMaxVisible ? View.GONE : View.VISIBLE);
final View leftIcon = child.findViewById(R.id.left_icon);
leftIcon.setVisibility(i > numViews - mMaxVisible && i != 0 ? View.VISIBLE : View.GONE);
}
}
}
use of android.support.v4.app.FragmentManager.BackStackEntry in project aFileChooser by iPaulPro.
the class FileChooserActivity method onBackStackChanged.
@Override
public void onBackStackChanged() {
int count = mFragmentManager.getBackStackEntryCount();
if (count > 0) {
BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
mPath = fragment.getName();
} else {
mPath = EXTERNAL_BASE_PATH;
}
setTitle(mPath);
if (HAS_ACTIONBAR)
invalidateOptionsMenu();
}
use of android.support.v4.app.FragmentManager.BackStackEntry in project HanselAndGretel by JakeWharton.
the class FragmentBreadCrumbs method updateCrumbs.
void updateCrumbs() {
FragmentManager fm = mActivity.getSupportFragmentManager();
int numEntries = fm.getBackStackEntryCount();
int numPreEntries = getPreEntryCount();
int numViews = mContainer.getChildCount();
for (int i = 0; i < numEntries + numPreEntries; i++) {
BackStackEntry bse = i < numPreEntries ? getPreEntry(i) : fm.getBackStackEntryAt(i - numPreEntries);
if (i < numViews) {
View v = mContainer.getChildAt(i);
Object tag = v.getTag();
if (tag != bse) {
for (int j = i; j < numViews; j++) {
mContainer.removeViewAt(i);
}
numViews = i;
}
}
if (i >= numViews) {
final View item = mInflater.inflate(R.layout.hag__fragment_bread_crumb_item, this, false);
final TextView text = (TextView) item.findViewById(android.R.id.title);
text.setText(bse.getBreadCrumbTitle());
text.setTag(bse);
if (i == 0) {
item.findViewById(android.R.id.icon).setVisibility(View.GONE);
}
mContainer.addView(item);
text.setOnClickListener(mOnClickListener);
}
}
int viewI = numEntries + numPreEntries;
numViews = mContainer.getChildCount();
while (numViews > viewI) {
mContainer.removeViewAt(numViews - 1);
numViews--;
}
// Adjust the visibility and availability of the bread crumbs and divider
for (int i = 0; i < numViews; i++) {
final View child = mContainer.getChildAt(i);
// Disable the last one
child.findViewById(android.R.id.title).setEnabled(i < numViews - 1);
if (mMaxVisible > 0) {
// Make only the last mMaxVisible crumbs visible
child.setVisibility(i < numViews - mMaxVisible ? View.GONE : View.VISIBLE);
final View leftIcon = child.findViewById(android.R.id.icon);
// Remove the divider for all but the last mMaxVisible - 1
leftIcon.setVisibility(i > numViews - mMaxVisible && i != 0 ? View.VISIBLE : View.GONE);
}
}
}
use of android.support.v4.app.FragmentManager.BackStackEntry in project routerkeygenAndroid by routerkeygen.
the class FileChooserActivity method onBackStackChanged.
@Override
public void onBackStackChanged() {
int count = mFragmentManager.getBackStackEntryCount();
if (count > 0) {
BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
mPath = fragment.getName();
} else {
mPath = EXTERNAL_BASE_PATH;
}
setTitle(mPath);
if (HAS_ACTIONBAR)
invalidateOptionsMenu();
}
use of android.support.v4.app.FragmentManager.BackStackEntry in project carat by amplab.
the class MainActivity method onBackPressed.
/**
* Avoid displaying a white screen when the back button is pressed in the summary fragment.
* When we are in the summary fragment, since there is only one fragment in the backstack,
* the fragment manager will fail to pop another fragment from the backstack,
* so only the framelayout (the parent/host widget for fragments (in our activity's layout)) is shown.
* We need to check the number of fragments present in the backstack, and act accordingly
*/
@Override
public void onBackPressed() {
FragmentManager manager = getSupportFragmentManager();
// If we will pop a top level screen, show drawer indicator again
int stackTop = manager.getBackStackEntryCount() - 1;
BackStackEntry entry = manager.getBackStackEntryAt(stackTop);
String name = entry.getName();
String[] titles = CaratApplication.getTitles();
boolean found = false;
for (String t : titles) {
if (!found)
found = t.equals(name);
}
if (found) {
// Restore menu
mDrawerToggle.setDrawerIndicatorEnabled(true);
}
if (stackTop > 0) {
// If there are back-stack entries, replace the fragment (go to the fragment)
manager.popBackStack();
} else
finish();
}
Aggregations