List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:eu.lucazanini.arpav.fragment.CreditsFragment.java
@Nullable @Override/*from www. j av a 2 s . c om*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.fragment_credits, container, false); unbinder = ButterKnife.bind(this, v); tvDataTitle.setText(dataTitle); tvDataBody.setMovementMethod(LinkMovementMethod.getInstance()); SpannableString ssDataBody = getTextWithLink(new SpannableString(dataBody), arpavName, arpavSite); ssDataBody = getTextWithLink(ssDataBody, arpavLicenseName, arpavLicenseSite); tvDataBody.setText(ssDataBody); tvIconsTitle.setText(iconsTitle); tvIconsBody.setMovementMethod(LinkMovementMethod.getInstance()); SpannableString ssIconsBody = getTextWithLink(new SpannableString(iconsBody), nickName, nickSite); ssIconsBody = getTextWithLink(ssIconsBody, nickLicenseName, nickSite); ssIconsBody = getTextWithLink(ssIconsBody, emilieName, emilieSite); ssIconsBody = getTextWithLink(ssIconsBody, emilieLicenseName, emilieLicenseSite); tvIconsBody.setText(ssIconsBody); tvDeveloperTitle.setText(developerTitle); tvDeveloperBody.setMovementMethod(LinkMovementMethod.getInstance()); SpannableString ssDeveloperBody = getTextWithLink(new SpannableString(developerBody), developerName, developerSite); ssDeveloperBody = getTextWithLink(ssDeveloperBody, appLicenseName, appLicenseSite); ssDeveloperBody = getTextWithLink(ssDeveloperBody, repositoryName, repositorySite); tvDeveloperBody.setText(ssDeveloperBody); return v; }
From source file:hku.fyp14017.blencode.ui.dialogs.TermsOfUseDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { Bundle fragmentDialogArguments = getArguments(); boolean acceptTermsOfUse = false; if (fragmentDialogArguments != null) { acceptTermsOfUse = fragmentDialogArguments.getBoolean(DIALOG_ARGUMENT_TERMS_OF_USE_ACCEPT, false); }//from ww w. j a va2 s.c om View view = LayoutInflater.from(getActivity()).inflate(hku.fyp14017.blencode.R.layout.dialog_terms_of_use, null); final CheckBox checkBoxTermsOfUseAcceptedPermanently = (CheckBox) view .findViewById(hku.fyp14017.blencode.R.id.dialog_terms_of_use_check_box_agree_permanently); TextView termsOfUseUrlTextView = (TextView) view .findViewById(hku.fyp14017.blencode.R.id.dialog_terms_of_use_text_view_url); termsOfUseUrlTextView.setMovementMethod(LinkMovementMethod.getInstance()); String termsOfUseUrl = getString(hku.fyp14017.blencode.R.string.terms_of_use_link_template, Constants.CATROBAT_TERMS_OF_USE_URL, getString(hku.fyp14017.blencode.R.string.dialog_terms_of_use_link_text)); termsOfUseUrlTextView.setText(Html.fromHtml(termsOfUseUrl)); AlertDialog.Builder termsOfUseDialogBuilder = new AlertDialog.Builder(getActivity()).setView(view) .setTitle(hku.fyp14017.blencode.R.string.dialog_terms_of_use_title); if (!acceptTermsOfUse) { termsOfUseDialogBuilder.setNeutralButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); } else { termsOfUseDialogBuilder.setNegativeButton( hku.fyp14017.blencode.R.string.dialog_terms_of_use_do_not_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { getActivity().finish(); dialog.dismiss(); } }); termsOfUseDialogBuilder.setPositiveButton(hku.fyp14017.blencode.R.string.dialog_terms_of_use_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (checkBoxTermsOfUseAcceptedPermanently.isChecked()) { SettingsActivity.setTermsOfServiceAgreedPermanently(getActivity(), true); } dialog.dismiss(); DroneInitializer droneInitializer = ((PreStageActivity) getActivity()) .getDroneInitializer(); if (droneInitializer != null) { droneInitializer.initialiseDrone(); } } }); termsOfUseDialogBuilder.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { Log.d(TAG, "prevent canceling the dialog with back button"); return true; } }); checkBoxTermsOfUseAcceptedPermanently.setVisibility(CheckBox.VISIBLE); checkBoxTermsOfUseAcceptedPermanently .setText(hku.fyp14017.blencode.R.string.dialog_terms_of_use_agree_permanent); termsOfUseDialogBuilder.setCancelable(false); } AlertDialog termsOfUseDialog = termsOfUseDialogBuilder.create(); if (!acceptTermsOfUse) { termsOfUseDialog.setCanceledOnTouchOutside(true); } else { termsOfUseDialog.setCancelable(false); termsOfUseDialog.setCanceledOnTouchOutside(false); } return termsOfUseDialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.LoginRegisterDialog.java
@Override public Dialog onCreateDialog(Bundle bundle) { View rootView = LayoutInflater.from(getActivity()) .inflate(hku.fyp14017.blencode.R.layout.dialog_login_register, null); usernameEditText = (EditText) rootView.findViewById(hku.fyp14017.blencode.R.id.username); passwordEditText = (EditText) rootView.findViewById(hku.fyp14017.blencode.R.id.password); termsOfUseLinkTextView = (TextView) rootView.findViewById(hku.fyp14017.blencode.R.id.register_terms_link); String termsOfUseUrl = getString(hku.fyp14017.blencode.R.string.about_link_template, Constants.CATROBAT_TERMS_OF_USE_URL, getString(hku.fyp14017.blencode.R.string.register_pocketcode_terms_of_use_text)); termsOfUseLinkTextView.setMovementMethod(LinkMovementMethod.getInstance()); termsOfUseLinkTextView.setText(Html.fromHtml(termsOfUseUrl)); usernameEditText.setText(""); passwordEditText.setText(""); final AlertDialog loginRegisterDialog = new AlertDialog.Builder(getActivity()).setView(rootView) .setTitle(hku.fyp14017.blencode.R.string.login_register_dialog_title) .setPositiveButton(hku.fyp14017.blencode.R.string.login_or_register, null) .setNeutralButton(hku.fyp14017.blencode.R.string.password_forgotten, null).create(); loginRegisterDialog.setCanceledOnTouchOutside(true); loginRegisterDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); loginRegisterDialog.setOnShowListener(new OnShowListener() { @Override/*w w w. j a va2 s . c o m*/ public void onShow(DialogInterface dialog) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(usernameEditText, InputMethodManager.SHOW_IMPLICIT); Button loginRegisterButton = loginRegisterDialog.getButton(AlertDialog.BUTTON_POSITIVE); loginRegisterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handleLoginRegisterButtonClick(); } }); Button passwordFhkuottenButton = loginRegisterDialog.getButton(AlertDialog.BUTTON_NEUTRAL); passwordFhkuottenButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handlePasswordForgottenButtonClick(); } }); } }); return loginRegisterDialog; }
From source file:com.cpd.activities.NewsOpenActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_news_open); if (getResources().getBoolean(R.bool.portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else {/*from www .j av a 2 s . co m*/ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } Intent intent = getIntent(); mNewsVo = (NewsVo) intent.getSerializableExtra(AppTags.NEWS_VO); TrackerUtils.clickNewsArticle(mNewsVo.title); final TextView articleTextView = (TextView) findViewById(R.id.news_activity_text); mLoader = new NewsLoader(new NewsParser.NewsReady() { @Override public void OnNewsReady(NewsVo newsArticle) { mConnectionTries++; /* Avoid infinite loop */ if (mConnectionTries <= ConnectionUtils.MAX_NETWORK_TENTATIVES) { if (newsArticle.articleText == null) { mLoader.run(mNewsVo, true); } else { // Interpret HTML tags mConnectionTries = 0; articleTextView.setText(Html.fromHtml(newsArticle.articleText)); articleTextView.setMovementMethod(LinkMovementMethod.getInstance()); if (DebugUtils.DEBUG) Log.d(TAG, "Opened article: " + newsArticle.title); } } else { if (DebugUtils.ERROR) Log.e(TAG, "Not connecting to news!"); } } }); mLoader.run(mNewsVo, true); // The RssParser already gives the title and image. Therefore, we can load this content // while the NewsParser is running. Toolbar toolbar = (Toolbar) findViewById(R.id.news_open_toolbar); setSupportActionBar(toolbar); ImageView imageView = (ImageView) findViewById(R.id.news_activity_picture); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openImageActivity(); } }); Picasso.with(this).load(mNewsVo.imgLargeUrl).into(imageView); TextView titleView = (TextView) findViewById(R.id.news_activity_title); titleView.setText(mNewsVo.title); }
From source file:com.mycelium.wallet.activity.main.AdFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = Preconditions.checkNotNull(inflater.inflate(R.layout.main_ad_fragment, container, false)); btAdvice = (Button) root.findViewById(R.id.btAdvice); updateAdContent();//ww w . ja va 2 s. c o m btAdvice.setMovementMethod(LinkMovementMethod.getInstance()); return root; }
From source file:com.henry.ecdemo.ui.chatting.model.DescriptionTxRow.java
@Override public void buildChattingData(Context context, BaseHolder baseHolder, ECMessage msg, int position) { DescriptionViewHolder holder = (DescriptionViewHolder) baseHolder; if (msg != null) { String msgType = ""; JSONArray jsonArray = null;/* ww w . jav a 2 s . co m*/ if (!TextUtils.isEmpty(msg.getUserData())) try { JSONObject jsonObject = new JSONObject(msg.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_to_bg_normal); } ECTextMessageBody textBody = (ECTextMessageBody) msg.getBody(); String msgTextString = textBody.getMessage(); holder.getDescTextView().showMessage(msg.getId() + "", msgTextString, msgType, jsonArray); holder.getDescTextView().setMovementMethod(LinkMovementMethod.getInstance()); View.OnClickListener onClickListener = ((ChattingActivity) context).mChattingFragment .getChattingAdapter().getOnClickListener(); ViewHolderTag holderTag = ViewHolderTag.createTag(msg, ViewHolderTag.TagType.TAG_IM_TEXT, position); holder.getDescTextView().setTag(holderTag); holder.getDescTextView().setOnClickListener(onClickListener); setAutoLinkForTextView(holder.getDescTextView()); getMsgStateResId(position, holder, msg, onClickListener); } }
From source file:com.grokkingandroid.sampleapp.samples.SampleBaseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_demo_base, container, false); if (isFragmentWithInlineDescription()) { TextView description = (TextView) rootView.findViewById(R.id.demoapp_fragment_description); Spanned descSpannable = Html.fromHtml(getResources().getString(getDescriptionTextId())); description.setText(descSpannable); description.setMovementMethod(LinkMovementMethod.getInstance()); ViewGroup linkContainer = (ViewGroup) rootView.findViewById(R.id.container_demo_blog_links); showLinks(linkContainer);/*from ww w .j a v a 2s.c om*/ linkContainer.invalidate(); } else { rootView.findViewById(R.id.container_demo_description).setVisibility(View.GONE); rootView.findViewById(R.id.container_demo_blog_links).setVisibility(View.GONE); } // delegate to subclass for content view ViewGroup contentContainer = (ViewGroup) rootView.findViewById(R.id.container_demo_content); onCreateContentView(inflater, contentContainer, savedInstanceState); return rootView; }
From source file:cw.kop.autobackground.tutorial.FinishFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tutorial_finish_fragment, container, false); int colorFilterInt = AppSettings.getColorFilterInt(appContext); TextView titleText = (TextView) view.findViewById(R.id.title_text); titleText.setTextColor(colorFilterInt); titleText.setText("That's it."); TextView tutorialText = (TextView) view.findViewById(R.id.tutorial_text); tutorialText.setTextColor(colorFilterInt); tutorialText.setText("Now you're ready to use AutoBackground. I'd suggest adding a new source first " + "and then hitting download." + "\n" + "\n" + "If you have any questions, concerns, suggestions, or whatever else, feel free to " + "email me at "); SpannableString emailString = new SpannableString("chiuwinson@gmail.com"); ClickableSpan clickableSpan = new ClickableSpan() { @Override/*from w ww . j av a 2 s . c om*/ public void onClick(View widget) { Log.i(TAG, "Clicked"); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "chiuwinson@gmail.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "AutoBackground Feedback"); startActivity(Intent.createChooser(emailIntent, "Send email")); } }; emailString.setSpan(clickableSpan, 0, emailString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tutorialText.append(emailString); tutorialText.append("."); tutorialText.setMovementMethod(LinkMovementMethod.getInstance()); return view; }
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//www .j a v a 2 s . c o 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.anysoftkeyboard.ui.settings.AboutAnySoftKeyboardFragment.java
@Override public void onViewStateRestored(Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); TextView additionalSoftware = (TextView) getView().findViewById(R.id.about_legal_stuff_link); SpannableStringBuilder sb = new SpannableStringBuilder(additionalSoftware.getText()); sb.clearSpans();//removing any previously (from instance-state) set click spans. sb.setSpan(new ClickableSpan() { @Override/*w ww. j a v a 2s.c om*/ public void onClick(View widget) { FragmentChauffeurActivity activity = (FragmentChauffeurActivity) getActivity(); activity.addFragmentToUi(new AdditionalSoftwareLicensesFragment(), FragmentChauffeurActivity.FragmentUiContext.DeeperExperience); } }, 0, additionalSoftware.getText().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); additionalSoftware.setMovementMethod(LinkMovementMethod.getInstance()); additionalSoftware.setText(sb); }