From 4de1901921d73bf728fd462b1f57aa20d7b08b7b Mon Sep 17 00:00:00 2001 From: cgspine Date: Fri, 8 Jun 2018 16:44:14 +0800 Subject: [PATCH] issue fix: #304 --- .../widget/textview/QMUILinkTextView.java | 10 +++++++- .../components/QDLinkTextViewFragment.java | 24 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/qmui/src/main/java/com/qmuiteam/qmui/widget/textview/QMUILinkTextView.java b/qmui/src/main/java/com/qmuiteam/qmui/widget/textview/QMUILinkTextView.java index 27187228c..81e364696 100644 --- a/qmui/src/main/java/com/qmuiteam/qmui/widget/textview/QMUILinkTextView.java +++ b/qmui/src/main/java/com/qmuiteam/qmui/widget/textview/QMUILinkTextView.java @@ -19,9 +19,9 @@ import android.view.ViewConfiguration; import android.widget.TextView; -import com.qmuiteam.qmui.link.QMUILinkify; import com.qmuiteam.qmui.R; import com.qmuiteam.qmui.link.QMUILinkTouchMovementMethod; +import com.qmuiteam.qmui.link.QMUILinkify; import com.qmuiteam.qmui.span.QMUIOnSpanClickListener; import java.util.HashSet; @@ -232,6 +232,14 @@ protected boolean performSpanLongClick(String text) { return false; } + @Override + public boolean performClick() { + if (!mTouchSpanHit && !mNeedForceEventToParent) { + return super.performClick(); + } + return false; + } + @Override public boolean performLongClick() { int end = getSelectionEnd(); diff --git a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/fragment/components/QDLinkTextViewFragment.java b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/fragment/components/QDLinkTextViewFragment.java index 861d77978..149e9691e 100644 --- a/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/fragment/components/QDLinkTextViewFragment.java +++ b/qmuidemo/src/main/java/com/qmuiteam/qmuidemo/fragment/components/QDLinkTextViewFragment.java @@ -6,10 +6,10 @@ import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.textview.QMUILinkTextView; -import com.qmuiteam.qmuidemo.manager.QDDataManager; -import com.qmuiteam.qmuidemo.base.BaseFragment; import com.qmuiteam.qmuidemo.R; +import com.qmuiteam.qmuidemo.base.BaseFragment; import com.qmuiteam.qmuidemo.lib.annotation.Widget; +import com.qmuiteam.qmuidemo.manager.QDDataManager; import butterknife.BindView; import butterknife.ButterKnife; @@ -32,6 +32,26 @@ protected View onCreateView() { ButterKnife.bind(this, view); initTopBar(); mLinkTextView.setOnLinkClickListener(mOnLinkClickListener); + mLinkTextView.setOnLinkLongClickListener(new QMUILinkTextView.OnLinkLongClickListener() { + @Override + public void onLongClick(String text) { + Toast.makeText(getContext(), "long click: " + text, Toast.LENGTH_SHORT).show(); + } + }); + mLinkTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(getContext(), "click TextView", Toast.LENGTH_SHORT).show(); + } + }); + // if parent click event should be triggered when TextView area is clicked +// mLinkTextView.setNeedForceEventToParent(true); +// view.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// Toast.makeText(getContext(), "forceEventToParent", Toast.LENGTH_SHORT).show(); +// } +// }); return view; }