Example #1
0
  public static void requestPersitentFileQuota(
      double size, final RequestPersitentFileQuotaListener listener) {

    WebkitStorageInfo.requestQuota(
        RequestFileSystem.PERSISTENT,
        size,
        new RequestQuotaCallback() {
          @Override
          public void requestQuotaCallback(final double grantedBytes) {

            if (grantedBytes == 0) {
              listener.onError("zero quota", null);
              return;
            }

            RequestFileSystem.requestFileSystem(
                RequestFileSystem.PERSISTENT,
                grantedBytes,
                new FileSystemCallback() {
                  @Override
                  public void fileSystemCallback(FileSystem fileSystem) {
                    listener.onAccepted(fileSystem, grantedBytes);
                  }
                },
                new FileErrorCallback() {
                  @Override
                  public void fileErrorCallback(FileError fileError) {
                    listener.onError("onRequestFileSystem", fileError);
                  }
                });
          }
        });
  }
Example #2
0
  public static void getFileSystem(boolean persitent, final GetFileSystemListener listener) {
    int type = RequestFileSystem.TEMPORARY;
    if (persitent) {
      type = RequestFileSystem.PERSISTENT;
    }
    // use 1 for detect not granted
    WebkitStorageInfo.requestQuota(
        type,
        1,
        new RequestQuotaCallback() {
          @Override
          public void requestQuotaCallback(final double grantedBytes) {

            if (grantedBytes == 0) {
              listener.onError("zero quota", null);
              return;
            }

            RequestFileSystem.requestFileSystem(
                RequestFileSystem.PERSISTENT,
                grantedBytes,
                new FileSystemCallback() {
                  @Override
                  public void fileSystemCallback(FileSystem fileSystem) {
                    listener.onGetFileSystem(fileSystem);
                  }
                },
                new FileErrorCallback() {
                  @Override
                  public void fileErrorCallback(FileError fileError) {
                    listener.onError("onRequestFileSystem", fileError);
                  }
                });
          }
        });
  }
Example #3
0
 public static void getFileQuataAndUsage(boolean persistent, FileQuataAndUsageListener listener) {
   WebkitStorageInfo.queryUsageAndQuota(
       persistent ? RequestFileSystem.PERSISTENT : RequestFileSystem.TEMPORARY, listener);
 }