List of usage examples for android.widget ScrollView addView
@Override public void addView(View child)
From source file:com.ryan.ryanreader.activities.CaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); getSupportActionBar().setTitle(R.string.post_captcha_title); super.onCreate(savedInstanceState); final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true); setContentView(loadingView);// w w w . j a v a 2s . c o m final RedditAccount selectedAccount = RedditAccountManager.getInstance(this) .getAccount(getIntent().getStringExtra("username")); final CacheManager cm = CacheManager.getInstance(this); RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) { @Override protected void onSuccess(final String captchaId) { final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId); cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null, Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA, false, false, true, CaptchaActivity.this) { @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { loadingView.setIndeterminate(R.string.download_downloading); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onProgress(long bytesRead, long totalBytes) { loadingView.setProgress(R.string.download_downloading, (float) ((double) bytesRead / (double) totalBytes)); } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, String mimetype) { final Bitmap image; try { image = BitmapFactory.decodeStream(cacheFile.getInputStream()); } catch (IOException e) { BugReportActivity.handleGlobalError(CaptchaActivity.this, e); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { final LinearLayout ll = new LinearLayout(CaptchaActivity.this); ll.setOrientation(LinearLayout.VERTICAL); final ImageView captchaImg = new ImageView(CaptchaActivity.this); ll.addView(captchaImg); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg .getLayoutParams(); layoutParams.setMargins(20, 20, 20, 20); layoutParams.height = General.dpToPixels(context, 100); captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER); final EditText captchaText = new EditText(CaptchaActivity.this); ll.addView(captchaText); ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20, 20); captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); captchaImg.setImageBitmap(image); final Button submitButton = new Button(CaptchaActivity.this); submitButton.setText(R.string.post_captcha_submit_button); ll.addView(submitButton); ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20, 20); ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).gravity = Gravity.RIGHT; ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT; submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Intent result = new Intent(); result.putExtra("captchaId", captchaId); result.putExtra("captchaText", captchaText.getText().toString()); setResult(RESULT_OK, result); finish(); } }); final ScrollView sv = new ScrollView(CaptchaActivity.this); sv.addView(ll); setContentView(sv); } }); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onFailure(APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type); General.showResultDialog(CaptchaActivity.this, error); finish(); } }, selectedAccount, this); }
From source file:org.quantumbadger.redreader.activities.CaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); getSupportActionBar().setTitle(R.string.post_captcha_title); super.onCreate(savedInstanceState); final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true); setContentView(loadingView);/*w w w .j a va 2 s. c om*/ final RedditAccount selectedAccount = RedditAccountManager.getInstance(this) .getAccount(getIntent().getStringExtra("username")); final CacheManager cm = CacheManager.getInstance(this); RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) { @Override protected void onSuccess(final String captchaId) { final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId); cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null, Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA, false, false, true, CaptchaActivity.this) { @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { loadingView.setIndeterminate(R.string.download_downloading); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, url.toString()); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onProgress(long bytesRead, long totalBytes) { loadingView.setProgress(R.string.download_downloading, (float) ((double) bytesRead / (double) totalBytes)); } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, String mimetype) { final Bitmap image; try { image = BitmapFactory.decodeStream(cacheFile.getInputStream()); } catch (IOException e) { BugReportActivity.handleGlobalError(CaptchaActivity.this, e); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { final LinearLayout ll = new LinearLayout(CaptchaActivity.this); ll.setOrientation(LinearLayout.VERTICAL); final ImageView captchaImg = new ImageView(CaptchaActivity.this); ll.addView(captchaImg); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg .getLayoutParams(); layoutParams.setMargins(20, 20, 20, 20); layoutParams.height = General.dpToPixels(context, 100); captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER); final EditText captchaText = new EditText(CaptchaActivity.this); ll.addView(captchaText); ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20, 20); captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); captchaImg.setImageBitmap(image); final Button submitButton = new Button(CaptchaActivity.this); submitButton.setText(R.string.post_captcha_submit_button); ll.addView(submitButton); ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20, 20); ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).gravity = Gravity.RIGHT; ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT; submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Intent result = new Intent(); result.putExtra("captchaId", captchaId); result.putExtra("captchaText", captchaText.getText().toString()); setResult(RESULT_OK, result); finish(); } }); final ScrollView sv = new ScrollView(CaptchaActivity.this); sv.addView(ll); setContentView(sv); } }); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, null); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onFailure(APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type); General.showResultDialog(CaptchaActivity.this, error); finish(); } }, selectedAccount, this); }
From source file:org.sufficientlysecure.keychain.ui.HelpHtmlFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity = getActivity();/*from ww w.jav a2 s. c o m*/ mHtmlFile = getArguments().getInt(ARG_HTML_FILE); ScrollView scroller = new ScrollView(mActivity); HtmlTextView text = new HtmlTextView(mActivity); // padding int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mActivity.getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, 0); scroller.addView(text); // load html from raw resource (Parsing handled by HtmlTextView library) text.setHtmlFromRawResource(getActivity(), mHtmlFile, true); // no flickering when clicking textview for Android < 4 text.setTextColor(getResources().getColor(android.R.color.black)); return scroller; }
From source file:com.github.wakhub.monodict.activity.settings.DownloadsActivity.java
@ItemClick(android.R.id.list) void onClickListItem(int position) { final DownloadsItem item = listAdapter.getItem(position); TextView textView = new TextView(this); textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES); textView.setPadding((int) spaceRelax, (int) spaceRelax, (int) spaceRelax, (int) spaceRelax); textView.setText(String.format("%s\nsize: %s", item.getDescription(), item.getSize())); ScrollView scrollView = new ScrollView(this); scrollView.addView(textView); new AlertDialog.Builder(this) .setPositiveButton(R.string.action_download, new AlertDialog.OnClickListener() { @Override//from www . j a va 2 s. c o m public void onClick(DialogInterface dialogInterface, int i) { resultIntent.putExtra(RESULT_INTENT_ENGLISH, item.isEnglish()); resultIntent.putExtra(RESULT_INTENT_FILENAME, item.getName()); startDownload(item); } }).setNegativeButton(android.R.string.cancel, null).setIcon(R.drawable.ic_action_download) .setTitle(item.getName()).setView(scrollView).show(); }
From source file:org.thialfihar.android.apg.ui.HelpHtmlFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity = getActivity();/*from w ww .ja v a2 s. com*/ mHtmlFile = getArguments().getInt(ARG_HTML_FILE); ScrollView scroller = new ScrollView(mActivity); HtmlTextView text = new HtmlTextView(mActivity); // padding int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mActivity.getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, 0); scroller.addView(text); // load html from raw resource (Parsing handled by HtmlTextView library) text.setHtmlFromRawResource(getActivity(), mHtmlFile); // no flickering when clicking textview for Android < 4 text.setTextColor(getResources().getColor(R.color.html_text_color)); return scroller; }
From source file:org.adaway.ui.help.HelpFragmentHtml.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { htmlFile = getArguments().getInt(ARG_HTML_FILE); mActivity = getActivity();/*from w w w. ja va 2s.c o m*/ ScrollView scroller = new ScrollView(mActivity); HtmlTextView text = new HtmlTextView(mActivity); // padding int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, mActivity.getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, 0); scroller.addView(text); // load html from raw resource (Parsing handled by HtmlTextView library) text.setHtml(htmlFile); // no flickering when clicking textview for Android < 4 text.setTextColor(getResources().getColor(android.R.color.secondary_text_dark_nodisable)); return scroller; }
From source file:org.sufficientlysecure.keychain.ui.HelpMarkdownFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int mHtmlFile = getArguments().getInt(ARG_MARKDOWN_RES); ScrollView scroller = new ScrollView(getActivity()); HtmlTextView text = new HtmlTextView(getActivity()); // padding//from ww w. j a v a2 s . c o m int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getActivity().getResources().getDisplayMetrics()); text.setPadding(padding, padding, padding, 0); scroller.addView(text); // load markdown from raw resource try { String html = new Markdown4jProcessor() .process(getActivity().getResources().openRawResource(mHtmlFile)); text.setHtml(html, new HtmlResImageGetter(text)); } catch (IOException e) { Log.e(Constants.TAG, "IOException", e); } return scroller; }
From source file:net.gsantner.opoc.util.ActivityUtils.java
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml, DialogInterface.OnDismissListener dismissedListener) { ScrollView scroll = new ScrollView(_context); AppCompatTextView textView = new AppCompatTextView(_context); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, _context.getResources().getDisplayMetrics()); scroll.setPadding(padding, 0, padding, 0); scroll.addView(textView); textView.setMovementMethod(new LinkMovementMethod()); textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text); AlertDialog.Builder dialog = new AlertDialog.Builder(_context).setPositiveButton(android.R.string.ok, null) .setOnDismissListener(dismissedListener).setTitle(resTitleId).setView(scroll); dialog.show();// w ww . j a v a 2 s. c o m }
From source file:com.nineducks.hereader.HackfulReaderActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog result = null;/*from w ww . ja v a2s .c o m*/ AlertDialog.Builder builder = null; switch (id) { case R.id.open_dialog: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.open_dialog_title); builder.setItems(R.array.open_dialog_options, (OnClickListener) itemsController); builder.setCancelable(true); result = builder.create(); break; case R.id.about_dialog: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.about_dialog_title); ScrollView scroll = new ScrollView(this); TextView msg = new TextView(this); SpannableString s = new SpannableString(getString(R.string.about_dialog_text)); Linkify.addLinks(s, Linkify.WEB_URLS); msg.setText(s); msg.setMovementMethod(LinkMovementMethod.getInstance()); msg.setTextSize(16); msg.setPadding(15, 15, 15, 15); scroll.addView(msg); builder.setView(scroll); builder.setInverseBackgroundForced(true); result = builder.create(); break; } return result; }
From source file:com.nttec.everychan.http.recaptcha.Recaptcha2fallback.java
@Override public void handle(final Activity activity, final CancellableTask task, final Callback callback) { try {//from ww w . j a v a 2s .c o m final HttpClient httpClient = ((HttpChanModule) MainApplication.getInstance().getChanModule(chanName)) .getHttpClient(); final String usingURL = scheme + RECAPTCHA_FALLBACK_URL + publicKey + (sToken != null && sToken.length() > 0 ? ("&stoken=" + sToken) : ""); String refererURL = baseUrl != null && baseUrl.length() > 0 ? baseUrl : usingURL; Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, refererURL) }; String htmlChallenge; if (lastChallenge != null && lastChallenge.getLeft().equals(usingURL)) { htmlChallenge = lastChallenge.getRight(); } else { htmlChallenge = HttpStreamer.getInstance().getStringFromUrl(usingURL, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task, false); } lastChallenge = null; Matcher challengeMatcher = Pattern.compile("name=\"c\" value=\"([\\w-]+)").matcher(htmlChallenge); if (challengeMatcher.find()) { final String challenge = challengeMatcher.group(1); HttpResponseModel responseModel = HttpStreamer.getInstance().getFromUrl( scheme + RECAPTCHA_IMAGE_URL + challenge + "&k=" + publicKey, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task); try { InputStream imageStream = responseModel.stream; final Bitmap challengeBitmap = BitmapFactory.decodeStream(imageStream); final String message; Matcher messageMatcher = Pattern.compile("imageselect-message(?:.*?)>(.*?)</div>") .matcher(htmlChallenge); if (messageMatcher.find()) message = RegexUtils.removeHtmlTags(messageMatcher.group(1)); else message = null; final Bitmap candidateBitmap; Matcher candidateMatcher = Pattern .compile("fbc-imageselect-candidates(?:.*?)src=\"data:image/(?:.*?);base64,([^\"]*)\"") .matcher(htmlChallenge); if (candidateMatcher.find()) { Bitmap bmp = null; try { byte[] imgData = Base64.decode(candidateMatcher.group(1), Base64.DEFAULT); bmp = BitmapFactory.decodeByteArray(imgData, 0, imgData.length); } catch (Exception e) { } candidateBitmap = bmp; } else candidateBitmap = null; activity.runOnUiThread(new Runnable() { final int maxX = 3; final int maxY = 3; final boolean[] isSelected = new boolean[maxX * maxY]; @SuppressLint("InlinedApi") @Override public void run() { LinearLayout rootLayout = new LinearLayout(activity); rootLayout.setOrientation(LinearLayout.VERTICAL); if (candidateBitmap != null) { ImageView candidateView = new ImageView(activity); candidateView.setImageBitmap(candidateBitmap); int picSize = (int) (activity.getResources().getDisplayMetrics().density * 50 + 0.5f); candidateView.setLayoutParams(new LinearLayout.LayoutParams(picSize, picSize)); candidateView.setScaleType(ImageView.ScaleType.FIT_XY); rootLayout.addView(candidateView); } if (message != null) { TextView textView = new TextView(activity); textView.setText(message); CompatibilityUtils.setTextAppearance(textView, android.R.style.TextAppearance); textView.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); rootLayout.addView(textView); } FrameLayout frame = new FrameLayout(activity); frame.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final ImageView imageView = new ImageView(activity); imageView.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageBitmap(challengeBitmap); frame.addView(imageView); final LinearLayout selector = new LinearLayout(activity); selector.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); AppearanceUtils.callWhenLoaded(imageView, new Runnable() { @Override public void run() { selector.setLayoutParams(new FrameLayout.LayoutParams(imageView.getWidth(), imageView.getHeight())); } }); selector.setOrientation(LinearLayout.VERTICAL); selector.setWeightSum(maxY); for (int y = 0; y < maxY; ++y) { LinearLayout subSelector = new LinearLayout(activity); subSelector.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); subSelector.setOrientation(LinearLayout.HORIZONTAL); subSelector.setWeightSum(maxX); for (int x = 0; x < maxX; ++x) { FrameLayout switcher = new FrameLayout(activity); switcher.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); switcher.setTag(new int[] { x, y }); switcher.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int[] coord = (int[]) v.getTag(); int index = coord[1] * maxX + coord[0]; isSelected[index] = !isSelected[index]; v.setBackgroundColor(isSelected[index] ? Color.argb(128, 0, 255, 0) : Color.TRANSPARENT); } }); subSelector.addView(switcher); } selector.addView(subSelector); } frame.addView(selector); rootLayout.addView(frame); Button checkButton = new Button(activity); checkButton.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); checkButton.setText(android.R.string.ok); rootLayout.addView(checkButton); ScrollView dlgView = new ScrollView(activity); dlgView.addView(rootLayout); final Dialog dialog = new Dialog(activity); dialog.setTitle("Recaptcha"); dialog.setContentView(dlgView); dialog.setCanceledOnTouchOutside(false); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!task.isCancelled()) { callback.onError("Cancelled"); } } }); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); dialog.show(); checkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (task.isCancelled()) return; Async.runAsync(new Runnable() { @Override public void run() { try { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("c", challenge)); for (int i = 0; i < isSelected.length; ++i) if (isSelected[i]) pairs.add(new BasicNameValuePair("response", Integer.toString(i))); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")) .setCustomHeaders(new Header[] { new BasicHeader(HttpHeaders.REFERER, usingURL) }) .build(); String response = HttpStreamer.getInstance().getStringFromUrl( usingURL, request, httpClient, null, task, false); String hash = ""; Matcher matcher = Pattern.compile( "fbc-verification-token(?:.*?)<textarea[^>]*>([^<]*)<", Pattern.DOTALL).matcher(response); if (matcher.find()) hash = matcher.group(1); if (hash.length() > 0) { Recaptcha2solved.push(publicKey, hash); activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } else { lastChallenge = Pair.of(usingURL, response); throw new RecaptchaException( "incorrect answer (hash is empty)"); } } catch (final Exception e) { Logger.e(TAG, e); if (task.isCancelled()) return; handle(activity, task, callback); } } }); } }); } }); } finally { responseModel.release(); } } else throw new Exception("can't parse recaptcha challenge answer"); } catch (final Exception e) { Logger.e(TAG, e); if (!task.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(e.getMessage() != null ? e.getMessage() : e.toString()); } }); } } }