I have created an application that sends data via Bluetooth. The application sends the corresponding seekBar value once it has been changed then updates the text view with a special value calculated from that seekBar value.
The problem is that there is a lag during the Bluetooth communication. I've determined that the lag comes from the update event of the textView:
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if(fromUser) {
switch (seekBar.getId()) {
case R.id.seek_bar_vario:
if (progress < 100) {
seekBarVarioDim.setProgressDrawable(getResources().getDrawable(R.drawable.warm_white_progress));
seekBarVarioDim.setThumb(getResources().getDrawable(R.drawable.warm_white_thumb));
} else if (progress > 150) {
seekBarVarioDim.setProgressDrawable(getResources().getDrawable(R.drawable.cool_white_progress));
seekBarVarioDim.setThumb(getResources().getDrawable(R.drawable.cool_white_thumb));
} else {
seekBarVarioDim.setProgressDrawable(getResources().getDrawable(R.drawable.netural_white_progress));
seekBarVarioDim.setThumb(getResources().getDrawable(R.drawable.netural_white_thumb));
}
varioLighting.setMessage(Constants.MESSAGE_NOP_ID);
varioLighting.setWarmWhiteRatio(255 - progress);
varioLighting.setCoolWhiteRatio(progress);
sendData(varioLighting.getStateMessage());
mVarioKelvin = 3000 + (int)(progress * 12);//11.76470588f);
//THE FOLLOWING LINE CAUSES THE LAG:
textViewVarioKelvinAndIntensity.setText(mVarioKelvin + "K - " + mVarioIntensity + "%");
break;
case R.id.seek_bar_vario_dim:
varioLighting.setMessage(Constants.MESSAGE_NOP_ID);
varioLighting.setIntensity(seekBarVarioDim.getProgress());
sendData(varioLighting.getStateMessage());
mVarioIntensity = (progress * 100) / 255;
//THE FOLLOWING LINE CAUSES THE LAG:
textViewVarioKelvinAndIntensity.setText(mVarioKelvin + "K - " + (mVarioIntensity) + "%");
break;
}
}
}
Even if I update the textView with a constant one-char string (e.g. "K"), it still causes the lag. If I remove that line(s) it works as I expected.
So, what can be the problem. And what should I do to fix that problem?