From 65058dd02d3b77ff7fab5bdeb5542d9b18aa90b3 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 18 Jan 2019 20:35:10 +0000 Subject: [PATCH] Prevent initial rule scroll --- app/src/main/java/eu/faircode/email/FragmentRule.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index bad31d0a87..5f70a318cf 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -147,8 +147,12 @@ public class FragmentRule extends FragmentBase { spAction.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int position, long id) { - Action action = (Action) adapterView.getAdapter().getItem(position); - onActionSelected(action.type); + Integer prev = (Integer) adapterView.getTag(); + if (prev != null && !prev.equals(position)) { + Action action = (Action) adapterView.getAdapter().getItem(position); + onActionSelected(action.type); + } + adapterView.setTag(position); } @Override @@ -298,6 +302,7 @@ public class FragmentRule extends FragmentBase { for (int pos = 0; pos < adapterAction.getCount(); pos++) if (adapterAction.getItem(pos).type == type) { + spAction.setTag(pos); spAction.setSelection(pos); break; }