diff options
author | stefan-niedermann <info@niedermann.it> | 2019-10-19 18:43:20 +0300 |
---|---|---|
committer | stefan-niedermann <info@niedermann.it> | 2019-10-19 18:43:20 +0300 |
commit | 787683093f0d617758090f8c21ba85ecf253eca2 (patch) | |
tree | 029ea262d536def28fa4ae42ae2544a4339d7997 | |
parent | 19135eee20794204c980243e10c87cede785fbb3 (diff) |
Push boardId to UserAutoCompleteAdapter
3 files changed, 12 insertions, 17 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 815cf0307..c4c02e9ab 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 @@ -105,8 +105,6 @@ public class MainActivity extends DrawerActivity implements private boolean currentBoardHasEditPermission = false; private boolean currentBoardHasStacks = false; - private TabLayoutHelper mTabLayoutHelper; - @Override protected void onCreate(Bundle savedInstanceState) { setTheme(Application.getAppTheme(this) ? R.style.DarkAppTheme : R.style.AppTheme); @@ -389,19 +387,15 @@ public class MainActivity extends DrawerActivity implements } syncManager.getStacksForBoard(account.getId(), board.getLocalId()).observe(MainActivity.this, (List<FullStack> fullStacks) -> { - if (fullStacks == null) { + if (fullStacks == null || fullStacks.size() == 0) { noStacks.setVisibility(View.VISIBLE); currentBoardHasStacks = false; } else { + noStacks.setVisibility(View.GONE); + currentBoardHasStacks = true; + long savedStackId = sharedPreferences.getLong(sharedPreferencesLastStackForAccountAndBoard_ + account.getId() + "_" + this.currentBoardId, NO_STACKS); DeckLog.log("--- Read: shared_preference_last_stack_for_account_and_board" + account.getId() + "_" + this.currentBoardId + " | " + savedStackId); - if (fullStacks.size() == 0) { - noStacks.setVisibility(View.VISIBLE); - currentBoardHasStacks = false; - } else { - noStacks.setVisibility(View.GONE); - currentBoardHasStacks = true; - } StackAdapter newStackAdapter = new StackAdapter(getSupportFragmentManager()); for (int i = 0; i < fullStacks.size(); i++) { @@ -415,8 +409,7 @@ public class MainActivity extends DrawerActivity implements runOnUiThread(() -> { viewPager.setAdapter(newStackAdapter); - mTabLayoutHelper = new TabLayoutHelper(stackLayout, viewPager); - mTabLayoutHelper.setAutoAdjustTabModeEnabled(true); + new TabLayoutHelper(stackLayout, viewPager).setAutoAdjustTabModeEnabled(true); viewPager.setCurrentItem(stackPositionInAdapter); stackLayout.setupWithViewPager(viewPager); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java index 0d730557f..52aac70e1 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardDetailsFragment.java @@ -177,7 +177,7 @@ public class CardDetailsFragment extends Fragment implements DatePickerDialog.On } private void setupView(long accountId, long boardId, boolean canEdit) { - setupPeople(accountId); + setupPeople(accountId, boardId); setupLabels(accountId, boardId, canEdit); setupDueDate(); setupDescription(); @@ -384,11 +384,11 @@ public class CardDetailsFragment extends Fragment implements DatePickerDialog.On return chip; } - private void setupPeople(long accountId) { + private void setupPeople(long accountId, long boardId) { if (canEdit) { Long localCardId = fullCard.getCard().getLocalId(); localCardId = localCardId == null ? -1 : localCardId; - people.setAdapter(new UserAutoCompleteAdapter(this, activity, accountId, localCardId)); + people.setAdapter(new UserAutoCompleteAdapter(this, activity, accountId, boardId, localCardId)); people.setOnItemClickListener((adapterView, view, position, id) -> { User user = (User) adapterView.getItemAtPosition(position); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java index f878d713e..723e96f42 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/UserAutoCompleteAdapter.java @@ -41,17 +41,19 @@ public class UserAutoCompleteAdapter extends BaseAdapter implements Filterable { private List<User> userList = new ArrayList<>(); private SyncManager syncManager; private long accountId; + private long boardId; private long cardId; private LifecycleOwner owner; @BindInt(R.integer.max_users_suggested) int maxUsersSuggested; - UserAutoCompleteAdapter(@NonNull LifecycleOwner owner, Activity activity, long accountId, long cardId) { + UserAutoCompleteAdapter(@NonNull LifecycleOwner owner, Activity activity, long accountId, long boardId, long cardId) { ButterKnife.bind(this, activity); this.owner = owner; this.activity = activity; this.accountId = accountId; + this.boardId = boardId; this.cardId = cardId; syncManager = new SyncManager(activity); } @@ -114,7 +116,7 @@ public class UserAutoCompleteAdapter extends BaseAdapter implements Filterable { Objects.requireNonNull(((Fragment) owner).getActivity()).runOnUiThread(() -> { LiveData<List<User>> liveData = constraint.length() > 0 ? syncManager.searchUserByUidOrDisplayName(accountId, constraint.toString()) - : syncManager.findProposalsForUsersToAssign(accountId, cardId, maxUsersSuggested); + : syncManager.findProposalsForUsersToAssign(accountId, boardId, cardId, maxUsersSuggested); observeOnce(liveData, owner, users -> { if (users != null) { filterResults.values = users; |