Example usage for android.text.method LinkMovementMethod getInstance

List of usage examples for android.text.method LinkMovementMethod getInstance

Introduction

In this page you can find the example usage for android.text.method LinkMovementMethod getInstance.

Prototype

public static MovementMethod getInstance() 

Source Link

Usage

From source file:app.hacked.ScheduleItemDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.schedule_detail_fragment, container, false);

    ((TextView) rootView.findViewById(R.id.times)).setText(scheduleStartTime + " till " + scheduleEndTime);
    ((TextView) rootView.findViewById(R.id.times))
            .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));

    if (rootView.findViewById(R.id.Title) != null) {
        ((TextView) rootView.findViewById(R.id.Title)).setText(scheduleDesc);
        ((TextView) rootView.findViewById(R.id.Title))
                .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
        ((TextView) rootView.findViewById(R.id.times))
                .setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
        getActivity().getActionBar()/*from   www.j av  a2 s  .  c o  m*/
                .setTitle(scheduleTitle + " - " + getActivity().getString(R.string.app_name));
    }

    TextView fullDetailsTV = (TextView) rootView.findViewById(R.id.fullDetails);

    if (null == scheduleFullDataHTML || scheduleFullDataHTML.equals("")
            || scheduleFullDataHTML.equals("null")) {
        fullDetailsTV.setText(Html.fromHtml(scheduleDesc));
    } else {
        fullDetailsTV.setText(Html.fromHtml(scheduleFullDataHTML));
    }
    fullDetailsTV.setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));

    try {
        fullDetailsTV.setMovementMethod(LinkMovementMethod.getInstance());
    } catch (Exception e) {
        //Worth a shot
    }
    return rootView;
}

From source file:org.klnusbaum.udj.auth.AuthActivity.java

/**
 * {@inheritDoc}//from  w  w w.  j  ava 2s .c o m
 */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mAccountManager = AccountManager.get(this);
    final Intent intent = getIntent();
    mUsername = intent.getStringExtra(PARAM_USERNAME);
    mRequestNewAccount = mUsername == null;
    mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);
    Log.i(TAG, "    request new: " + mRequestNewAccount);
    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.login_activity);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
    mMessage = (TextView) findViewById(R.id.message);
    mUsernameEdit = (EditText) findViewById(R.id.username_edit);
    mPasswordEdit = (EditText) findViewById(R.id.password_edit);
    if (!TextUtils.isEmpty(mUsername))
        mUsernameEdit.setText(mUsername);
    mMessage.setText(getMessage());

    TextView signUp = (TextView) findViewById(R.id.signup_text);
    signUp.setText(Html.fromHtml(getString(R.string.dont_have_account)));
    signUp.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.qiscus.sdk.ui.adapter.viewholder.QiscusBaseLinkViewHolder.java

private void clickify(String clickableText, ClickSpan.OnClickListener listener) {
    CharSequence text = messageTextView.getText();
    String string = text.toString();
    ClickSpan span = new ClickSpan(listener);

    int start = string.indexOf(clickableText);
    int end = start + clickableText.length();
    if (start == -1) {
        return;//  www .  j a va  2 s  . c  o  m
    }

    if (text instanceof Spannable) {
        ((Spannable) text).setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        SpannableString s = SpannableString.valueOf(text);
        s.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        messageTextView.setText(s);
    }

    MovementMethod m = messageTextView.getMovementMethod();
    if (m == null || !(m instanceof LinkMovementMethod)) {
        messageTextView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}

From source file:org.liberty.android.fantastischmemo.downloader.AbstractDownloaderFragment.java

protected void showFetchDatabaseDialog(final DownloadItem item) {
    View alertView = View.inflate(mActivity, R.layout.link_alert, null);
    TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(/*  w ww  .  j a v a  2s  .  co  m*/
            Html.fromHtml(getString(R.string.downloader_download_alert_message) + item.getDescription()));
    new AlertDialog.Builder(mActivity).setView(alertView)
            .setTitle(getString(R.string.downloader_download_alert) + item.getTitle())
            .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    startFetchDatabaseTask(item);
                }
            }).setNegativeButton(getString(R.string.no_text), null).show();
}

From source file:com.fa.mastodon.activity.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        setTheme(R.style.AppTheme_Light);
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        setTheme(R.style.AppThemeAmoled);
    }/*from   w w w .  j  av a 2s .c  o  m*/

    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    if (savedInstanceState != null) {
        domain = savedInstanceState.getString("domain");
        clientId = savedInstanceState.getString("clientId");
        clientSecret = savedInstanceState.getString("clientSecret");
    } else {
        domain = null;
        clientId = null;
        clientSecret = null;
    }

    preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onButtonClick(editText);
        }
    });

    final Context context = this;

    whatsAnInstance.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(context).setMessage(R.string.dialog_whats_an_instance)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).show();
            TextView textView = (TextView) dialog.findViewById(android.R.id.message);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    });

    bp = new BillingProcessor(this, PublicValues.LICENSE_KEY, this);

    bp.loadOwnedPurchasesFromGoogle();
}

From source file:cn.zhangls.android.weibo.ui.weibo.WeiboFrameProvider.java

@Override
protected void onBindViewHolder(@NonNull final FrameHolder holder, @NonNull final Status status) {
    holder.binding.setStatus(status);//from   ww w .  j a v  a 2s . com
    // ?
    setClickListeners(holder);
    //
    setupPopupBar(holder, status);

    Context context = holder.binding.getRoot().getContext();
    // ??
    if (status.getUser() != null) {
        Glide.with(context).load(status.getUser().getProfile_image_url()).centerCrop().crossFade().dontAnimate()
                .error(R.drawable.avator_default).placeholder(R.drawable.avator_default)
                .into(holder.binding.fgHomeRecyclerItemAvatar);
    }
    holder.binding.fgHomeRecyclerItemAvatar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            UserActivity.actonStart(holder.binding.fgHomeRecyclerItemAvatar.getContext(), status.getUser());
        }
    });
    // ? getBinding()
    holder.binding.tvWeiboText.setText(TextUtil.convertText(context, status.getText(),
            ContextCompat.getColor(context, R.color.colorAccent),
            (int) holder.binding.tvWeiboText.getTextSize()));
    holder.binding.tvWeiboText.setMovementMethod(LinkMovementMethod.getInstance());
    holder.binding.tvWeiboText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            CommentActivity.actionStart(holder.binding.comment.getContext(), holder.binding.llWeiboContentList,
                    holder.binding.getStatus());
        }
    });
    // ?????
    if (status.getRetweeted_status() != null && status.getRetweeted_status().getUser() == null) {
        holder.binding.repost.setEnabled(false);
    } else {
        holder.binding.repost.setEnabled(true);
    }

    onBindContentViewHolder((SubViewHolder) holder.subViewHolder, status);
}

From source file:com.deliciousdroid.fragment.ViewBookmarkFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null) {
        viewType = (BookmarkViewType) savedInstanceState.getSerializable(STATE_VIEWTYPE);
    }// w  w w  . j  a v a 2  s .co m

    base = (FragmentBaseActivity) getActivity();

    container = (View) getView().findViewById(R.id.view_bookmark_container);
    mBookmarkView = (ScrollView) getView().findViewById(R.id.bookmark_scroll_view);
    mTitle = (TextView) getView().findViewById(R.id.view_bookmark_title);
    mUrl = (TextView) getView().findViewById(R.id.view_bookmark_url);
    mNotes = (TextView) getView().findViewById(R.id.view_bookmark_notes);
    mTags = (TextView) getView().findViewById(R.id.view_bookmark_tags);
    mTime = (TextView) getView().findViewById(R.id.view_bookmark_time);
    mUsername = (TextView) getView().findViewById(R.id.view_bookmark_account);
    mIcon = (ImageView) getView().findViewById(R.id.view_bookmark_icon);
    mWebContent = (WebView) getView().findViewById(R.id.web_view);
    readSection = getView().findViewById(R.id.read_bookmark_section);
    readTitle = (TextView) getView().findViewById(R.id.read_bookmark_title);
    readView = (TextView) getView().findViewById(R.id.read_view);

    mWebContent.getSettings().setJavaScriptEnabled(true);
    readView.setMovementMethod(LinkMovementMethod.getInstance());

    setHasOptionsMenu(true);
    //setRetainInstance(true);
}

From source file:org.floens.chan.ui.controller.ThemeSettingsController.java

@Override
public void onCreate() {
    super.onCreate();

    navigationItem.setTitle(R.string.settings_screen_theme);
    navigationItem.swipeable = false;//from   ww w  .  java 2  s .c  o m
    view = inflateRes(R.layout.controller_theme);

    themeHelper = ThemeHelper.getInstance();
    themes = themeHelper.getThemes();

    pager = (ViewPager) view.findViewById(R.id.pager);
    done = (FloatingActionButton) view.findViewById(R.id.add);
    done.setOnClickListener(this);

    textView = (TextView) view.findViewById(R.id.text);

    SpannableString changeAccentColor = new SpannableString(getString(R.string.setting_theme_accent));
    changeAccentColor.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View widget) {
            showAccentColorPicker();
        }
    }, 0, changeAccentColor.length(), 0);

    textView.setText(TextUtils.concat(getString(R.string.setting_theme_explanation), changeAccentColor));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    adapter = new Adapter();
    pager.setAdapter(adapter);

    ChanSettings.ThemeColor currentSettingsTheme = ChanSettings.getThemeAndColor();
    for (int i = 0; i < themeHelper.getThemes().size(); i++) {
        Theme theme = themeHelper.getThemes().get(i);
        ThemeHelper.PrimaryColor primaryColor = theme.primaryColor;

        if (theme.name.equals(currentSettingsTheme.theme)) {
            // Current theme
            pager.setCurrentItem(i, false);
        }
        selectedPrimaryColors.add(primaryColor);
    }
    selectedAccentColor = themeHelper.getTheme().accentColor;
    done.setBackgroundTintList(ColorStateList.valueOf(selectedAccentColor.color));
}

From source file:org.thoughtcrime.securesms.components.webrtc.WebRtcCallScreen.java

public void setUntrustedIdentity(Recipient personInfo, IdentityKey untrustedIdentity) {
    String name = recipient.toShortString();
    String introduction = String.format(getContext().getString(R.string.WebRtcCallScreen_new_safety_numbers),
            name, name);//from w w w . j a va2  s  .  c o m
    SpannableString spannableString = new SpannableString(introduction + " "
            + getContext().getString(R.string.WebRtcCallScreen_you_may_wish_to_verify_this_contact));

    spannableString.setSpan(new VerifySpan(getContext(), personInfo.getRecipientId(), untrustedIdentity),
            introduction.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    setPersonInfo(personInfo);

    this.incomingCallOverlay.setActiveCall();
    this.status.setText(R.string.WebRtcCallScreen_new_safety_numbers_title);
    this.untrustedIdentityContainer.setVisibility(View.VISIBLE);
    this.untrustedIdentityExplanation.setText(spannableString);
    this.untrustedIdentityExplanation.setMovementMethod(LinkMovementMethod.getInstance());

    this.endCallButton.setVisibility(View.INVISIBLE);
}

From source file:com.coincide.alphafitness.ui.Activity_Main.java

public boolean optionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        getFragmentManager().popBackStackImmediate();
        break;//from www.j  a  va  2s . c  om
    case R.id.action_settings:
        getFragmentManager().beginTransaction().replace(android.R.id.content, new Fragment_Settings())
                .addToBackStack(null).commit();
        break;
    case R.id.action_leaderboard:
    case R.id.action_achievements:
        AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
        builder2.setTitle("Google services required");
        builder2.setMessage("This feature is not available on the F-Droid version of the app");
        builder2.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder2.create().show();
        break;
    case R.id.action_faq:
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://j4velin.de/faq/index.php?app=pm"))
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        break;
    case R.id.action_about:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.about);
        TextView tv = new TextView(this);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(R.string.about_text_links);
        try {
            tv.append(getString(R.string.about_app_version,
                    getPackageManager().getPackageInfo(getPackageName(), 0).versionName));
        } catch (NameNotFoundException e1) {
            // should not happen as the app is definitely installed when
            // seeing the dialog
            e1.printStackTrace();
        }
        tv.setMovementMethod(LinkMovementMethod.getInstance());
        builder.setView(tv);
        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.create().show();
        break;
    }
    return true;
}