JEB output

// Decompiled by JEB v0.9.0 alpha

package android.support.v4.app;

import android.util.Log;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;

final class BackStackRecord extends FragmentTransaction implements BackStackEntry, Runnable {
    final class Op {
        Op() {
            super();
        }
    }

    static final int OP_ADD = 1;
    static final int OP_ATTACH = 7;
    static final int OP_DETACH = 6;
    static final int OP_HIDE = 4;
    static final int OP_NULL = 0;
    static final int OP_REMOVE = 3;
    static final int OP_REPLACE = 2;
    static final int OP_SHOW = 5;
    static final String TAG = "BackStackEntry";
    boolean mAddToBackStack;
    boolean mAllowAddToBackStack;
    int mBreadCrumbShortTitleRes;
    CharSequence mBreadCrumbShortTitleText;
    int mBreadCrumbTitleRes;
    CharSequence mBreadCrumbTitleText;
    boolean mCommitted;
    int mEnterAnim;
    int mExitAnim;
    Op mHead;
    int mIndex;
    final FragmentManagerImpl mManager;
    String mName;
    int mNumOp;
    int mPopEnterAnim;
    int mPopExitAnim;
    Op mTail;
    int mTransition;
    int mTransitionStyle;

    public BackStackRecord(FragmentManagerImpl arg2) {
        super();
        this.mAllowAddToBackStack = true;
        this.mManager = arg2;
    }

    public FragmentTransaction add(int arg3, Fragment arg4) {
        this.doAddOp(arg3, arg4, 0, 1);
        return this;
    }

    public FragmentTransaction add(int arg2, Fragment arg3, String arg4) {
        this.doAddOp(arg2, arg3, arg4, 1);
        return this;
    }

    public FragmentTransaction add(Fragment arg3, String arg4) {
        this.doAddOp(0, arg3, arg4, 1);
        return this;
    }

    void addOp(Op arg2) {
        if(this.mHead == 0) {
            this.mTail = arg2;
            this.mHead = arg2;
        }
        else {
            arg2.prev = this.mTail;
            this.mTail.next = arg2;
            this.mTail = arg2;
        }

        arg2.enterAnim = this.mEnterAnim;
        arg2.exitAnim = this.mExitAnim;
        arg2.popEnterAnim = this.mPopEnterAnim;
        arg2.popExitAnim = this.mPopExitAnim;
        ++this.mNumOp;
    }

    public FragmentTransaction addToBackStack(String arg3) {
        if(!this.mAllowAddToBackStack) {
            throw new IllegalStateException("This FragmentTransaction is not allowed to be added to the back stack.");
        }

        this.mAddToBackStack = true;
        this.mName = arg3;
        return this;
    }

    public FragmentTransaction attach(Fragment arg3) {
        Op v0 = new Op();
        v0.cmd = 7;
        v0.fragment = arg3;
        this.addOp(v0);
        return this;
    }

    void bumpBackStackNesting(int arg7) {
        if(this.mAddToBackStack) {
            if(FragmentManagerImpl.DEBUG != false) {
                StringBuilder v4 = new StringBuilder();
                v4 = v4.append("Bump nesting in ");
                v4 = v4.append(((Object)this));
                v4 = v4.append(" by ");
                v4 = v4.append(arg7);
                String v4_1 = v4.toString();
                Log.v("BackStackEntry", v4_1);
            }

            Op v1 = this.mHead;
            while(v1 != 0) {
                if(v1.fragment != 0) {
                    v1.fragment.mBackStackNesting += arg7;
                    if(FragmentManagerImpl.DEBUG != false) {
                        v4 = new StringBuilder();
                        v4 = v4.append("Bump nesting of ");
                        v4 = v4.append(v1.fragment);
                        v4 = v4.append(" to ");
                        v4 = v4.append(v1.fragment.mBackStackNesting);
                        v4_1 = v4.toString();
                        Log.v("BackStackEntry", v4_1);
                    }

                }

                if(v1.removed != 0) {
                    int v0 = v1.removed.size() - 1;
                    while(v0 >= 0) {
                        Object v2 = v1.removed.get(v0);
                        ((Fragment)v2).mBackStackNesting += arg7;
                        if(FragmentManagerImpl.DEBUG != false) {
                            v4 = new StringBuilder();
                            v4 = v4.append("Bump nesting of ");
                            v4 = v4.append(v2);
                            v4 = v4.append(" to ");
                            v4 = v4.append(((Fragment)v2).mBackStackNesting);
                            v4_1 = v4.toString();
                            Log.v("BackStackEntry", v4_1);
                        }

                        --v0;
                    }

                }

                v1 = v1.next;
            }

        }

    }

    public int commit() {
        return this.commitInternal(false);
    }

    public int commitAllowingStateLoss() {
        return this.commitInternal(true);
    }

    int commitInternal(boolean arg4) {
        if(this.mCommitted) {
            throw new IllegalStateException("commit already called");
        }

        if(FragmentManagerImpl.DEBUG) {
            StringBuilder v1 = new StringBuilder();
            v1 = v1.append("Commit: ");
            v1 = v1.append(((Object)this));
            String v1_1 = v1.toString();
            Log.v("BackStackEntry", v1_1);
        }

        this.mCommitted = true;
        if(this.mAddToBackStack) {
            this.mIndex = this.mManager.allocBackStackIndex(this);
        }
        else {
            this.mIndex = 1;
        }

        this.mManager.enqueueAction(((Runnable)this), arg4);
        return this.mIndex;
    }

    public FragmentTransaction detach(Fragment arg3) {
        Op v0 = new Op();
        v0.cmd = 6;
        v0.fragment = arg3;
        this.addOp(v0);
        return this;
    }

    public FragmentTransaction disallowAddToBackStack() {
        if(this.mAddToBackStack) {
            throw new IllegalStateException("This transaction is already being added to the back stack");
        }

        this.mAllowAddToBackStack = false;
        return this;
    }

    private void doAddOp(int arg5, Fragment arg6, String arg7, int arg8) {
        arg6.mFragmentManager = this.mManager;
        if(arg7 != 0) {
            if(arg6.mTag != 0 && arg7.equals(arg6.mTag) == false) {
                StringBuilder v2 = new StringBuilder();
                v2 = v2.append("Can\'t change tag of fragment ");
                v2 = v2.append(((Object)arg6));
                v2 = v2.append(": was ");
                v2 = v2.append(arg6.mTag);
                v2 = v2.append(" now ");
                v2 = v2.append(arg7);
                String v2_1 = v2.toString();
                throw new IllegalStateException(v2_1);
            }

            arg6.mTag = arg7;
        }

        if(arg5 != 0) {
            if(arg6.mFragmentId != 0 && arg6.mFragmentId != arg5) {
                v2 = new StringBuilder();
                v2 = v2.append("Can\'t change container ID of fragment ");
                v2 = v2.append(((Object)arg6));
                v2 = v2.append(": was ");
                v2 = v2.append(arg6.mFragmentId);
                v2 = v2.append(" now ");
                v2 = v2.append(arg5);
                v2_1 = v2.toString();
                throw new IllegalStateException(v2_1);
            }

            arg6.mFragmentId = arg5;
            arg6.mContainerId = arg5;
        }

        Op v0 = new Op();
        v0.cmd = arg8;
        v0.fragment = arg6;
        this.addOp(v0);
    }

    public void dump(String arg7, FileDescriptor arg8, PrintWriter arg9, String[] arg10) {
        arg9.print(arg7);
        arg9.print("mName=");
        arg9.print(this.mName);
        arg9.print(" mIndex=");
        arg9.print(this.mIndex);
        arg9.print(" mCommitted=");
        arg9.println(this.mCommitted);
        if(this.mTransition != 0) {
            arg9.print(arg7);
            arg9.print("mTransition=#");
            String v4 = Integer.toHexString(this.mTransition);
            arg9.print(v4);
            arg9.print(" mTransitionStyle=#");
            v4 = Integer.toHexString(this.mTransitionStyle);
            arg9.println(v4);
        }

        if(this.mEnterAnim != 0 || this.mExitAnim != 0) {
            arg9.print(arg7);
            arg9.print("mEnterAnim=#");
            v4 = Integer.toHexString(this.mEnterAnim);
            arg9.print(v4);
            arg9.print(" mExitAnim=#");
            v4 = Integer.toHexString(this.mExitAnim);
            arg9.println(v4);
        }

        if(this.mPopEnterAnim != 0 || this.mPopExitAnim != 0) {
            arg9.print(arg7);
            arg9.print("mPopEnterAnim=#");
            v4 = Integer.toHexString(this.mPopEnterAnim);
            arg9.print(v4);
            arg9.print(" mPopExitAnim=#");
            v4 = Integer.toHexString(this.mPopExitAnim);
            arg9.println(v4);
        }

        if(this.mBreadCrumbTitleRes != 0 || this.mBreadCrumbTitleText != 0) {
            arg9.print(arg7);
            arg9.print("mBreadCrumbTitleRes=#");
            v4 = Integer.toHexString(this.mBreadCrumbTitleRes);
            arg9.print(v4);
            arg9.print(" mBreadCrumbTitleText=");
            arg9.println(this.mBreadCrumbTitleText);
        }

        if(this.mBreadCrumbShortTitleRes != 0 || this.mBreadCrumbShortTitleText != 0) {
            arg9.print(arg7);
            arg9.print("mBreadCrumbShortTitleRes=#");
            v4 = Integer.toHexString(this.mBreadCrumbShortTitleRes);
            arg9.print(v4);
            arg9.print(" mBreadCrumbShortTitleText=");
            arg9.println(this.mBreadCrumbShortTitleText);
        }

        if(this.mHead != 0) {
            arg9.print(arg7);
            arg9.println("Operations:");
            StringBuilder v4_1 = new StringBuilder();
            v4_1 = v4_1.append(arg7);
            v4_1 = v4_1.append("    ");
            String v1 = v4_1.toString();
            Op v3 = this.mHead;
            while(v3 != 0) {
                arg9.print(arg7);
                arg9.print("  Op #");
                arg9.print(0);
                arg9.println(":");
                arg9.print(v1);
                arg9.print("cmd=");
                arg9.print(v3.cmd);
                arg9.print(" fragment=");
                arg9.println(v3.fragment);
                if(v3.enterAnim != 0 || v3.exitAnim != 0) {
                    arg9.print(arg7);
                    arg9.print("enterAnim=#");
                    v4 = Integer.toHexString(v3.enterAnim);
                    arg9.print(v4);
                    arg9.print(" exitAnim=#");
                    v4 = Integer.toHexString(v3.exitAnim);
                    arg9.println(v4);
                }

                if(v3.popEnterAnim != 0 || v3.popExitAnim != 0) {
                    arg9.print(arg7);
                    arg9.print("popEnterAnim=#");
                    v4 = Integer.toHexString(v3.popEnterAnim);
                    arg9.print(v4);
                    arg9.print(" popExitAnim=#");
                    v4 = Integer.toHexString(v3.popExitAnim);
                    arg9.println(v4);
                }

                if(v3.removed != 0 && v3.removed.size() > 0) {
                    int v0 = 0;
                    while(v0 < v3.removed.size()) {
                        arg9.print(v1);
                        if(v3.removed.size() == 1) {
                            arg9.print("Removed: ");
                        }
                        else {
                            arg9.println("Removed:");
                            arg9.print(v1);
                            arg9.print("  #");
                            arg9.print(0);
                            arg9.print(": ");
                        }

                        Object v4_2 = v3.removed.get(v0);
                        arg9.println(v4_2);
                        ++v0;
                    }

                }

                v3 = v3.next;
            }

        }

    }

    public CharSequence getBreadCrumbShortTitle() {
        if(this.mBreadCrumbShortTitleRes != 0) {
            CharSequence v0 = this.mManager.mActivity.getText(this.mBreadCrumbShortTitleRes);
        }
        else {
            v0 = this.mBreadCrumbShortTitleText;
        }

        return v0;
    }

    public int getBreadCrumbShortTitleRes() {
        return this.mBreadCrumbShortTitleRes;
    }

    public CharSequence getBreadCrumbTitle() {
        if(this.mBreadCrumbTitleRes != 0) {
            CharSequence v0 = this.mManager.mActivity.getText(this.mBreadCrumbTitleRes);
        }
        else {
            v0 = this.mBreadCrumbTitleText;
        }

        return v0;
    }

    public int getBreadCrumbTitleRes() {
        return this.mBreadCrumbTitleRes;
    }

    public int getId() {
        return this.mIndex;
    }

    public String getName() {
        return this.mName;
    }

    public int getTransition() {
        return this.mTransition;
    }

    public int getTransitionStyle() {
        return this.mTransitionStyle;
    }

    public FragmentTransaction hide(Fragment arg3) {
        Op v0 = new Op();
        v0.cmd = 4;
        v0.fragment = arg3;
        this.addOp(v0);
        return this;
    }

    public boolean isAddToBackStackAllowed() {
        return this.mAllowAddToBackStack;
    }

    public boolean isEmpty() {
        if(this.mNumOp == 0) {
            boolean v0 = true;
        }
        else {
            v0 = false;
        }

        return v0;
    }

    public void popFromBackStack(boolean arg11) {
        int v9 = 1;
        if(FragmentManagerImpl.DEBUG) {
            StringBuilder v5 = new StringBuilder();
            v5 = v5.append("popFromBackStack: ");
            v5 = v5.append(((Object)this));
            String v5_1 = v5.toString();
            Log.v("BackStackEntry", v5_1);
        }

        this.bumpBackStackNesting(v9);
        Op v3 = this.mTail;
        while(v3 != 0) {
            switch(v3.cmd) {
                case 0x1: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.popExitAnim;
                    v4 = this.mManager;
                    v5_2 = FragmentManagerImpl.reverseTransit(this.mTransition);
                    v4.removeFragment(v0, v5_2, this.mTransitionStyle);
                    break;
                }
                case 0x2: {
                    v0 = v3.fragment;
                    if(v0 != 0) {
                        v0.mNextAnim = v3.popExitAnim;
                        FragmentManagerImpl v4 = this.mManager;
                        int v5_2 = FragmentManagerImpl.reverseTransit(this.mTransition);
                        v4.removeFragment(v0, v5_2, this.mTransitionStyle);
                    }

                    if(v3.removed == 0) {
                        goto label_32;
                    }

                    int v1 = 0;
                    while(v1 < v3.removed.size()) {
                        Object v2 = v3.removed.get(v1);
                        ((Fragment)v2).mNextAnim = v3.popEnterAnim;
                        this.mManager.addFragment(((Fragment)v2), false);
                        ++v1;
                    }

                }
                case 0x3: {
                    Fragment v0 = v3.fragment;
                    v0.mNextAnim = v3.popEnterAnim;
                    this.mManager.addFragment(v0, false);
                    break;
                }
                case 0x4: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.popEnterAnim;
                    v4 = this.mManager;
                    v5_2 = FragmentManagerImpl.reverseTransit(this.mTransition);
                    v4.showFragment(v0, v5_2, this.mTransitionStyle);
                    break;
                }
                case 0x5: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.popExitAnim;
                    v4 = this.mManager;
                    v5_2 = FragmentManagerImpl.reverseTransit(this.mTransition);
                    v4.hideFragment(v0, v5_2, this.mTransitionStyle);
                    break;
                }
                case 0x6: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.popEnterAnim;
                    v4 = this.mManager;
                    v5_2 = FragmentManagerImpl.reverseTransit(this.mTransition);
                    v4.attachFragment(v0, v5_2, this.mTransitionStyle);
                    break;
                }
                case 0x7: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.popEnterAnim;
                    v4 = this.mManager;
                    v5_2 = FragmentManagerImpl.reverseTransit(this.mTransition);
                    v4.detachFragment(v0, v5_2, this.mTransitionStyle);
                    break;
                }
                default: {
                    v5 = new StringBuilder();
                    v5 = v5.append("Unknown cmd: ");
                    v5 = v5.append(v3.cmd);
                    v5_1 = v5.toString();
                    throw new IllegalArgumentException(v5_1);
                }
            }

        label_32:
            v3 = v3.prev;
        }

        if(arg11) {
            v4 = this.mManager;
            v5_2 = this.mManager.mCurState;
            int v6 = FragmentManagerImpl.reverseTransit(this.mTransition);
            v4.moveToState(v5_2, v6, this.mTransitionStyle, true);
        }

        if(this.mIndex >= 0) {
            this.mManager.freeBackStackIndex(this.mIndex);
            this.mIndex = v9;
        }

    }

    public FragmentTransaction remove(Fragment arg3) {
        Op v0 = new Op();
        v0.cmd = 3;
        v0.fragment = arg3;
        this.addOp(v0);
        return this;
    }

    public FragmentTransaction replace(int arg2, Fragment arg3) {
        return this.replace(arg2, arg3, 0);
    }

    public FragmentTransaction replace(int arg3, Fragment arg4, String arg5) {
        if(arg3 == 0) {
            throw new IllegalArgumentException("Must use non-zero containerViewId");
        }

        this.doAddOp(arg3, arg4, arg5, 2);
        return this;
    }

    public void run() {
        if(FragmentManagerImpl.DEBUG) {
            StringBuilder v5 = new StringBuilder();
            v5 = v5.append("Run: ");
            v5 = v5.append(((Object)this));
            String v5_1 = v5.toString();
            Log.v("BackStackEntry", v5_1);
        }

        if(this.mAddToBackStack) {
            if(this.mIndex >= 0) {
                goto label_18;
            }

            goto label_15;
        }

    label_18:
        this.bumpBackStackNesting(1);
        Op v3 = this.mHead;
        while(v3 != 0) {
            switch(v3.cmd) {
                case 0x1: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.enterAnim;
                    this.mManager.addFragment(v0, false);
                    break;
                }
                case 0x2: {
                    v0 = v3.fragment;
                    if(this.mManager.mAdded != 0) {
                        int v1 = 0;
                        while(v1 < this.mManager.mAdded.size()) {
                            Object v2 = this.mManager.mAdded.get(v1);
                            if(FragmentManagerImpl.DEBUG != false) {
                                v5 = new StringBuilder();
                                v5 = v5.append("OP_REPLACE: adding=");
                                v5 = v5.append(((Object)v0));
                                v5 = v5.append(" old=");
                                v5 = v5.append(v2);
                                v5_1 = v5.toString();
                                Log.v("BackStackEntry", v5_1);
                            }

                            if(v0 == 0 || ((Fragment)v2).mContainerId == v0.mContainerId) {
                                if((((Fragment)v2)) == v0) {
                                    Object v0_1 = 0;
                                    v3.fragment = v0;
                                }
                                else {
                                    if(v3.removed == 0) {
                                        v3.removed = new ArrayList();
                                    }

                                    v3.removed.add(v2);
                                    ((Fragment)v2).mNextAnim = v3.exitAnim;
                                    if(this.mAddToBackStack != false) {
                                        ++((Fragment)v2).mBackStackNesting;
                                        if(FragmentManagerImpl.DEBUG != false) {
                                            v5 = new StringBuilder();
                                            v5 = v5.append("Bump nesting of ");
                                            v5 = v5.append(v2);
                                            v5 = v5.append(" to ");
                                            v5 = v5.append(((Fragment)v2).mBackStackNesting);
                                            v5_1 = v5.toString();
                                            Log.v("BackStackEntry", v5_1);
                                        }

                                    }

                                    this.mManager.removeFragment(((Fragment)v2), this.mTransition, this.mTransitionStyle);
                                }

                            }

                            ++v1;
                        }

                    }

                    if(v0 == 0) {
                        goto label_36;
                    }

                    v0.mNextAnim = v3.enterAnim;
                    this.mManager.addFragment(v0, false);
                    break;
                }
                case 0x3: {
                    Fragment v0 = v3.fragment;
                    v0.mNextAnim = v3.exitAnim;
                    this.mManager.removeFragment(v0, this.mTransition, this.mTransitionStyle);
                    break;
                }
                case 0x4: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.exitAnim;
                    this.mManager.hideFragment(v0, this.mTransition, this.mTransitionStyle);
                    break;
                }
                case 0x5: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.enterAnim;
                    this.mManager.showFragment(v0, this.mTransition, this.mTransitionStyle);
                    break;
                }
                case 0x6: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.exitAnim;
                    this.mManager.detachFragment(v0, this.mTransition, this.mTransitionStyle);
                    break;
                }
                case 0x7: {
                    v0 = v3.fragment;
                    v0.mNextAnim = v3.enterAnim;
                    this.mManager.attachFragment(v0, this.mTransition, this.mTransitionStyle);
                    break;
                }
                default: {
                    v5 = new StringBuilder();
                    v5 = v5.append("Unknown cmd: ");
                    v5 = v5.append(v3.cmd);
                    v5_1 = v5.toString();
                    throw new IllegalArgumentException(v5_1);
                }
            }

        label_36:
            v3 = v3.next;
        }

        this.mManager.moveToState(this.mManager.mCurState, this.mTransition, this.mTransitionStyle, true);
        if(this.mAddToBackStack) {
            this.mManager.addBackStackState(this);
        }

        return;
    label_15:
        throw new IllegalStateException("addToBackStack() called after commit()");
    }

    public FragmentTransaction setBreadCrumbShortTitle(int arg2) {
        this.mBreadCrumbShortTitleRes = arg2;
        this.mBreadCrumbShortTitleText = 0;
        return this;
    }

    public FragmentTransaction setBreadCrumbShortTitle(CharSequence arg2) {
        this.mBreadCrumbShortTitleRes = 0;
        this.mBreadCrumbShortTitleText = arg2;
        return this;
    }

    public FragmentTransaction setBreadCrumbTitle(int arg2) {
        this.mBreadCrumbTitleRes = arg2;
        this.mBreadCrumbTitleText = 0;
        return this;
    }

    public FragmentTransaction setBreadCrumbTitle(CharSequence arg2) {
        this.mBreadCrumbTitleRes = 0;
        this.mBreadCrumbTitleText = arg2;
        return this;
    }

    public FragmentTransaction setCustomAnimations(int arg2, int arg3) {
        return this.setCustomAnimations(arg2, arg3, 0, 0);
    }

    public FragmentTransaction setCustomAnimations(int arg1, int arg2, int arg3, int arg4) {
        this.mEnterAnim = arg1;
        this.mExitAnim = arg2;
        this.mPopEnterAnim = arg3;
        this.mPopExitAnim = arg4;
        return this;
    }

    public FragmentTransaction setTransition(int arg1) {
        this.mTransition = arg1;
        return this;
    }

    public FragmentTransaction setTransitionStyle(int arg1) {
        this.mTransitionStyle = arg1;
        return this;
    }

    public FragmentTransaction show(Fragment arg3) {
        Op v0 = new Op();
        v0.cmd = 5;
        v0.fragment = arg3;
        this.addOp(v0);
        return this;
    }
}