Example usage for android.app BackStackRecord getName

List of usage examples for android.app BackStackRecord getName

Introduction

In this page you can find the example usage for android.app BackStackRecord getName.

Prototype

public String getName() 

Source Link

Usage

From source file:android.app.FragmentManager.java

boolean popBackStackState(Handler handler, String name, int id, int flags) {
    if (mBackStack == null) {
        return false;
    }//from   ww w .  ja v  a  2  s  .co  m
    if (name == null && id < 0 && (flags & POP_BACK_STACK_INCLUSIVE) == 0) {
        int last = mBackStack.size() - 1;
        if (last < 0) {
            return false;
        }
        final BackStackRecord bss = mBackStack.remove(last);
        bss.popFromBackStack(true);
        reportBackStackChanged();
    } else {
        int index = -1;
        if (name != null || id >= 0) {
            // If a name or ID is specified, look for that place in
            // the stack.
            index = mBackStack.size() - 1;
            while (index >= 0) {
                BackStackRecord bss = mBackStack.get(index);
                if (name != null && name.equals(bss.getName())) {
                    break;
                }
                if (id >= 0 && id == bss.mIndex) {
                    break;
                }
                index--;
            }
            if (index < 0) {
                return false;
            }
            if ((flags & POP_BACK_STACK_INCLUSIVE) != 0) {
                index--;
                // Consume all following entries that match.
                while (index >= 0) {
                    BackStackRecord bss = mBackStack.get(index);
                    if ((name != null && name.equals(bss.getName())) || (id >= 0 && id == bss.mIndex)) {
                        index--;
                        continue;
                    }
                    break;
                }
            }
        }
        if (index == mBackStack.size() - 1) {
            return false;
        }
        final ArrayList<BackStackRecord> states = new ArrayList<BackStackRecord>();
        for (int i = mBackStack.size() - 1; i > index; i--) {
            states.add(mBackStack.remove(i));
        }
        final int LAST = states.size() - 1;
        for (int i = 0; i <= LAST; i++) {
            if (DEBUG)
                Log.v(TAG, "Popping back stack state: " + states.get(i));
            states.get(i).popFromBackStack(i == LAST);
        }
        reportBackStackChanged();
    }
    return true;
}

From source file:android.app.FragmentManager.java

boolean popBackStackState(Handler handler, String name, int id, int flags) {
    if (mBackStack == null) {
        return false;
    }// w w w . j  a v  a 2s . com
    if (name == null && id < 0 && (flags & POP_BACK_STACK_INCLUSIVE) == 0) {
        int last = mBackStack.size() - 1;
        if (last < 0) {
            return false;
        }
        final BackStackRecord bss = mBackStack.remove(last);
        SparseArray<Fragment> firstOutFragments = new SparseArray<Fragment>();
        SparseArray<Fragment> lastInFragments = new SparseArray<Fragment>();
        bss.calculateBackFragments(firstOutFragments, lastInFragments);
        bss.popFromBackStack(true, null, firstOutFragments, lastInFragments);
        reportBackStackChanged();
    } else {
        int index = -1;
        if (name != null || id >= 0) {
            // If a name or ID is specified, look for that place in
            // the stack.
            index = mBackStack.size() - 1;
            while (index >= 0) {
                BackStackRecord bss = mBackStack.get(index);
                if (name != null && name.equals(bss.getName())) {
                    break;
                }
                if (id >= 0 && id == bss.mIndex) {
                    break;
                }
                index--;
            }
            if (index < 0) {
                return false;
            }
            if ((flags & POP_BACK_STACK_INCLUSIVE) != 0) {
                index--;
                // Consume all following entries that match.
                while (index >= 0) {
                    BackStackRecord bss = mBackStack.get(index);
                    if ((name != null && name.equals(bss.getName())) || (id >= 0 && id == bss.mIndex)) {
                        index--;
                        continue;
                    }
                    break;
                }
            }
        }
        if (index == mBackStack.size() - 1) {
            return false;
        }
        final ArrayList<BackStackRecord> states = new ArrayList<BackStackRecord>();
        for (int i = mBackStack.size() - 1; i > index; i--) {
            states.add(mBackStack.remove(i));
        }
        final int LAST = states.size() - 1;
        SparseArray<Fragment> firstOutFragments = new SparseArray<Fragment>();
        SparseArray<Fragment> lastInFragments = new SparseArray<Fragment>();
        for (int i = 0; i <= LAST; i++) {
            states.get(i).calculateBackFragments(firstOutFragments, lastInFragments);
        }
        BackStackRecord.TransitionState state = null;
        for (int i = 0; i <= LAST; i++) {
            if (DEBUG)
                Log.v(TAG, "Popping back stack state: " + states.get(i));
            state = states.get(i).popFromBackStack(i == LAST, state, firstOutFragments, lastInFragments);
        }
        reportBackStackChanged();
    }
    return true;
}