- // Get users and groups to fill the "share with" list
- private void getShares(OCFile file){
- mShares = new ArrayList<>();
+ /**
+ * Get users and groups fromn the DB to fill in the "share with" list
+ */
+ public void refreshUsersOrGroupsListFromDB (){
+ // Get Users and Groups
+ FileDataStorageManager fileDataStorageManager =
+ new FileDataStorageManager(mAccount, getActivity().getContentResolver());
+ mShares = fileDataStorageManager.getSharesWithForAFile(mFile.getRemotePath(),
+ mAccount.name);
+
+ // Update list of users/groups
+ updateListOfUserGroups();
+ }
+
+ private void updateListOfUserGroups() {
+ // Update list of users/groups
+ mUserGroupsAdapter = new ShareUserListAdapter(getActivity().getApplicationContext(),
+ R.layout.share_user_item, mShares);
+
+ // Show data
+ TextView noShares = (TextView) getView().findViewById(R.id.shareNoUsers);
+ ListView usersList = (ListView) getView().findViewById(R.id.shareUsersList);
+
+ if (mShares.size() > 0) {
+ noShares.setVisibility(View.GONE);
+ usersList.setVisibility(View.VISIBLE);
+ usersList.setAdapter(mUserGroupsAdapter);
+
+ // Add unshare options
+ registerLongClickListener(usersList);
+
+ } else {
+ noShares.setVisibility(View.VISIBLE);
+ usersList.setVisibility(View.GONE);
+ }
+ }