diff options
Diffstat (limited to 'app')
3 files changed, 9 insertions, 20 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index d79d7d2be..ec9cff68c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -68,7 +68,6 @@ import it.niedermann.nextcloud.deck.model.Stack; import it.niedermann.nextcloud.deck.model.full.FullBoard; import it.niedermann.nextcloud.deck.model.full.FullCard; import it.niedermann.nextcloud.deck.model.full.FullStack; -import it.niedermann.nextcloud.deck.model.internal.FilterInformation; import it.niedermann.nextcloud.deck.model.ocs.Capabilities; import it.niedermann.nextcloud.deck.model.ocs.Version; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; @@ -138,9 +137,6 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener private boolean currentBoardHasStacks = false; private int currentBoardStacksCount = 0; - @Nullable - FilterInformation filterInformation; - private boolean firstAccountAdded = false; private ConnectivityManager.NetworkCallback networkCallback; @@ -494,7 +490,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener this.currentBoardId = board.getLocalId(); Application.saveCurrentBoardId(this, currentAccount.getId(), this.currentBoardId); - filterInformation = null; + viewModel.postFilterInformation(null); binding.toolbar.setTitle(board.getTitle()); currentBoardHasEditPermission = board.isPermissionEdit(); @@ -654,7 +650,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener final long stackId = stackAdapter.getItem(binding.viewPager.getCurrentItem()).getLocalId(); switch (item.getItemId()) { case R.id.filter: { - FilterDialogFragment.newInstance(currentAccount, currentBoardId, filterInformation) + FilterDialogFragment.newInstance(currentAccount, currentBoardId) .show(getSupportFragmentManager(), EditStackDialogFragment.class.getCanonicalName()); return true; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java index 253ce6d1c..1f373d6e9 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java @@ -7,7 +7,6 @@ import android.view.View; import android.widget.AdapterView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import androidx.lifecycle.ViewModelProvider; @@ -26,7 +25,6 @@ public class FilterDialogFragment extends BrandedDialogFragment { private static final String KEY_ACCOUNT = "account"; private static final String KEY_BOARD_ID = "board_id"; - private static final String KEY_FILTER_INFORMATION = "filterInformation"; private MainViewModel viewModel; @@ -59,13 +57,6 @@ public class FilterDialogFragment extends BrandedDialogFragment { if (this.boardId == 0L || this.account == null) { throw new IllegalArgumentException(KEY_ACCOUNT + " and " + KEY_BOARD_ID + " must be valid localIds and not be 0 or null"); } - - Object filterInformation = args.getSerializable(KEY_FILTER_INFORMATION); - if (filterInformation instanceof FilterInformation) { - this.filterInformation = (FilterInformation) filterInformation; - } else { - this.filterInformation = new FilterInformation(); - } } @NonNull @@ -74,6 +65,10 @@ public class FilterDialogFragment extends BrandedDialogFragment { super.onCreate(savedInstanceState); viewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class); + this.filterInformation = viewModel.getFilterInformation().getValue(); + if (this.filterInformation == null) { + this.filterInformation = new FilterInformation(); + } final AlertDialog.Builder dialogBuilder = new BrandedAlertDialogBuilder(requireContext()); @@ -100,15 +95,12 @@ public class FilterDialogFragment extends BrandedDialogFragment { .create(); } - public static DialogFragment newInstance(@NonNull Account account, long boardId, @Nullable FilterInformation filterInformation) { + public static DialogFragment newInstance(@NonNull Account account, long boardId) { final DialogFragment dialog = new FilterDialogFragment(); final Bundle args = new Bundle(); args.putSerializable(KEY_ACCOUNT, account); args.putLong(KEY_BOARD_ID, boardId); - if (filterInformation != null) { - args.putSerializable(KEY_FILTER_INFORMATION, filterInformation); - } dialog.setArguments(args); return dialog; diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java index 3732ecb61..a15c29c0b 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java @@ -121,7 +121,8 @@ public class StackFragment extends BrandedFragment implements DragAndDropTab<Car defaultCardsLiveData.observe(getViewLifecycleOwner(), cardObserver); viewModel.getFilterInformation().observe(activity, (filterInformation -> { - if (filterInformation == null) { + // Remove filter only if it has never been set before + if (filterInformation == null && filteredCardsLiveData != null) { filteredCardsLiveData.removeObserver(cardObserver); defaultCardsLiveData.observe(getViewLifecycleOwner(), cardObserver); } else { |