Example usage for android.app Fragment dump

List of usage examples for android.app Fragment dump

Introduction

In this page you can find the example usage for android.app Fragment dump.

Prototype

public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) 

Source Link

Document

Print the Fragments's state into the given stream.

Usage

From source file:android.app.FragmentManager.java

@Override
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
    String innerPrefix = prefix + "    ";

    int N;/*from w  w  w.java2s. com*/
    if (mActive != null) {
        N = mActive.size();
        if (N > 0) {
            writer.print(prefix);
            writer.print("Active Fragments in ");
            writer.print(Integer.toHexString(System.identityHashCode(this)));
            writer.println(":");
            for (int i = 0; i < N; i++) {
                Fragment f = mActive.get(i);
                writer.print(prefix);
                writer.print("  #");
                writer.print(i);
                writer.print(": ");
                writer.println(f);
                if (f != null) {
                    f.dump(innerPrefix, fd, writer, args);
                }
            }
        }
    }

    if (mAdded != null) {
        N = mAdded.size();
        if (N > 0) {
            writer.print(prefix);
            writer.println("Added Fragments:");
            for (int i = 0; i < N; i++) {
                Fragment f = mAdded.get(i);
                writer.print(prefix);
                writer.print("  #");
                writer.print(i);
                writer.print(": ");
                writer.println(f.toString());
            }
        }
    }

    if (mCreatedMenus != null) {
        N = mCreatedMenus.size();
        if (N > 0) {
            writer.print(prefix);
            writer.println("Fragments Created Menus:");
            for (int i = 0; i < N; i++) {
                Fragment f = mCreatedMenus.get(i);
                writer.print(prefix);
                writer.print("  #");
                writer.print(i);
                writer.print(": ");
                writer.println(f.toString());
            }
        }
    }

    if (mBackStack != null) {
        N = mBackStack.size();
        if (N > 0) {
            writer.print(prefix);
            writer.println("Back Stack:");
            for (int i = 0; i < N; i++) {
                BackStackRecord bs = mBackStack.get(i);
                writer.print(prefix);
                writer.print("  #");
                writer.print(i);
                writer.print(": ");
                writer.println(bs.toString());
                bs.dump(innerPrefix, fd, writer, args);
            }
        }
    }

    synchronized (this) {
        if (mBackStackIndices != null) {
            N = mBackStackIndices.size();
            if (N > 0) {
                writer.print(prefix);
                writer.println("Back Stack Indices:");
                for (int i = 0; i < N; i++) {
                    BackStackRecord bs = mBackStackIndices.get(i);
                    writer.print(prefix);
                    writer.print("  #");
                    writer.print(i);
                    writer.print(": ");
                    writer.println(bs);
                }
            }
        }

        if (mAvailBackStackIndices != null && mAvailBackStackIndices.size() > 0) {
            writer.print(prefix);
            writer.print("mAvailBackStackIndices: ");
            writer.println(Arrays.toString(mAvailBackStackIndices.toArray()));
        }
    }

    if (mPendingActions != null) {
        N = mPendingActions.size();
        if (N > 0) {
            writer.print(prefix);
            writer.println("Pending Actions:");
            for (int i = 0; i < N; i++) {
                Runnable r = mPendingActions.get(i);
                writer.print(prefix);
                writer.print("  #");
                writer.print(i);
                writer.print(": ");
                writer.println(r);
            }
        }
    }

    writer.print(prefix);
    writer.println("FragmentManager misc state:");
    writer.print(prefix);
    writer.print("  mActivity=");
    writer.println(mActivity);
    writer.print(prefix);
    writer.print("  mContainer=");
    writer.println(mContainer);
    if (mParent != null) {
        writer.print(prefix);
        writer.print("  mParent=");
        writer.println(mParent);
    }
    writer.print(prefix);
    writer.print("  mCurState=");
    writer.print(mCurState);
    writer.print(" mStateSaved=");
    writer.print(mStateSaved);
    writer.print(" mDestroyed=");
    writer.println(mDestroyed);
    if (mNeedMenuInvalidate) {
        writer.print(prefix);
        writer.print("  mNeedMenuInvalidate=");
        writer.println(mNeedMenuInvalidate);
    }
    if (mNoTransactionsBecause != null) {
        writer.print(prefix);
        writer.print("  mNoTransactionsBecause=");
        writer.println(mNoTransactionsBecause);
    }
    if (mAvailIndices != null && mAvailIndices.size() > 0) {
        writer.print(prefix);
        writer.print("  mAvailIndices: ");
        writer.println(Arrays.toString(mAvailIndices.toArray()));
    }
}