List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:de.audioattack.yacy32c3search.activity.AlertDialog.java
@Override public void onStart() { super.onStart(); ((TextView) getDialog().findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java
/** * Sets a text on a {@link TextView}, provided via viewResId, within a parent view. * If there's a web url in the tag the text will be converted from Html, respecting tags. * * @param parent The view's parent./* ww w . j av a 2 s .c om*/ * @param viewResId The resource to resolve. * @param text The text to set. */ public static void setTextOn(@NonNull View parent, @IdRes int viewResId, @Nullable CharSequence text) { if (TextUtils.isEmpty(text)) { text = ""; } View view = parent.findViewById(viewResId); if (view instanceof TextView) { TextView textView = (TextView) view; // Only perform Html conversion if there's actually an Url in the text. if (Patterns.WEB_URL.matcher(text).find()) { textView.setText(Html.fromHtml(text.toString())); textView.setMovementMethod(LinkMovementMethod.getInstance()); } else { textView.setText(text); } } }
From source file:com.henry.ecdemo.ui.chatting.model.DescriptionRxRow.java
@Override public void buildChattingData(final Context context, BaseHolder baseHolder, ECMessage detail, int position) { DescriptionViewHolder holder = (DescriptionViewHolder) baseHolder; ECMessage message = detail;//from w ww.j a v a 2 s .c o m if (message != null) { if (message.getType() == ECMessage.Type.TXT) { String msgType = ""; JSONArray jsonArray = null; if (!TextUtils.isEmpty(message.getUserData())) try { JSONObject jsonObject = new JSONObject(message.getUserData()); msgType = jsonObject.getString(CCPChattingFooter2.TXT_MSGTYPE); jsonArray = jsonObject.getJSONArray(CCPChattingFooter2.MSG_DATA); } catch (JSONException e) { e.printStackTrace(); } if (TextUtils.equals(msgType, CCPChattingFooter2.FACETYPE)) { holder.getDescTextView().setBackgroundResource(0); } else { holder.getDescTextView().setBackgroundResource(R.drawable.chat_from_bg_normal); } ECTextMessageBody textBody = (ECTextMessageBody) message.getBody(); String msgTextString = textBody.getMessage(); holder.getDescTextView().showMessage(message.getId() + "", msgTextString, msgType, jsonArray); holder.getDescTextView().setMovementMethod(LinkMovementMethod.getInstance()); View.OnClickListener onClickListener = ((ChattingActivity) context).mChattingFragment .getChattingAdapter().getOnClickListener(); ViewHolderTag holderTag = ViewHolderTag.createTag(message, ViewHolderTag.TagType.TAG_IM_TEXT, position); holder.getDescTextView().setTag(holderTag); holder.getDescTextView().setOnClickListener(onClickListener); } else if (message.getType() == ECMessage.Type.CALL) { ECCallMessageBody textBody = (ECCallMessageBody) message.getBody(); holder.getDescTextView().setText(textBody.getCallText()); holder.getDescTextView().setMovementMethod(LinkMovementMethod.getInstance()); } } }
From source file:com.github.jobs.ui.fragment.JobDetailsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Bundle arguments = getArguments();// w w w . ja v a 2 s.c om String jobId = arguments.getString(KEY_JOB_ID); mJob = new Job(); mJob.setId(jobId); mJob = adapter.findFirst(mJob); if (mJob == null) { mJob = new Job(); Toast.makeText(getActivity(), R.string.error_getting_job_info, Toast.LENGTH_LONG).show(); } setHasOptionsMenu(true); TextView title = (TextView) getView().findViewById(R.id.title); title.setText(StringUtils.trim(mJob.getTitle())); TextView description = (TextView) getView().findViewById(R.id.description); String jobDescription = mJob.getDescription(); if (jobDescription != null) { description.setText(Html.fromHtml(jobDescription)); description.setMovementMethod(LinkMovementMethod.getInstance()); } TextView company = (TextView) getView().findViewById(R.id.company); company.setText(mJob.getCompany()); TextView companyUrl = (TextView) getView().findViewById(R.id.company_url); if (mJob.getCompanyUrl() == null) { companyUrl.setVisibility(View.GONE); } else { SpannableString content = new SpannableString(mJob.getCompanyUrl()); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); companyUrl.setText(content); companyUrl.setOnClickListener(this); companyUrl.setVisibility(View.VISIBLE); } TextView companyLocation = (TextView) getView().findViewById(R.id.company_location); if (mJob.getLocation() == null) { companyLocation.setVisibility(View.GONE); } else { companyLocation.setText(mJob.getLocation()); companyLocation.setVisibility(View.VISIBLE); } if (!JobDetailsActivity.FULL_TIME.equalsIgnoreCase(mJob.getType())) { getView().findViewById(R.id.full_time).setVisibility(View.INVISIBLE); } mBackground = (ImageView) getView().findViewById(R.id.job_details_background); setLogoBackground(); }
From source file:de.atomfrede.android.scc.about.AboutDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.dialog_about, container, false); Resources resources = getActivity().getResources(); getDialog().setTitle(resources.getString(R.string.about_header)); // Look for all text views and fill them with data String app_ver = ""; try {//w w w . j ava2 s . co m app_ver = this.getActivity().getPackageManager().getPackageInfo(this.getActivity().getPackageName(), 0).versionName; } catch (NameNotFoundException e) { Log.v(TAG, e.getMessage()); } String appName = resources.getString(R.string.app_name); String homepage = resources.getString(R.string.link_homepage); String androidAnnotations = resources.getString(R.string.link_android_annotations); String viewpagerIndicator = resources.getString(R.string.link_viewpager_indicator); String greendao = resources.getString(R.string.link_viewpager_green_dao); TextView versionText = (TextView) v.findViewById(R.id.version_text); versionText.setText("Version " + app_ver); TextView appNameText = (TextView) v.findViewById(R.id.app_name_text); appNameText.setText(appName); TextView aboutAppNameText = (TextView) v.findViewById(R.id.scc_application_text); aboutAppNameText.setText(resources.getString(R.string.about_app_name)); TextView homepageText = (TextView) v.findViewById(R.id.homepage_link_text); homepageText.setText(Html.fromHtml(homepage)); homepageText.setMovementMethod(LinkMovementMethod.getInstance()); TextView androidAnnotationsText = (TextView) v.findViewById(R.id.android_annotations_text); androidAnnotationsText.setText(Html.fromHtml(androidAnnotations)); androidAnnotationsText.setMovementMethod(LinkMovementMethod.getInstance()); TextView viewpagerText = (TextView) v.findViewById(R.id.viewpager_text); viewpagerText.setText(Html.fromHtml(viewpagerIndicator)); viewpagerText.setMovementMethod(LinkMovementMethod.getInstance()); TextView greendaoText = (TextView) v.findViewById(R.id.greendao_text); greendaoText.setText(Html.fromHtml(greendao)); greendaoText.setMovementMethod(LinkMovementMethod.getInstance()); Button feedbackButton = (Button) v.findViewById(R.id.feedback_button); feedbackButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendFeedbackMail(); } }); return v; }
From source file:cn.zhangls.android.weibo.ui.weibo.content.RepostViewProvider.java
@Override protected void onBindContentViewHolder(@NonNull final RepostHolder holder, @NonNull final Status status) { // ??/*ww w.j a v a 2s . c om*/ // ? StringBuffer buffer = new StringBuffer(); if (status.getRetweeted_status().getUser() != null) {// ??? buffer.append("@"); buffer.append(status.getRetweeted_status().getUser().getName() != null ? status.getRetweeted_status().getUser().getName() : status.getRetweeted_status().getUser().getScreen_name() != null ? status.getRetweeted_status().getUser().getScreen_name() : "") .append(" :"); holder.mTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CommentActivity.actionStart(holder.mTextView.getContext(), status.getRetweeted_status()); } }); } buffer.append(status.getRetweeted_status().getText()); final Context context = holder.itemView.getContext(); holder.mTextView.setText(TextUtil.convertText(context, buffer.toString(), ContextCompat.getColor(context, R.color.colorAccent), (int) holder.mTextView.getTextSize())); holder.mTextView.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.naman14.algovisualizer.AlgoDescriptionFragment.java
private void addDescData(String algorithmKey) { if (descJson == null || descObject == null || getActivity() == null) { return;//from w w w. j a v a 2s .c om } rootView.removeAllViews(); try { JSONObject dataObject = descObject.getJSONObject(algorithmKey); Iterator<?> keys = dataObject.keys(); while (keys.hasNext()) { View descView = LayoutInflater.from(getActivity()).inflate(R.layout.item_code_desc, rootView, false); TextView title = (TextView) descView.findViewById(R.id.title); TextView desc = (TextView) descView.findViewById(R.id.desc); desc.setMovementMethod(LinkMovementMethod.getInstance()); String key = (String) keys.next(); title.setText(key); if (dataObject.get(key) instanceof JSONObject) { JSONObject jsonObject = dataObject.getJSONObject(key); String descString = ""; Iterator<?> complexityKeys = jsonObject.keys(); while (complexityKeys.hasNext()) { String complexityKey = (String) complexityKeys.next(); descString += " - "; descString += complexityKey; descString += " : "; descString += jsonObject.getString(complexityKey); descString += "<br>"; } desc.setText(Html.fromHtml(descString)); } else if (dataObject.get(key) instanceof JSONArray) { JSONArray array = dataObject.getJSONArray(key); String descString = ""; for (int i = 0; i < array.length(); i++) { descString += " - "; descString += array.getString(i); descString += "<br>"; } desc.setText(Html.fromHtml(descString)); } else if (dataObject.get(key) instanceof String) { desc.setText(Html.fromHtml(dataObject.getString(key))); } rootView.addView(descView); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ota.updates.fragments.AboutFragment.java
private void setupChangelog(View view, File file) { if (DEBUGGING) { Log.d(TAG, "Setting up changelog"); }/*w w w. j a v a 2s.c o m*/ TextView changelogTV = (TextView) view.findViewById(R.id.changelog); Bypass bypass = new Bypass(mContext); String changelogString; try { changelogString = Utils.getFileContents(file); } catch (IOException e) { changelogString = getResources().getString(R.string.changelog_error); e.printStackTrace(); } CharSequence changelogText = bypass.markdownToSpannable(changelogString); changelogTV.setText(changelogText); changelogTV.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.gdgsp.fragment.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); view = inflater.inflate(R.layout.fragment_about, container, false); String about_text = "<h3>GDG</h3>" + "<p>O Google Developers Group uma iniciativa de pessoas interessadas em construir com tecnologia e disseminar o conhecimento. Nossos eventos so direcionados para a comunidade de desenvolvedores, engenheiros, designers e empreendedores, organizados pelos nossos membros de forma voluntria e sem fins lucrativos. Encontre outros captulos do GDG no Brasil no <a href=\"https://developers.google.com/groups/directory/Brazil\">Google Developers</a>.</p>" + "<p><h3>Aplicativo</h3></p>" + "<p>" + activity.getString(R.string.app_name) + " para Android verso: " + Other.getAppVersion(activity) + "</p>" + "<p>Aplicativo desenvolvido por <a href=\"http://alefesouza.com\">Alefe Souza</a></p>" + "<p>Esse aplicativo foi desenvolvido em cdigo aberto para Android, Universal Windows Platform e Xamarin.Forms, voc pode ver o cdigo exato dos aplicativos e o back-end em PHP no meu <a href=\"http://github.com/alefesouza/gdg-sp\">GitHub</a>, procurei deixar o cdigo para ser facilmente adaptado para outros meetups, deixando informaes de como fazer isso em cada projeto.</p>" + "Nesse aplicativo foi utilizado:" + "<br><br><a href=\"http://icons8.com\">Icons8</a>" + "<br><a href=\"http://github.com/koush/ion\">Ion</a>" + "<br><a href=\"http://onesignal.com\">OneSignal</a>" + "<br><a href=\"http://github.com/vinc3m1/RoundedImageView\">Rounded Image View</a>" + "<br><a href=\"https://gist.github.com/darnmason/7bbf8beae24fe7296c8a\">HeaderViewRecyclerAdapter</a>" + "<br><a href=\"http://github.com/google/gson\">Gson</a>" + "<br><a href=\"http://developer.android.com/topic/libraries/support-library/index.html\">Android Support Libraries</a>" + "<br><a href=\"http://developers.google.com/android/guides/overview\">Google Play Services</a>"; TextView about = (TextView) view.findViewById(R.id.about); about.setMovementMethod(LinkMovementMethod.getInstance()); about.setText(Html.fromHtml(about_text)); return view;//from ww w . j a v a2 s .c o m }
From source file:com.abcs.haiwaigou.yyg.view.ReadMoreTextView.java
private void setText() { super.setText(getDisplayableText(), bufferType); setMovementMethod(LinkMovementMethod.getInstance()); setHighlightColor(Color.TRANSPARENT); }