fix app crash

This commit is contained in:
Milos Kozak 2017-05-16 20:02:09 +02:00
parent 91fa355d8c
commit 3ec08ab10f

View file

@ -33,24 +33,18 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
TextView treatmentsTab; TextView treatmentsTab;
TextView tempBasalsTab; TextView tempBasalsTab;
Fragment bolusFragment;
Fragment tempBasalsFragment;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.treatments_fragment, container, false); View view = inflater.inflate(R.layout.treatments_fragment, container, false);
bolusFragment = new TreatmentsBolusFragment();
tempBasalsFragment = new TreatmentsTempBasalsFragment();
treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments); treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments);
tempBasalsTab = (TextView) view.findViewById(R.id.treatments_tempbasals); tempBasalsTab = (TextView) view.findViewById(R.id.treatments_tempbasals);
treatmentsTab.setOnClickListener(this); treatmentsTab.setOnClickListener(this);
tempBasalsTab.setOnClickListener(this); tempBasalsTab.setOnClickListener(this);
context = getContext(); context = getContext();
setFragment(bolusFragment); setFragment(new TreatmentsBolusFragment());
return view; return view;
} }
@ -60,10 +54,10 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
switch (v.getId()) { switch (v.getId()) {
case R.id.treatments_treatments: case R.id.treatments_treatments:
setFragment(bolusFragment); setFragment(new TreatmentsBolusFragment());
break; break;
case R.id.treatments_tempbasals: case R.id.treatments_tempbasals:
setFragment(tempBasalsFragment); setFragment(new TreatmentsTempBasalsFragment());
break; break;
} }