API Class Name | Description |
TAVDraftManager | Draft operation manager class. |
/*** Sets the directory for saving drafts* @param storageDir storage directory path*/public static void setDraftStorageDir(String storageDir);
/*** Reads all drafts in the draft storage directory* @return list of drafts sorted in reverse chronological order*/public static List<TAVDraft> readDraftList();
/*** Deletes the specified draft* @param draft draft object to delete* @return whether deletion succeeds*/public static boolean deleteDraft(TAVDraft draft);/*** Deletes all drafts* @return whether deletion succeeds*/public static boolean deleteAllDrafts();
/*** Saves the current editing state as a draft* @param consumer callback that receives the saved draft path*/public abstract void generateDraft(TAVConsumer<String> consumer);
/*** Loads the specified draft* @param draft draft object to load* @param callback loading result callback*/public abstract void loadDraft(TAVDraft draft, DraftLoadingCallback callback);
/*** Commits the current editing state* @param tag tag value* @return whether this commit takes effect*/public abstract boolean commit(String tag);
/*** Checks whether undo is available* @return whether undo is available*/public abstract boolean canUndo();/*** Checks whether redo is available* @return whether redo is available*/public abstract boolean canRedo();
/*** Performs the undo operation* @param callback operation result callback*/public abstract void undo(DraftActionCallback callback);/*** Performs the redo operation* @param callback operation result callback*/public abstract void redo(DraftActionCallback callback);
/*** Sets the draft state listener* @param listener state listener*/public abstract void setDraftStateListener(DraftStateListener listener);
/*** Sets the draft component change observer* @param observer component observer*/public abstract void setDraftComponentObserver(DraftComponentObserver observer);
public interface DraftStateListener {/*** Undo availability state changed* @param canUndo whether undo is available*/void onUndoStateChange(boolean canUndo);/*** Redo availability state changed* @param canRedo whether redo is available*/void onRedoStateChange(boolean canRedo);}
public interface DraftActionCallback {/*** Callback when the operation is completed* @param tag tag value used during commit* @param diffResult change result*/void onCheckoutDraft(String tag, TAVDiffResult diffResult);/*** Callback when the operation fails* @param errorCode error code*/void onError(int errorCode);}
Error Code | Constant Name | Description |
1 | ERROR_NOT_COMMITTED | Draft has not been committed. |
100 | ERROR_SDK_INTERNAL | Internal SDK error. |
101 | ERROR_RESOURCE_NOT_FOUND | Resource does not exist. |
102 | ERROR_RESOURCE_INVALID | Invalid resource format. |
-1 | ERROR_UNKNOWN | Unknown error. |
public interface DraftComponentObserver {/*** Component update callback* @param component updated draft component*/void onComponentUpdate(TAVDraftComponent component);}
// Set the draft storage directoryTAVDraftManager.setDraftStorageDir("/sdcard/drafts/");// Read the draft listList<TAVDraft> drafts = TAVDraftManager.readDraftList();// Load a drafttavEditor.getDraftManager().loadDraft(drafts.get(0), new DraftLoadingCallback() {@Overridepublic void onDraftLoadingFinished(DraftLoadingResult result) {if (result.isSuccess()) {// Load succeeded} else {// Handle the error}}});// Commit the current stateboolean committed = tavEditor.getDraftManager().commit("auto_save");// Set the state listenertavEditor.getDraftManager().setDraftStateListener(new DraftStateListener() {@Overridepublic void onUndoStateChange(boolean canUndo) {// Update the UI state of the undo button}@Overridepublic void onRedoStateChange(boolean canRedo) {// Update the UI state of the redo button}});
피드백