use of lecho.lib.hellocharts.view.LineChartView in project xDrip by NightscoutFoundation.
the class BIGChart method performViewSetup.
public void performViewSetup() {
final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
messageReceiver = new MessageReceiver();
localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTime = (TextView) stub.findViewById(R.id.watch_time);
mDate = (TextView) stub.findViewById(R.id.watch_date);
mSgv = (TextView) stub.findViewById(R.id.sgv);
mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
mDelta = (TextView) stub.findViewById(R.id.delta);
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
chart = (LineChartView) stub.findViewById(R.id.chart);
statusView = (TextView) stub.findViewById(R.id.aps_status);
stepsButton = (Button) stub.findViewById(R.id.walkButton);
mStepsLinearLayout = (LinearLayout) stub.findViewById(R.id.steps_layout);
menuButton = (Button) stub.findViewById(R.id.menuButton);
mMenuLinearLayout = (LinearLayout) stub.findViewById(R.id.menu_layout);
mDirectionDelta = (LinearLayout) stub.findViewById(R.id.directiondelta_layout);
layoutSet = true;
Context context = xdrip.getAppContext();
if (Home.get_forced_wear()) {
if (d)
Log.d(TAG, "performViewSetup FORCE WEAR init BGs for graph");
BgSendQueue.resendData(context);
}
if ((chart != null) && sharedPrefs.getBoolean("show_wear_treatments", false)) {
if (d)
Log.d(TAG, "performViewSetup init Treatments for graph");
ListenerService.showTreatments(context, "all");
}
showAgeAndStatus();
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight());
}
});
Log.d(TAG, "performViewSetup requestData");
ListenerService.requestData(this);
wakeLock.acquire(50);
}
use of lecho.lib.hellocharts.view.LineChartView in project xDrip-plus by jamorham.
the class BaseWatchFace method performViewSetup.
public void performViewSetup() {
final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
messageReceiver = new MessageReceiver();
localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTime = (TextView) stub.findViewById(R.id.watch_time);
mDate = (TextView) stub.findViewById(R.id.watch_date);
mSgv = (TextView) stub.findViewById(R.id.sgv);
mDirection = (TextView) stub.findViewById(R.id.direction);
mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
mStatus = (TextView) stub.findViewById(R.id.externaltstatus);
mRaw = (TextView) stub.findViewById(R.id.raw);
mUploaderBattery = (TextView) stub.findViewById(R.id.uploader_battery);
mUploaderXBattery = (TextView) stub.findViewById(R.id.uploader_xbattery);
mDelta = (TextView) stub.findViewById(R.id.delta);
stepsButton = (Button) stub.findViewById(R.id.walkButton);
try {
heartButton = (Button) stub.findViewById(R.id.heartButton);
} catch (Exception e) {
//
}
mStepsLinearLayout = (LinearLayout) stub.findViewById(R.id.steps_layout);
menuButton = (Button) stub.findViewById(R.id.menuButton);
mMenuLinearLayout = (LinearLayout) stub.findViewById(R.id.menu_layout);
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout);
mDirectionDelta = (LinearLayout) stub.findViewById(R.id.directiondelta_layout);
setSmallFontsize(false);
chart = (LineChartView) stub.findViewById(R.id.chart);
layoutSet = true;
Context context = xdrip.getAppContext();
if (Home.get_forced_wear()) {
if (d)
Log.d(TAG, "performViewSetup FORCE WEAR init BGs for graph");
BgSendQueue.resendData(context);
}
if ((chart != null) && sharedPrefs.getBoolean("show_wear_treatments", false)) {
if (d)
Log.d(TAG, "performViewSetup init Treatments for graph");
ListenerService.showTreatments(context, "all");
}
showAgoRawBattStatus();
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight());
showSteps();
showHeartRate();
}
});
Log.d(TAG, "performViewSetup requestData");
ListenerService.requestData(this);
wakeLock.acquire(50);
}
use of lecho.lib.hellocharts.view.LineChartView in project openScale by oliexdev.
the class GraphFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
openScale = OpenScale.getInstance(getContext());
if (savedInstanceState == null) {
List<ScaleMeasurement> scaleMeasurementList = openScale.getScaleMeasurementList();
if (!scaleMeasurementList.isEmpty()) {
calYears.setTime(scaleMeasurementList.get(0).getDateTime());
calLastSelected.setTime(scaleMeasurementList.get(0).getDateTime());
}
} else {
calYears.setTimeInMillis(savedInstanceState.getLong(CAL_YEARS_KEY));
calLastSelected.setTimeInMillis(savedInstanceState.getLong(CAL_LAST_SELECTED_KEY));
}
graphView = inflater.inflate(R.layout.fragment_graph, container, false);
chartBottom = (LineChartView) graphView.findViewById(R.id.chart_bottom);
chartTop = (ColumnChartView) graphView.findViewById(R.id.chart_top);
chartBottom.setOnTouchListener(new chartBottomListener());
chartBottom.setOnValueTouchListener(new chartBottomValueTouchListener());
chartTop.setOnValueTouchListener(new chartTopValueTouchListener());
// HACK: get default text color from hidden text view to set the correct axis colors
textColor = ((TextView) graphView.findViewById(R.id.colorHack)).getCurrentTextColor();
txtYear = (TextView) graphView.findViewById(R.id.txtYear);
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
floatingActionBar = (LinearLayout) graphView.findViewById(R.id.floatingActionBar);
optionMenu = (ImageView) graphView.findViewById(R.id.optionMenu);
optionMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popup.show();
}
});
btnLeftYear = graphView.findViewById(R.id.btnLeftYear);
btnLeftYear.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
calYears.roll(Calendar.YEAR, false);
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
List<ScaleMeasurement> scaleMeasurementList = OpenScale.getInstance(getContext()).getScaleDataOfYear(calYears.get(Calendar.YEAR));
if (!scaleMeasurementList.isEmpty()) {
calLastSelected.setTime(scaleMeasurementList.get(0).getDateTime());
}
generateGraphs();
}
});
btnRightYear = graphView.findViewById(R.id.btnRightYear);
btnRightYear.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
calYears.roll(Calendar.YEAR, true);
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
List<ScaleMeasurement> scaleMeasurementList = OpenScale.getInstance(getContext()).getScaleDataOfYear(calYears.get(Calendar.YEAR));
if (!scaleMeasurementList.isEmpty()) {
calLastSelected.setTime(scaleMeasurementList.get(scaleMeasurementList.size() - 1).getDateTime());
}
generateGraphs();
}
});
measurementViews = MeasurementView.getMeasurementList(getContext(), MeasurementView.DateTimeOrder.NONE);
popup = new PopupMenu(getContext(), optionMenu);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.enableMonth:
if (item.isChecked()) {
item.setChecked(false);
prefs.edit().putBoolean("showMonth", false).commit();
} else {
item.setChecked(true);
prefs.edit().putBoolean("showMonth", true).commit();
}
generateGraphs();
return true;
case R.id.enableWeek:
if (item.isChecked()) {
item.setChecked(false);
prefs.edit().putBoolean("showWeek", false).commit();
} else {
item.setChecked(true);
prefs.edit().putBoolean("showWeek", true).commit();
}
generateGraphs();
return true;
default:
return false;
}
}
});
popup.getMenuInflater().inflate(R.menu.graph_menu, popup.getMenu());
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
MenuItem enableMonth = popup.getMenu().findItem(R.id.enableMonth);
enableMonth.setChecked(prefs.getBoolean("showMonth", true));
MenuItem enableWeek = popup.getMenu().findItem(R.id.enableWeek);
enableWeek.setChecked(prefs.getBoolean("showWeek", false));
openScale.registerFragment(this);
return graphView;
}
Aggregations