mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 05:35:39 +03:00
Replace equals with == on enums
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
bce8866961
commit
a9608108ac
13 changed files with 44 additions and 46 deletions
|
@ -1192,12 +1192,12 @@ public class FileDataStorageManager {
|
|||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
|
||||
|
||||
if (!ShareType.PUBLIC_LINK.equals(type)) {
|
||||
if (ShareType.PUBLIC_LINK != type) {
|
||||
selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?";
|
||||
}
|
||||
|
||||
String[] selectionArgs;
|
||||
if (ShareType.PUBLIC_LINK.equals(type)) {
|
||||
if (ShareType.PUBLIC_LINK == type) {
|
||||
selectionArgs = new String[]{
|
||||
path,
|
||||
Integer.toString(type.getValue()),
|
||||
|
|
|
@ -814,7 +814,7 @@ public final class ThumbnailsCacheManager {
|
|||
// Not found in disk cache
|
||||
if (thumbnail == null) {
|
||||
|
||||
if (Type.IMAGE.equals(type)) {
|
||||
if (Type.IMAGE == type) {
|
||||
int px = getThumbnailDimension();
|
||||
|
||||
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getAbsolutePath(), px, px);
|
||||
|
@ -822,7 +822,7 @@ public final class ThumbnailsCacheManager {
|
|||
if (bitmap != null) {
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), px, px);
|
||||
}
|
||||
} else if (Type.VIDEO.equals(type)) {
|
||||
} else if (Type.VIDEO == type) {
|
||||
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
||||
try {
|
||||
retriever.setDataSource(file.getAbsolutePath());
|
||||
|
|
|
@ -640,7 +640,7 @@ public class FileDownloader extends Service
|
|||
int tickerId = downloadResult.isSuccess() ?
|
||||
R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
|
||||
|
||||
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(downloadResult.getCode());
|
||||
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED == downloadResult.getCode();
|
||||
tickerId = needsToUpdateCredentials ?
|
||||
R.string.downloader_download_failed_credentials_error : tickerId;
|
||||
|
||||
|
|
|
@ -778,11 +778,11 @@ public class FileUploader extends Service
|
|||
// Only notify if the upload fails
|
||||
if (!uploadResult.isCancelled() &&
|
||||
!uploadResult.isSuccess() &&
|
||||
!ResultCode.LOCAL_FILE_NOT_FOUND.equals(uploadResult.getCode()) &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_WIFI) &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_CHARGING) &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_IN_POWER_SAVE_MODE) &&
|
||||
!uploadResult.getCode().equals(ResultCode.LOCK_FAILED)) {
|
||||
ResultCode.LOCAL_FILE_NOT_FOUND != uploadResult.getCode() &&
|
||||
uploadResult.getCode() != ResultCode.DELAYED_FOR_WIFI &&
|
||||
uploadResult.getCode() != ResultCode.DELAYED_FOR_CHARGING &&
|
||||
uploadResult.getCode() != ResultCode.DELAYED_IN_POWER_SAVE_MODE &&
|
||||
uploadResult.getCode() != ResultCode.LOCK_FAILED) {
|
||||
|
||||
int tickerId = R.string.uploader_upload_failed_ticker;
|
||||
|
||||
|
@ -827,7 +827,7 @@ public class FileUploader extends Service
|
|||
));
|
||||
} else {
|
||||
Intent intent;
|
||||
if (uploadResult.getCode().equals(ResultCode.SYNC_CONFLICT)) {
|
||||
if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) {
|
||||
intent = ConflictsResolveActivity.createIntent(upload.getFile(),
|
||||
upload.getUser(),
|
||||
upload.getOCUploadId(),
|
||||
|
|
|
@ -699,7 +699,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|||
for (Object obj : result.getData()) {
|
||||
share = (OCShare) obj;
|
||||
|
||||
if (!ShareType.NO_SHARED.equals(share.getShareType())) {
|
||||
if (ShareType.NO_SHARED != share.getShareType()) {
|
||||
shares.add(share);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,10 +68,10 @@ public class UnshareOperation extends SyncOperation {
|
|||
if (result.isSuccess()) {
|
||||
Log_OC.d(TAG, "Share id = " + share.getRemoteId() + " deleted");
|
||||
|
||||
if (ShareType.PUBLIC_LINK.equals(share.getShareType())) {
|
||||
if (ShareType.PUBLIC_LINK == share.getShareType()) {
|
||||
file.setSharedViaLink(false);
|
||||
} else if (ShareType.USER.equals(share.getShareType()) || ShareType.GROUP.equals(share.getShareType())
|
||||
|| ShareType.FEDERATED.equals(share.getShareType())) {
|
||||
} else if (ShareType.USER == share.getShareType() || ShareType.GROUP == share.getShareType()
|
||||
|| ShareType.FEDERATED == share.getShareType()) {
|
||||
// Check if it is the last share
|
||||
List<OCShare> sharesWith = getStorageManager().
|
||||
getSharesWithForAFile(remotePath,
|
||||
|
|
|
@ -292,7 +292,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
|||
|
||||
} else if (result.getCode() != ResultCode.FILE_NOT_FOUND) {
|
||||
// in failures, the statistics for the global result are updated
|
||||
if (RemoteOperationResult.ResultCode.UNAUTHORIZED.equals(result.getCode())) {
|
||||
if (ResultCode.UNAUTHORIZED == result.getCode()) {
|
||||
mSyncResult.stats.numAuthExceptions++;
|
||||
|
||||
} else if (result.getException() instanceof DavException) {
|
||||
|
@ -321,10 +321,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
|||
private boolean isFinisher(RemoteOperationResult failedResult) {
|
||||
if (failedResult != null) {
|
||||
RemoteOperationResult.ResultCode code = failedResult.getCode();
|
||||
return code.equals(RemoteOperationResult.ResultCode.SSL_ERROR)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.BAD_OC_VERSION)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
|
||||
return code == ResultCode.SSL_ERROR
|
||||
|| code == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED
|
||||
|| code == ResultCode.BAD_OC_VERSION
|
||||
|| code == ResultCode.INSTANCE_NOT_CONFIGURED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
|||
private void notifyFailedSynchronization() {
|
||||
NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
|
||||
boolean needsToUpdateCredentials = mLastFailedResult != null
|
||||
&& ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode());
|
||||
&& ResultCode.UNAUTHORIZED == mLastFailedResult.getCode();
|
||||
if (needsToUpdateCredentials) {
|
||||
// let the user update credentials with one click
|
||||
Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
|
||||
|
|
|
@ -358,7 +358,7 @@ public abstract class FileActivity extends DrawerActivity
|
|||
);
|
||||
}
|
||||
|
||||
} else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(result.getCode())) {
|
||||
} else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == result.getCode()) {
|
||||
|
||||
showUntrustedCertDialog(result);
|
||||
|
||||
|
|
|
@ -1298,8 +1298,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
}
|
||||
}
|
||||
|
||||
if (synchResult != null && synchResult.getCode().equals(
|
||||
RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
|
||||
if (synchResult != null && synchResult.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {
|
||||
mLastSslUntrustedServerResult = synchResult;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
|
@ -1317,7 +1316,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
}
|
||||
|
||||
private boolean checkForRemoteOperationError(RemoteOperationResult syncResult) {
|
||||
return ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) ||
|
||||
return ResultCode.UNAUTHORIZED == syncResult.getCode() ||
|
||||
(syncResult.isException() && syncResult.getException()
|
||||
instanceof AuthenticatorException);
|
||||
}
|
||||
|
|
|
@ -520,11 +520,10 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
|||
/// TODO refactor and make common
|
||||
syncResult != null && !syncResult.isSuccess()) {
|
||||
|
||||
if (ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) || (syncResult.isException()
|
||||
if (ResultCode.UNAUTHORIZED == syncResult.getCode() || (syncResult.isException()
|
||||
&& syncResult.getException() instanceof AuthenticatorException)) {
|
||||
requestCredentialsUpdate(context);
|
||||
} else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED
|
||||
.equals(syncResult.getCode())) {
|
||||
} else if (ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult.getCode()) {
|
||||
showUntrustedCertDialog(syncResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -1145,7 +1145,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|||
|
||||
requestCredentialsUpdate(context);
|
||||
|
||||
} else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(syncResult.getCode())) {
|
||||
} else if (ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult.getCode()) {
|
||||
|
||||
showUntrustedCertDialog(syncResult);
|
||||
}
|
||||
|
|
|
@ -462,7 +462,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
}
|
||||
|
||||
private boolean isReshareForbidden(OCShare share) {
|
||||
return ShareType.FEDERATED.equals(share.getShareType()) ||
|
||||
return ShareType.FEDERATED == share.getShareType() ||
|
||||
capabilities != null && capabilities.getFilesSharingResharing().isFalse();
|
||||
}
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ public final class ErrorMessageAdapter {
|
|||
if (result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME) {
|
||||
return res.getString(R.string.filename_forbidden_characters);
|
||||
|
||||
} else if (result.getCode().equals(ResultCode.FORBIDDEN)) {
|
||||
} else if (result.getCode() == ResultCode.FORBIDDEN) {
|
||||
return String.format(res.getString(R.string.forbidden_permissions),
|
||||
res.getString(R.string.forbidden_permissions_create));
|
||||
|
||||
|
@ -277,15 +277,15 @@ public final class ErrorMessageAdapter {
|
|||
|
||||
private static @Nullable
|
||||
String getMessageForRenameFileOperation(RemoteOperationResult result, Resources res) {
|
||||
if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
|
||||
if (result.getCode() == ResultCode.INVALID_LOCAL_FILE_NAME) {
|
||||
return res.getString(R.string.rename_local_fail_msg);
|
||||
|
||||
} else if (result.getCode().equals(ResultCode.FORBIDDEN)) {
|
||||
} else if (result.getCode() == ResultCode.FORBIDDEN) {
|
||||
// Error --> No permissions
|
||||
return String.format(res.getString(R.string.forbidden_permissions),
|
||||
res.getString(R.string.forbidden_permissions_rename));
|
||||
|
||||
} else if (result.getCode().equals(ResultCode.INVALID_CHARACTER_IN_NAME)) {
|
||||
} else if (result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME) {
|
||||
return res.getString(R.string.filename_forbidden_characters);
|
||||
|
||||
} else if (result.getCode() == ResultCode.INVALID_CHARACTER_DETECT_IN_SERVER) {
|
||||
|
@ -302,7 +302,7 @@ public final class ErrorMessageAdapter {
|
|||
return res.getString(R.string.remove_success_msg);
|
||||
|
||||
} else {
|
||||
if (result.getCode().equals(ResultCode.FORBIDDEN)) {
|
||||
if (result.getCode() == ResultCode.FORBIDDEN) {
|
||||
// Error --> No permissions
|
||||
return String.format(res.getString(R.string.forbidden_permissions),
|
||||
res.getString(R.string.forbidden_permissions_delete));
|
||||
|
|
Loading…
Reference in a new issue