Skip to content

Commit 837a54e

Browse files
authored
Merge pull request #67 from Jiiiiiin/feature/handler_download_service_isRunning_status_not_reset_on_def_dilaog_close_btn_tap
Feature/handler download service is running status not reset on def dilaog close btn tap
2 parents ef4fd0a + 8b87f33 commit 837a54e

File tree

7 files changed

+31
-291
lines changed

7 files changed

+31
-291
lines changed

sample/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ dependencies {
3131
})
3232
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
3333

34-
// compile project(':update-app')
35-
compile project(':update-app-kotlin')
34+
compile project(':update-app')
35+
// compile project(':update-app-kotlin')
3636

3737
//compile 'com.qianwen:update-app-kotlin:1.1.0'
3838
//okgo

sample/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
</intent-filter>
3333
</activity>
3434

35-
<activity android:name=".ui.KotlinActivity">
36-
</activity>
35+
<!--<activity android:name=".ui.KotlinActivity">-->
36+
<!--</activity>-->
3737
<activity android:name=".ui.JavaActivity">
3838
</activity>
3939

sample/src/main/java/com/vector/appupdatedemo/ui/JavaActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public void updateApp(View view) {
8080
.setActivity(this)
8181
//更新地址
8282
.setUpdateUrl(mUpdateUrl)
83+
.dismissNotificationProgress()
8384
//实现httpManager接口的对象
8485
.setHttpManager(new UpdateAppHttpUtil())
8586
// // 监听更新提示框相关事件

sample/src/main/java/com/vector/appupdatedemo/ui/KotlinActivity.kt

Lines changed: 0 additions & 281 deletions
This file was deleted.

sample/src/main/java/com/vector/appupdatedemo/ui/MainActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void updateJava(View view) {
5555
startActivity(new Intent(this, JavaActivity.class));
5656
}
5757

58-
public void updateKotlin(View view) {
59-
startActivity(new Intent(this, KotlinActivity.class));
60-
}
58+
// public void updateKotlin(View view) {
59+
// startActivity(new Intent(this, KotlinActivity.class));
60+
// }
6161
}

update-app/src/main/java/com/vector/update_app/UpdateDialogFragment.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public void onServiceDisconnected(ComponentName name) {
7373
private ImageView mTopIv;
7474
private TextView mIgnore;
7575
private IUpdateDialogFragmentListener mUpdateDialogFragmentListener;
76+
private DownloadService.DownloadBinder mDownloadBinder;
7677

7778
public UpdateDialogFragment setUpdateDialogFragmentListener(IUpdateDialogFragmentListener updateDialogFragmentListener) {
7879
this.mUpdateDialogFragmentListener = updateDialogFragmentListener;
@@ -81,7 +82,7 @@ public UpdateDialogFragment setUpdateDialogFragmentListener(IUpdateDialogFragmen
8182

8283
public static UpdateDialogFragment newInstance(Bundle args) {
8384
UpdateDialogFragment fragment = new UpdateDialogFragment();
84-
if(args != null) {
85+
if (args != null) {
8586
fragment.setArguments(args);
8687
}
8788
return fragment;
@@ -297,7 +298,8 @@ public void onClick(View view) {
297298
// if (mNumberProgressBar.getVisibility() == View.VISIBLE) {
298299
// Toast.makeText(getApplicationContext(), "后台更新app", Toast.LENGTH_LONG).show();
299300
// }
300-
if(mUpdateDialogFragmentListener != null){
301+
cancelDownloadService();
302+
if (mUpdateDialogFragmentListener != null) {
301303
// 通知用户
302304
mUpdateDialogFragmentListener.onUpdateNotifyDialogCancel(mUpdateApp);
303305
}
@@ -308,6 +310,10 @@ public void onClick(View view) {
308310
}
309311
}
310312

313+
public void cancelDownloadService() {
314+
mDownloadBinder.stop("取消下载");
315+
}
316+
311317
private void installApp() {
312318
if (AppUpdateUtils.appIsDownloaded(mUpdateApp)) {
313319
AppUpdateUtils.installApp(UpdateDialogFragment.this, AppUpdateUtils.getAppFile(mUpdateApp));
@@ -355,6 +361,8 @@ private void startDownloadApp(DownloadService.DownloadBinder binder) {
355361
// 开始下载,监听下载进度,可以用对话框显示
356362
if (mUpdateApp != null) {
357363

364+
this.mDownloadBinder = binder;
365+
358366
binder.start(mUpdateApp, new DownloadService.DownloadCallback() {
359367
@Override
360368
public void onStart() {
@@ -419,8 +427,9 @@ public boolean onInstallAppAndAppOnForeground(File file) {
419427
public void show(FragmentManager manager, String tag) {
420428

421429
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
422-
if (manager.isDestroyed())
430+
if (manager.isDestroyed()) {
423431
return;
432+
}
424433
}
425434

426435
try {
@@ -436,3 +445,4 @@ public void onDestroyView() {
436445
super.onDestroyView();
437446
}
438447
}
448+

0 commit comments

Comments
 (0)