当前位置: 首页>>代码示例>>Java>>正文


Java ProgressMonitor.STATE_BUSY属性代码示例

本文整理汇总了Java中net.lingala.zip4j.progress.ProgressMonitor.STATE_BUSY属性的典型用法代码示例。如果您正苦于以下问题:Java ProgressMonitor.STATE_BUSY属性的具体用法?Java ProgressMonitor.STATE_BUSY怎么用?Java ProgressMonitor.STATE_BUSY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.lingala.zip4j.progress.ProgressMonitor的用法示例。


在下文中一共展示了ProgressMonitor.STATE_BUSY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractFile

/**
 * Extracts a specific file from the zip file to the destination path.
 * If destination path is invalid, then this method throws an exception.
 * @param fileHeader
 * @param destPath
 * @param unzipParameters
 * @param newFileName
 * @throws ZipException
 */
public void extractFile(FileHeader fileHeader, String destPath, 
		UnzipParameters unzipParameters, String newFileName) throws ZipException {
	
	if (fileHeader == null) {
		throw new ZipException("input file header is null, cannot extract file");
	}
	
	if (!Zip4jUtil.isStringNotNullAndNotEmpty(destPath)) {
		throw new ZipException("destination path is empty or null, cannot extract file");
	}
	
	readZipInfo();
	
	if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) {
		throw new ZipException("invalid operation - Zip4j is in busy state");
	}
	
	fileHeader.extractFile(zipModel, destPath, unzipParameters, newFileName, progressMonitor, runInThread);
	
}
 
开发者ID:joielechong,项目名称:Zip4jAndroid,代码行数:29,代码来源:ZipFile.java

示例2: run

@Override
public void run() {
    if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) {
        progressDialog.setProgress(progressMonitor.getPercentDone());
        handler.postDelayed(this, PROGRESS_INTERVAL);
    } else if (progressMonitor.getResult() == ProgressMonitor.RESULT_SUCCESS) {
        progressDialog.dismiss();
        startActivityForResult(pendingIntent, REQUEST_OPEN_FILE);
        overridePendingTransitionForBuiltInViewer(pendingIntent);
        extracting = null;
    } else if (progressMonitor.getResult() == ProgressMonitor.RESULT_ERROR) {
        progressDialog.dismiss();
        Log.e(TAG, "failed to extract file " + extracting.getFileName(), progressMonitor.getException());
        Toast.makeText(this, "密码错误", Toast.LENGTH_SHORT).show();
        extracting.setPassword(null);
        extracting = null;
    }
}
 
开发者ID:xingrz,项目名称:Finder,代码行数:18,代码来源:ZipFinderActivity.java

示例3: addFiles

/**
 * Adds the list of input files to the zip file. If zip file does not exist, then 
 * this method creates a new zip file. Parameters such as compression type, etc
 * can be set in the input parameters.
 * @param sourceFileList
 * @param parameters
 * @throws ZipException
 */
public void addFiles(ArrayList sourceFileList, ZipParameters parameters) throws ZipException {
	
	checkZipModel();
	
	if (this.zipModel == null) {
		throw new ZipException("internal error: zip model is null");
	}
	
	if (sourceFileList == null) {
		throw new ZipException("input file ArrayList is null, cannot add files");
	}
	
	if (!Zip4jUtil.checkArrayListTypes(sourceFileList, InternalZipConstants.LIST_TYPE_FILE)) {
		throw new ZipException("One or more elements in the input ArrayList is not of type File");
	}
	
	if (parameters == null) {
		throw new ZipException("input parameters are null, cannot add files to zip");
	}
	
	if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) {
		throw new ZipException("invalid operation - Zip4j is in busy state");
	}
	
	if (Zip4jUtil.checkFileExists(file)) {
		if (zipModel.isSplitArchive()) {
			throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");
		}
	}
	
	ZipEngine zipEngine = new ZipEngine(zipModel);
	zipEngine.addFiles(sourceFileList, parameters, progressMonitor, runInThread);
}
 
开发者ID:joielechong,项目名称:Zip4jAndroid,代码行数:41,代码来源:ZipFile.java

示例4: extractAll

/**
 * Extracts all the files in the given zip file to the input destination path.
 * If zip file does not exist or destination path is invalid then an 
 * exception is thrown.
 * @param destPath
 * @param unzipParameters
 * @throws ZipException
 */
public void extractAll(String destPath, 
		UnzipParameters unzipParameters) throws ZipException {
	
	if (!Zip4jUtil.isStringNotNullAndNotEmpty(destPath)) {
		throw new ZipException("output path is null or invalid");
	}
	
	if (!Zip4jUtil.checkOutputFolder(destPath)) {
		throw new ZipException("invalid output path");
	}
	
	if (zipModel == null) {
		readZipInfo();
	}
	
	// Throw an exception if zipModel is still null
	if (zipModel == null) {
		throw new ZipException("Internal error occurred when extracting zip file");
	}
	
	if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) {
		throw new ZipException("invalid operation - Zip4j is in busy state");
	}
	
	Unzip unzip = new Unzip(zipModel);
	unzip.extractAll(unzipParameters, destPath, progressMonitor, runInThread);
	
}
 
开发者ID:blinkboxbooks,项目名称:android-ePub-Library,代码行数:36,代码来源:ZipFile.java

示例5: extractCompressedFile

protected void extractCompressedFile(File destinationDirectory, File compressedFile, Boolean deleteOnSuccess) {
  try {
    Util.log("Extracting %s to %s", compressedFile.getPath(), destinationDirectory.getPath());
    if (!compressedFile.exists()) {
      Util.log("[File not Found] Cannot find %s to extract", compressedFile.getPath());
      return;
    }
    if (!destinationDirectory.exists()) {
      Util.log("Creating directory %s", destinationDirectory.getPath());
      destinationDirectory.mkdirs();
    }
    ZipFile zipFile = new ZipFile(compressedFile);
    zipFile.setRunInThread(true);
    zipFile.extractAll(destinationDirectory.getAbsolutePath());
    ProgressMonitor monitor = zipFile.getProgressMonitor();
    while (monitor.getState() == ProgressMonitor.STATE_BUSY) {
      long totalProgress = monitor.getWorkCompleted() / monitor.getTotalWork();
      stateChanged(String.format("Extracting '%s'...", monitor.getFileName()), totalProgress);
    }
    File metainfDirectory = new File(destinationDirectory, "META-INF");
    if (metainfDirectory.exists()) {
      Util.removeDirectory(metainfDirectory);
    }
    stateChanged(String.format("Extracted '%s'", compressedFile.getPath()), 100f);
    if (monitor.getResult() == ProgressMonitor.RESULT_ERROR) {
      if (monitor.getException() != null) {
        monitor.getException().printStackTrace();
      } else {
        Util.log("An error occurred without any exception while extracting %s", compressedFile.getPath());
      }
    }
    Util.log("Extracted %s to %s", compressedFile.getPath(), destinationDirectory.getPath());
  } catch (ZipException e) {
    Util.log("An error occurred while extracting %s", compressedFile.getPath());
    e.printStackTrace();
  }
}
 
开发者ID:TechnicPack,项目名称:LegacyLauncher,代码行数:37,代码来源:GameUpdater.java

示例6: execute

public void execute(ASPackage aspackage){
	
	aspackage.getManifest();
	aspackage.extract();
	
	ScriptEngine engine = evaluator.getEngine();
	engine.put("Package", aspackage);
	
	ProgressMonitor packageProgress = aspackage.getZippedPackage().getProgressMonitor();
	
	while(packageProgress.getState() == ProgressMonitor.STATE_BUSY){
		
		System.out.println("\b\b\b\b" + packageProgress.getPercentDone() + "%");
		
	}
	
	if(packageProgress.getState() == ProgressMonitor.STATE_READY){
		
		aspackage.init();
		
		String script = aspackage.getMainScript().getAbsolutePath();
		ASCompiler compiler = new ASCompiler(evaluator);
		compiler.cr(script);
		
	}
	
}
 
开发者ID:arjay07,项目名称:AtomScript,代码行数:27,代码来源:ASExecutableHandler.java


注:本文中的net.lingala.zip4j.progress.ProgressMonitor.STATE_BUSY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。