{"id":204248,"date":"2013-12-03T11:46:02","date_gmt":"2013-12-03T07:46:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=204248"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=204248","title":{"rendered":"<span class=\"post_title\">\u041f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u043a\u043e\u0434\u0430 \u043d\u0430 android. \u041c\u043e\u0439 \u043e\u043f\u044b\u0442<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/455\/182\/fec\/455182fec7812b639447b77bdd31ac04.png\" align=\"right\"\/><br \/>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044f \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438 \u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044e <a href=\"http:\/\/developer.android.com\/reference\/android\/text\/style\/CharacterStyle.html\">span&#8217;\u043e\u0432<\/a> \u0432 EditText. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0442\u043e\u0433 \u044d\u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u044f\u043f\u0440\u0435\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u043c, \u043a\u0442\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  \u041a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0447\u0443 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0432\u0435\u0441\u0442\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0432 \u043a\u0443\u0440\u0441 \u0434\u0435\u043b\u0430:<\/p>\n<ul>\n<li>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 N \u044f\u0434\u0435\u0440 (\u043a\u0430\u0436\u0434\u043e\u0435 \u0441 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439), \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0438\u043c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u043c. <\/li>\n<li>\u041a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432 \u0430\u043d\u0434\u0440\u043e\u0438\u0434\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0418 \u043e\u043d \u043d\u0435 \u0432\u0435\u043b\u0438\u043a. <\/li>\n<li>\u041c\u0435\u0442\u043e\u0434 <a href=\"http:\/\/developer.android.com\/reference\/android\/text\/Spannable.html#setSpan(java.lang.Object, int, int, int)\">setSpan<\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/li>\n<li>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b \u0432\u044b\u043d\u0435\u0441\u0435\u0442\u0435 \u0432 Worker&#8217;\u044b, \u0442\u0435\u043c \u043e\u0442\u0437\u044b\u0432\u0447\u0438\u0432\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/li>\n<li>\u0414\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u043d\u044b\u043c \u0432\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0434\u0438\u043c\u0443\u044e \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c.<\/li>\n<li>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435: \u043f\u043e\u0438\u0441\u043a \u043c\u0435\u0441\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u043f\u0430\u043d\u0430 \u0432 UI \u043f\u043e\u0442\u043e\u043a\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/li>\n<\/ul>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0441\u0440\u0430\u0437\u0443 \u043a \u043c\u043e\u0435\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0441\u0430\u043c\u043e\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0441\u043e\u0432\u0435\u0442\u0430\u043c.<\/p>\n<h4>\u041e\u0431\u0449\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/8d1\/ee5\/6e1\/8d1ee56e16aedbf2cbcce1043454bc6e.png\"\/><br \/>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/ScrollView.html\">ScrollView<\/a> \u0438 \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/EditText.html\">EditText<\/a>. \u0423 ScrollView \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/View.html#onScrollChanged(int, int, int, int)\">onScrollChanged<\/a> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0441\u043a\u0440\u043e\u043b\u043b\u0438\u043d\u0433\u0430. \u0412 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432\u0438\u0441\u044f\u0449\u0438\u0439 \u0432 \u0444\u043e\u043d\u0435 \u043f\u043e\u0442\u043e\u043a \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c.<br \/>  EditText&#8217;\u0443 \u0432\u0435\u0448\u0430\u0435\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u2014 <a href=\"http:\/\/developer.android.com\/reference\/android\/text\/TextWatcher.html\">TextWatcher&#8217;\u0430 <\/a>. \u0412 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0435 <a href=\"http:\/\/developer.android.com\/reference\/android\/text\/TextWatcher.html#afterTextChanged(android.text.Editable)\">afterTextChanged<\/a> \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c Worker&#8217;\u0430 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442. \u0412 \u043a\u043b\u0430\u0441\u0441\u0435 (\u043f\u043e\u0442\u043e\u043c\u043a\u0435 EditText) \u0437\u0430\u0432\u043e\u0434\u0438\u043c Handler, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437 Worker&#8217;\u0430 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u044b\u043b\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0430\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0432\u0435\u0441\u0438\u0442\u044c \u043d\u0430 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>  \u041e\u0431\u0449\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u043e\u0432\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043a \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043b\u043e\u0436\u0443 \u0432 \u0444\u043e\u0440\u043c\u0435 \u0432\u043e\u043f\u0440\u043e\u0441-\u043e\u0442\u0432\u0435\u0442.<\/p>\n<h4>\u041a\u0430\u043a \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0441\u0440\u043e\u043b\u043b\u0438\u043d\u0433\u0430?<\/h4>\n<p>  \u041c\u0435\u0442\u043e\u0434 onScrollChanged \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u00ab\u043f\u0440\u043e\u0441\u043a\u0440\u043e\u043b\u043b\u0435\u043d\u043e\u0433\u043e\u00bb \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u0438 \u0435\u0441\u043b\u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0442\u043e\u043a-\u043f\u0430\u0440\u0441\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, \u0442\u043e, \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u043d\u0438\u0447\u0435\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"java\">private Thread timerThread; protected void onScrollChanged(int x, int y, int oldx, int oldy) {     super.onScrollChanged(x, y, oldx, oldy);          timer = 500;          if (timerThread == null || !timerThread.isAlive()) {         timerThread = new Thread(lastScrollTime);         timerThread.start();     } }  Runnable lastScrollTime = new Runnable() {     @Override     public void run() {         while (timer != 0) {             timer -= 10;             try {                 Thread.sleep(10);                 } catch (InterruptedException e) {             }         }                  CustomScrollView.this.post(new Runnable() {             @Override             public void run() {                 if (onScrollStoppedListener != null) {                     onScrollStoppedListener.onScrollStopped(CustomScrollView.this.getScrollY());                 }             }         });     } };  public interface OnScrollStoppedListener {     void onScrollStopped(int scrollY); } <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440 \u0432 500 \u043c\u0441 \u0438, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u043c OnScrollStoppedListener \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043a\u0440\u043e\u043b\u043b\u0438\u043d\u0433 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 OnScrollStoppedListener \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u043e\u0439 EditText.<\/p>\n<h4>\u041a\u0430\u043a \u043d\u0435 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a-\u043f\u0430\u0440\u0441\u0435\u0440 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430?<\/h4>\n<p>  \u0421\u043c. \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0443\u043d\u043a\u0442. <br \/>  \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u0435\u043d \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0436\u0434\u0430\u0442\u044c N-\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430. \u041f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443 \u0442\u0443\u0442 \u043d\u0443\u0436\u043d\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0443\u0436\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e ( \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 echo).<\/p>\n<h4>\u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0432\u0438\u0434\u0438\u043c\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c?<\/h4>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u043e\u0447\u043d\u043e \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"java\">List&lt;Integer&gt; charsCountPerLine = new ArrayList&lt;&gt;(); public void fillArrayWithCharsCountPerLine(String text) {     charsCountPerLine.clear();     charsCountPerLine.add(0);     BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(text.getBytes())));     int currentLineLength = 0;     char current;     try {         while (true) {             int c = br.read();             if (c == -1) {                 charsCountPerLine.add(currentLineLength);                 break;             }             current = (char) c;             currentLineLength++;                          if (current == '\\n') {                 charsCountPerLine.add(currentLineLength);             }         }         } catch (IOException e) {         Log.e(TAG, &quot;&quot;, e);     } } <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u043e\u043c\u0435\u0440 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0417\u0430\u0442\u0435\u043c, \u0437\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445, \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043d\u043e\u043c\u0435\u0440 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<pre><code class=\"java\">        int lineHeight = mEditText.getLineHeight();          int startLine = scrollY \/ lineHeight; \/\/ scrollY - \u0442\u043e \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 \u043d\u0430\u043c ScrollView         int endLine = mEditText.startLine + viewHeight \/ lineHeight + 1; \/\/ viewHeight  \u0432\u044b\u0441\u043e\u0442\u0430 \u0434\u0438\u0441\u043f\u043b\u0435\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 <\/code><\/pre>\n<p>  \u0418\u043c\u0435\u044f \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u044b \u0431\u0435\u0437 \u0442\u0440\u0443\u0434\u0430 \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u0438\u0434\u0438\u043c\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b.<\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e \u0441\u043f\u0430\u043d\u0430\u043c\u0438? \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043f\u0430\u043d \u0432 handler \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f?<\/h4>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0442\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442\u0435 \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0442\u0435\u043a\u0441\u0442\u0430. \u0412 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432\u044b, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u043f\u0430\u043d\u0430 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0432\u043e\u0439\u043d\u0438\u043a\u0430 \u0432 \u043b\u0438\u0441\u0442\u0435. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e. \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u0441\u0434\u0435\u043b\u0430\u043b \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f. \u0412 \u044d\u0442\u043e\u0442-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0438 \u043f\u0440\u0438\u0434\u0435\u0442 \u043f\u0430\u0447\u043a\u0430 \u0441\u043f\u0430\u043d\u043e\u0432 \u0432 \u043d\u0430\u0448 ui \u043f\u043e\u0442\u043e\u043a \u0438 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442 \u0435\u0433\u043e \u043d\u0430 \u0434\u043e\u043b\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u0412 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043f\u0430\u043d\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043c\u0438\u043a\u0440\u043e \u0442\u043e\u0440\u043c\u043e\u0437\u0430 UI.<\/p>\n<h4>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0441\u043f\u044f\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a? \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ThreadPool?<\/h4>\n<p>  \u041f\u043e \u0438\u0434\u0435\u0435, \u0442\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u044f \u043d\u0435 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b.<\/p>\n<p>  \u042f \u043e\u0441\u0432\u0435\u0442\u0438\u043b \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0438, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0421\u043f\u0430\u0441\u0438\u0431\u043e.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/204248\/\"> http:\/\/habrahabr.ru\/post\/204248\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/455\/182\/fec\/455182fec7812b639447b77bdd31ac04.png\" align=\"right\"\/><br \/>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044f \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438 \u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044e <a href=\"http:\/\/developer.android.com\/reference\/android\/text\/style\/CharacterStyle.html\">span&#8217;\u043e\u0432<\/a> \u0432 EditText. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0434\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0442\u043e\u0433 \u044d\u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u044f\u043f\u0440\u0435\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u043c, \u043a\u0442\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  \u041a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u043e\u0447\u0443 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0432\u0435\u0441\u0442\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0432 \u043a\u0443\u0440\u0441 \u0434\u0435\u043b\u0430:<\/p>\n<ul>\n<li>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 N \u044f\u0434\u0435\u0440 (\u043a\u0430\u0436\u0434\u043e\u0435 \u0441 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439), \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0438\u043c, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430\u043c. <\/li>\n<li>\u041a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432 \u0430\u043d\u0434\u0440\u043e\u0438\u0434\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0418 \u043e\u043d \u043d\u0435 \u0432\u0435\u043b\u0438\u043a. <\/li>\n<li>\u041c\u0435\u0442\u043e\u0434 <a href=\"http:\/\/developer.android.com\/reference\/android\/text\/Spannable.html#setSpan(java.lang.Object, int, int, int)\">setSpan<\/a> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/li>\n<li>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b \u0432\u044b\u043d\u0435\u0441\u0435\u0442\u0435 \u0432 Worker&#8217;\u044b, \u0442\u0435\u043c \u043e\u0442\u0437\u044b\u0432\u0447\u0438\u0432\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/li>\n<li>\u0414\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0435\u043d\u043d\u044b\u043c \u0432\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0434\u0438\u043c\u0443\u044e \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c.<\/li>\n<li>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435: \u043f\u043e\u0438\u0441\u043a \u043c\u0435\u0441\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u043f\u0430\u043d\u0430 \u0432 UI \u043f\u043e\u0442\u043e\u043a\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-204248","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/204248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=204248"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/204248\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=204248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=204248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=204248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}