1. Are you ready for the Galaxy S20? Here is everything we know so far!

TextView Slow what's the solution?

Discussion in 'Android Development' started by Sy Roz, Mar 10, 2016.

  1. Sy Roz

    Sy Roz Newbie
    Thread Starter

    Hello to everyone...

    So what's the issue I have is that the TextView become slow after a wile when its buffer gets full with information... You see it's reprints evry time entire buffer if it wold just append like it sounds that would not be happening. The speed of incoming information is 100ms.. So the textView gets freeze pretty fast.. .If Im delitting part of information it's become fast againt.. But I need to save it...
    What I need is the solution Im pretty sure already exists in many different ways... Is that the textView reads the info to print from something like external buffer (String) just partly. Lets says its showing just a hundred last lines and if i scroll up it's downloads from that buffer what before that 100s? So how to that? It should called like textView control can't find really any info close to what I need.


    Code (Text):
    1.   case ListPaireeDeviceActivity.MESSAGE_READ:
    2.  
    3.                     final String readMessage = (String) msg.obj;
    4.  
    5.  
    6.                                    if(readMessage.contains(">")){
    7.                                        textView_terminal.append(readMessage  +"\n" );
    8.  
    9.                                    }else {
    10.                                        textView_terminal.append(readMessage );
    11.                                    }
    12.                        // textView_terminal.setText(readMessage);
    13.  
    14.                     }
    15.                     break;
     


  2. Deleted User

    Deleted User Guest

    Just a suggestion but if the frequency of incoming messages is so rapid, why don't you batch them up and only write to the TextView when you receive, say 10 or 20 messages? That would give a 1 or 2 second update frequency.

    Also what piece of code is receiving these messages? Reason for asking that is if you have this going in your main UI thread, it may cause performance problems. Normally you will get runtime warning messages if you are doing too much work on the main thread.
     
  3. Sy Roz

    Sy Roz Newbie
    Thread Starter

    No it's over bluetooth "Connected" thread.. So nothing to do with main... And no this is not a solution getting 10 massages and print them as bunch.. Im trying to builled a terminal... if hardware can why the soft won't? But thanks for respond.
    So seems like it's got to be like that.... The all incoming readMessage should be buffered in String or something maybe arrays and the only part of that should be shown in the TextView... Like last a 100 lines. And also nothing losted and I have access to it at my convenience.
    Im sure theres a solution out there. just what's name of it?

    Code (Text):
    1.  public void run() {
    2.  
    3.             Log.d(TAG2, "run start");
    4.             byte[] buffer = new byte[512];  // buffer store for the stream
    5.             int intBytes; // bytes returned from read()
    6.  
    7.             // Keep listening to the InputStream until an exception occurs
    8.             StringBuilder readMessage = new StringBuilder();
    9.  
    10.  
    11.             while (true) {
    12.                 try {
    13.  
    14.                     intBytes = mmInStream.read(buffer);
    15.                     String readed = new String(buffer, 0, intBytes);
    16.                     readMessage.append(readed);
    17.  
    18.                 //    if (readed.contains("\n") || readed.contains(">")) {
    19.                                                                                // readMessage.toString() активити.
    20.                         mHandler.obtainMessage(MESSAGE_READ, intBytes, -1, readMessage.toString()).sendToTarget();
    21.  
    22.                         readMessage.setLength(0); //
    23.  
    24.                   //  }
    25.  
     
    #3 Sy Roz, Mar 10, 2016
    Last edited: Mar 10, 2016
Loading...
Similar Threads - TextView Slow what's
  1. Ronald Scholten
    Replies:
    0
    Views:
    417
  2. Cinemato
    Replies:
    0
    Views:
    468
  3. CitingGazelle
    Replies:
    1
    Views:
    610
  4. UmBottesWillen
    Replies:
    1
    Views:
    413
  5. Greum
    Replies:
    20
    Views:
    700
  6. irajfacebook84
    Replies:
    0
    Views:
    362
  7. Lampros_36
    Replies:
    3
    Views:
    905
  8. Greum
    Replies:
    2
    Views:
    1,911
  9. BobAchgill
    Replies:
    0
    Views:
    465
  10. Sean Meagher
    Replies:
    2
    Views:
    549

Share This Page

Loading...