aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app/src/main/java/com/wireguard
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
commitdf28b073606e1a6797d65f906bc57a9d4e4d37f0 (patch)
treeef149f795ef2f7118224572d2260b20b40764a36 /app/src/main/java/com/wireguard
parentFloatingActionButonBehavior: set translation back to 0 when snackbar dies (diff)
downloadwireguard-android-df28b073606e1a6797d65f906bc57a9d4e4d37f0.tar.xz
wireguard-android-df28b073606e1a6797d65f906bc57a9d4e4d37f0.zip
TunnelListFragment: fix multiselection on rotation
Diffstat (limited to 'app/src/main/java/com/wireguard')
-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);
}