中断当前的 TalkBack 读出并开始新的读出?

Interrupt current TalkBack readout and begin new one?

我有一个可重新订购的 RecyclerView,每次您将一个项目移动到另一个项目的下方或上方时,TalkBack 都会读出:

"Moved ItemTitle above item 2".

问题是它将所有这些读数排队并全部执行。所以如果你把一个项目从位置 12 快速移动到位置 1,它会说:

"Moved ItemTitle above item 12. Moved ItemTitle above item 11. Moved ItemTitle above item 10. Moved ItemTitle above item 9..."

如何让它停止当前读出,清除队列并只读最近的公告?

这是每次 RecyclerView 项目被拖动到另一个项目上方或下方时触发的方法。

@Override
public boolean onItemMove(int fromPosition, int toPosition) {

    String direction = fromPosition < toPosition ? "below" : "above";
    String title1 = viewModel.get(fromPosition).getItemTitle();
    String title2 = viewModel.get(toPosition)).getItemTitle();

    // these announcements are queued 
    view.announceForAccessibility(view.getContext().getString(R.string.on_move_draggable_item_announce, title1, direction, title2));

    return true;
}

这样做:

((AccessibilityManager) view.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).interrupt();

在你这样宣布之前:

view.announceForAccessibility(announcementMessage);