فهرست منبع

Spotbugs

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 سال پیش
والد
کامیت
6d1d4a732d

+ 4 - 1
src/main/java/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java

@@ -372,6 +372,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
 
 
     @Nullable
     @Nullable
     @Override
     @Override
+    @SuppressFBWarnings("IOI_USE_OF_FILE_STREAM_CONSTRUCTORS") // TODO remove with API26
     public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException {
     public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException {
         ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver());
         ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver());
 
 
@@ -398,7 +399,9 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
         // create a file to write bitmap data
         // create a file to write bitmap data
         File f = new File(getContext().getCacheDir(), "test");
         File f = new File(getContext().getCacheDir(), "test");
         try {
         try {
-            f.createNewFile();
+            if (!f.createNewFile()) {
+                throw new IllegalStateException("File could not be created!");
+            }
 
 
             //Convert bitmap to byte array
             //Convert bitmap to byte array
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             ByteArrayOutputStream bos = new ByteArrayOutputStream();

+ 11 - 6
src/main/java/com/owncloud/android/ui/StatusDrawable.java

@@ -36,16 +36,18 @@ import com.owncloud.android.lib.resources.users.Status;
 import androidx.annotation.DrawableRes;
 import androidx.annotation.DrawableRes;
 import androidx.annotation.NonNull;
 import androidx.annotation.NonNull;
 import androidx.core.content.res.ResourcesCompat;
 import androidx.core.content.res.ResourcesCompat;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 
 /**
 /**
  * A Drawable object that draws a status
  * A Drawable object that draws a status
  */
  */
+@SuppressFBWarnings("PME_POOR_MANS_ENUM")
 public class StatusDrawable extends Drawable {
 public class StatusDrawable extends Drawable {
     private String text;
     private String text;
     private @DrawableRes int icon = -1;
     private @DrawableRes int icon = -1;
     private Paint textPaint;
     private Paint textPaint;
     private Paint backgroundPaint;
     private Paint backgroundPaint;
-    private float radius;
+    private final float radius;
     private Context context;
     private Context context;
     private final static int whiteBackground = Color.argb(200, 255, 255, 255);
     private final static int whiteBackground = Color.argb(200, 255, 255, 255);
     private final static int onlineStatus = Color.argb(255, 73, 179, 130);
     private final static int onlineStatus = Color.argb(255, 73, 179, 130);
@@ -112,11 +114,14 @@ public class StatusDrawable extends Drawable {
 
 
         if (icon != -1) {
         if (icon != -1) {
             Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), icon, null);
             Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), icon, null);
-            drawable.setBounds(0,
-                               0,
-                               (int) (2 * radius),
-                               (int) (2 * radius));
-            drawable.draw(canvas);
+
+            if (drawable != null) {
+                drawable.setBounds(0,
+                                   0,
+                                   (int) (2 * radius),
+                                   (int) (2 * radius));
+                drawable.draw(canvas);
+            }
         }
         }
     }
     }