private void showRecoedData(int[] recordMsgBuffer) { generateDefaultData(recordMsgBuffer); // Viewport maxV=recordChart.getMaximumViewport(); // recordChart.setMaximumViewport(new Viewport(maxV.left, 100, maxV.right, 0)); recordChart.setLineChartData(data); recordChart.setZoomEnabled(false); recordChart.setScrollEnabled(false); recordPreviewChart.setLineChartData(previewData); recordPreviewChart.setViewportChangeListener(new ViewportListener()); previewX(false); disRecordHideReal(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment setHasOptionsMenu(true); View rootView = inflater.inflate(R.layout.fragment_temperature, container, false); chart = (LineChartView) rootView.findViewById(R.id.chart); previewChart = (PreviewLineChartView) rootView.findViewById(R.id.chart_preview); // Generate data for previewed chart and copy of that data for preview chart. if (getArguments() != null) { temperatureData = getArguments(); latitude = temperatureData.getFloat("latitude"); longitude = temperatureData.getFloat("longitude"); temperatures = temperatureData.getDoubleArray("temperatureArr"); times = temperatureData.getIntArray("timeArr"); numData = temperatureData.getInt("numData"); Log.d("ARRAY", Arrays.toString(temperatures)); Log.d("ARRAY", Arrays.toString(times)); getForecastData(); Log.d("receiver", "OK"); } else { generateDefaultData(); } chart.setLineChartData(data); // Disable zoom/scroll for previewed chart, visible chart ranges depends on preview chart // viewport so // zoom/scroll is unnecessary. chart.setZoomEnabled(false); chart.setScrollEnabled(false); previewChart.setLineChartData(previewData); previewChart.setViewportChangeListener(new ViewportListener()); previewX(false); return rootView; }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); chart = (LineChartView) view.findViewById(R.id.chart); chart.setLineChartData(data); chart.setZoomEnabled(true); chart.setScrollEnabled(true); previewChart = (PreviewLineChartView) view.findViewById(R.id.chart_preview); previewChart.setLineChartData(previewData); previewChart.setViewportChangeListener(new ViewportListener()); final Button selectButton = (Button) view.findViewById(R.id.button_left); selectButton.setText(selectString[userChoice]); selectButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (dialogSelect == null) { dialogSelect = new Dialog(v.getContext()); } dialogSelect.setContentView(R.layout.dialog_select); dialogSelect.setTitle(dialogSelectPeriodTitle); numberPicker = (NumberPicker) dialogSelect.findViewById(R.id.number_picker); numberPicker.setMinValue(0); numberPicker.setMaxValue(selectString.length - 1); numberPicker.setDisplayedValues(selectString); numberPicker.setWrapSelectorWheel(true); Button dialogButton = (Button) dialogSelect.findViewById(R.id.apply_button_select); dialogButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { userChoice = numberPicker.getValue(); selectButton.setText(selectString[userChoice]); dialogSelect.dismiss(); dateButton.callOnClick(); } }); dialogSelect.show(); } }); dateButton = (Button) view.findViewById(R.id.button_right); if (pickedCalendar == null) { dateButton.setText("Datum"); } else { setDateButtonText(); } dateButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (dialog == null) { dialog = new Dialog(v.getContext()); } switch (userChoice) { case DAY: case WEEK: dialog.setContentView(R.layout.dialog); datePicker = (DatePicker) dialog.findViewById(R.id.dpResult); break; case MONTH: dialog.setContentView(R.layout.dialog_month); monthPicker = (NumberPicker) dialog.findViewById(R.id.picker_month_month); monthPicker.setMinValue(0); monthPicker.setMaxValue(11); monthPicker.setDisplayedValues(monthString); monthPicker.setWrapSelectorWheel(true); yearPicker = (NumberPicker) dialog.findViewById(R.id.picker_month_year); yearPicker.setMinValue(2015); yearPicker.setMaxValue(2100); yearPicker.setWrapSelectorWheel(true); break; case YEAR: dialog.setContentView(R.layout.dialog_year); yearPicker = (NumberPicker) dialog.findViewById(R.id.picker_year_year); yearPicker.setMinValue(2015); yearPicker.setMaxValue(2100); yearPicker.setWrapSelectorWheel(true); break; } dialog.setTitle(dialogSelectDateTilte); Button dialogButton = (Button) dialog.findViewById(R.id.apply_button); dialogButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setPickedDate(); handleUserChoice(); updateChartView(); dialog.dismiss(); } }); dialog.show(); } }); updateChartView(); }