fix NPE in pairing dialog
This commit is contained in:
parent
7aa689d331
commit
ad2f2e18b4
1 changed files with 23 additions and 11 deletions
|
@ -60,8 +60,10 @@ public class PairingProgressDialog extends DaggerDialogFragment {
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
binding.danarsPairingprogressProgressbar.setProgress(100);
|
if (binding != null) {
|
||||||
binding.danarsPairingprogressStatus.setText(R.string.danars_pairingok);
|
binding.danarsPairingprogressProgressbar.setProgress(100);
|
||||||
|
binding.danarsPairingprogressStatus.setText(R.string.danars_pairingok);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
@ -72,7 +74,7 @@ public class PairingProgressDialog extends DaggerDialogFragment {
|
||||||
dismiss();
|
dismiss();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
binding.danarsPairingprogressProgressbar.setProgress(i * 5);
|
if (binding != null) binding.danarsPairingprogressProgressbar.setProgress(i * 5);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
@ -81,9 +83,11 @@ public class PairingProgressDialog extends DaggerDialogFragment {
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
binding.danarsPairingprogressProgressbar.setProgress(100);
|
if (binding != null) {
|
||||||
binding.danarsPairingprogressStatus.setText(R.string.danars_pairingtimedout);
|
binding.danarsPairingprogressProgressbar.setProgress(100);
|
||||||
binding.ok.setVisibility(View.VISIBLE);
|
binding.danarsPairingprogressStatus.setText(R.string.danars_pairingtimedout);
|
||||||
|
binding.ok.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -131,12 +135,20 @@ public class PairingProgressDialog extends DaggerDialogFragment {
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void setViews() {
|
private void setViews() {
|
||||||
binding.danarsPairingprogressProgressbar.setMax(100);
|
if (binding != null) {
|
||||||
binding.danarsPairingprogressProgressbar.setProgress(0);
|
binding.danarsPairingprogressProgressbar.setMax(100);
|
||||||
binding.danarsPairingprogressStatus.setText(resourceHelper.gs(R.string.danars_waitingforpairing));
|
binding.danarsPairingprogressProgressbar.setProgress(0);
|
||||||
binding.ok.setVisibility(View.GONE);
|
binding.danarsPairingprogressStatus.setText(resourceHelper.gs(R.string.danars_waitingforpairing));
|
||||||
binding.ok.setOnClickListener(v -> dismiss());
|
binding.ok.setVisibility(View.GONE);
|
||||||
|
binding.ok.setOnClickListener(v -> dismiss());
|
||||||
|
}
|
||||||
handler.post(runnable);
|
handler.post(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue