forked from fanruan/design
pengda
4 years ago
4 changed files with 70 additions and 62 deletions
@ -0,0 +1,50 @@
|
||||
package com.fr.design.update.actions; |
||||
|
||||
import com.fr.decision.update.SyncExecutor; |
||||
import com.fr.decision.update.info.UpdateCallBack; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import java.util.concurrent.ExecutionException; |
||||
import javax.swing.SwingWorker; |
||||
|
||||
public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> { |
||||
private UpdateCallBack callBack; |
||||
private String buildNo; |
||||
|
||||
public SyncFileProcess(UpdateCallBack callBack,String buildNo) { |
||||
this.callBack = callBack; |
||||
this.buildNo = buildNo; |
||||
} |
||||
|
||||
@Override |
||||
protected Boolean doInBackground() throws Exception { |
||||
return SyncExecutor.getInstance().execute(callBack,buildNo); |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
boolean success = false; |
||||
try { |
||||
success = get(); |
||||
} catch (InterruptedException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
Thread.currentThread().interrupt(); |
||||
} catch (ExecutionException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
if (success) { |
||||
onDownloadSuccess(); |
||||
} else { |
||||
onDownloadFailed(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 下载成功 |
||||
*/ |
||||
public abstract void onDownloadSuccess(); |
||||
|
||||
/** |
||||
* 下载失败 |
||||
*/ |
||||
public abstract void onDownloadFailed(); |
||||
} |
Loading…
Reference in new issue