In my application I have some bar charts using MPAndroidChart, when I touch in one bar an activity opens showing some informations about the value selected. I'm using "OnChartValueSelectedListener" to do that.
The problem is which this is too much sensible to touch. When I touch the screen just to scroll it, if I touch in one value, one activity opens.
I'm looking for something like "OnLongClickListener" to avoid the activity to be opened every time I touch the bars. But I could not find anything. There's some way to emulate an "long touch value" on MP Android Chart?
That is part of my code:
mChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
// registra o estado da selecao para chamar esta funcao na funcao onNothingSelected
entry = e;
index = dataSetIndex;
highlight = h;
// caso algum cliente tenha sido cadastrado no dia selecionado
if(e.getVal() > 0) {
ViewUtil.exibirMensagemAguarde(R.string.aguarde, R.string.carregando_dados, OverviewActivity.this);
// guarda os dados para serem usados pelo metodo onNothingSelected
entry = e;
index = dataSetIndex;
highlight = h;
// obtem o ano atual
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
// obtem o dia selecionado e concatena o ano atual
dateSelected = xVals.get(h.getXIndex()) + "/" + currentYear;
// chama a tarefa assincrona que obtem os clientes cadastrados no dia selecionado
// e abre a activity
ClientesCadastradosDiaAsync task = new ClientesCadastradosDiaAsync();
task.execute();
}
}
@Override
public void onNothingSelected(){
onValueSelected(entry, index, highlight);
}
});