|
8 | 8 | import android.graphics.Color;
|
9 | 9 | import android.os.Build;
|
10 | 10 | import android.os.Bundle;
|
| 11 | +import android.os.*; |
11 | 12 | import android.text.TextUtils;
|
12 | 13 | import android.util.TypedValue;
|
13 | 14 | import android.view.Gravity;
|
14 | 15 | import android.view.View;
|
15 | 16 | import android.view.ViewGroup;
|
| 17 | +import android.view.ViewTreeObserver; |
16 | 18 | import android.widget.EditText;
|
17 | 19 | import android.widget.LinearLayout;
|
18 | 20 | import android.widget.TextView;
|
@@ -328,10 +330,6 @@ private void setupPaymentItemOnClickListener(ViewGroup rootView) {
|
328 | 330 | ViewUtils.getChildViewsByRegex(rootView, ".*选中,.+", paymentMethodsViewList);
|
329 | 331 | long paymentMethodsViewListSize = paymentMethodsViewList.size();
|
330 | 332 | for (int i = 0; i < paymentMethodsViewListSize; i++) {
|
331 |
| - if (i == paymentMethodsViewListSize - 1) { |
332 |
| - // 最后一个 |
333 |
| - continue; |
334 |
| - } |
335 | 333 | View paymentMethodView = paymentMethodsViewList.get(i);
|
336 | 334 | L.d("paymentMethodView", ViewUtils.getViewInfo(paymentMethodView));
|
337 | 335 | // 只取第一次, 防止多次调用造成出错
|
@@ -380,39 +378,18 @@ private void reEnteredPayDialogSolution(Activity activity) {
|
380 | 378 | outViewList.add(shortPwdView);
|
381 | 379 | }
|
382 | 380 | });
|
383 |
| - ActivityViewObserverHolder.start(ActivityViewObserverHolder.Key.TaobaoPasswordView, |
| 381 | + ActivityViewObserverHolder.start(ActivityViewObserverHolder.Key.AlipayPasswordView, |
384 | 382 | activityViewObserver, 300, (observer, view) -> {
|
385 | 383 | ActivityViewObserverHolder.stop(observer);
|
386 | 384 | L.d("找到密码框", view);
|
387 |
| - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { |
388 |
| - view.setOnFocusChangeListener(new View.OnFocusChangeListener() { |
389 |
| - private boolean lastFocusState = true; //初始化默认给true |
390 |
| - @Override |
391 |
| - public void onFocusChange(View v, boolean hasFocus) { |
392 |
| - L.d("密码框", "onFocusChange", view, hasFocus); |
393 |
| - try { |
394 |
| - // 如果失去焦点并且获得新焦点, 通常是切换支付方式, 尝试重新触发识别 |
395 |
| - if (!lastFocusState && hasFocus) { |
396 |
| - // 如果支付方式点了第一项, 页面会刷新, 需要重建OnclickListener |
397 |
| - Task.onMain(666, () -> { |
398 |
| - setupPaymentItemOnClickListener(rootView); |
399 |
| - }); |
400 |
| - AlertDialog dialog = mFingerPrintAlertDialog; |
401 |
| - if (dialog == null) { |
402 |
| - return; |
403 |
| - } |
404 |
| - if (!dialog.isShowing()) { |
405 |
| - dialog.show(); |
406 |
| - } |
407 |
| - } |
408 |
| - } finally { |
409 |
| - lastFocusState = hasFocus; |
410 |
| - } |
411 |
| - |
412 |
| - } |
413 |
| - |
414 |
| - }); |
415 |
| - } |
| 385 | + Object debounceToken = new Object(); |
| 386 | + Handler debounceHandler = view.getHandler(); |
| 387 | + view.getViewTreeObserver().addOnGlobalLayoutListener(() -> { |
| 388 | + debounceHandler.removeCallbacksAndMessages(debounceToken); |
| 389 | + debounceHandler.postAtTime(() -> { |
| 390 | + setupPaymentItemOnClickListener(rootView); |
| 391 | + }, debounceToken, SystemClock.uptimeMillis() + 666); |
| 392 | + }); |
416 | 393 | },
|
417 | 394 | 10000);
|
418 | 395 | }
|
|
0 commit comments