1.Bug fix
This commit is contained in:
parent
bcb17bb3cc
commit
51e0428968
|
@ -12,8 +12,8 @@ android {
|
|||
applicationId "com.zane.smapiinstaller"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 28
|
||||
versionCode 29
|
||||
versionName "1.4.0"
|
||||
versionCode 30
|
||||
versionName "1.4.1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
package com.zane.smapiinstaller.ui.download;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -37,6 +31,12 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* {@link RecyclerView.Adapter} that can display a {@link DownloadableContent}
|
||||
* @author Zane
|
||||
|
@ -162,8 +162,7 @@ public class DownloadableContentAdapter extends RecyclerView.Adapter<Downloadabl
|
|||
@Override
|
||||
public void onError(Response<File> response) {
|
||||
super.onError(response);
|
||||
ProgressDialog dialog = dialogRef.get();
|
||||
dialog.dismiss();
|
||||
DialogUtils.dismissDialog(itemView, dialogRef.get());
|
||||
downloading.set(false);
|
||||
DialogUtils.showAlertDialog(itemView, R.string.error, R.string.error_failed_to_download);
|
||||
}
|
||||
|
@ -180,8 +179,7 @@ public class DownloadableContentAdapter extends RecyclerView.Adapter<Downloadabl
|
|||
|
||||
@Override
|
||||
public void onSuccess(Response<File> response) {
|
||||
ProgressDialog dialog = dialogRef.get();
|
||||
dialog.dismiss();
|
||||
DialogUtils.dismissDialog(itemView, dialogRef.get());
|
||||
downloading.set(false);
|
||||
File downloadedFile = response.body();
|
||||
String hash = com.zane.smapiinstaller.utils.FileUtils.getFileHash(downloadedFile);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.zane.smapiinstaller.ui.install;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -32,7 +32,7 @@ import butterknife.OnClick;
|
|||
*/
|
||||
public class InstallFragment extends Fragment {
|
||||
|
||||
private Context context;
|
||||
private Activity context;
|
||||
|
||||
private Thread task;
|
||||
|
||||
|
@ -120,9 +120,7 @@ public class InstallFragment extends Fragment {
|
|||
Crashes.trackError(e);
|
||||
DialogUtils.showAlertDialog(root, R.string.error, e.getLocalizedMessage());
|
||||
} finally {
|
||||
if(dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
DialogUtils.dismissDialog(root, dialog);
|
||||
}
|
||||
});
|
||||
task.start();
|
||||
|
|
|
@ -173,13 +173,35 @@ public class DialogUtils {
|
|||
public static void dismissDialog(View view, MaterialDialog dialog) {
|
||||
Activity activity = CommonLogic.getActivityFromView(view);
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
if (dialog != null && dialog.isShowing()) {
|
||||
try {
|
||||
dialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
Crashes.trackError(e);
|
||||
activity.runOnUiThread(()->{
|
||||
if (dialog != null && dialog.isShowing()) {
|
||||
try {
|
||||
dialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
Crashes.trackError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 解散指定对话框
|
||||
*
|
||||
* @param view view
|
||||
* @param dialog 对话框
|
||||
*/
|
||||
public static void dismissDialog(View view, ProgressDialog dialog) {
|
||||
Activity activity = CommonLogic.getActivityFromView(view);
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(()->{
|
||||
if (dialog != null) {
|
||||
try {
|
||||
dialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
Crashes.trackError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue