remove butterknife from HistoryBrowseActivity
This commit is contained in:
parent
607d7c4b24
commit
9226a561db
|
@ -2,9 +2,6 @@ package info.nightscout.androidaps.activities;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -15,6 +12,9 @@ import android.widget.ImageButton;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||||
|
@ -25,10 +25,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import butterknife.OnLongClick;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -36,12 +32,12 @@ import info.nightscout.androidaps.events.EventCustomCalculationFinished;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
|
@ -55,19 +51,12 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
||||||
boolean showIob, showCob, showDev, showRat, showActPrim, showActSec, showDevslope;
|
boolean showIob, showCob, showDev, showRat, showActPrim, showActSec, showDevslope;
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.historybrowse_date)
|
|
||||||
Button buttonDate;
|
Button buttonDate;
|
||||||
@BindView(R.id.historybrowse_zoom)
|
|
||||||
Button buttonZoom;
|
Button buttonZoom;
|
||||||
@BindView(R.id.historyybrowse_bggraph)
|
|
||||||
GraphView bgGraph;
|
GraphView bgGraph;
|
||||||
@BindView(R.id.historybrowse_iobgraph)
|
|
||||||
GraphView iobGraph;
|
GraphView iobGraph;
|
||||||
@BindView(R.id.historybrowse_seekBar)
|
|
||||||
SeekBar seekBar;
|
SeekBar seekBar;
|
||||||
@BindView(R.id.historybrowse_noprofile)
|
|
||||||
TextView noProfile;
|
TextView noProfile;
|
||||||
@BindView(R.id.overview_iobcalculationprogess)
|
|
||||||
TextView iobCalculationProgressView;
|
TextView iobCalculationProgressView;
|
||||||
|
|
||||||
private int rangeToDisplay = 24; // for graph
|
private int rangeToDisplay = 24; // for graph
|
||||||
|
@ -86,7 +75,79 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_historybrowse);
|
setContentView(R.layout.activity_historybrowse);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
buttonDate = findViewById(R.id.historybrowse_date);
|
||||||
|
buttonZoom = findViewById(R.id.historybrowse_zoom);
|
||||||
|
bgGraph = findViewById(R.id.historyybrowse_bggraph);
|
||||||
|
iobGraph = findViewById(R.id.historybrowse_iobgraph);
|
||||||
|
seekBar = findViewById(R.id.historybrowse_seekBar);
|
||||||
|
noProfile = findViewById(R.id.historybrowse_noprofile);
|
||||||
|
iobCalculationProgressView = findViewById(R.id.overview_iobcalculationprogess);
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_left).setOnClickListener(v -> {
|
||||||
|
start -= T.hours(rangeToDisplay).msecs();
|
||||||
|
updateGUI("onClickLeft");
|
||||||
|
runCalculation("onClickLeft");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_right).setOnClickListener(v -> {
|
||||||
|
start += T.hours(rangeToDisplay).msecs();
|
||||||
|
updateGUI("onClickRight");
|
||||||
|
runCalculation("onClickRight");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_end).setOnClickListener(v -> {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
start = calendar.getTimeInMillis();
|
||||||
|
updateGUI("onClickEnd");
|
||||||
|
runCalculation("onClickEnd");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_zoom).setOnClickListener(v -> {
|
||||||
|
rangeToDisplay += 6;
|
||||||
|
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||||
|
updateGUI("rangeChange");
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_zoom).setOnLongClickListener(v -> {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(start);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
start = calendar.getTimeInMillis();
|
||||||
|
updateGUI("resetToMidnight");
|
||||||
|
runCalculation("onLongClickZoom");
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.historybrowse_date).setOnClickListener(v -> {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(new Date(start));
|
||||||
|
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
||||||
|
(view, year, monthOfYear, dayOfMonth) -> {
|
||||||
|
Date date = new Date(0);
|
||||||
|
date.setYear(year - 1900);
|
||||||
|
date.setMonth(monthOfYear);
|
||||||
|
date.setDate(dayOfMonth);
|
||||||
|
date.setHours(0);
|
||||||
|
start = date.getTime();
|
||||||
|
updateGUI("onClickDate");
|
||||||
|
runCalculation("onClickDate");
|
||||||
|
},
|
||||||
|
calendar.get(Calendar.YEAR),
|
||||||
|
calendar.get(Calendar.MONTH),
|
||||||
|
calendar.get(Calendar.DAY_OF_MONTH)
|
||||||
|
);
|
||||||
|
dpd.setThemeDark(true);
|
||||||
|
dpd.dismissOnPause(true);
|
||||||
|
dpd.show(getFragmentManager(), "Datepickerdialog");
|
||||||
|
});
|
||||||
|
|
||||||
bgGraph.getGridLabelRenderer().setGridColor(MainApp.gc(R.color.graphgrid));
|
bgGraph.getGridLabelRenderer().setGridColor(MainApp.gc(R.color.graphgrid));
|
||||||
bgGraph.getGridLabelRenderer().reloadStyles();
|
bgGraph.getGridLabelRenderer().reloadStyles();
|
||||||
|
@ -124,78 +185,6 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
||||||
updateGUI("onResume");
|
updateGUI("onResume");
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_left)
|
|
||||||
void onClickLeft() {
|
|
||||||
start -= T.hours(rangeToDisplay).msecs();
|
|
||||||
updateGUI("onClickLeft");
|
|
||||||
runCalculation("onClickLeft");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_right)
|
|
||||||
void onClickRight() {
|
|
||||||
start += T.hours(rangeToDisplay).msecs();
|
|
||||||
updateGUI("onClickRight");
|
|
||||||
runCalculation("onClickRight");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_end)
|
|
||||||
void onClickEnd() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
start = calendar.getTimeInMillis();
|
|
||||||
updateGUI("onClickEnd");
|
|
||||||
runCalculation("onClickEnd");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_zoom)
|
|
||||||
void onClickZoom() {
|
|
||||||
rangeToDisplay += 6;
|
|
||||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
|
||||||
updateGUI("rangeChange");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnLongClick(R.id.historybrowse_zoom)
|
|
||||||
boolean onLongClickZoom() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(start);
|
|
||||||
calendar.set(Calendar.MILLISECOND, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
start = calendar.getTimeInMillis();
|
|
||||||
updateGUI("resetToMidnight");
|
|
||||||
runCalculation("onLongClickZoom");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClick(R.id.historybrowse_date)
|
|
||||||
void onClickDate() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(new Date(start));
|
|
||||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
|
||||||
(view, year, monthOfYear, dayOfMonth) -> {
|
|
||||||
Date date = new Date(0);
|
|
||||||
date.setYear(year - 1900);
|
|
||||||
date.setMonth(monthOfYear);
|
|
||||||
date.setDate(dayOfMonth);
|
|
||||||
date.setHours(0);
|
|
||||||
start = date.getTime();
|
|
||||||
updateGUI("onClickDate");
|
|
||||||
runCalculation("onClickDate");
|
|
||||||
},
|
|
||||||
calendar.get(Calendar.YEAR),
|
|
||||||
calendar.get(Calendar.MONTH),
|
|
||||||
calendar.get(Calendar.DAY_OF_MONTH)
|
|
||||||
);
|
|
||||||
dpd.setThemeDark(true);
|
|
||||||
dpd.dismissOnPause(true);
|
|
||||||
dpd.show(getFragmentManager(), "Datepickerdialog");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runCalculation(String from) {
|
private void runCalculation(String from) {
|
||||||
long end = start + T.hours(rangeToDisplay).msecs();
|
long end = start + T.hours(rangeToDisplay).msecs();
|
||||||
iobCobCalculatorPlugin.stopCalculation(from);
|
iobCobCalculatorPlugin.stopCalculation(from);
|
||||||
|
|
Loading…
Reference in a new issue