summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-07-29 04:50:16 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-07-29 04:50:16 +0200
commit1b10e75168043a7838629d48e3658c918d7caeca (patch)
treeef149f795ef2f7118224572d2260b20b40764a36 /app/src
parent07359e392cc3ce26fa8ac79079897973fa53acd1 (diff)
TunnelListFragment: fix multiselection on rotation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
index 53c6d612..3ecc2e7a 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -305,6 +305,26 @@ public class TunnelListFragment extends BaseFragment {
}
@Override
+ public void onSaveInstanceState(final Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ outState.putIntegerArrayList("CHECKED_ITEMS", actionModeListener.getCheckedItems());
+ }
+
+ @Override
+ public void onActivityCreated(@Nullable final Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ if (savedInstanceState != null) {
+ final Collection<Integer> checkedItems = savedInstanceState.getIntegerArrayList("CHECKED_ITEMS");
+ if (checkedItems != null) {
+ for (final Integer i : checkedItems)
+ actionModeListener.setItemChecked(i, true);
+ }
+ }
+ }
+
+ @Override
public void onViewStateRestored(@Nullable final Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
@@ -393,6 +413,10 @@ public class TunnelListFragment extends BaseFragment {
setItemChecked(position, !checkedItems.contains(position));
}
+ public ArrayList<Integer> getCheckedItems() {
+ return new ArrayList<>(checkedItems);
+ }
+
void setItemChecked(final int position, final boolean checked) {
if (checked) {
checkedItems.add(position);
@@ -406,7 +430,7 @@ public class TunnelListFragment extends BaseFragment {
actionMode.finish();
}
- if (binding != null) {
+ if (binding != null && binding.tunnelList.getAdapter() != null) {
binding.tunnelList.getAdapter().notifyItemChanged(position);
}