+ /**
+ * Get users and groups from the DB to fill in the "share with" list
+ *
+ * Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
+ * instance ready to use. If not ready, does nothing.
+ */
+ public void refreshUsersOrGroupsListFromDB (){
+ if (((FileActivity) mListener).getStorageManager() != null) {
+ // Get Users and Groups
+ mShares = ((FileActivity) mListener).getStorageManager().getSharesWithForAFile(
+ mFile.getRemotePath(),
+ mAccount.name
+ );
+
+ // Update list of users/groups
+ updateListOfUserGroups();
+ }
+ }
+
+ private void updateListOfUserGroups() {
+ // Update list of users/groups
+ // TODO Refactoring: create a new {@link ShareUserListAdapter} instance with every call should not be needed
+ mUserGroupsAdapter = new ShareUserListAdapter(
+ getActivity(),
+ R.layout.share_user_item,
+ mShares,
+ this
+ );
+
+ // 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);
+
+ } else {
+ noShares.setVisibility(View.VISIBLE);
+ usersList.setVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public void unshareButtonPressed(OCShare share) {
+ // Unshare
+ mListener.unshareWith(share);
+ Log_OC.d(TAG, "Unshare - " + share.getSharedWithDisplayName());
+ }
+
+