Droidekas
Droidekas

Reputation: 3504

FragmentTransaction `commit()` implementation

I have combed through GrepCode and the downloaded source,but i cannot find a FragmentTransaction class implementation.Can anyone point me to a source?

Upvotes: 2

Views: 474

Answers (1)

tom91136
tom91136

Reputation: 8962

Here is one of the possible implementations.

The signature of the class looks like this:

final class BackStackRecord extends FragmentTransaction implements FragmentManager.BackStackEntry, Runnable {...}

In grep code, you can click on the small arrow pointing down next to the class name to find the derived class.

Just to make this answer complete:

 int commitInternal(boolean allowStateLoss) {
     if (mCommitted) {
         throw new IllegalStateException("commit already called");
     }
     if (FragmentManagerImpl.DEBUG) {
         Log.v(TAG, "Commit: " + this);
         LogWriter logw = new LogWriter(Log.VERBOSE, TAG);
         PrintWriter pw = new FastPrintWriter(logw, false, 1024);
         dump("  ", null, pw, null);
         pw.flush();
     }
     mCommitted = true;
     if (mAddToBackStack) {
         mIndex = mManager.allocBackStackIndex(this);
     } else {
         mIndex = -1;
     }
     mManager.enqueueAction(this, allowStateLoss);
     return mIndex;
 }

commitInternal is called by commit

Upvotes: 4

Related Questions