java - scroll view in relation to tts android -


how can scroll view (recyclerview) in relation tts, ive looked @ onutterance seems have start , stop listener, need think outside box, give tts string arraylist

 arraylist<string> list = new arraylist<>();      (int = 0; < speakrecyclergrid.recyclerview.getchildcount(); i++)        {        list.add(((edittext) speakrecyclergrid.recyclerview.getchildat(i)).gettext().tostring());       }        speakwords(words); 

i thinking cutting string sections , giving tts 1 string @ time , move view go. give gridlayout manager int amount of columns (called columns). array list adds comma after every word, thinking

  • find nth/(column) comma
  • split string
  • check if tts speaking , listen onutterance ondone pass new string
  • read string
  • move view

and keep doing until theres no words left , coding remainder % im not sure how of if wants feel free, (i think im looking @ stringutils , creating each smaller string loop , passing them tts in onutterancelistener ondone, im still little new android), have better way

okay have far use work im still amateur, i've split string blocks based on size of screen, , handler scrolls screen relies on amount of letters in each broken string, smoothscrolltoposition scrolling custom layout manager scrolls pretty im having issue though on devices array list counting words reach 20 not sure why ill ask , update when ive fixed here speak , move method

public void speakandmove(){      final arraylist<string> list = new arraylist<>();      speakgrid.recyclerview.getlayoutmanager().scrolltoposition(0);      (int = 0; < speakrecyclergrid.recyclerview.getchildcount(); i++) {         list.add(((edittext) speakrecyclergrid.recyclerview.getchildat(i)).gettext().tostring());     }      integer numofwords = list.size();     words = list.tostring();     integer count = 0;     integer startpoint = 0;     scrollpos = 0;     final integer speed = words.length() * 15;     integer leftover = 0;     final int columns = getresources().getinteger(r.integer.grid_columns);     system.out.println(numofwords);     arraylist<string> arraylist = new arraylist<>();      if (list.size() <= columns) {          if (words.contains("[]")) {             speakwords("");         } else if (words.contains(", 's")) {             formatstring = words.replacefirst(", 's", "'s");             speakwords(formatstring);         } else if (words.contains(", ing")) {             formatstring = words.replacefirst(", ing", "ing");             speakwords(formatstring);         } else {             speakwords(words);         }     }     if (list.size()>=columns) {          (int = 0; < words.length(); i++) {              if (words.charat(i) == ',') {                 count++;                 if (count == columns) {                      string ab = words.substring(startpoint, + 1);                     //speakwords(ab);                     if (ab.contains(", 's")) {                         formatstring = ab.replacefirst(", 's", "'s");                         speakwords(formatstring);                     } else if (ab.contains(", ing")) {                         formatstring = ab.replacefirst(", ing", "ing");                         speakwords(formatstring);                     } else {                         speakwords(ab);                     }                     startpoint = + 1;                     count = 0;                     leftover = words.length() - startpoint;                 }                   //speakgrid.recyclerview.getlayoutmanager().scrolltoposition(scrollpos);                 system.out.println("main string"+" scroll " + scrollpos + " startpoint " + startpoint +" speed " + speed);             }         }         if (leftover > 0) {             string ab2 = words.substring(startpoint, words.length());             //speakwords(ab2);             if (ab2.contains(", 's")) {                 formatstring = ab2.replacefirst(", 's", "'s");                 speakwords(formatstring);             } else if (ab2.contains(", ing")) {                 formatstring = ab2.replacefirst(", ing", "ing");                 speakwords(formatstring);             } else {                 speakwords(ab2);             }             //speakgrid.recyclerview.getlayoutmanager().scrolltoposition(scrollpos);             system.out.println("leftovers "+ leftover + " scroll " + scrollpos + " startpoint " + startpoint +" count " + scrollpos);             count = 0;             //scrollpos = 0;         }      }      final handler h = new handler();     h.postdelayed(new runnable() {         public void run() {             // method executed once timer on             // start app main activity              scrollpos = scrollpos + columns;             speakgrid.recyclerview.getlayoutmanager().smoothscrolltoposition(speakgrid.recyclerview, null ,scrollpos);             system.out.println("position "+ scrollpos + " speed " + speed + " list size " + list.size());             if (scrollpos < list.size())                 h.postdelayed(this,speed);             // close activity         }     }, speed);   }