List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:com.rareventure.gps2.reviewer.map.OsmMapGpsTrailerReviewerMapActivity.java
private void initUI() { TextView ty = (TextView) findViewById(R.id.thankyou); ty.setMovementMethod(LinkMovementMethod.getInstance()); sasPanelButton = (ImageButton) findViewById(R.id.sas_open_close_button); sasPanelButton.setOnClickListener(this); gtgStatus = (OngoingProcessStatusFragment) getSupportFragmentManager().findFragmentById(R.id.status); toolTip = (ToolTipFragment) getSupportFragmentManager().findFragmentById(R.id.tooltip); infoNotice = (InfoNoticeStatusFragment) getSupportFragmentManager().findFragmentById(R.id.infoNotice); superThreadManager = new SuperThreadManager(); SuperThread cpuThread = new SuperThread(superThreadManager); SuperThread fileIOThread = new SuperThread(superThreadManager); fileIOThread.start();// w w w. ja v a2 s .co m cpuThread.start(); //co: this has been replaced by notifyProcessing() method // superThreadManager.setSleepingThreadsListener(new SuperThreadManager.SleepingThreadsListener() { // // @Override // public void notifySleepingThreadsChanged(final boolean allThreadsAreSleeping) { // runOnUiThread(new Runnable() { // // @Override // public void run() { // setProgressBarIndeterminateVisibility(!allThreadsAreSleeping); // } // }); // } // }); zoomControls = (ZoomControls) this.findViewById(R.id.zoomControls); zoomControls.setOnZoomInClickListener(new OnClickListener() { @Override public void onClick(View v) { osmMapView.zoomIn(); toolTip.setAction(UserAction.ZOOM_IN); } }); zoomControls.setOnZoomOutClickListener(new OnClickListener() { @Override public void onClick(View v) { osmMapView.zoomOut(); toolTip.setAction(UserAction.ZOOM_OUT); } }); osmMapView.addOverlay(gpsTrailerOverlay = new GpsTrailerOverlay(this, cpuThread, osmMapView)); osmMapView.addOverlay(locationOverlay = new GpsLocationOverlay(this)); osmMapView.init(fileIOThread, this); scaleWidget = (MapScaleWidget) this.findViewById(R.id.scaleWidget); osmMapView.setScaleWidget(scaleWidget); panToLocation = (ImageView) this.findViewById(R.id.pan_to_location); panToLocation.setOnClickListener(this); autoZoom = (ImageView) this.findViewById(R.id.AutoZoom); autoZoom.setOnClickListener(this); menuButton = (ImageButton) findViewById(R.id.menu_button); menuButton.setOnClickListener(this); datePicker = findViewById(R.id.date_picker); datePicker.setOnClickListener(this); timeView = (TimeView) findViewById(R.id.timeview); timeView.setListener(this); timeView.setActivity(this); // selectedAreaAddLock = (CheckBox) findViewById(R.id.selected_areas_add_lock); // selectedAreaAddLock.setOnCheckedChangeListener(new OnCheckedChangeListener() { // // @Override // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // GpsTrailerOverlayDrawer.doMethodTracing = true; // if(isChecked) // { // toolTip.setAction(ToolTipFragment.UserAction.SELECTED_AREA_ADD_LOCKED); // gpsTrailerOverlay.setSelectedAreaAddLock(true); // } // else // { // toolTip.setAction(ToolTipFragment.UserAction.SELECTED_AREA_ADD_UNLOCKED); // gpsTrailerOverlay.setSelectedAreaAddLock(false); // } // } // }); // sasPanel = findViewById(R.id.sas_panel); sasPanel.setVisibility(View.INVISIBLE); distanceView = (TextView) findViewById(R.id.dist_traveled); updateDistanceView(-1); initSasPanel(); }
From source file:pro.dbro.bart.TheActivity.java
private void showErrorDialog(String message) { TextView crashTv = (TextView) View.inflate(c, R.layout.tabletext, null); if (message.compareTo("") == 0) crashTv.setText(Html.fromHtml(res.getStringArray(R.array.crashCatchDialog)[1])); else//from w w w . ja v a 2 s . c om crashTv.setText(message); crashTv.setTextSize(18); crashTv.setPadding(0, 0, 0, 0); crashTv.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(c).setTitle(res.getStringArray(R.array.crashCatchDialog)[0]).setView(crashTv) .setIcon(R.drawable.sad_mac).setPositiveButton("Bummer", null).show(); }
From source file:com.stu.zdy.weather.ui.fragment.InfoFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollview_info); DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); int height = dm.heightPixels; scrollView.getLayoutParams().height = (height - ScreenUtils.getStatusHeight(getActivity())) * 586 / 640; TextView textView2 = (TextView) getActivity().findViewById(R.id.textview2); TextView textView3 = (TextView) getActivity().findViewById(R.id.textview3); String string = "<p>icon:<a href=\"http://azuresol.deviantart.com\">AzureSol</a>"; string = string + "<a href=\"http://creativecommons.org/licenses/by-sa/3.0/\"> ???</a></p>"; string = string + "<p>??:</p>"; string = string//from w w w. j av a 2s . co m + "<p>Material Design Icons <a href=\"https://github.com/google/material-design-icons/releases/tag/1.0.0\">Github</a></p>"; string = string + "<p>MaterialDialog <a href=\"https://github.com/drakeet\">GitHub</a></p>"; string = string + "<p>Ldrawer <a href=\"https://github.com/keklikhasan/LDrawer\">GitHub</a></p>"; string = string + "<p>FloatingActionButton <a href=\"https://github.com/makovkastar/FloatingActionButton\">GitHub</a></p>"; string = string + "<p>materialish-progress-master <a href=\"https://github.com/pnikosis/materialish-progress\">GitHub</a></p>"; string = string + "<p>Java:json-lib <a href=\"http://json-lib.sourceforge.net\">GitHub</a></p>"; string = string + "<p>okhttp-utils <a href=\"https://github.com/hongyangAndroid/okhttp-utils\">GitHub</a></p>"; string = string + "<p>glide <a href=\"https://github.com/bumptech/glide\">GitHub</a></p>"; CharSequence charSequence = Html.fromHtml(string); textView2.setText(charSequence); textView2.setMovementMethod(LinkMovementMethod.getInstance()); String string2 = "<p><a href=\"http://weibo.com/u/3123268127\">?</a></p>"; CharSequence charSequence2 = Html.fromHtml(string2); textView3.setText(charSequence2); textView3.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.ichi2.anki.Info.java
@Override protected void onCreate(Bundle savedInstanceState) { Timber.d("onCreate()"); Themes.applyTheme(this); super.onCreate(savedInstanceState); Resources res = getResources(); mType = getIntent().getIntExtra(TYPE_EXTRA, TYPE_ABOUT); setTitle(getTitleString());/*ww w . j a va 2s . co m*/ setContentView(R.layout.info); mWebView = (WebView) findViewById(R.id.info); mWebView.setBackgroundColor(res.getColor(Themes.getBackgroundColor())); Themes.setWallpaper((View) mWebView.getParent().getParent().getParent()); TextView termsAndConditionsView = (TextView) findViewById(R.id.info_terms_and_conditions); termsAndConditionsView.setMovementMethod(LinkMovementMethod.getInstance()); Button continueButton = (Button) findViewById(R.id.info_continue); continueButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (mType == TYPE_ABOUT) { if (AnkiDroidApp.isKindle()) { Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.amazon.com/gp/mas/dl/android?p=com.ichi2.anki")); startActivity(intent); } else { Info.this.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.ichi2.anki"))); } return; } setResult(RESULT_OK); switch (mType) { case TYPE_NEW_VERSION: AnkiDroidApp.getSharedPrefs(Info.this.getBaseContext()).edit() .putString("lastVersion", AnkiDroidApp.getPkgVersionName()).commit(); break; case TYPE_UPGRADE_DECKS: break; } finishWithAnimation(); } }); StringBuilder sb = new StringBuilder(); switch (mType) { case TYPE_ABOUT: String[] content = res.getStringArray(R.array.about_content); sb.append("<html><body text=\"#000000\" link=\"#E37068\" alink=\"#E37068\" vlink=\"#E37068\">"); sb.append( String.format(content[0], res.getString(R.string.app_name), res.getString(R.string.link_anki))) .append("<br/><br/>"); sb.append(String.format(content[1], res.getString(R.string.link_issue_tracker), res.getString(R.string.link_wiki), res.getString(R.string.link_forum))).append("<br/><br/>"); sb.append(String.format(content[2], res.getString(R.string.link_wikipedia_open_source), res.getString(R.string.link_contribution), res.getString(R.string.link_contribution_contributors))).append(" "); sb.append(String.format(content[3], res.getString(R.string.link_translation), res.getString(R.string.link_donation))).append("<br/><br/>"); sb.append(String.format(content[4], res.getString(R.string.licence_wiki), res.getString(R.string.link_source))).append("<br/><br/>"); sb.append("</body></html>"); mWebView.loadDataWithBaseURL("", sb.toString(), "text/html", "utf-8", null); ((Button) findViewById(R.id.info_continue)).setText(res.getString(R.string.info_rate)); Button debugCopy = ((Button) findViewById(R.id.info_later)); debugCopy.setText(res.getString(R.string.feedback_copy_debug)); debugCopy.setVisibility(View.VISIBLE); debugCopy.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { copyDebugInfo(); } }); break; case TYPE_NEW_VERSION: sb.append(res.getString(R.string.new_version_message)); sb.append("<ul>"); String[] features = res.getStringArray(R.array.new_version_features); for (int i = 0; i < features.length; i++) { sb.append("<li>"); sb.append(features[i]); sb.append("</li>"); } sb.append("</ul>"); sb.append( "<br><br><br>A new design is coming in v2.5, <a href=\"https://groups.google.com/d/msg/anki-android/DrMPHn9NQtk/aZYXdIZRCwAJ\">preview it here</a>!"); sb.append("</body></html>"); mWebView.loadDataWithBaseURL("", sb.toString(), "text/html", "utf-8", null); // reactivating ssl check for every new version AnkiDroidApp.getSharedPrefs(Info.this.getBaseContext()).edit().putBoolean("sslAcceptAll", false) .commit(); break; case TYPE_SHARED_DECKS: mLoadingLayer = (RelativeLayout) findViewById(R.id.info_loading_layer); mLoadingLayer.setVisibility(View.VISIBLE); try { mShareDecksTemplate = Utils.convertStreamToString(getAssets().open("shared_decks_template.html")); } catch (IOException e) { e.printStackTrace(); } mWebView.setWebViewClient(new MobileAnkiWebview()); mWebView.loadUrl(res.getString(R.string.shared_decks_url)); mWebView.getSettings().setJavaScriptEnabled(true); termsAndConditionsView.setVisibility(View.VISIBLE); continueButton.setText(res.getString(R.string.download_button_return)); break; case TYPE_UPGRADE_DECKS: setTitle(R.string.deck_upgrade_title); sb.append("<html><body>"); // add "later" button Button but = (Button) findViewById(R.id.info_later); but.setVisibility(View.VISIBLE); // add sync button Button syncButton = (Button) findViewById(R.id.info_sync); syncButton.setVisibility(View.VISIBLE); mUpgradeStage = getIntent().getIntExtra(TYPE_UPGRADE_STAGE, -1); boolean reupgrading = false; switch (mUpgradeStage) { case UPGRADE_SCREEN_BASIC1: sb.append(getString(R.string.deck_upgrade_major_warning)); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Themes.showThemedToast(Info.this, getString(R.string.deck_upgrade_start_again_to_upgrade_toast), false); setResult(RESULT_CANCELED); finish(); } }); syncButton.setText(R.string.more_options); syncButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_MORE_OPTIONS); setResult(RESULT_OK, result); finishWithAnimation(); } }); continueButton.setText(R.string.now); continueButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); setResult(RESULT_OK, result); finishWithAnimation(); } }); break; case UPGRADE_SCREEN_BASIC2: sb.append(getString(R.string.deck_upgrade_recommended_method)); but.setText(R.string.back); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); result.putExtra(TYPE_ANIMATION_RIGHT, true); setResult(RESULT_OK, result); finishWithAnimation(false); } }); syncButton.setEnabled(false); syncButton.setText("N/A"); syncButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_WEB_UPGRADE); setResult(RESULT_OK, result); finishWithAnimation(); } }); continueButton.setText(getString(R.string.pc)); continueButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE); setResult(RESULT_OK, result); finishWithAnimation(); } }); break; case UPGRADE_SCREEN_MORE_OPTIONS: // If re-upgrading a collection exists already, so don't offer to make a new one if (new File(AnkiDroidApp.getCollectionPath()).exists()) { setTitle(getString(R.string.exit_wizard)); reupgrading = true; sb.append(getString(R.string.deck_upgrade_more_options_exit)); } else { sb.append(getString(R.string.deck_upgrade_more_options_new_collection)); } sb.append(getString(R.string.deck_upgrade_more_options_downgrade)); but.setText(R.string.upgrade_decks_button); but.setText(R.string.back); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1); result.putExtra(TYPE_ANIMATION_RIGHT, true); setResult(RESULT_OK, result); finishWithAnimation(false); } }); if (reupgrading) { syncButton.setText(getString(R.string.upgrade_deck_dont_upgrade)); syncButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_CONTINUE); setResult(RESULT_OK, result); finishWithAnimation(); } }); } else { syncButton.setText(R.string.deck_upgrade_create_new_collection_button); syncButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { StyledDialog.Builder builder = new StyledDialog.Builder(Info.this); builder.setTitle(R.string.deck_upgrade_create_new_collection_title); builder.setIcon(R.drawable.ic_dialog_alert); builder.setMessage(R.string.deck_upgrade_not_import_warning); builder.setPositiveButton(R.string.dialog_positive_create, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_CONTINUE); setResult(RESULT_OK, result); finishWithAnimation(); } }); builder.setNegativeButton(R.string.dialog_cancel, null); builder.show(); } }); } continueButton.setVisibility(View.GONE); break; case UPGRADE_SCREEN_WEB_UPGRADE: sb.append(getString(R.string.deck_upgrade_via_web)); but.setText(R.string.back); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); result.putExtra(TYPE_ANIMATION_RIGHT, true); setResult(RESULT_OK, result); finishWithAnimation(false); } }); syncButton.setVisibility(View.GONE); continueButton.setText(R.string.dialog_continue); continueButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { lockScreenOrientation(); Connection.upgradeDecks(mWebUpgradeListener, new Connection.Payload( new Object[] { AnkiDroidApp.getCurrentAnkiDroidDirectory() })); } }); break; case UPGRADE_SCREEN_PC_UPGRADE: sb.append(getString(R.string.deck_upgrade_via_anki_desktop)); but.setText(R.string.back); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); result.putExtra(TYPE_ANIMATION_RIGHT, true); setResult(RESULT_OK, result); finishWithAnimation(false); } }); syncButton.setText(R.string.usb); syncButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_MANUAL_UPGRADE); setResult(RESULT_OK, result); finishWithAnimation(); } }); continueButton.setEnabled(false); continueButton.setText("N/A"); continueButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_AUTO_UPGRADE); setResult(RESULT_OK, result); finishWithAnimation(); } }); break; case UPGRADE_SCREEN_MANUAL_UPGRADE: sb.append(getString(R.string.deck_upgrade_manual)); but.setText(R.string.back); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2); result.putExtra(TYPE_ANIMATION_RIGHT, true); setResult(RESULT_OK, result); finishWithAnimation(false); } }); syncButton.setText(R.string._import); syncButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { File apkgFile = new File(AnkiDroidApp.getCurrentAnkiDroidDirectory(), DeckPicker.IMPORT_REPLACE_COLLECTION_NAME); List<File> importables = Utils.getImportableDecks(); if (importables == null || !importables.contains(apkgFile)) { Themes.showThemedToast(Info.this, getResources().getString(R.string.upgrade_import_no_file_found, DeckPicker.IMPORT_REPLACE_COLLECTION_NAME), false); } else { lockScreenOrientation(); DeckTask.launchDeckTask(DeckTask.TASK_TYPE_IMPORT_REPLACE, mUpgradeImportListener, new DeckTask.TaskData(AnkiDroidApp.getCol(), apkgFile.getAbsolutePath())); } } }); continueButton.setVisibility(View.GONE); break; case UPGRADE_SCREEN_AUTO_UPGRADE: sb.append(getString(R.string.deck_upgrade_auto_upgrade)); but.setText(R.string.back); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent result = new Intent(); result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE); result.putExtra(TYPE_ANIMATION_RIGHT, true); setResult(RESULT_OK, result); finishWithAnimation(false); } }); syncButton.setText(getString(R.string.upgrade_deck_sync_from_ankiweb)); syncButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { StyledDialog.Builder builder = new StyledDialog.Builder(Info.this); builder.setTitle(R.string.upgrade_deck_sync_from_ankiweb); builder.setIcon(R.drawable.ic_dialog_alert); builder.setMessage(getString(R.string.upgrade_deck_have_you_synced)); builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { lockScreenOrientation(); downloadCollection(); } }); builder.setNegativeButton(R.string.back, null); builder.show(); } }); continueButton.setVisibility(View.GONE); break; } // File[] fileList = (new File(AnkiDroidApp.getCurrentAnkiDroidDirectory())).listFiles(new // OldAnkiDeckFilter()); // StringBuilder fsb = new StringBuilder(); // fsb.append("<ul>"); // for (File f : fileList) { // fsb.append("<li>").append(f.getName().replace(".anki", "")).append("</li>"); // } // fsb.append("</ul>"); // sb.append(res.getString(R.string.upgrade_decks_message, fsb.toString())); // sb.append("<ul><li>"); // sb.append(res.getString(R.string.upgrade_decks_message_pos1, // AnkiDroidApp.getCurrentAnkiDroidDirectory())); // sb.append("</li><li>"); // sb.append(res.getString(R.string.upgrade_decks_message_pos2, res.getString(R.string.link_anki))); // sb.append("</li><li>"); // sb.append(res.getString(R.string.upgrade_decks_message_pos3)); // sb.append("</li></ul>"); // sb.append(res.getString(R.string.upgrade_decks_message_finish)); sb.append("</body></html>"); mWebView.loadDataWithBaseURL("", sb.toString(), "text/html", "utf-8", null); StyledDialog.Builder builder2 = new StyledDialog.Builder(this); // builder2.setTitle(res.getString(R.string.connection_error_title)); builder2.setIcon(R.drawable.ic_dialog_alert); builder2.setMessage(res.getString(R.string.youre_offline)); builder2.setPositiveButton(res.getString(R.string.dialog_ok), null); mNoConnectionAlert = builder2.create(); break; default: finish(); break; } }
From source file:cgeo.geocaching.CacheDetailActivity.java
static void updateCacheLists(final View view, final Geocache cache, final Resources res) { final SpannableStringBuilder builder = new SpannableStringBuilder(); for (final Integer listId : cache.getLists()) { if (builder.length() > 0) { builder.append(", "); }// w w w.j av a 2 s . c om appendClickableList(builder, view, listId); } builder.insert(0, res.getString(R.string.list_list_headline) + " "); final TextView offlineLists = ButterKnife.findById(view, R.id.offline_lists); offlineLists.setText(builder); offlineLists.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:ru.valle.btc.MainActivity.java
private void showSpendPanelForKeyPair(KeyPair keyPair) { if (keyPair != null && keyPair.privateKey.privateKeyDecoded == null) { keyPair = null;//from www.j a v a 2 s.com } if (keyPair != null && !TextUtils.isEmpty(keyPair.address)) { currentKeyPair = keyPair; final String address = keyPair.address; String descStr = getString(R.string.raw_tx_description_header, address); SpannableStringBuilder builder = new SpannableStringBuilder(descStr); int spanBegin = descStr.indexOf(address); if (spanBegin >= 0) { ForegroundColorSpan addressColorSpan = new ForegroundColorSpan( getColor(MainActivity.this, R.color.dark_orange)); builder.setSpan(addressColorSpan, spanBegin, spanBegin + address.length(), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE); } rawTxDescriptionHeaderView.setText(builder); String wutLink = getString(R.string.raw_tx_description_wut_link); String jsonLink = getString(R.string.raw_tx_description_json_link); builder = new SpannableStringBuilder(getString(R.string.raw_tx_description, wutLink, jsonLink)); spanBegin = builder.toString().indexOf(wutLink); ClickableSpan urlSpan = new ClickableSpan() { @Override public void onClick(View widget) { SpannableStringBuilder builder = new SpannableStringBuilder( getText(R.string.raw_tx_description_wut)); setUrlSpanForAddress("blockexplorer.com", address, builder); setUrlSpanForAddress("blockchain.info", address, builder); TextView messageView = new TextView(MainActivity.this); messageView.setText(builder); messageView.setMovementMethod(LinkMovementMethod.getInstance()); int padding = (int) (16 * (getResources().getDisplayMetrics().densityDpi / 160f)); messageView.setPadding(padding, padding, padding, padding); new AlertDialog.Builder(MainActivity.this).setView(messageView) .setPositiveButton(android.R.string.ok, null).show(); } }; builder.setSpan(urlSpan, spanBegin, spanBegin + wutLink.length(), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE); spanBegin = builder.toString().indexOf(jsonLink); urlSpan = new URLSpan("http://blockchain.info/unspent?active=" + address); builder.setSpan(urlSpan, spanBegin, spanBegin + jsonLink.length(), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE); rawTxDescriptionView.setText(builder); rawTxDescriptionView.setMovementMethod(LinkMovementMethod.getInstance()); onUnspentOutputsInfoChanged(); } sendLayout.setVisibility(keyPair != null ? View.VISIBLE : View.GONE); enterPrivateKeyAck.setVisibility(keyPair == null ? View.VISIBLE : View.GONE); }
From source file:pro.dbro.bart.TheActivity.java
public void displayEtdResponse(etdResponse etdResponse) { if (timer != null) timer.cancel(); // cancel previous timer long now = new Date().getTime(); timerViews = new ArrayList(); // release old ETA text views maxTimer = 0; // reset maxTimer fareTv.setText(""); fareTv.setVisibility(View.GONE); tableLayout.removeAllViews();/*from w w w . j ava 2s. c om*/ String lastDestination = ""; // Display the alert ImageView and create a click listener to display alert html if (etdResponse.message != null) { // If the response message matches the response for a closed station, // Display "Closed for tonight" and time of next train, if available. if (etdResponse.message.contains("No data matched your criteria.")) { String message = "This station is closed for tonight"; TextView specialScheduleTextView = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTextView.setPadding(0, 0, 0, 0); if (etdResponse.etds != null && etdResponse.etds.size() > 0) { Date nextTrain = new Date(etdResponse.date.getTime() + ((etd) etdResponse.etds.get(0)).minutesToArrival * 60 * 1000); SimpleDateFormat sdf = new SimpleDateFormat("KK:MM a"); message += ". Next train at " + sdf.format(nextTrain); } specialScheduleTextView.setText(message); tableLayout.addView(specialScheduleTextView); } else { // Create an imageview that spawns an alertDialog with BART message ImageView specialScheduleImageView = (ImageView) View.inflate(c, R.layout.specialschedulelayout, null); // Tag the specialScheduleImageView with the message html specialScheduleImageView.setTag(Html.fromHtml(etdResponse.message)); // Set the OnClickListener for the specialScheduleImageView to display the tagged message html specialScheduleImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { TextView specialScheduleTv = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTv.setPadding(0, 0, 0, 0); specialScheduleTv.setText(Html.fromHtml(arg0.getTag().toString())); specialScheduleTv.setTextSize(16); specialScheduleTv.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(c).setTitle("Station Alerts").setIcon(R.drawable.warning) .setView(specialScheduleTv).setPositiveButton("Bummer", null).show(); } }); tableLayout.addView(specialScheduleImageView); } } TableRow tr = (TableRow) View.inflate(c, R.layout.tablerow_right, null); LinearLayout destinationRow = (LinearLayout) View.inflate(c, R.layout.destination_row, null); //TextView timeTv =(TextView) View.inflate(c, R.layout.tabletext, null); int numAlt = 0; for (int x = 0; x < etdResponse.etds.size(); x++) { if (etdResponse.etds.get(x) == null) break; etd thisEtd = (etd) etdResponse.etds.get(x); if (thisEtd.destination != lastDestination) { // new train destination numAlt = 0; tr = (TableRow) View.inflate(c, R.layout.tablerow_right, null); tr.setPadding(0, 0, 10, 0); destinationRow = (LinearLayout) View.inflate(c, R.layout.destination_row, null); TextView destinationTv = (TextView) View.inflate(c, R.layout.destinationlayout, null); if (x == 0) destinationTv.setPadding(0, 0, 0, 0); //bullet.setWidth(200); //destinationTv.setPadding(0, 0, 0, 0); destinationTv.setTextSize(28); destinationTv.setText(thisEtd.destination); TextView timeTv = (TextView) View.inflate(c, R.layout.tabletext, null); // Display eta less than 1m as "<1" if (thisEtd.minutesToArrival == 0) timeTv.setText("<1"); else timeTv.setText(String.valueOf(thisEtd.minutesToArrival)); timeTv.setSingleLine(false); timeTv.setTextSize(36); //timeTv.setPadding(30, 0, 0, 0); long counterTime = thisEtd.minutesToArrival * 60 * 1000; if (counterTime > maxTimer) { maxTimer = counterTime; } timeTv.setTag(counterTime + now); timerViews.add(timeTv); //new ViewCountDownTimer(timeTv, counterTime, 60*1000).start(); //text.setWidth(120); destinationRow.addView(destinationTv); //tr.addView(destinationTv); tr.addView(timeTv); tr.setTag(thisEtd); tableLayout.addView(destinationRow); tableLayout.addView(tr); tr.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { int index = tableLayout.indexOfChild(arg0); // index of clicked view. Expanded view will always be +1 etd thisEtd = (etd) arg0.getTag(); if (!thisEtd.isExpanded) { // if route not expanded thisEtd.isExpanded = true; LinearLayout routeDetail = (LinearLayout) View.inflate(c, R.layout.routedetail, null); TextView platformTv = (TextView) View.inflate(c, R.layout.tabletext, null); platformTv.setPadding(0, 0, 0, 0); platformTv.setText("platform " + thisEtd.platform); platformTv.setTextSize(20); routeDetail.addView(platformTv); ImageView bikeIv = (ImageView) View.inflate(c, R.layout.bikeimage, null); if (!thisEtd.bikes) bikeIv.setImageResource(R.drawable.no_bicycle); routeDetail.addView(bikeIv); tableLayout.addView(routeDetail, index + 1); } else { thisEtd.isExpanded = false; tableLayout.removeViewAt(index + 1); } } }); } else { // append next trains arrival time to existing destination display //timeTv.append(String.valueOf(", "+thisEtd.minutesToArrival)); numAlt++; TextView nextTimeTv = (TextView) View.inflate(c, R.layout.tabletext, null); //nextTimeTv.setTextSize(36-(5*numAlt)); nextTimeTv.setTextSize(36); nextTimeTv.setText(String.valueOf(thisEtd.minutesToArrival)); //nextTimeTv.setPadding(30, 0, 0, 0); if (numAlt == 1) //0xFFF06D2F C9C7C8 nextTimeTv.setTextColor(0xFFC9C7C8); else if (numAlt == 2) nextTimeTv.setTextColor(0xFFA8A7A7); long counterTime = thisEtd.minutesToArrival * 60 * 1000; nextTimeTv.setTag(counterTime + now); if (counterTime > maxTimer) { maxTimer = counterTime; } timerViews.add(nextTimeTv); //new ViewCountDownTimer(nextTimeTv, counterTime, 60*1000).start(); tr.addView(nextTimeTv); } lastDestination = thisEtd.destination; } // end for //scrolly.scrollTo(0, 0); // Avoid spamming bart.gov. Only re-ping if etd response is valid for at least 3m if (maxTimer > 1000 * 60 * 3) { timer = new ViewCountDownTimer(timerViews, "etd", maxTimer, 30 * 1000); timer.start(); } }
From source file:net.phase.wallet.Currency.java
protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case DIALOG_URL: TextView tv = (TextView) dialog.findViewById(R.id.pasteBinHelpText); tv.setMovementMethod(LinkMovementMethod.getInstance()); break;/* www . j a v a 2s . co m*/ case DIALOG_FILE: TextView tvhelp = (TextView) dialog.findViewById(R.id.helpText); tvhelp.setMovementMethod(LinkMovementMethod.getInstance()); Spinner fileSpinner = (Spinner) dialog.findViewById(R.id.fileInput); File[] files = Environment.getExternalStorageDirectory().listFiles(fileFilter); if (files == null || files.length == 0) { toastMessage("No files found on sdcard"); } else { ArrayAdapter<File> adapter = new ArrayAdapter<File>(this, android.R.layout.simple_spinner_item, files); fileSpinner.setAdapter(adapter); } break; case DIALOG_PASTE: EditText keyText = (EditText) dialog.findViewById(R.id.keysText); keyText.setText(""); break; case DIALOG_OPTIONS: EditText reqText = (EditText) dialog.findViewById(R.id.reqText); reqText.setText(Integer.toString(maxlength)); Spinner currencySpinner = (Spinner) dialog.findViewById(R.id.currencySpinner); Spinner decimalSpinner = (Spinner) dialog.findViewById(R.id.decpointSpinner); String current = getActiveCurrency(); String[] currencies = { current }; try { currencies = Currency.getAvailableCurrencies(); } catch (IOException e) { WalletActivity.toastMessage("Warning: unable to obtain currency information"); } catch (JSONException e) { } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, currencies); currencySpinner.setAdapter(adapter); for (int i = 0; i < currencies.length; i++) { if (currencies[i].equals(current)) { currencySpinner.setSelection(i); break; } } Integer[] decimaloptions = { 0, 1, 2, 3, 4, 5 }; ArrayAdapter<Integer> adapter2 = new ArrayAdapter<Integer>(this, android.R.layout.simple_spinner_item, decimaloptions); decimalSpinner.setAdapter(adapter2); for (int i = 0; i < decimaloptions.length; i++) { if (decimaloptions[i].intValue() == decimalpoints) { decimalSpinner.setSelection(i); break; } } break; } }
From source file:com.heath_bar.tvdb.SeriesOverview.java
/** Populate the GUI with the episode information */ private void PopulateStuffPartTwo() { // Populate the next/last episodes TvEpisode last = episodeList.getLastAired(); TvEpisode next = episodeList.getNextAired(); SpannableString text = null;/*from ww w . j a va2s . c o m*/ TextView richTextView = (TextView) findViewById(R.id.last_episode); if (last == null) { text = new SpannableString("Last Episode: unknown"); } else { text = new SpannableString( "Last Episode: " + last.getName() + " (" + DateUtil.toString(last.getAirDate()) + ")"); NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() { @Override public void onClick(View view) { episodeListener.onClick(view); } }; int start = 14; int end = start + last.getName().length(); text.setSpan(clickableSpan, start, end, 0); text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0); text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0); richTextView.setId(last.getId()); richTextView.setMovementMethod(LinkMovementMethod.getInstance()); } richTextView.setText(text, BufferType.SPANNABLE); text = null; richTextView = (TextView) findViewById(R.id.next_episode); if (seriesInfo != null && seriesInfo.getStatus() != null && !seriesInfo.getStatus().equals("Ended")) { if (next == null) { text = new SpannableString("Next Episode: unknown"); } else { text = new SpannableString( "Next Episode: " + next.getName() + " (" + DateUtil.toString(next.getAirDate()) + ")"); NonUnderlinedClickableSpan clickableSpan = new NonUnderlinedClickableSpan() { @Override public void onClick(View view) { episodeListener.onClick(view); } }; int start = 14; int end = start + next.getName().length(); text.setSpan(clickableSpan, start, end, 0); text.setSpan(new TextAppearanceSpan(this, R.style.episode_link), start, end, 0); text.setSpan(new AbsoluteSizeSpan((int) textSize, true), 0, text.length(), 0); richTextView.setId(next.getId()); richTextView.setMovementMethod(LinkMovementMethod.getInstance()); } richTextView.setText(text, BufferType.SPANNABLE); } }
From source file:eu.trentorise.smartcampus.trentinofamiglia.map.InfoDialog.java
@Override public void onStart() { super.onStart(); TextView msg = (TextView) getDialog().findViewById(R.id.mapdialog_msg); if (data instanceof POIObject) { msg.setText(Html.fromHtml("<h2>" + ((POIObject) data).getTitle() + "</h2><br/><p>" + Utils.getPOIshortAddress(((POIObject) data)) + "</p>")); } else if (data instanceof ExplorerObject) { ExplorerObject event = (ExplorerObject) data; POIObject poi = DTHelper.findPOIById(event.getPoiId()); String msgText = ""; msgText += "<h2>"; msgText += event.getTitle();/*from www. j a va 2 s.c om*/ msgText += "</h2><br/><p>"; if (event.getType() != null) { msgText += "<p>"; msgText += getString(CategoryHelper.getCategoryDescriptorByCategoryFiltered( CategoryHelper.CATEGORY_TYPE_EVENTS, event.getType()).description); msgText += "</p><br/>"; } msgText += "<p>" + event.eventDatesString() + "</p>"; if (event.getTiming() != null) { msgText += "<p>" + event.getTiming() + "</p>"; } if (poi != null) { msgText += "<p>" + Utils.getPOIshortAddress(poi) + "</p>"; } else { String place = Utils.getEventShortAddress(event); if (place != null) { msgText += "<p>" + place + "</p>"; } } msg.setText(Html.fromHtml(msgText)); } else if (data instanceof TrackObject) { msg.setText(Html.fromHtml("<h2>" + data.getTitle() + "</h2>")); } msg.setMovementMethod(new ScrollingMovementMethod()); Button b = (Button) getDialog().findViewById(R.id.mapdialog_cancel); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getDialog().dismiss(); } }); b = (Button) getDialog().findViewById(R.id.mapdialog_ok); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager() .beginTransaction(); Bundle args = new Bundle(); if (data instanceof POIObject) { PoiDetailsFragment fragment = new PoiDetailsFragment(); args.putString(PoiDetailsFragment.ARG_POI_ID, data.getId()); fragment.setArguments(args); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); fragmentTransaction.replace(R.id.frame_content, fragment, "me"); fragmentTransaction.addToBackStack(fragment.getTag()); } else if (data instanceof ExplorerObject) { EventDetailsFragment fragment = new EventDetailsFragment(); args.putString(EventDetailsFragment.ARG_EVENT_ID, (data.getId())); fragment.setArguments(args); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); fragmentTransaction.replace(R.id.frame_content, fragment, "me"); fragmentTransaction.addToBackStack(fragment.getTag()); } else if (data instanceof TrackObject) { TrackDetailsFragment fragment = new TrackDetailsFragment(); args.putString(TrackDetailsFragment.ARG_TRACK_ID, (data.getId())); fragment.setArguments(args); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); fragmentTransaction.replace(R.id.frame_content, fragment, "me"); fragmentTransaction.addToBackStack(fragment.getTag()); } fragmentTransaction.commit(); getDialog().dismiss(); } }); }