From 5fe5754a2d9984c289b5fd0f6356c5c0b8798b22 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 3 Mar 2021 16:22:47 +0100 Subject: [PATCH] remove pointless null guards The cast to AppCompatActivity would throw an exception if it failed. --- .../org/fdroid/fdroid/views/main/SettingsView.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/main/SettingsView.java b/app/src/main/java/org/fdroid/fdroid/views/main/SettingsView.java index 4c779c99e..5aa71206c 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/main/SettingsView.java +++ b/app/src/main/java/org/fdroid/fdroid/views/main/SettingsView.java @@ -2,17 +2,14 @@ package org.fdroid.fdroid.views.main; import android.annotation.TargetApi; import android.content.Context; -import androidx.appcompat.app.AppCompatActivity; import android.util.AttributeSet; import android.widget.FrameLayout; - +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; - import org.fdroid.fdroid.R; import org.fdroid.fdroid.views.PreferencesFragment; -@SuppressWarnings("LineLength") /** * When attached to the window, the {@link PreferencesFragment} will be added. When detached from * the window, the fragment will be removed. @@ -52,9 +49,6 @@ public class SettingsView extends FrameLayout { super.onAttachedToWindow(); AppCompatActivity activity = (AppCompatActivity) getContext(); - if (activity == null) { - throw new IllegalArgumentException("Cannot add a SettingsView to activities which are not an AppCompatActivity"); - } if (currentTransaction == null) { currentTransaction = activity.getSupportFragmentManager().beginTransaction(); @@ -71,9 +65,6 @@ public class SettingsView extends FrameLayout { super.onDetachedFromWindow(); AppCompatActivity activity = (AppCompatActivity) getContext(); - if (activity == null) { - throw new IllegalArgumentException("Cannot add a SettingsView to activities which are not an AppCompatActivity"); - } Fragment existingFragment = activity.getSupportFragmentManager().findFragmentByTag("preferences-fragment"); if (existingFragment == null) {