Search in sources :

Example 6 with LineChartView

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);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Button(android.widget.Button) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) LineChartView(lecho.lib.hellocharts.view.LineChartView) WatchViewStub(android.support.wearable.view.WatchViewStub) LinearLayout(android.widget.LinearLayout)

Example 7 with LineChartView

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);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Button(android.widget.Button) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) LineChartView(lecho.lib.hellocharts.view.LineChartView) WatchViewStub(android.support.wearable.view.WatchViewStub) LinearLayout(android.widget.LinearLayout)

Example 8 with LineChartView

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;
}
Also used : ScaleMeasurement(com.health.openscale.core.datatypes.ScaleMeasurement) ColorStateList(android.content.res.ColorStateList) List(java.util.List) ArrayList(java.util.ArrayList) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) FloatMeasurementView(com.health.openscale.gui.views.FloatMeasurementView) TextView(android.widget.TextView) MeasurementView(com.health.openscale.gui.views.MeasurementView) BMRMeasurementView(com.health.openscale.gui.views.BMRMeasurementView) LineChartView(lecho.lib.hellocharts.view.LineChartView) WeightMeasurementView(com.health.openscale.gui.views.WeightMeasurementView) ColumnChartView(lecho.lib.hellocharts.view.ColumnChartView) PopupMenu(android.widget.PopupMenu)

Aggregations

LineChartView (lecho.lib.hellocharts.view.LineChartView)8 TextView (android.widget.TextView)6 RelativeLayout (android.widget.RelativeLayout)5 Context (android.content.Context)4 IntentFilter (android.content.IntentFilter)4 WatchViewStub (android.support.wearable.view.WatchViewStub)4 Button (android.widget.Button)4 LinearLayout (android.widget.LinearLayout)4 View (android.view.View)2 ImageView (android.widget.ImageView)2 BgGraphBuilder (com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder)2 ArrayList (java.util.ArrayList)2 Viewport (lecho.lib.hellocharts.model.Viewport)2 ColumnChartView (lecho.lib.hellocharts.view.ColumnChartView)2 ColorStateList (android.content.res.ColorStateList)1 Point (android.graphics.Point)1 ViewPager (android.support.v4.view.ViewPager)1 DisplayMetrics (android.util.DisplayMetrics)1 MenuItem (android.view.MenuItem)1 ViewTreeObserver (android.view.ViewTreeObserver)1