plugins type, SimpleDateFromat thread safe
This commit is contained in:
parent
891c5dd4d7
commit
22aab61b02
9 changed files with 131 additions and 145 deletions
|
@ -17,10 +17,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
||||||
import info.nightscout.androidaps.tabs.*;
|
import info.nightscout.androidaps.tabs.*;
|
||||||
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
|
import info.nightscout.androidaps.plugins.Objectives.ObjectivesFragment;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity
|
public class MainActivity extends AppCompatActivity {
|
||||||
implements ObjectivesFragment.OnFragmentInteractionListener,
|
|
||||||
TreatmentsFragment.OnFragmentInteractionListener,
|
|
||||||
TempBasalsFragment.OnFragmentInteractionListener {
|
|
||||||
private static Logger log = LoggerFactory.getLogger(MainActivity.class);
|
private static Logger log = LoggerFactory.getLogger(MainActivity.class);
|
||||||
|
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
|
@ -70,11 +67,6 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFragmentInteraction(String param) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerBus() {
|
private void registerBus() {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
|
|
@ -16,12 +16,21 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.PluginBase;
|
||||||
|
|
||||||
public class ObjectivesFragment extends Fragment {
|
public class ObjectivesFragment extends Fragment implements PluginBase {
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.GENERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFragmentVisible() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
class Objective {
|
class Objective {
|
||||||
String objective;
|
String objective;
|
||||||
|
@ -151,43 +160,4 @@ public class ObjectivesFragment extends Fragment {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// TODO: Rename method, update argument and hook method into UI event
|
|
||||||
public void onButtonPressed(Uri uri) {
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onFragmentInteraction(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
if (context instanceof OnFragmentInteractionListener) {
|
|
||||||
mListener = (OnFragmentInteractionListener) context;
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(context.toString()
|
|
||||||
+ " must implement OnFragmentInteractionListener");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetach() {
|
|
||||||
super.onDetach();
|
|
||||||
mListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface must be implemented by activities that contain this
|
|
||||||
* fragment to allow an interaction in this fragment to be communicated
|
|
||||||
* to the activity and potentially other fragments contained in that
|
|
||||||
* activity.
|
|
||||||
* <p/>
|
|
||||||
* See the Android Training lesson <a href=
|
|
||||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
||||||
* >Communicating with Other Fragments</a> for more information.
|
|
||||||
*/
|
|
||||||
public interface OnFragmentInteractionListener {
|
|
||||||
// TODO: Update argument type and name
|
|
||||||
void onFragmentInteraction(String param);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -27,15 +28,27 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
|
import info.nightscout.androidaps.plugins.PluginBase;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
|
|
||||||
public class OverviewFragment extends Fragment {
|
public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
||||||
|
|
||||||
TextView bg;
|
TextView bg;
|
||||||
GraphView bgGraph;
|
GraphView bgGraph;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.GENERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFragmentVisible() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static OverviewFragment newInstance() {
|
public static OverviewFragment newInstance() {
|
||||||
OverviewFragment fragment = new OverviewFragment();
|
OverviewFragment fragment = new OverviewFragment();
|
||||||
return fragment;
|
return fragment;
|
||||||
|
@ -94,14 +107,9 @@ public class OverviewFragment extends Fragment {
|
||||||
series.setSize(5);
|
series.setSize(5);
|
||||||
series.setColor(Color.GREEN);
|
series.setColor(Color.GREEN);
|
||||||
|
|
||||||
// set date label formatter
|
|
||||||
bgGraph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(getActivity(), new SimpleDateFormat("HH")));
|
|
||||||
bgGraph.getGridLabelRenderer().setNumVerticalLabels(11); // only 5 because of the space
|
|
||||||
bgGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
|
||||||
|
|
||||||
// allign to hours
|
// allign to hours
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTimeInMillis(bgReadings[0].timestamp);
|
calendar.setTimeInMillis(new Date().getTime());
|
||||||
calendar.set(Calendar.SECOND, 0);
|
calendar.set(Calendar.SECOND, 0);
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
calendar.add(Calendar.HOUR, 1);
|
calendar.add(Calendar.HOUR, 1);
|
||||||
|
@ -109,12 +117,17 @@ public class OverviewFragment extends Fragment {
|
||||||
bgGraph.getViewport().setMaxX(calendar.getTimeInMillis());
|
bgGraph.getViewport().setMaxX(calendar.getTimeInMillis());
|
||||||
bgGraph.getViewport().setMinX(calendar.getTimeInMillis() - hoursToFetch * 60 * 60 * 1000l);
|
bgGraph.getViewport().setMinX(calendar.getTimeInMillis() - hoursToFetch * 60 * 60 * 1000l);
|
||||||
bgGraph.getViewport().setXAxisBoundsManual(true);
|
bgGraph.getViewport().setXAxisBoundsManual(true);
|
||||||
|
bgGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(),"HH"));
|
||||||
|
bgGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
||||||
|
|
||||||
|
String test = new SimpleDateFormat("HH").format(calendar.getTimeInMillis());
|
||||||
|
|
||||||
// set manual y bounds to have nice steps
|
// set manual y bounds to have nice steps
|
||||||
// TODO: MGDL support
|
// TODO: MGDL support, some scale support
|
||||||
bgGraph.getViewport().setMaxY(20);
|
bgGraph.getViewport().setMaxY(20);
|
||||||
bgGraph.getViewport().setMinY(0);
|
bgGraph.getViewport().setMinY(0);
|
||||||
bgGraph.getViewport().setYAxisBoundsManual(true);
|
bgGraph.getViewport().setYAxisBoundsManual(true);
|
||||||
|
bgGraph.getGridLabelRenderer().setNumVerticalLabels(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package info.nightscout.androidaps.plugins.Overview;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.jjoe64.graphview.DefaultLabelFormatter;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 09.06.2016.
|
||||||
|
*/
|
||||||
|
public class TimeAsXAxisLabelFormatter extends DefaultLabelFormatter {
|
||||||
|
|
||||||
|
protected final String mFormat;
|
||||||
|
|
||||||
|
public TimeAsXAxisLabelFormatter(Context context, String format) {
|
||||||
|
mFormat = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String formatLabel(double value, boolean isValueX) {
|
||||||
|
if (isValueX) {
|
||||||
|
// format as date
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis((long) value);
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat(mFormat);
|
||||||
|
return dateFormat.format(calendar.getTimeInMillis());
|
||||||
|
} else {
|
||||||
|
return super.formatLabel(value, isValueX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package info.nightscout.androidaps.plugins;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 09.06.2016.
|
||||||
|
*/
|
||||||
|
public interface PluginBase {
|
||||||
|
int GENERAL = 1;
|
||||||
|
int PROFILE = 2;
|
||||||
|
int APS = 3;
|
||||||
|
int PUMP = 4;
|
||||||
|
|
||||||
|
public int getType();
|
||||||
|
public boolean isFragmentVisible();
|
||||||
|
}
|
|
@ -18,9 +18,10 @@ import java.text.DecimalFormat;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
|
import info.nightscout.androidaps.plugins.PluginBase;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
|
|
||||||
public class ProfileViewerFragment extends Fragment {
|
public class ProfileViewerFragment extends Fragment implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(ProfileViewerFragment.class);
|
private static Logger log = LoggerFactory.getLogger(ProfileViewerFragment.class);
|
||||||
|
|
||||||
private static TextView noProfile;
|
private static TextView noProfile;
|
||||||
|
@ -34,7 +35,15 @@ public class ProfileViewerFragment extends Fragment {
|
||||||
|
|
||||||
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
|
|
||||||
public ProfileViewerFragment() {
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.PROFILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFragmentVisible() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfileViewerFragment newInstance(String param1, String param2) {
|
public static ProfileViewerFragment newInstance(String param1, String param2) {
|
||||||
|
|
|
@ -35,9 +35,10 @@ import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempBasal;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
|
import info.nightscout.androidaps.plugins.PluginBase;
|
||||||
|
|
||||||
|
|
||||||
public class TempBasalsFragment extends Fragment {
|
public class TempBasalsFragment extends Fragment implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(TempBasalsFragment.class);
|
private static Logger log = LoggerFactory.getLogger(TempBasalsFragment.class);
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
@ -53,10 +54,19 @@ public class TempBasalsFragment extends Fragment {
|
||||||
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
private static DecimalFormat formatNumber3decimalplaces = new DecimalFormat("0.000");
|
private static DecimalFormat formatNumber3decimalplaces = new DecimalFormat("0.000");
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
|
||||||
|
|
||||||
private List<TempBasal> tempBasals;
|
private List<TempBasal> tempBasals;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.GENERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFragmentVisible() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void initializeData() {
|
private void initializeData() {
|
||||||
try {
|
try {
|
||||||
Dao<TempBasal, Long> dao = MainApp.getDbHelper().getDaoTempBasals();
|
Dao<TempBasal, Long> dao = MainApp.getDbHelper().getDaoTempBasals();
|
||||||
|
@ -221,31 +231,6 @@ public class TempBasalsFragment extends Fragment {
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// TODO: Rename method, update argument and hook method into UI event
|
|
||||||
public void onButtonPressed(Uri uri) {
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onFragmentInteraction(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
if (context instanceof OnFragmentInteractionListener) {
|
|
||||||
mListener = (OnFragmentInteractionListener) context;
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(context.toString()
|
|
||||||
+ " must implement OnFragmentInteractionListener");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetach() {
|
|
||||||
super.onDetach();
|
|
||||||
mListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerBus() {
|
private void registerBus() {
|
||||||
try {
|
try {
|
||||||
|
@ -293,19 +278,4 @@ public class TempBasalsFragment extends Fragment {
|
||||||
if (isVisibleToUser)
|
if (isVisibleToUser)
|
||||||
updateTotalIOBIfNeeded();
|
updateTotalIOBIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface must be implemented by activities that contain this
|
|
||||||
* fragment to allow an interaction in this fragment to be communicated
|
|
||||||
* to the activity and potentially other fragments contained in that
|
|
||||||
* activity.
|
|
||||||
* <p/>
|
|
||||||
* See the Android Training lesson <a href=
|
|
||||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
||||||
* >Communicating with Other Fragments</a> for more information.
|
|
||||||
*/
|
|
||||||
public interface OnFragmentInteractionListener {
|
|
||||||
// TODO: Update argument type and name
|
|
||||||
void onFragmentInteraction(String param);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,11 @@ import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
import info.nightscout.androidaps.plugins.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Dialogs.NewTreatmentDialogFragment;
|
import info.nightscout.androidaps.plugins.Treatments.Dialogs.NewTreatmentDialogFragment;
|
||||||
import info.nightscout.androidaps.Services.Intents;
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
|
|
||||||
public class TreatmentsFragment extends Fragment implements View.OnClickListener, NewTreatmentDialogFragment.Communicator {
|
public class TreatmentsFragment extends Fragment implements View.OnClickListener, NewTreatmentDialogFragment.Communicator, PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
|
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
@ -59,10 +60,19 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
private static DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
private static DecimalFormat formatNumber3decimalplaces = new DecimalFormat("0.000");
|
private static DecimalFormat formatNumber3decimalplaces = new DecimalFormat("0.000");
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
|
||||||
|
|
||||||
private List<Treatment> treatments;
|
private List<Treatment> treatments;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return PluginBase.GENERAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFragmentVisible() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void initializeData() {
|
private void initializeData() {
|
||||||
try {
|
try {
|
||||||
Dao<Treatment, Long> dao = MainApp.getDbHelper().getDaoTreatments();
|
Dao<Treatment, Long> dao = MainApp.getDbHelper().getDaoTreatments();
|
||||||
|
@ -222,23 +232,6 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
if (context instanceof OnFragmentInteractionListener) {
|
|
||||||
mListener = (OnFragmentInteractionListener) context;
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(context.toString()
|
|
||||||
+ " must implement OnFragmentInteractionListener");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetach() {
|
|
||||||
super.onDetach();
|
|
||||||
mListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerBus() {
|
private void registerBus() {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
@ -285,21 +278,6 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
updateTotalIOBIfNeeded();
|
updateTotalIOBIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface must be implemented by activities that contain this
|
|
||||||
* fragment to allow an interaction in this fragment to be communicated
|
|
||||||
* to the activity and potentially other fragments contained in that
|
|
||||||
* activity.
|
|
||||||
* <p/>
|
|
||||||
* See the Android Training lesson <a href=
|
|
||||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
||||||
* >Communicating with Other Fragments</a> for more information.
|
|
||||||
*/
|
|
||||||
public interface OnFragmentInteractionListener {
|
|
||||||
// TODO: Update argument type and name
|
|
||||||
void onFragmentInteraction(String param);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void treatmentDeliverRequest(Double insulin, Double carbs) {
|
public void treatmentDeliverRequest(Double insulin, Double carbs) {
|
||||||
// TODO: implement treatment delivery
|
// TODO: implement treatment delivery
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.tabs;
|
package info.nightscout.androidaps.tabs;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.PluralsRes;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
@ -8,6 +9,8 @@ import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.PluginBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 30.05.2016.
|
* Created by mike on 30.05.2016.
|
||||||
*/
|
*/
|
||||||
|
@ -39,12 +42,15 @@ public class TabPageAdapter extends FragmentPagerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int registerNewFragment(String name, Fragment fragment) {
|
public int registerNewFragment(String name, Fragment fragment) {
|
||||||
fragmentList.add(fragment);
|
if (((PluginBase) fragment).isFragmentVisible()){
|
||||||
Bundle args = new Bundle();
|
fragmentList.add(fragment);
|
||||||
args.putString("name", name);
|
Bundle args = new Bundle();
|
||||||
fragment.setArguments(args);
|
args.putString("name", name);
|
||||||
registeredTabs++;
|
fragment.setArguments(args);
|
||||||
notifyDataSetChanged();
|
registeredTabs++;
|
||||||
return registeredTabs-1;
|
notifyDataSetChanged();
|
||||||
|
return registeredTabs - 1;
|
||||||
|
}
|
||||||
|
return registeredTabs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue