FileDocCategorySizeDatePackage
UndoOperation.javaAPI DocAndroid 5.1 API3466Thu Mar 12 22:22:10 GMT 2015android.content

UndoOperation

public abstract class UndoOperation extends Object implements android.os.Parcelable
A single undoable operation. You must subclass this to implement the state and behavior for your operation. Instances of this class are placed and managed in an {@link UndoManager}.
hide

Fields Summary
UndoOwner
mOwner
Constructors Summary
public UndoOperation(UndoOwner owner)
Create a new instance of the operation.

param
owner Who owns the data being modified by this undo state; must be returned by {@link UndoManager#getOwner(String, Object) UndoManager.getOwner}.

        mOwner = owner;
    
protected UndoOperation(android.os.Parcel src, ClassLoader loader)
Construct from a Parcel.

    
Methods Summary
public booleanallowMerge()
Return true if this operation can be merged with a later operation. The default implementation always returns true.

        return true;
    
public abstract voidcommit()
Called when this undo state is being committed to the undo stack. The implementation should perform the initial edits and save any state that may be needed to undo them.

public intdescribeContents()

        return 0;
    
public UndoOwnergetOwner()
Owning object as given to {@link #UndoOperation(UndoOwner)}.

        return mOwner;
    
public DATAgetOwnerData()
Synonym for {@link #getOwner()}.{@link android.content.UndoOwner#getData()}.

        return (DATA)mOwner.getData();
    
public booleanhasData()
Return true if this operation actually contains modification data. The default implementation always returns true. If you return false, the operation will be dropped when the final undo state is being built.

        return true;
    
public booleanmatchOwner(UndoOwner owner)
Return true if this undo operation is a member of the given owner. The default implementation is owner == getOwner(). You can override this to provide more sophisticated dependencies between owners.

        return owner == getOwner();
    
public abstract voidredo()
Called when this undo state is being pushed back from the transient redo stack to the main undo stack. The implementation should re-apply the edits that were previously removed by {@link #undo}.

public abstract voidundo()
Called when this undo state is being popped off the undo stack (in to the temporary redo stack). The implementation should remove the original edits and thus restore the target object to its prior value.