fix crashing at start
This commit is contained in:
parent
1702ce7702
commit
013025b750
|
@ -162,7 +162,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
|
||||
log.debug("Requesting ignore battery optimization");
|
||||
|
||||
OKDialog.show(this, getString(R.string.pleaseallowpermission), String.format(getString(R.string.needwhitelisting), getString(R.string.app_name)), new Runnable() {
|
||||
OKDialog.show(getParent(), getString(R.string.pleaseallowpermission), String.format(getString(R.string.needwhitelisting), getString(R.string.app_name)), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -129,6 +129,8 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() == null)
|
||||
return;
|
||||
boolean allowProfileSwitch = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getProfileList().size() > 1;
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !allowProfileSwitch)
|
||||
profileSwitch.setVisibility(View.GONE);
|
||||
|
|
|
@ -1016,6 +1016,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
}
|
||||
// Unable to determine profile, failover to default
|
||||
if (activeProfile.getProfile() == null)
|
||||
return null; //app not initialized
|
||||
Profile defaultProfile = activeProfile.getProfile().getDefaultProfile();
|
||||
if (defaultProfile != null)
|
||||
return defaultProfile;
|
||||
|
|
|
@ -274,7 +274,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
|
||||
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
|
||||
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
|
||||
showBasalsView.setChecked(SP.getBoolean("showbasals", false));
|
||||
showBasalsView.setChecked(SP.getBoolean("showbasals", true));
|
||||
showIobView.setChecked(SP.getBoolean("showiob", false));
|
||||
showCobView.setChecked(SP.getBoolean("showcob", false));
|
||||
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
|
||||
|
@ -891,27 +891,27 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
@SuppressLint("SetTextI18n")
|
||||
public void updateGUI(String from) {
|
||||
log.debug("updateGUI entered from: " + from);
|
||||
if (MainApp.getConfigBuilder().getProfile() == null) {// app not initialized yet
|
||||
pumpStatusView.setText(R.string.noprofileset);
|
||||
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||
loopStatusLayout.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
pumpStatusLayout.setVisibility(View.GONE);
|
||||
loopStatusLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
updateNotifications();
|
||||
CareportalFragment.updateAge(getActivity(), sage, iage, cage, pbage);
|
||||
BgReading actualBG = DatabaseHelper.actualBg();
|
||||
BgReading lastBG = DatabaseHelper.lastBg();
|
||||
|
||||
// if (MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
|
||||
// pumpStatusView.setText(R.string.noprofileset);
|
||||
// pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||
// loopStatusLayout.setVisibility(View.GONE);
|
||||
// return;
|
||||
// } else {
|
||||
pumpStatusLayout.setVisibility(View.GONE);
|
||||
loopStatusLayout.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
// Skip if not initialized yet
|
||||
if (bgGraph == null)
|
||||
return;
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if (getActivity() == null)
|
||||
return;
|
||||
|
||||
|
@ -950,7 +950,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
// temp target
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime());
|
||||
if (tempTarget != null) {
|
||||
tempTargetView.setTextColor(Color.BLACK);
|
||||
|
|
|
@ -75,12 +75,12 @@ public class NSProfileFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void updateGUI() {
|
||||
// if (nsProfilePlugin.profile == null) {
|
||||
// noProfile.setVisibility(View.VISIBLE);
|
||||
// return;
|
||||
// } else {
|
||||
// noProfile.setVisibility(View.GONE);
|
||||
// }
|
||||
if (MainApp.getConfigBuilder().getProfile() == null) {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
} else {
|
||||
noProfile.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
units.setText(profile.getUnits());
|
||||
|
|
Loading…
Reference in a new issue