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