@@ -40,8 +40,17 @@ public class SuggestionEditor extends EditActionSupportEditor {
4040 * Small popup window to display list suggestion
4141 */
4242 private ListPopupWindow mPopup ;
43+ /**
44+ * Only show popup when suggestion is enable
45+ */
4346 private boolean mSuggestionEnable = false ;
4447
48+ private final Runnable mPostChangePopupPosition = new Runnable () {
49+ @ Override
50+ public void run () {
51+ onPopupChangePosition ();
52+ }
53+ };
4554 private AdapterView .OnItemClickListener mSuggestClickListener
4655 = new AdapterView .OnItemClickListener () {
4756 @ Override
@@ -96,11 +105,20 @@ public void setTheme(@NonNull EditorTheme editorTheme) {
96105 }
97106 }
98107
99-
100108 @ Override
101109 public void onTextChanged (CharSequence s , int start , int before , int count ) {
102110 super .onTextChanged (s , start , before , count );
103- onPopupChangePosition ();
111+ postUpdatePosition ();
112+ }
113+
114+ private void postUpdatePosition () {
115+ if (!mSuggestionEnable ) {
116+ return ;
117+ }
118+ if (mHandler != null ) {
119+ mHandler .removeCallbacks (mPostChangePopupPosition );
120+ mHandler .postDelayed (mPostChangePopupPosition , 50 );
121+ }
104122 }
105123
106124 protected void onPopupChangePosition () {
@@ -379,6 +397,7 @@ protected void onFocusChanged(boolean focused, int direction, Rect previouslyFoc
379397 @ Override
380398 protected void onDetachedFromWindow () {
381399 dismissDropDown ();
400+ mHandler .removeCallbacks (mPostChangePopupPosition );
382401 super .onDetachedFromWindow ();
383402 }
384403
0 commit comments