Fix unable to change language

In some cases, recycler view receives the cancel touch event,
it causes recycler view doesn't update the new locale list.

Currently, we also treat cancel event as a signal to update the locale.
According to the document, we can treat cancel event as a up
event, but not perform any action that you normally would.

It's ok in our case since we check if updated list is same as
last one in adapater.

Test: Drag and drop locale item, and make sure the language system
is updated.
Fix: 184051013
Fix: 184903189
Fix: 185000363

Change-Id: I06610080f34c5ed3562c74e1cdd955571cae55c0
This commit is contained in:
Tsung-Mao Fang
2021-04-23 22:26:19 +08:00
parent 3e6e4a1ad5
commit 2b78aa0988

View File

@@ -37,7 +37,7 @@ class LocaleRecyclerView extends RecyclerView {
@Override
public boolean onTouchEvent(MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_UP) {
if (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_CANCEL) {
LocaleDragAndDropAdapter adapter = (LocaleDragAndDropAdapter) this.getAdapter();
if (adapter != null) {
adapter.doTheUpdate();