瀏覽代碼

codacy: Avoid reassigning parameters

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 年之前
父節點
當前提交
d7c783f6b0

+ 22 - 13
src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -1178,13 +1178,11 @@ public class FileDataStorageManager {
      */
     public List<OCShare> getSharesByPathAndType(String path, ShareType type, String shareWith) {
         Cursor cursor;
-        if (shareWith == null) {
-            shareWith = "";
-        }
 
         String selection = ProviderTableMeta.OCSHARES_PATH + AND
             + ProviderTableMeta.OCSHARES_SHARE_TYPE + AND
             + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
+
         if (!ShareType.PUBLIC_LINK.equals(type)) {
             selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?";
         }
@@ -1197,12 +1195,21 @@ public class FileDataStorageManager {
                 account.name
             };
         } else {
-            selectionArgs = new String[]{
-                path,
-                Integer.toString(type.getValue()),
-                account.name,
-                shareWith
-            };
+            if (shareWith == null) {
+                selectionArgs = new String[]{
+                    path,
+                    Integer.toString(type.getValue()),
+                    account.name,
+                    ""
+                };
+            } else {
+                selectionArgs = new String[]{
+                    path,
+                    Integer.toString(type.getValue()),
+                    account.name,
+                    shareWith
+                };
+            }
         }
 
         if (getContentResolver() != null) {
@@ -1775,11 +1782,14 @@ public class FileDataStorageManager {
     }
 
     public void saveConflict(OCFile ocFile, String etagInConflict) {
+        String etag;
         if (!ocFile.isDown()) {
-            etagInConflict = null;
+            etag = null;
+        } else {
+            etag = etagInConflict;
         }
         ContentValues cv = new ContentValues();
-        cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict);
+        cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etag);
         int updated = 0;
         if (getContentResolver() != null) {
             updated = getContentResolver().update(
@@ -1804,7 +1814,7 @@ public class FileDataStorageManager {
         Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated);
 
         if (updated > 0) {
-            if (etagInConflict != null) {
+            if (etag != null) {
                 /// set conflict in all ancestor folders
 
                 long parentId = ocFile.getParentId();
@@ -1922,7 +1932,6 @@ public class FileDataStorageManager {
                 }
             }
         }
-
     }
 
     public void saveCapabilities(OCCapability capability) {

+ 2 - 4
src/main/java/com/owncloud/android/media/MediaControlView.java

@@ -165,13 +165,11 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
     private Handler handler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
-            int pos;
             if (msg.what == SHOW_PROGRESS) {
                 updatePausePlay();
-                pos = setProgress();
+                int pos = setProgress();
                 if (!isDragging) {
-                    msg = obtainMessage(SHOW_PROGRESS);
-                    sendMessageDelayed(msg, 1000 - (pos % 1000));
+                    sendMessageDelayed(obtainMessage(SHOW_PROGRESS), 1000 - (pos % 1000));
                 }
             }
         }

+ 6 - 8
src/main/java/com/owncloud/android/operations/UploadFileOperation.java

@@ -148,12 +148,6 @@ public class UploadFileOperation extends SyncOperation {
     private boolean encryptedAncestor;
 
     public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) {
-
-        // MIME type
-        if (TextUtils.isEmpty(mimeType)) {
-            mimeType = MimeTypeUtil.getBestMimeTypeByFilename(localPath);
-        }
-
         OCFile newFile = new OCFile(remotePath);
         newFile.setStoragePath(localPath);
         newFile.setLastSyncDateForProperties(0);
@@ -167,8 +161,12 @@ public class UploadFileOperation extends SyncOperation {
         } // don't worry about not assigning size, the problems with localPath
         // are checked when the UploadFileOperation instance is created
 
-
-        newFile.setMimeType(mimeType);
+        // MIME type
+        if (TextUtils.isEmpty(mimeType)) {
+            newFile.setMimeType(MimeTypeUtil.getBestMimeTypeByFilename(localPath));
+        } else {
+            newFile.setMimeType(mimeType);
+        }
 
         return newFile;
     }

+ 2 - 2
src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java

@@ -365,9 +365,9 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
             mFiles = mFilesAll;
         } else {
             List<File> result = new ArrayList<>();
-            text = text.toLowerCase(Locale.getDefault());
+            String filterText = text.toLowerCase(Locale.getDefault());
             for (File file : mFilesAll) {
-                if (file.getName().toLowerCase(Locale.getDefault()).contains(text)) {
+                if (file.getName().toLowerCase(Locale.getDefault()).contains(filterText)) {
                     result.add(file);
                 }
             }