File tree Expand file tree Collapse file tree 4 files changed +19
-8
lines changed
java/org/lzh/framework/updateplugin
updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/flow Expand file tree Collapse file tree 4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 33import android .Manifest ;
44import android .app .Activity ;
55import android .os .Bundle ;
6+ import android .support .annotation .NonNull ;
67
78import com .tbruyelle .rxpermissions .RxPermissions ;
89
@@ -55,8 +56,18 @@ public void call(Boolean aBoolean) {
5556 });
5657 }
5758
59+ @ OnClick (R .id .start_daemon_update )
60+ void onDaemonStartClick () {
61+ createBuilder ().checkWithDaemon (1000 * 5 );// 后台更新时间间隔设置为5秒。
62+ }
63+
5864 @ OnClick (R .id .start_update )
5965 void onStartClick () {
66+ createBuilder ().check ();
67+ }
68+
69+ @ NonNull
70+ private UpdateBuilder createBuilder () {
6071 UpdateBuilder builder = UpdateBuilder .create ();
6172 if (!newConfig .isDefaultSelected ()) {
6273 builder = UpdateBuilder .create (createNewConfig ());
@@ -89,12 +100,7 @@ void onStartClick () {
89100 if (!downloadWorker .isDefaultSelected ()) {
90101 builder .setDownloadWorker (OkhttpDownloadWorker .class );
91102 }
92- /*
93- * 以上为常用的需要定制的功能模块。如果需要更多的定制需求。请参考
94- * {@link org.lzh.framework.updatepluginlib.UpdateConfig}
95- * 类中所使用的其他模块的默认实现方式。
96- * */
97- builder .check ();
103+ return builder ;
98104 }
99105
100106 private UpdateConfig createNewConfig () {
Original file line number Diff line number Diff line change 6666 android : text =" @string/start_update"
6767 android : layout_width =" match_parent"
6868 android : layout_height =" wrap_content" />
69+ <Button
70+ android : id =" @+id/start_daemon_update"
71+ android : text =" @string/start_daemon_update"
72+ android : layout_width =" match_parent"
73+ android : layout_height =" wrap_content" />
6974
7075</LinearLayout >
Original file line number Diff line number Diff line change 1010 <string name =" custom_file_creator" >使用自定义下载文件创建器指定下载文件名</string >
1111 <string name =" show_update_dialog_in_another_activity" >跳转到下一页并显示更新</string >
1212 <string name =" upgrade_in_back_thread" >在子线程中启动更新检查</string >
13+ <string name =" start_daemon_update" >启动后台更新</string >
1314</resources >
Original file line number Diff line number Diff line change @@ -70,15 +70,14 @@ public void onCheckError(Throwable t) {
7070
7171 @ Override
7272 public void onUserCancel () {
73- retry ();
7473 }
7574
7675 @ Override
7776 public void onCheckIgnore (Update update ) {
7877 retry ();
7978 }
8079
81- private final synchronized void retry () {
80+ private synchronized void retry () {
8281 Utils .getMainHandler ().removeCallbacks (this );
8382 Utils .getMainHandler ().postDelayed (this , retryTime );
8483 }
You can’t perform that action at this time.
0 commit comments