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