Skip to content

Commit 36ff97e

Browse files
committed
change named of some fields
1 parent 7e7d6bd commit 36ff97e

File tree

15 files changed

+141
-159
lines changed

15 files changed

+141
-159
lines changed

app/src/main/java/org/lzh/framework/updateplugin/update/NotificationDownloadCreator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ private static class NotificationCB implements DownloadCallback {
4141
.setSmallIcon(activity.getApplicationInfo().icon)
4242
.setAutoCancel(false)
4343
.setContentText("下载中...")
44+
.setContentText("UpdatePlugin")
4445
.build();
4546
id = Math.abs(UUID.randomUUID().hashCode());
4647
}

updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/UpdateBuilder.java

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@
4141
* 2. 通过{@link #create(UpdateConfig)}指定使用某个特殊的更新配置。<br>
4242
*
4343
* <p>此Builder中的所有配置项,均在{@link UpdateConfig}中有对应的相同方法名的配置函数。此两者的关系为:
44-
* 在更新流程中当Builder中未设置对应的配置,将会使用在{@link UpdateConfig}更新配置中所提供的默认配置进行使用
44+
* 在更新流程中当Builder中未设置对应的配置,将会使用在{@link UpdateConfig}更新配置中所提供的默认配置。
4545
*
46-
* <p>正常启动:调用{@link #check()}进行启动。
46+
* <p>正常启动:调用{@link #check()}
47+
*
48+
* <p>后台启动:调用{@link #checkWithDaemon(long)}
4749
*
4850
* @author haoge
4951
*/
@@ -54,21 +56,22 @@ public class UpdateBuilder {
5456
private Class<? extends DownloadWorker> downloadWorker;
5557
private CheckEntity entity;
5658
private UpdateStrategy updateStrategy;
57-
private CheckNotifier updateDialogCreator;
58-
private InstallNotifier installDialogCreator;
59-
private DownloadNotifier downloadDialogCreator;
60-
private UpdateParser jsonParser;
59+
private CheckNotifier checkNotifier;
60+
private InstallNotifier installNotifier;
61+
private DownloadNotifier downloadNotifier;
62+
private UpdateParser updateParser;
6163
private FileCreator fileCreator;
6264
private UpdateChecker updateChecker;
6365
private FileChecker fileChecker;
6466
private InstallStrategy installStrategy;
6567
private UpdateConfig config;
6668

6769
private RetryCallback retryCallback;
68-
private CallbackDelegate callbackDelegate = new CallbackDelegate();
70+
private CallbackDelegate callbackDelegate;
6971

7072
private UpdateBuilder(UpdateConfig config) {
7173
this.config = config;
74+
callbackDelegate = new CallbackDelegate();
7275
callbackDelegate.setCheckDelegate(config.getCheckCallback());
7376
callbackDelegate.setDownloadDelegate(config.getDownloadCallback());
7477
}
@@ -98,8 +101,8 @@ public void check() {
98101
}
99102

100103
/**
101-
* 启动后台更新任务。此任务特性:当检查更新失败或者当前无更新。则等待指定时间之后,自动重启更新任务。
102-
* @param retryTime 重试时间间隔
104+
* 启动后台更新任务。特性:当检查更新失败或者当前无更新时。等待指定时间之后,自动重启更新任务。
105+
* @param retryTime 重启时间间隔
103106
*/
104107
public void checkWithDaemon(long retryTime) {
105108
RetryCallback retryCallback = getRetryCallback();
@@ -157,8 +160,8 @@ public UpdateBuilder setCheckCallback(CheckCallback callback) {
157160
return this;
158161
}
159162

160-
public UpdateBuilder setUpdateParser(UpdateParser jsonParser) {
161-
this.jsonParser = jsonParser;
163+
public UpdateBuilder setUpdateParser(UpdateParser updateParser) {
164+
this.updateParser = updateParser;
162165
return this;
163166
}
164167

@@ -167,18 +170,18 @@ public UpdateBuilder setFileCreator(FileCreator fileCreator) {
167170
return this;
168171
}
169172

170-
public UpdateBuilder setDownloadNotifier(DownloadNotifier downloadDialogCreator) {
171-
this.downloadDialogCreator = downloadDialogCreator;
173+
public UpdateBuilder setDownloadNotifier(DownloadNotifier downloadNotifier) {
174+
this.downloadNotifier = downloadNotifier;
172175
return this;
173176
}
174177

175-
public UpdateBuilder setInstallNotifier(InstallNotifier installDialogCreator) {
176-
this.installDialogCreator = installDialogCreator;
178+
public UpdateBuilder setInstallNotifier(InstallNotifier installNotifier) {
179+
this.installNotifier = installNotifier;
177180
return this;
178181
}
179182

180-
public UpdateBuilder setCheckNotifier(CheckNotifier updateDialogCreator) {
181-
this.updateDialogCreator = updateDialogCreator;
183+
public UpdateBuilder setCheckNotifier(CheckNotifier checkNotifier) {
184+
this.checkNotifier = checkNotifier;
182185
return this;
183186
}
184187

@@ -218,32 +221,32 @@ public FileChecker getFileChecker() {
218221
return fileChecker != null ? fileChecker : config.getFileChecker();
219222
}
220223

221-
public CheckNotifier getUpdateDialogCreator() {
222-
if (updateDialogCreator == null) {
223-
updateDialogCreator = config.getUpdateDialogCreator();
224+
public CheckNotifier getCheckNotifier() {
225+
if (checkNotifier == null) {
226+
checkNotifier = config.getCheckNotifier();
224227
}
225-
return updateDialogCreator;
228+
return checkNotifier;
226229
}
227230

228-
public InstallNotifier getInstallDialogCreator() {
229-
if (installDialogCreator == null) {
230-
installDialogCreator = config.getInstallDialogCreator();
231+
public InstallNotifier getInstallNotifier() {
232+
if (installNotifier == null) {
233+
installNotifier = config.getInstallNotifier();
231234
}
232-
return installDialogCreator;
235+
return installNotifier;
233236
}
234237

235-
public DownloadNotifier getDownloadDialogCreator() {
236-
if (downloadDialogCreator == null) {
237-
downloadDialogCreator = config.getDownloadDialogCreator();
238+
public DownloadNotifier getDownloadNotifier() {
239+
if (downloadNotifier == null) {
240+
downloadNotifier = config.getDownloadNotifier();
238241
}
239-
return downloadDialogCreator;
242+
return downloadNotifier;
240243
}
241244

242-
public UpdateParser getJsonParser() {
243-
if (jsonParser == null) {
244-
jsonParser = config.getJsonParser();
245+
public UpdateParser getUpdateParser() {
246+
if (updateParser == null) {
247+
updateParser = config.getUpdateParser();
245248
}
246-
return jsonParser;
249+
return updateParser;
247250
}
248251

249252
public Class<? extends CheckWorker> getCheckWorker() {
@@ -267,11 +270,11 @@ public FileCreator getFileCreator() {
267270
return fileCreator;
268271
}
269272

270-
public CheckCallback getCheckCB() {
273+
public CheckCallback getCheckCallback() {
271274
return callbackDelegate;
272275
}
273276

274-
public DownloadCallback getDownloadCB() {
277+
public DownloadCallback getDownloadCallback() {
275278
return callbackDelegate;
276279
}
277280

@@ -290,7 +293,7 @@ public boolean isDaemon() {
290293
return isDaemon;
291294
}
292295

293-
public RetryCallback getRetryCallback() {
296+
RetryCallback getRetryCallback() {
294297
if (retryCallback == null) {
295298
retryCallback = new RetryCallback(this);
296299
}

updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/UpdateConfig.java

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
import java.util.concurrent.Executors;
4848

4949
/**
50-
* 此类用于提供一些默认使用的更新配置。在进行更新任务时,当{@link UpdateBuilder} 中未设置对应的配置时。
51-
* 将从此配置类中读取默认的配置进行使用
50+
* 此类用于提供一些默认使用的更新配置。
51+
*
52+
* <p>在进行更新任务时,当{@link UpdateBuilder} 中未设置对应的配置时。将从此配置类中读取默认的配置进行使用
5253
*
5354
* @author haoge
5455
*/
@@ -58,10 +59,10 @@ public final class UpdateConfig {
5859
private Class<? extends DownloadWorker> downloadWorker;
5960
private CheckEntity entity;
6061
private UpdateStrategy updateStrategy;
61-
private CheckNotifier updateDialogCreator;
62-
private InstallNotifier installDialogCreator;
63-
private DownloadNotifier downloadDialogCreator;
64-
private UpdateParser jsonParser;
62+
private CheckNotifier checkNotifier;
63+
private InstallNotifier installNotifier;
64+
private DownloadNotifier downloadNotifier;
65+
private UpdateParser updateParser;
6566
private FileCreator fileCreator;
6667
private UpdateChecker updateChecker;
6768
private FileChecker fileChecker;
@@ -193,12 +194,12 @@ public UpdateConfig setCheckCallback(CheckCallback callback) {
193194

194195
/**
195196
* 配置更新数据解析器。
196-
* @param jsonParser 解析器
197+
* @param updateParser 解析器
197198
* @return itself
198199
* @see UpdateParser
199200
*/
200-
public UpdateConfig setUpdateParser(UpdateParser jsonParser) {
201-
this.jsonParser = jsonParser;
201+
public UpdateConfig setUpdateParser(UpdateParser updateParser) {
202+
this.updateParser = updateParser;
202203
return this;
203204
}
204205

@@ -215,35 +216,35 @@ public UpdateConfig setFileCreator(FileCreator fileCreator) {
215216

216217
/**
217218
* 配置下载进度通知创建器 默认参考{@link DefaultDownloadNotifier}
218-
* @param downloadDialogCreator 下载进度通知创建器
219+
* @param notifier 下载进度通知创建器
219220
* @return itself
220221
* @see DownloadNotifier
221222
*/
222-
public UpdateConfig setDownloadNotifier(DownloadNotifier downloadDialogCreator) {
223-
this.downloadDialogCreator = downloadDialogCreator;
223+
public UpdateConfig setDownloadNotifier(DownloadNotifier notifier) {
224+
this.downloadNotifier = notifier;
224225
return this;
225226
}
226227

227228
/**
228229
* 配置启动安装任务前通知创建器 默认参考{@link DefaultInstallNotifier}
229230
*
230-
* @param installDialogCreator 下载完成后。启动安装前的通知创建器
231+
* @param notifier 下载完成后。启动安装前的通知创建器
231232
* @return itself
232233
* @see InstallNotifier
233234
*/
234-
public UpdateConfig setInstallNotifier(InstallNotifier installDialogCreator) {
235-
this.installDialogCreator = installDialogCreator;
235+
public UpdateConfig setInstallNotifier(InstallNotifier notifier) {
236+
this.installNotifier = notifier;
236237
return this;
237238
}
238239

239240
/**
240241
* 配置检查到有更新时的通知创建器 默认参考{@link DefaultUpdateNotifier}
241-
* @param updateDialogCreator 通知创建器
242+
* @param notifier 通知创建器
242243
* @return itself
243244
* @see CheckNotifier
244245
*/
245-
public UpdateConfig setCheckNotifier(CheckNotifier updateDialogCreator) {
246-
this.updateDialogCreator = updateDialogCreator;
246+
public UpdateConfig setCheckNotifier(CheckNotifier notifier) {
247+
this.checkNotifier = notifier;
247248
return this;
248249
}
249250

@@ -286,18 +287,18 @@ public CheckEntity getCheckEntity () {
286287
return this.entity;
287288
}
288289

289-
public CheckNotifier getUpdateDialogCreator() {
290-
if (updateDialogCreator == null) {
291-
updateDialogCreator = new DefaultUpdateNotifier();
290+
public CheckNotifier getCheckNotifier() {
291+
if (checkNotifier == null) {
292+
checkNotifier = new DefaultUpdateNotifier();
292293
}
293-
return updateDialogCreator;
294+
return checkNotifier;
294295
}
295296

296-
public InstallNotifier getInstallDialogCreator() {
297-
if (installDialogCreator == null) {
298-
installDialogCreator = new DefaultInstallNotifier();
297+
public InstallNotifier getInstallNotifier() {
298+
if (installNotifier == null) {
299+
installNotifier = new DefaultInstallNotifier();
299300
}
300-
return installDialogCreator;
301+
return installNotifier;
301302
}
302303

303304
public UpdateChecker getUpdateChecker() {
@@ -314,18 +315,18 @@ public FileChecker getFileChecker() {
314315
return fileChecker;
315316
}
316317

317-
public DownloadNotifier getDownloadDialogCreator() {
318-
if (downloadDialogCreator == null) {
319-
downloadDialogCreator = new DefaultDownloadNotifier();
318+
public DownloadNotifier getDownloadNotifier() {
319+
if (downloadNotifier == null) {
320+
downloadNotifier = new DefaultDownloadNotifier();
320321
}
321-
return downloadDialogCreator;
322+
return downloadNotifier;
322323
}
323324

324-
public UpdateParser getJsonParser() {
325-
if (jsonParser == null) {
325+
public UpdateParser getUpdateParser() {
326+
if (updateParser == null) {
326327
throw new IllegalStateException("update parser is null");
327328
}
328-
return jsonParser;
329+
return updateParser;
329330
}
330331

331332
public Class<? extends CheckWorker> getCheckWorker() {

updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/base/CheckNotifier.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public abstract class CheckNotifier {
4646

4747
protected UpdateBuilder builder;
4848
protected Update update;
49-
private CheckCallback checkCB;
49+
private CheckCallback callback;
5050
public final void setBuilder(UpdateBuilder builder) {
5151
this.builder = builder;
52-
this.checkCB = builder.getCheckCB();
52+
this.callback = builder.getCheckCallback();
5353
}
5454

5555
public void setUpdate(Update update) {
@@ -82,17 +82,17 @@ public final void sendDownloadRequest() {
8282
* 当用户手动取消此次更新任务时,通过此方法进行取消并通知用户
8383
*/
8484
protected final void sendUserCancel() {
85-
if (this.checkCB != null) {
86-
this.checkCB.onUserCancel();
85+
if (this.callback != null) {
86+
this.callback.onUserCancel();
8787
}
8888
}
8989

9090
/**
9191
* 当用户指定需要忽略此版本的更新请求时:通过此方法进行取消并忽略此版本的后续更新请求。
9292
*/
9393
protected final void sendUserIgnore() {
94-
if (this.checkCB != null) {
95-
this.checkCB.onCheckIgnore(update);
94+
if (this.callback != null) {
95+
this.callback.onCheckIgnore(update);
9696
}
9797
UpdatePreference.saveIgnoreVersion(update.getVersionCode());
9898
}

updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/base/CheckWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected boolean useAsync() {
108108
*/
109109
public final void onResponse(String response) {
110110
try {
111-
UpdateParser jsonParser = builder.getJsonParser();
111+
UpdateParser jsonParser = builder.getUpdateParser();
112112
Update update = jsonParser.parse(response);
113113
if (update == null) {
114114
throw new IllegalArgumentException(String.format(

updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/base/InstallNotifier.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public final void sendToInstall() {
8787
* 请求取消更新任务
8888
*/
8989
public final void sendUserCancel() {
90-
if (builder.getCheckCB() != null) {
91-
builder.getCheckCB().onUserCancel();
90+
if (builder.getCheckCallback() != null) {
91+
builder.getCheckCallback().onUserCancel();
9292
}
9393

9494
}
@@ -97,8 +97,8 @@ public final void sendUserCancel() {
9797
* 请求将此版本加入版本忽略列表
9898
*/
9999
public final void sendCheckIgnore() {
100-
if (builder.getCheckCB() != null) {
101-
builder.getCheckCB().onCheckIgnore(update);
100+
if (builder.getCheckCallback() != null) {
101+
builder.getCheckCallback().onCheckIgnore(update);
102102
}
103103
UpdatePreference.saveIgnoreVersion(update.getVersionCode());
104104
}

0 commit comments

Comments
 (0)