Prevent crash

pull/159/head
M66B 6 years ago
parent 9bb8437096
commit b7a562994d

@ -1251,13 +1251,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (swipes == null) if (swipes == null)
return; return;
Long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left);
if (action == null)
return;
AdapterMessage.ViewHolder holder = ((AdapterMessage.ViewHolder) viewHolder); AdapterMessage.ViewHolder holder = ((AdapterMessage.ViewHolder) viewHolder);
Rect rect = holder.getItemRect(); Rect rect = holder.getItemRect();
int margin = Helper.dp2pixels(getContext(), 12); int margin = Helper.dp2pixels(getContext(), 12);
int size = Helper.dp2pixels(getContext(), 24); int size = Helper.dp2pixels(getContext(), 24);
int icon; int icon;
long action = (dX > 0 ? swipes.swipe_right : swipes.swipe_left);
if (FragmentAccount.SWIPE_ACTION_ASK.equals(action)) if (FragmentAccount.SWIPE_ACTION_ASK.equals(action))
icon = R.drawable.baseline_list_24; icon = R.drawable.baseline_list_24;
else if (FragmentAccount.SWIPE_ACTION_SEEN.equals(action)) else if (FragmentAccount.SWIPE_ACTION_SEEN.equals(action))
@ -1312,15 +1315,20 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return; return;
} }
Long action = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right);
if (action == null) {
adapter.notifyDataSetChanged();
return;
}
Log.i("Swiped dir=" + direction + " message=" + message.id); Log.i("Swiped dir=" + direction + " message=" + message.id);
Long target = (direction == ItemTouchHelper.LEFT ? swipes.swipe_left : swipes.swipe_right); if (FragmentAccount.SWIPE_ACTION_SEEN.equals(action))
if (FragmentAccount.SWIPE_ACTION_SEEN.equals(target))
onActionSeenSelection(!message.ui_seen, message.id); onActionSeenSelection(!message.ui_seen, message.id);
else if (FragmentAccount.SWIPE_ACTION_ASK.equals(target)) else if (FragmentAccount.SWIPE_ACTION_ASK.equals(action))
swipeAsk(message, viewHolder); swipeAsk(message, viewHolder);
else else
swipeFolder(message, target); swipeFolder(message, action);
} }
private TupleMessageEx getMessage(@NonNull RecyclerView.ViewHolder viewHolder) { private TupleMessageEx getMessage(@NonNull RecyclerView.ViewHolder viewHolder) {

Loading…
Cancel
Save