Java 类android.text.method.MovementMethod 实例源码
项目:Password-Storage
文件:AboutUsActivity.java
private void onClickURL(){
MovementMethod contributors_descMovementMethod = contributors_desc.getMovementMethod();
if ((contributors_descMovementMethod == null) || !(contributors_descMovementMethod instanceof LinkMovementMethod)) {
if (contributors_desc.getLinksClickable()) {
contributors_desc.setMovementMethod(LinkMovementMethod.getInstance());
}
}
MovementMethod app_report_issues_descMovementMethod = app_report_issues_desc.getMovementMethod();
if ((app_report_issues_descMovementMethod == null) || !(app_report_issues_descMovementMethod instanceof LinkMovementMethod)) {
if (app_report_issues_desc.getLinksClickable()) {
app_report_issues_desc.setMovementMethod(LinkMovementMethod.getInstance());
}
}
MovementMethod app_license_info_descMovementMethod = app_license_info_desc.getMovementMethod();
if ((app_license_info_descMovementMethod == null) || !(app_license_info_descMovementMethod instanceof LinkMovementMethod)) {
if (app_license_info_desc.getLinksClickable()) {
app_license_info_desc.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
项目:inventum
文件:AboutActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
setupToolbar();
MovementMethod movementMethod = LinkMovementMethod.getInstance();
versionTextView.setText(getVersionName());
appInfoTextView.setText(StringUtils.fromHtml(getString(R.string.about_app_info)));
appInfoTextView.setMovementMethod(movementMethod);
librariesTextView.setText(StringUtils.fromHtml(getString(R.string.about_libraries_text)));
librariesTextView.setMovementMethod(movementMethod);
licenseTextView.setText(StringUtils.fromHtml(getString(R.string.about_license_text)));
licenseTextView.setMovementMethod(movementMethod);
}
项目:Show_Chat
文件:AboutActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
setupToolbar();
MovementMethod movementMethod = LinkMovementMethod.getInstance();
versionTextView.setText(getVersionName());
appInfoTextView.setText(StringUtils.fromHtml(getString(R.string.about_app_info)));
appInfoTextView.setMovementMethod(movementMethod);
librariesTextView.setText(StringUtils.fromHtml(getString(R.string.about_libraries_text)));
librariesTextView.setMovementMethod(movementMethod);
licenseTextView.setText(StringUtils.fromHtml(getString(R.string.about_license_text)));
licenseTextView.setMovementMethod(movementMethod);
}
项目:Tada
文件:TextView.java
/**
* Sets the movement method (arrow key handler) to be used for
* this TextView. This can be null to disallow using the arrow keys
* to move the cursor or scroll the view.
* <p>
* Be warned that if you want a TextView with a key listener or movement
* method not to be focusable, or if you want a TextView without a
* key listener or movement method to be focusable, you must call
* {@link #setFocusable} again after calling this to get the focusability
* back the way you want it.
*/
public final void setMovementMethod(MovementMethod movement) {
if (mMovement != movement) {
mMovement = movement;
if (movement != null && !(mText instanceof Spannable)) {
setText(mText);
}
fixFocusableAndClickableSettings();
// SelectionModifierCursorController depends on textCanBeSelected, which depends on
// mMovement
if (mEditor != null) mEditor.prepareCursorControllers();
}
}
项目:DeviceConnect-Android
文件:ApiActivity.java
private void showResponseText(final DConnectResponseMessage response) {
View view = findViewById(R.id.response_layout);
view.setVisibility(View.VISIBLE);
final MessageParser parser = new MessageParser();
parser.setClickLinkListener(new MessageParser.OnClickLinkListener() {
@Override
public void onClick(String uri) {
openImageActivity(uri);
}
});
MovementMethod method = LinkMovementMethod.getInstance();
TextView textView = (TextView) findViewById(R.id.response);
textView.setText(parser.parse(response, 4));
textView.setMovementMethod(method);
}
项目:DeviceConnect-Android
文件:ApiActivity.java
private void showEventText(final DConnectEventMessage event) {
View view = findViewById(R.id.event_layout);
view.setVisibility(View.VISIBLE);
final MessageParser parser = new MessageParser();
parser.setClickLinkListener(new MessageParser.OnClickLinkListener() {
@Override
public void onClick(String uri) {
openImageActivity(uri);
}
});
MovementMethod method = LinkMovementMethod.getInstance();
TextView textView = (TextView) findViewById(R.id.event);
textView.setText(parser.parse(event, 4));
textView.setMovementMethod(method);
}
项目:Android-TextView-LinkBuilder
文件:LinkConsumableTextView.java
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
MovementMethod movementMethod = getMovementMethod();
if (movementMethod instanceof TouchableMovementMethod) {
TouchableBaseSpan span = ((TouchableMovementMethod) movementMethod).getPressedSpan();
if (span != null) {
return true;
}
}
return false;
}
项目:LinkEnabledWidgets
文件:TextViewActivity.java
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
setContentView(R.layout.activity_main);
mContext = this;
prefs = PreferenceManager.getDefaultSharedPreferences(this);
String text = "This is a #test of regular expressions with http://example.com/ links as used in @twitter for performing various operations based on the links this handles multiple links like http://this_is_fun.com/ and #Awesomess and @Cool";
// textview = new LinkEnabledTextView(this, null);
textview = (LinkEnabledTextView) findViewById(R.id.textview);
textview.setOnTextLinkClickListener(this);
textview.gatherLinksForText(text);
edittext = (LinkEnabledEditText) findViewById(R.id.edittext);
edittext.setText(prefs.getString("edittextstring", ""));
edittext.gatherLinksForText();
edittext.setOnTextLinkClickListener(this);
MovementMethod m = textview.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (textview.getLinksClickable()) {
textview.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
项目:TorrentFreak-Reader
文件:AboutActivity.java
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
// apply the link movement method to all appropriate text views to allow the user to click
// any anchors
final MovementMethod movementMethod = LinkMovementMethod.getInstance();
appCredits.setMovementMethod(movementMethod);
contentCredits.setMovementMethod(movementMethod);
styleCredits.setMovementMethod(movementMethod);
backendCredits.setMovementMethod(movementMethod);
interfaceCredits.setMovementMethod(movementMethod);
// setup the action bar, setting the logo and title and enabling the home button
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setIcon(R.drawable.spaced_logo);
actionBar.setTitle(R.string.about_activity_title);
}
项目:EventApp
文件:AppListFragment.java
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
int padding = (int) (getResources().getDisplayMetrics().density * 8); // 8dip
ListView listView = getListView();
listView.setPadding(padding, 0, padding, 0);
listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
listView.setDivider(null);
LayoutInflater inflater = LayoutInflater.from(getActivity());
View header = inflater.inflate(R.layout.list_header_footer, listView, false);
View footer = inflater.inflate(R.layout.list_footer, listView, false);
TextView tv = (TextView) footer.findViewById(R.id.footer);
String str = getResources().getString(R.string.footer);
MovementMethod method = LinkMovementMethod.getInstance();
tv.setMovementMethod(method);
CharSequence html = Html.fromHtml(str);
tv.setText(html);
listView.addHeaderView(header, null, false);
listView.addFooterView(footer, null, false);
setTrack(7);
}
项目:TMinus
文件:AboutFragment.java
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState )
{
View view = inflater.inflate( R.layout.fragment_about, container, false );
ButterKnife.inject( this, view );
Dialog dialog = getDialog();
if( dialog != null )
{
dialog.setTitle( R.string.about_title );
}
Button marketButton = (Button) view.findViewById( R.id.ABOUT_market_button );
marketButton.setOnClickListener( this );
MovementMethod linkMovementMethod = LinkMovementMethod.getInstance();
m_githubAndroidView.setMovementMethod( linkMovementMethod );
m_githubAndroidView.setText( getText( R.string.about_body_github_android ) );
m_githubFeedbackView.setMovementMethod( linkMovementMethod );
m_githubFeedbackView.setText( getText( R.string.about_body_feedback ) );
m_versionView.setText( "v" + getAppVersion() );
return view;
}
项目:ingress-indonesia-dev
文件:s.java
public s(View paramView, boolean paramBoolean)
{
this.a = ((TextView)paramView.findViewById(2131230732));
this.b = ((TextView)paramView.findViewById(2131230733));
if (ao.m());
for (Object localObject = u.a(); ; localObject = LinkMovementMethod.getInstance())
{
this.b.setMovementMethod((MovementMethod)localObject);
if (paramBoolean)
{
this.b.setSingleLine(true);
this.b.setEllipsize(TextUtils.TruncateAt.END);
this.a.setTextColor(paramView.getContext().getResources().getColor(2131165198));
}
return;
}
}
项目:qmui
文件:QMUILinkify.java
private static final void addLinkMovementMethod(TextView t) {
MovementMethod m = t.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (t.getLinksClickable()) {
t.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
项目:OSchina_resources_android
文件:TweetTextView.java
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
MovementMethod mm = getMovementMethod();
CharSequence text = getText();
if (mm != null && (text instanceof Spannable)
&& handleTouchEvent(event)) {
mm.onTouchEvent(this, (Spannable) text, event);
if (dispatchToParent) {
return false;
}
}
return super.onTouchEvent(event);
}
项目:OSchina_resources_android
文件:TweetTextView.java
@Override
public boolean performLongClick() {
MovementMethod mm = getMovementMethod();
if (mm != null && (mm instanceof MyLinkMovementMethod))
((MyLinkMovementMethod) mm).a(this);
return super.performLongClick();
}
项目:QMUI_Android
文件:QMUILinkify.java
private static void addLinkMovementMethod(TextView t) {
MovementMethod m = t.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (t.getLinksClickable()) {
t.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
项目:RLibrary
文件:RExTextView.java
@Override
protected MovementMethod getDefaultMovementMethod() {
if (isNeedPattern()) {
return ImageClickMethod.getInstance();
}
return super.getDefaultMovementMethod();
}
项目:Coding-Android
文件:LongClickLinkMovementMethod.java
public static MovementMethod getInstance() {
if (sInstance == null) {
sInstance = new LongClickLinkMovementMethod();
}
return sInstance;
}
项目:RespawnIRC-Android
文件:LongClickLinkMovementMethod.java
public static MovementMethod getInstance() {
if (instance == null) {
instance = new LongClickLinkMovementMethod();
instance.longClickHandler = new Handler();
}
return instance;
}
项目:TUI-ConsoleLauncher
文件:LongClickMovementMethod.java
public static MovementMethod getInstance(int longClickDuration) {
if (sInstance == null) {
sInstance = new LongClickMovementMethod();
sInstance.longClickDuration = longClickDuration;
}
return sInstance;
}
项目:Mimix-Client
文件:Linkify.java
private static final void addLinkMovementMethod(TextView t) {
MovementMethod m = t.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (t.getLinksClickable()) {
t.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
项目:TehranBrt
文件:AboutActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
TextView appVersionTextView = (TextView) findViewById(R.id.appVersionTextView);
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
appVersionTextView.setText(getString(R.string.app_version_format,
packageInfo.versionName));
} catch (NameNotFoundException e) {
appVersionTextView.setText("1.0");
}
MovementMethod movementMethod = LinkMovementMethod.getInstance();
((TextView) findViewById(R.id.library1)).setMovementMethod(movementMethod);
((TextView) findViewById(R.id.library2)).setMovementMethod(movementMethod);
((TextView) findViewById(R.id.library3)).setMovementMethod(movementMethod);
((TextView) findViewById(R.id.library4)).setMovementMethod(movementMethod);
((TextView) findViewById(R.id.fontNameTextView)).setMovementMethod(movementMethod);
setupWindowAnimation();
}
项目:S1-Next
文件:PostMovementMethod.java
public static MovementMethod getInstance() {
if (sInstance == null) {
sInstance = new PostMovementMethod();
sInstance.addURLSpanClick(new SarabaSpan());
sInstance.addURLSpanClick(new BilibiliSpan());
}
return sInstance;
}
项目:S1-Next
文件:SearchMovementMethod.java
public static MovementMethod getInstance() {
if (sInstance == null) {
sInstance = new SearchMovementMethod();
sInstance.addURLSpanClick(new SarabaInsideThreadSpan());
sInstance.addURLSpanClick(new SarabaSpan());
sInstance.addURLSpanClick(new BilibiliSpan());
}
return sInstance;
}
项目:Markdown
文件:LongPressLinkMovementMethod.java
public static MovementMethod getInstance() {
if (sInstance == null) {
sInstance = new LongPressLinkMovementMethod();
}
return sInstance;
}
项目:Textoo
文件:TextViewConfiguratorImplTest.java
private void testLinkifyAll(TextView initState, MovementMethod expectedMovementMethod) {
TextViewConfigurator config = createConfigurator(createTextooContext(), initState);
TextView result = config
.linkifyAll()
.apply();
assertEquals(expectedMovementMethod, result.getMovementMethod());
}
项目:Textoo
文件:TextViewConfiguratorImplTest.java
private void testLinkifyPattern(TextView initState, Pattern pattern, MovementMethod expectedMovementMethod) {
TextViewConfigurator config = createConfigurator(createTextooContext(), initState);
TextView result = config
.linkify(pattern, "http://www.google.ie/search?q=")
.apply();
assertEquals(expectedMovementMethod, result.getMovementMethod());
}
项目:World-Weather
文件:AboutActivity.java
/**
* Sets text with clickable links in the specified TextView.
*/
private void displayTextWithLinks(TextView textView, final SpannableString spannableString) {
MovementMethod m1 = textView.getMovementMethod();
if ((m1 == null) || !(m1 instanceof LinkMovementMethod))
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setLinkTextColor(linkTextColour);
textView.setText(spannableString);
}
项目:android-social-ui
文件:SocialTextView.java
public void linkify(SocialActionCallback actionCallback)
{
Linkify.TransformFilter filter = new Linkify.TransformFilter()
{
public final String transformUrl(final Matcher match, String url)
{
return match.group();
}
};
// emails
Linkify.addLinks(this, Patterns.EMAIL_ADDRESS, null, null, filter);
// @mentions
Linkify.addLinks(this, MENTION_PATTERN, SocialMovementMethod.SOCIAL_UI_MENTION_SCHEME, null, filter);
// #hashtags
Linkify.addLinks(this, HASHTAG_PATTERN, SocialMovementMethod.SOCIAL_UI_HASHTAG_SCHEME, null, filter);
// Links
Linkify.addLinks(this, Patterns.WEB_URL, null, null, filter);
// Hooking up the actionHandler
MovementMethod movementMethod = null;
if(actionCallback != null)
{
movementMethod = new SocialMovementMethod(actionCallback);
}
setMovementMethod(movementMethod);
}
项目:X.Ray
文件:HackyTextView.java
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean ret = super.onTouchEvent(event);
MovementMethod method = getMovementMethod();
if (method instanceof HackyMovementMethod) {
return ((HackyMovementMethod) method).isLinkHit();
}
return ret;
}
项目:Android-TextView-LinkBuilder
文件:LinkBuilder.java
/**
* Add the movement method to handle the clicks.
*/
private void addLinkMovementMethod() {
MovementMethod m = textView.getMovementMethod();
if ((m == null) || !(m instanceof TouchableMovementMethod)) {
if (textView.getLinksClickable()) {
textView.setMovementMethod(TouchableMovementMethod.getInstance());
}
}
}
项目:Android-TextView-LinkBuilder
文件:TouchableMovementMethod.java
/**
* Don't need to create a new instance for every text view. We can re-use them
* @return Instance of the movement method
*/
public static MovementMethod getInstance() {
if (sInstance == null)
sInstance = new TouchableMovementMethod();
return sInstance;
}
项目:ApkLauncher
文件:LogTextBox.java
@Override
protected MovementMethod getDefaultMovementMethod() {
return ScrollingMovementMethod.getInstance();
}
项目:AndroidAppShareHelper
文件:ShareHistoryFragment.java
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// データなし時TextViewのリンクタップでブラウザ表示されるように設定します。
TextView emptyView = (TextView) getListView().getEmptyView();
MovementMethod mMethod = LinkMovementMethod.getInstance();
emptyView.setMovementMethod(mMethod);
}
项目:ApiDemos
文件:LogTextBox.java
@Override
protected MovementMethod getDefaultMovementMethod() {
return ScrollingMovementMethod.getInstance();
}
项目:Textoo
文件:TextViewConfiguratorImplTest.java
private void testLinkifyAll(TextView initState, MovementMethod expectedMovementMethod) {
TextViewConfigurator config = createConfigurator(createTextooContext(), initState);
TextView result = config
.linkifyAll()
.apply();
assertEquals(expectedMovementMethod, result.getMovementMethod());
}
项目:Textoo
文件:TextViewConfiguratorImplTest.java
private void testLinkifyPattern(TextView initState, Pattern pattern, MovementMethod expectedMovementMethod) {
TextViewConfigurator config = createConfigurator(createTextooContext(), initState);
TextView result = config
.linkify(pattern, "http://www.google.ie/search?q=")
.apply();
assertEquals(expectedMovementMethod, result.getMovementMethod());
}
项目:translationRecorder
文件:ViewUtil.java
/**
* Makes links in a textview clickable
* includes support for long clicks
* @param view
*/
public static void makeLinksClickable(TextView view) {
MovementMethod m = view.getMovementMethod();
if(m == null || !(m instanceof LongClickLinkMovementMethod)) {
if(view.getLinksClickable()) {
view.setMovementMethod(LongClickLinkMovementMethod.getInstance());
}
}
}
项目:LinkifiedTextView
文件:LinkTextView.java
public void setLinkText(String text) {
links.clear();
if (containsLinkType(LINK_TYPE_WEB)) {
gatherLinks(text, hyperlinkPattern, LINK_TYPE_WEB);
}
if (containsLinkType(LINK_TYPE_HASHTAG)) {
gatherLinks(text, hashtagPattern, LINK_TYPE_HASHTAG);
}
if (containsLinkType(LINK_TYPE_SCREENNAME)) {
gatherLinks(text, screenNamePattern, LINK_TYPE_SCREENNAME);
}
if (containsLinkType(LINK_TYPE_EMAIL)) {
gatherLinks(text, emailPattern, LINK_TYPE_EMAIL);
}
SpannableString linkableText = new SpannableString(text);
if (!links.isEmpty()) {
for (Hyperlink linkSpec : links) {
linkableText.setSpan(linkSpec.span, linkSpec.start, linkSpec.end, 0);
}
MovementMethod m = getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (getLinksClickable()) {
setMovementMethod(LocalLinkMovementMethod.getInstance());
}
}
}
setText(linkableText);
}
项目:oschina-app
文件:TweetTextView.java
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
MovementMethod mm = getMovementMethod();
CharSequence text = getText();
if (mm != null && (text instanceof Spannable)
&& handleTouchEvent(event)) {
mm.onTouchEvent(this, (Spannable) text, event);
if (dispatchToParent) {
return false;
}
}
return super.onTouchEvent(event);
}