OC-2868: Fix bug: Unshare a file that does not exist any more, no message is shown

This commit is contained in:
masensio 2014-02-07 13:25:53 +01:00
parent eb7bbebc08
commit 7cf9c82cc0
2 changed files with 25 additions and 3 deletions

View file

@ -1350,9 +1350,12 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) { private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
if (result.isSuccess() || result.getCode() == ResultCode.SHARE_NOT_FOUND) { if (result.isSuccess()) {
refreshShowDetails(); refreshShowDetails();
refeshListOfFilesFragment(); refeshListOfFilesFragment();
} else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) {
cleanSecondFragment();
refeshListOfFilesFragment();
} }
} }
@ -1364,12 +1367,12 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
file = getStorageManager().getFileByPath(file.getRemotePath()); { file = getStorageManager().getFileByPath(file.getRemotePath()); {
if (!(details instanceof PreviewMediaFragment || details instanceof PreviewImageFragment)) { if (!(details instanceof PreviewMediaFragment || details instanceof PreviewImageFragment)) {
showDetails(file); showDetails(file);
} else if (details instanceof PreviewMediaFragment) { } else if (details instanceof PreviewMediaFragment) {
startMediaPreview(file, 0, false); startMediaPreview(file, 0, false);
} }
} }
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
} }
} }

View file

@ -48,7 +48,9 @@ import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.lib.operations.common.OnRemoteOperationListener; import com.owncloud.android.lib.operations.common.OnRemoteOperationListener;
import com.owncloud.android.lib.operations.common.RemoteOperation; import com.owncloud.android.lib.operations.common.RemoteOperation;
import com.owncloud.android.lib.operations.common.RemoteOperationResult; import com.owncloud.android.lib.operations.common.RemoteOperationResult;
import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;
import com.owncloud.android.operations.CreateShareOperation; import com.owncloud.android.operations.CreateShareOperation;
import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.PinCodeActivity; import com.owncloud.android.ui.activity.PinCodeActivity;
@ -158,9 +160,26 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
if (operation instanceof CreateShareOperation) { if (operation instanceof CreateShareOperation) {
onCreateShareOperationFinish((CreateShareOperation) operation, result); onCreateShareOperationFinish((CreateShareOperation) operation, result);
} else if (operation instanceof UnshareLinkOperation) {
onUnshareLinkOperationFinish((UnshareLinkOperation) operation, result);
} }
} }
private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
if (file != null) {
setFile(file);
invalidateOptionsMenu();
}
} else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) {
backToDisplayActivity();
}
}
private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) { private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath()); OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());