X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/d4df65d7c737993231fc8e774adfd5766adaf484..c4f6cac7659ddfce23a51027e7a41bb99e6e7c0b:/src/com/owncloud/android/ui/fragment/ShareFileFragment.java diff --git a/src/com/owncloud/android/ui/fragment/ShareFileFragment.java b/src/com/owncloud/android/ui/fragment/ShareFileFragment.java index 5ee2a87c..a0296533 100644 --- a/src/com/owncloud/android/ui/fragment/ShareFileFragment.java +++ b/src/com/owncloud/android/ui/fragment/ShareFileFragment.java @@ -41,6 +41,7 @@ import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.OCShare; +import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.ShareActivity; import com.owncloud.android.ui.adapter.ShareUserListAdapter; import com.owncloud.android.utils.DisplayUtils; @@ -49,12 +50,14 @@ import com.owncloud.android.utils.MimetypeIconUtil; import java.util.ArrayList; /** - * Fragment for Sharing a file with users + * Fragment for Sharing a file with sharees (users or groups) * * A simple {@link Fragment} subclass. + * * Activities that contain this fragment must implement the * {@link ShareFileFragment.OnShareFragmentInteractionListener} interface * to handle interaction events. + * * Use the {@link ShareFileFragment#newInstance} factory method to * create an instance of this fragment. */ @@ -71,9 +74,9 @@ public class ShareFileFragment extends Fragment private OCFile mFile; private Account mAccount; + // other members private ArrayList mShares; private ShareUserListAdapter mUserGroupsAdapter = null; - private OnShareFragmentInteractionListener mListener; /** @@ -96,6 +99,9 @@ public class ShareFileFragment extends Fragment // Required empty public constructor } + /** + * {@inheritDoc} + */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -105,6 +111,9 @@ public class ShareFileFragment extends Fragment } } + /** + * {@inheritDoc} + */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -160,11 +169,6 @@ public class ShareFileFragment extends Fragment // Load data into the list refreshUsersOrGroupsListFromDB(); - - // Request for a refresh of the data through the server (starts an Async Task) - if (mListener != null) { - mListener.refreshUsersOrGroupsListFromServer(); - } } @Override @@ -185,19 +189,27 @@ public class ShareFileFragment extends Fragment } /** - * Get users and groups fromn the DB to fill in the "share with" list + * 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 (){ - // Get Users and Groups - mShares = ((ShareActivity) mListener).getStorageManager().getSharesWithForAFile(mFile.getRemotePath(), - mAccount.name); - - // Update list of users/groups - updateListOfUserGroups(); + 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,