diff options
author | Trumeet <liangyuteng12345@gmail.com> | 2017-09-15 20:28:56 +0800 |
---|---|---|
committer | Trumeet <liangyuteng12345@gmail.com> | 2017-09-15 20:28:56 +0800 |
commit | 6e3f75a9c55de4e9b2c731ec70ced08901aa7862 (patch) | |
tree | 238714a3de3919320b7448bfd60750d895cc8f95 /library/src/main/java/top/trumeet/redirectstorage/wrapper/AbstractWrapper.java | |
parent | b8c9ff8b8d04a1107405bbcd6539eec05f8a1b4e (diff) | |
download | RedirectStorage-6e3f75a9c55de4e9b2c731ec70ced08901aa7862.tar RedirectStorage-6e3f75a9c55de4e9b2c731ec70ced08901aa7862.tar.gz RedirectStorage-6e3f75a9c55de4e9b2c731ec70ced08901aa7862.tar.bz2 RedirectStorage-6e3f75a9c55de4e9b2c731ec70ced08901aa7862.zip |
refactor: use AbstractWrapper
Diffstat (limited to 'library/src/main/java/top/trumeet/redirectstorage/wrapper/AbstractWrapper.java')
-rw-r--r-- | library/src/main/java/top/trumeet/redirectstorage/wrapper/AbstractWrapper.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/library/src/main/java/top/trumeet/redirectstorage/wrapper/AbstractWrapper.java b/library/src/main/java/top/trumeet/redirectstorage/wrapper/AbstractWrapper.java new file mode 100644 index 0000000..2a3d2ce --- /dev/null +++ b/library/src/main/java/top/trumeet/redirectstorage/wrapper/AbstractWrapper.java @@ -0,0 +1,58 @@ +package top.trumeet.redirectstorage.wrapper; + +import android.os.Build; +import android.os.Environment; + +import java.io.File; + +/** + * Created by Trumeet on 2017/9/15. + */ + +public abstract class AbstractWrapper extends Environment.UserEnvironment { + public static AbstractWrapper getWrapper (Environment.UserEnvironment base, + String customPath, + Integer userId) { + checkNonNull(base); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + checkNonNull(userId); + return new UserEnvironmentWrapperMarshmallow(base, + userId, customPath); + } + return null; + } + + private static void checkNonNull (Object object) { + if (object == null) + throw new NullPointerException(); + } + + final Environment.UserEnvironment mBase; + String mCustomPath; + boolean mEnable = true; + + public AbstractWrapper(Environment.UserEnvironment ue, + int userId, String customPath) { + super(userId); + mBase = ue; + mCustomPath = customPath; + } + + public boolean isEnable() { + return mEnable; + } + + public void setEnable(boolean mEnable) { + this.mEnable = mEnable; + } + + public String getCustomPath() { + return mCustomPath; + } + + public void setCustomPath(String mCustomPath) { + this.mCustomPath = mCustomPath; + } + + public abstract File getRealExternalStorageDirectory (); +} |