Back to project page HRForecast-WFM.
The source code is released under:
Copyright 2014 Ahmed Shafei
If you think the Android project HRForecast-WFM listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package de.hrf.workforcemanagement.listener; /*from w ww . j a v a2 s . c o m*/ import java.util.ArrayList; import android.app.Activity; import android.util.DisplayMetrics; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener; import de.hrf.workforcemanagement.dialog.MetadataListDialog; import de.hrf.workforcemanagement.models.MetadataList; import lecho.lib.hellocharts.model.BubbleValue; import lecho.lib.hellocharts.model.PointValue; import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.view.ComboLineColumnChartView.ComboLineColumnChartOnValueTouchListener; import lecho.lib.hellocharts.view.BubbleChartView.BubbleChartOnValueTouchListener; /** * Listener class responsible for showing the dialog popup when a chart entry is * selected. All chart fragments should use this interface to register a * callback for their charts. * */ public class ChartValueSelectedListener implements OnChartValueSelectedListener, ComboLineColumnChartOnValueTouchListener, BubbleChartOnValueTouchListener { private Activity activity; private int windowHeight, windowWidth; private ArrayList<? extends MetadataList> metadataList; /** * Constructs object of callback listener * * @param context * Activity context * @param metadataList * ArrayList of MetadataList * */ public ChartValueSelectedListener(Activity context, ArrayList<? extends MetadataList> metadataList) { this.activity = context; this.metadataList = metadataList; DisplayMetrics metrics = new DisplayMetrics(); context.getWindowManager().getDefaultDisplay().getMetrics(metrics); windowHeight = metrics.heightPixels; windowWidth = metrics.widthPixels; } /** * Called when a value has been selected inside the MPAndroid library charts * (Pie, Bar, StackedBar, Line, Radar charts). * * @param e * the selected entry * @param dataSetIndex * the index in the datasets array of the data object the Entrys * DataSet is in */ @Override public void onValueSelected(Entry e, int dataSetIndex) { showMetadataDialog(e.getXIndex()); } @Override public void onNothingSelected() { } /** * Called when a bar has been selected inside the * ComboLineColumnChartOnValueTouchListener (part of the HelloChart library) * * @param selectedBar * the number of the selected bar * @param selectedValue * the value of the selected bar * @param value * the value of the subcolumn selected */ @Override public void onColumnValueTouched(int selectedBar, int selectedValue, SubcolumnValue value) { showMetadataDialog(selectedBar); } /** * Called when a point has been selected inside the * ComboLineColumnChartOnValueTouchListener (part of the HelloChart library) * * @param selectedPoint * the number of the selected point * @param selectedValue * the value of the selected point * @param value * the point value selected */ @Override public void onPointValueTouched(int selectedPoint, int selectedValue, PointValue value) { showMetadataDialog(selectedPoint); } /** * Called when a bubble has been selected inside the * BubbleChartOnValueTouchListener (part of the HelloChart library) * * @param selectedBar * the number of the selected bar * @param selectedValue * the value of the selected bar * @param value * the bubble value selected */ @Override public void onValueTouched(int selectedBubble, BubbleValue value) { showMetadataDialog(selectedBubble); } @Override public void onValueDeselected() { // TODO Auto-generated method stub } private void showMetadataDialog(int selectedElement) { MetadataList entryMetadataList = metadataList.get(selectedElement); MetadataListDialog metadataDialog = new MetadataListDialog(activity, entryMetadataList.getMetaDataList(), windowWidth, windowHeight); metadataDialog.show(); } }