title: how to replace AsyncTask by RxAndroid
body: <p>I am trying to use RxAndroid to do the same work which is AsyncTask exactly does. I coded a simple example, where I enter a n integer in an edittext and when I press
  a button, I make the hread to sleep for 3 seconds using "SystemClock.sleep" and while the thread is sleeping I show a progressbar and when the three seconds 
  elapsed the progresssbar will adisappear and the value entered in the edittext will be multiplied by 10 and displayed in atextview.</p>
  
  <p>normally, when I use AsyncTask, I show the progressbar in onPreExecute and make it to disappear in onPostExecute. but when I run the below code I  receive the 
  following error:</p>
  
  <pre><code>Only the original thread that created a view hierarchy can touch its views.
  </code></pre>
  
  <p>how to handle it properly in RxAndroid?</p>
  
  <p><strong>code</strong>:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private static final String TAG = MainActivity.class.getSimpleName();
  private EditText mEditTextValueToProcess = null;
  private Button mButtonGoAsynchronous = null;
  private TextView mTextViewProcessedValue = null;
  private ProgressBar mProgressBar = null;
  private rx.Observable&lt;String&gt; mAsyncObservable = null;
  
  Subscriber mAsyncSubscriber = new Subscriber&lt;String&gt;() {
      @Override
      public void onCompleted() {
          Log.w(TAG, "onCompleted");
          mProgressBar.setVisibility(View.GONE);
      }
  
      @Override
      public void onError(Throwable e) {
          Log.w(TAG, "onError: " + e.getMessage().toString());
          mProgressBar.setVisibility(View.GONE);
      }
  
      @Override
      public void onNext(String o) {
          Log.w(TAG, "onNext:-&gt;after processing " + o);
          mTextViewProcessedValue.setText(o);
      }
  };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      intiViews();
  
      mAsyncObservable = rx.Observable.create(new rx.Observable.OnSubscribe&lt;String&gt;() {
          @Override
          public void call(Subscriber&lt;? super String&gt; subscriber) {
              mProgressBar = (ProgressBar) findViewById(R.id.progressDialog);
              mProgressBar.setVisibility(View.VISIBLE);
  
              SystemClock.sleep(3000);
  
              subscriber.onNext("" + Integer.valueOf(mEditTextValueToProcess.getText().toString()) * 10);
              subscriber.onCompleted();
          }
      });
  
  }
  
  private void intiViews() {
      mEditTextValueToProcess = (EditText) findViewById(R.id.edittext);
      mButtonGoAsynchronous = (Button) findViewById(R.id.button_go_asynchronous);
      mTextViewProcessedValue = (TextView) findViewById(R.id.textview_processed_value);
      //mProgressBar = (ProgressBar) findViewById(R.id.progressDialog);
  
      mButtonGoAsynchronous.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              mAsyncObservable.subscribeOn(Schedulers.io())
                      .observeOn(AndroidSchedulers.mainThread())
                      .subscribe(mAsyncSubscriber);
          }
      });
  }
  </code></pre>
  
  <p>}</p>