1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-15 13:14:22 +02:00

catch illegal state argument if context is lost

This commit is contained in:
oliexdev
2020-12-02 11:20:43 +01:00
parent c32b02e279
commit 4d9f1a878f

View File

@@ -160,21 +160,25 @@ public class BluetoothSettingsFragment extends Fragment {
new Handler().post(new Runnable() {
@Override
public void run() {
BluetoothDeviceView notSupported = new BluetoothDeviceView(requireContext());
notSupported.setDeviceName(requireContext().getString(R.string.label_scale_not_supported));
notSupported.setSummaryText(requireContext().getString(R.string.label_click_to_help_add_support));
notSupported.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent notSupportedIntent = new Intent(Intent.ACTION_VIEW);
notSupportedIntent.setData(
Uri.parse("https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale"));
try {
BluetoothDeviceView notSupported = new BluetoothDeviceView(requireContext());
notSupported.setDeviceName(requireContext().getString(R.string.label_scale_not_supported));
notSupported.setSummaryText(requireContext().getString(R.string.label_click_to_help_add_support));
notSupported.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent notSupportedIntent = new Intent(Intent.ACTION_VIEW);
notSupportedIntent.setData(
Uri.parse("https://github.com/oliexdev/openScale/wiki/Supported-scales-in-openScale"));
startActivity(notSupportedIntent);
}
});
deviceListView.addView(notSupported);
}
startActivity(notSupportedIntent);
}
});
deviceListView.addView(notSupported);
} catch(IllegalStateException ex) {
Timber.e(ex.getMessage());
}
}
});
}
}, 20 * 1000);