Search in sources :

Example 1 with WaterMeasurementView

use of com.health.openscale.gui.views.WaterMeasurementView in project openScale by oliexdev.

the class StatisticsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    statisticsView = inflater.inflate(R.layout.fragment_statistics, container, false);
    // Set android:tint="?attr/editTextColor" programmatically as setting it in xml layout
    // throws an exception on API 19.
    int color = new EditText(getContext()).getCurrentTextColor();
    for (int id : new int[] { R.id.imageGoalWeight, R.id.imageGoalDiff, R.id.imageDayLeft }) {
        ImageView image = statisticsView.findViewById(id);
        image.setColorFilter(color);
    }
    txtGoalWeight = (TextView) statisticsView.findViewById(R.id.txtGoalWeight);
    txtGoalDiff = (TextView) statisticsView.findViewById(R.id.txtGoalDiff);
    txtGoalDayLeft = (TextView) statisticsView.findViewById(R.id.txtGoalDayLeft);
    txtLabelGoalWeight = (TextView) statisticsView.findViewById(R.id.txtLabelGoalWeight);
    txtLabelGoalDiff = (TextView) statisticsView.findViewById(R.id.txtLabelGoalDiff);
    txtLabelDayLeft = (TextView) statisticsView.findViewById(R.id.txtLabelDayLeft);
    tableWeekAveragesLayoutColumnA = (TableLayout) statisticsView.findViewById(R.id.tableWeekAveragesLayoutColumnA);
    tableWeekAveragesLayoutColumnB = (TableLayout) statisticsView.findViewById(R.id.tableWeekAveragesLayoutColumnB);
    tableMonthAveragesLayoutColumnA = (TableLayout) statisticsView.findViewById(R.id.tableMonthAveragesLayoutColumnA);
    tableMonthAveragesLayoutColumnB = (TableLayout) statisticsView.findViewById(R.id.tableMonthAveragesLayoutColumnB);
    viewMeasurementsListWeek = new ArrayList<>();
    viewMeasurementsListWeek.add(new WeightMeasurementView(statisticsView.getContext()));
    viewMeasurementsListWeek.add(new WaterMeasurementView(statisticsView.getContext()));
    viewMeasurementsListWeek.add(new MuscleMeasurementView(statisticsView.getContext()));
    viewMeasurementsListWeek.add(new LBWMeasurementView(statisticsView.getContext()));
    viewMeasurementsListWeek.add(new FatMeasurementView(statisticsView.getContext()));
    viewMeasurementsListWeek.add(new BoneMeasurementView(statisticsView.getContext()));
    viewMeasurementsListWeek.add(new WaistMeasurementView(statisticsView.getContext()));
    viewMeasurementsListWeek.add(new HipMeasurementView(statisticsView.getContext()));
    final int paddingBottom = 10;
    int i = 0;
    for (MeasurementView measurement : viewMeasurementsListWeek) {
        measurement.setEditMode(STATISTIC);
        if (measurement.getSettings().isEnabled()) {
            measurement.setVisible(true);
            measurement.setPadding(-1, -1, -1, paddingBottom);
            if ((i % 2) == 0) {
                tableWeekAveragesLayoutColumnA.addView(measurement);
            } else {
                tableWeekAveragesLayoutColumnB.addView(measurement);
            }
            i++;
        }
    }
    viewMeasurementsListMonth = new ArrayList<>();
    viewMeasurementsListMonth.add(new WeightMeasurementView(statisticsView.getContext()));
    viewMeasurementsListMonth.add(new WaterMeasurementView(statisticsView.getContext()));
    viewMeasurementsListMonth.add(new MuscleMeasurementView(statisticsView.getContext()));
    viewMeasurementsListMonth.add(new LBWMeasurementView(statisticsView.getContext()));
    viewMeasurementsListMonth.add(new FatMeasurementView(statisticsView.getContext()));
    viewMeasurementsListMonth.add(new BoneMeasurementView(statisticsView.getContext()));
    viewMeasurementsListMonth.add(new WaistMeasurementView(statisticsView.getContext()));
    viewMeasurementsListMonth.add(new HipMeasurementView(statisticsView.getContext()));
    i = 0;
    for (MeasurementView measurement : viewMeasurementsListMonth) {
        measurement.setEditMode(STATISTIC);
        if (measurement.getSettings().isEnabled()) {
            measurement.setVisible(true);
            measurement.setPadding(-1, -1, -1, paddingBottom);
            if ((i % 2) == 0) {
                tableMonthAveragesLayoutColumnA.addView(measurement);
            } else {
                tableMonthAveragesLayoutColumnB.addView(measurement);
            }
            i++;
        }
    }
    OpenScale.getInstance(getContext()).registerFragment(this);
    return statisticsView;
}
Also used : EditText(android.widget.EditText) LBWMeasurementView(com.health.openscale.gui.views.LBWMeasurementView) FatMeasurementView(com.health.openscale.gui.views.FatMeasurementView) HipMeasurementView(com.health.openscale.gui.views.HipMeasurementView) BoneMeasurementView(com.health.openscale.gui.views.BoneMeasurementView) MuscleMeasurementView(com.health.openscale.gui.views.MuscleMeasurementView) WaistMeasurementView(com.health.openscale.gui.views.WaistMeasurementView) WaterMeasurementView(com.health.openscale.gui.views.WaterMeasurementView) WeightMeasurementView(com.health.openscale.gui.views.WeightMeasurementView) MeasurementView(com.health.openscale.gui.views.MeasurementView) BoneMeasurementView(com.health.openscale.gui.views.BoneMeasurementView) WeightMeasurementView(com.health.openscale.gui.views.WeightMeasurementView) WaistMeasurementView(com.health.openscale.gui.views.WaistMeasurementView) WaterMeasurementView(com.health.openscale.gui.views.WaterMeasurementView) LBWMeasurementView(com.health.openscale.gui.views.LBWMeasurementView) FatMeasurementView(com.health.openscale.gui.views.FatMeasurementView) HipMeasurementView(com.health.openscale.gui.views.HipMeasurementView) MuscleMeasurementView(com.health.openscale.gui.views.MuscleMeasurementView) ImageView(android.widget.ImageView)

Aggregations

EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 BoneMeasurementView (com.health.openscale.gui.views.BoneMeasurementView)1 FatMeasurementView (com.health.openscale.gui.views.FatMeasurementView)1 HipMeasurementView (com.health.openscale.gui.views.HipMeasurementView)1 LBWMeasurementView (com.health.openscale.gui.views.LBWMeasurementView)1 MeasurementView (com.health.openscale.gui.views.MeasurementView)1 MuscleMeasurementView (com.health.openscale.gui.views.MuscleMeasurementView)1 WaistMeasurementView (com.health.openscale.gui.views.WaistMeasurementView)1 WaterMeasurementView (com.health.openscale.gui.views.WaterMeasurementView)1 WeightMeasurementView (com.health.openscale.gui.views.WeightMeasurementView)1