Skip to content

Commit

Permalink
complete javadoc for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
lingol committed Jun 22, 2021
1 parent 34dd114 commit aee3e24
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 46 deletions.
219 changes: 186 additions & 33 deletions Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.tencent.mmkv;

/**
* Inter-process content change notification.
* Triggered by any method call, such as getXXX() or setXXX() or {@link MMKV#checkContentChangedByOuterProcess()}.
*/
public interface MMKVContentChangeNotification {

// content change notification of other process
// trigger by getXXX() or setXXX() or checkContentChangedByOuterProcess()
/**
* Inter-process content change notification.
* Triggered by any method call, such as getXXX() or setXXX() or {@link MMKV#checkContentChangedByOuterProcess()}.
* @param mmapID The unique ID of the changed MMKV instance.
*/
void onContentChangedByOuterProcess(String mmapID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
* A helper class for MMKV based on Anonymous Shared Memory. {@link MMKV#mmkvWithAshmemID}
*/
public class MMKVContentProvider extends ContentProvider {

static protected final String KEY = "KEY";
Expand Down
32 changes: 25 additions & 7 deletions Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,37 @@

package com.tencent.mmkv;

// callback is called on the operating thread of the MMKV instance
/**
* Callback handler for MMKV.
* Callback is called on the operating thread of the MMKV instance.
*/
public interface MMKVHandler {
// by default MMKV will discard all data on crc32-check failure
// return `OnErrorRecover` to recover any data on the file
/**
* By default MMKV will discard all data on crc32-check failure. {@link MMKVRecoverStrategic#OnErrorDiscard}
* @param mmapID The unique ID of the MMKV instance.
* @return Return {@link MMKVRecoverStrategic#OnErrorRecover} to recover any data on the file.
*/
MMKVRecoverStrategic onMMKVCRCCheckFail(String mmapID);

// by default MMKV will discard all data on file length mismatch
// return `OnErrorRecover` to recover any data on the file
/**
* By default MMKV will discard all data on file length mismatch. {@link MMKVRecoverStrategic#OnErrorDiscard}
* @param mmapID The unique ID of the MMKV instance.
* @return Return {@link MMKVRecoverStrategic#OnErrorRecover} to recover any data on the file.
*/
MMKVRecoverStrategic onMMKVFileLengthError(String mmapID);

// return false if you don't want log redirecting
/**
* @return Return False if you don't want log redirecting.
*/
boolean wantLogRedirecting();

// log redirecting
/**
* Log Redirecting.
* @param level The level of this log.
* @param file The file name of this log.
* @param line The line of code of this log.
* @param function The function name of this log.
* @param message The content of this log.
*/
void mmkvLog(MMKVLogLevel level, String file, int line, String function, String message);
}
29 changes: 26 additions & 3 deletions Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKVLogLevel.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
package com.tencent.mmkv;

/**
* The levels of MMKV log.
*/
public enum MMKVLogLevel {
LevelDebug, // not available for release/production build
LevelInfo, // default level
/**
* Debug level. Not available for release/production build.
*/
LevelDebug,

/**
* Info level. The default level.
*/
LevelInfo,

/**
* Warning level.
*/
LevelWarning,

/**
* Error level.
*/
LevelError,
LevelNone // special level used to disable all log messages

/**
* Special level for disabling all logging.
* It's highly NOT suggested to turn off logging. Makes it hard to diagnose online/production bugs.
*/
LevelNone
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@

package com.tencent.mmkv;

/**
* The recover strategic of MMKV on errors. {@link MMKV#registerHandler}
*/
public enum MMKVRecoverStrategic {
/**
* The default strategic is to discard everything on errors.
*/
OnErrorDiscard,

/**
* The recover strategic will try to recover as much data as possible.
*/
OnErrorRecover,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.tencent.mmkv;

/**
* A native memory wrapper, whose underlying memory can be passed to another JNI method directly.
* Avoiding unnecessary JNI boxing & unboxing.
* Must be destroy manually {@link MMKV#destroyNativeBuffer}.
*/
public final class NativeBuffer {
public long pointer;
public int size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import android.os.Parcelable;
import java.io.IOException;

/**
* A helper class for MMKV based on Anonymous Shared Memory. {@link MMKV#mmkvWithAshmemID}
*/
public final class ParcelableMMKV implements Parcelable {
private final String mmapID;
private int ashmemFD = -1;
Expand Down

0 comments on commit aee3e24

Please sign in to comment.