fix(YouTube Music - Hide buttons): Crashes on startup due to null LayoutParams (#6799)
This commit is contained in:
parent
ce85fbfad7
commit
3e32c38732
1 changed files with 10 additions and 22 deletions
|
|
@ -32,11 +32,7 @@ import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.Toolbar;
|
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -138,6 +134,7 @@ public class Utils {
|
||||||
return versionName;
|
return versionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static String getApplicationName() {
|
public static String getApplicationName() {
|
||||||
if (applicationLabel == null) {
|
if (applicationLabel == null) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -184,24 +181,13 @@ public class Utils {
|
||||||
* @param view The view to hide.
|
* @param view The view to hide.
|
||||||
*/
|
*/
|
||||||
public static void hideViewBy0dp(View view) {
|
public static void hideViewBy0dp(View view) {
|
||||||
if (view instanceof LinearLayout) {
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, 0);
|
if (params == null)
|
||||||
view.setLayoutParams(layoutParams);
|
params = new ViewGroup.LayoutParams(0, 0);
|
||||||
} else if (view instanceof FrameLayout) {
|
|
||||||
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(0, 0);
|
params.width = 0;
|
||||||
view.setLayoutParams(layoutParams2);
|
params.height = 0;
|
||||||
} else if (view instanceof RelativeLayout) {
|
view.setLayoutParams(params);
|
||||||
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(0, 0);
|
|
||||||
view.setLayoutParams(layoutParams3);
|
|
||||||
} else if (view instanceof Toolbar) {
|
|
||||||
Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(0, 0);
|
|
||||||
view.setLayoutParams(layoutParams4);
|
|
||||||
} else {
|
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
params.width = 0;
|
|
||||||
params.height = 0;
|
|
||||||
view.setLayoutParams(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -478,6 +464,7 @@ public class Utils {
|
||||||
return str != null && !str.isEmpty();
|
return str != null && !str.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static boolean isTablet() {
|
public static boolean isTablet() {
|
||||||
return context.getResources().getConfiguration().smallestScreenWidthDp >= 600;
|
return context.getResources().getConfiguration().smallestScreenWidthDp >= 600;
|
||||||
}
|
}
|
||||||
|
|
@ -517,6 +504,7 @@ public class Utils {
|
||||||
return getTextDirectionString(isRightToLeftLocale());
|
return getTextDirectionString(isRightToLeftLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static String getTextDirectionString(Locale locale) {
|
public static String getTextDirectionString(Locale locale) {
|
||||||
return getTextDirectionString(isRightToLeftLocale(locale));
|
return getTextDirectionString(isRightToLeftLocale(locale));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue