Thread를 돌려 count를 증가시키고 textView에 append 하여 데이터를 뿌려주는 기능을 추가하고있습니다.
set Text를 했을 때는 이상 없이 잘되는데, append를 하게 되면 textView에 많은 텍스트가 쌓여서 그런건지
점차 느려지는 현상을 보이고 있습니다. 아래 쓰레드와 함수 첨부하였습니다.
// Thread Class
public class ReadThread implements Runnable {
private WeakReference<MainActivity> activityRef = null;
public Message msg = null;
public ReadThread(MainActivity activity){
this.activityRef = new WeakReference<MainActivity>(activity);
msg = new Message();
}
@Override
public void run() {
try{
while(!Thread.currentThread().isInterrupted())
{
GetDataFromNative(); // Data 받는 함수
UpdateUI(); // Data를 가지고 textView append 하는 함수.
Thread.sleep(100);
}
}catch(InterruptedException ie){
Log.e(TAG,"InterruptedException");
}
catch(RuntimeException ee){
Log.e(TAG,"RuntimeException");
}
}
}
public void GetDataFromNative() {
runOnUiThread(new Runnable() {
@Override
public void run() {
SA = CAN1Comm.Get_RX_SOURCEADDR();
PS = CAN1Comm.Get_RX_PS();
PF = CAN1Comm.Get_RX_PF();
PRIORITY = CAN1Comm.Get_RX_PRIORITY();
i = i + 1;
}
});
}
public void UpdateUI() {
// TODO Auto-generated method stub
runOnUiThread(new Runnable() {
@Override
public void run() {
//readThread.interrupt();
//Log.d(TAG, "Update UI");
// TODO Auto-generated method stub
//StringBuilder sb = new StringBuilder("\n + i" + i);
textView.append("\n SA : " + SA + " PS : " + PS + " PF : " + PF + " PRIORITY : " + PRIORITY + " i : " + i);
//autoScrollBottom(textView);
//readThread.run();
}
});
}
다음과 같이 두함수를 반복해서 textView에 append 하고 있지만 일정 크기 이상 되면 느려지는 현상이 나타납니다. runOnUiThread도 사용하였고, post, postDelayed 다사용해 보았지만 현상 개선이 안되서 질문 드립니다. 혹시 TextView에 쓸수 있는 최대 버퍼 크기가 따로 정해져있는지도 궁금합니다.