Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/handler download service is running status not reset on def dilaog close btn tap #67

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ dependencies {
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

// compile project(':update-app')
compile project(':update-app-kotlin')
compile project(':update-app')
// compile project(':update-app-kotlin')

//compile 'com.qianwen:update-app-kotlin:1.1.0'
//okgo
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</intent-filter>
</activity>

<activity android:name=".ui.KotlinActivity">
</activity>
<!--<activity android:name=".ui.KotlinActivity">-->
<!--</activity>-->
<activity android:name=".ui.JavaActivity">
</activity>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void updateApp(View view) {
.setActivity(this)
//更新地址
.setUpdateUrl(mUpdateUrl)
.dismissNotificationProgress()
//实现httpManager接口的对象
.setHttpManager(new UpdateAppHttpUtil())
// // 监听更新提示框相关事件
Expand Down Expand Up @@ -284,6 +285,11 @@ public void onError(String msg) {
HProgressDialogUtils.cancel();

}

@Override
public boolean onInstallAppAndAppOnForeground(File file) {
return false;
}
});
} else {
//不显示下载进度
Expand Down
281 changes: 0 additions & 281 deletions sample/src/main/java/com/vector/appupdatedemo/ui/KotlinActivity.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void updateJava(View view) {
startActivity(new Intent(this, JavaActivity.class));
}

public void updateKotlin(View view) {
startActivity(new Intent(this, KotlinActivity.class));
}
// public void updateKotlin(View view) {
// startActivity(new Intent(this, KotlinActivity.class));
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void onServiceDisconnected(ComponentName name) {
private ImageView mTopIv;
private TextView mIgnore;
private IUpdateDialogFragmentListener mUpdateDialogFragmentListener;
private DownloadService.DownloadBinder mDownloadBinder;

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

public static UpdateDialogFragment newInstance(Bundle args) {
UpdateDialogFragment fragment = new UpdateDialogFragment();
if(args != null) {
if (args != null) {
fragment.setArguments(args);
}
return fragment;
Expand Down Expand Up @@ -297,7 +298,8 @@ public void onClick(View view) {
// if (mNumberProgressBar.getVisibility() == View.VISIBLE) {
// Toast.makeText(getApplicationContext(), "后台更新app", Toast.LENGTH_LONG).show();
// }
if(mUpdateDialogFragmentListener != null){
cancelDownloadService();
if (mUpdateDialogFragmentListener != null) {
// 通知用户
mUpdateDialogFragmentListener.onUpdateNotifyDialogCancel(mUpdateApp);
}
Expand All @@ -308,6 +310,10 @@ public void onClick(View view) {
}
}

public void cancelDownloadService() {
mDownloadBinder.stop("取消下载");
}

private void installApp() {
if (AppUpdateUtils.appIsDownloaded(mUpdateApp)) {
AppUpdateUtils.installApp(UpdateDialogFragment.this, AppUpdateUtils.getAppFile(mUpdateApp));
Expand Down Expand Up @@ -355,6 +361,8 @@ private void startDownloadApp(DownloadService.DownloadBinder binder) {
// 开始下载,监听下载进度,可以用对话框显示
if (mUpdateApp != null) {

this.mDownloadBinder = binder;

binder.start(mUpdateApp, new DownloadService.DownloadCallback() {
@Override
public void onStart() {
Expand Down Expand Up @@ -419,8 +427,9 @@ public boolean onInstallAppAndAppOnForeground(File file) {
public void show(FragmentManager manager, String tag) {

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
if (manager.isDestroyed())
if (manager.isDestroyed()) {
return;
}
}

try {
Expand All @@ -436,3 +445,4 @@ public void onDestroyView() {
super.onDestroyView();
}
}

Loading