- // Get users and groups to fill the "share with" list
- private void getShares(OCFile file){
- mShares = new ArrayList<>();
-
- RemoteOperationResult result = null;
-
- // Show loading
- ( (ShareActivity) getActivity()).showWaitingLoadDialog();
- // Get Users and Groups
- GetShareWithUserAsyncTask getTask = new GetShareWithUserAsyncTask(this);
- FileDataStorageManager fileDataStorageManager =
- new FileDataStorageManager(mAccount, getActivity().getContentResolver());
- Object[] params = { mFile, mAccount, fileDataStorageManager};
- getTask.execute(params);
- }
-
- @Override
- public void onGetDataShareWithFinish(RemoteOperationResult result) {
- // Remove loading
- ((ShareActivity) getActivity()).dismissWaitingLoadDialog();
- if (result != null && result.isSuccess()) {
- // update local database
- for(Object obj: result.getData()) {
- if ( ((OCShare) obj).getShareType() == ShareType.USER ||
- ((OCShare) obj).getShareType() == ShareType.GROUP ){
- mShares.add((OCShare) obj);
- }
- }
+ /**
+ * 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
+ );