mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-02 17:56:56 +01:00
fixed crash when calling setForeground on some special cases
This commit is contained in:
parent
8812d6f5e7
commit
5d61948d08
@ -90,8 +90,6 @@ I started a crowdin project, so anyone can do something for Twidere. Visit this
|
||||
|
||||
PayPal & AliPay: `String.format("%s@%s", "mariotaku.lee", "gmail.com");`
|
||||
|
||||
PayPal & AliPay: `String.format("%s@%s", "pay", "uucky.me");`
|
||||
|
||||
Bitcoin: `1FHAVAzge7cj1LfCTMfnLL49DgA3mVUCuW`
|
||||
|
||||
**Donators**
|
||||
|
@ -14,7 +14,7 @@ android {
|
||||
applicationId "org.mariotaku.twidere"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 23
|
||||
versionCode 119
|
||||
versionCode 120
|
||||
versionName "0.3.0"
|
||||
multiDexEnabled true
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ import android.view.View;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -978,8 +979,8 @@ public class ThemeUtils implements Constants {
|
||||
if (contentLayout == null) {
|
||||
contentLayout = window.findViewById(android.R.id.content);
|
||||
}
|
||||
if (contentLayout instanceof ContentFrameLayout) {
|
||||
contentLayout.setForeground(overlay);
|
||||
if (contentLayout instanceof FrameLayout) {
|
||||
ViewSupport.setForeground(contentLayout, overlay);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -111,6 +112,16 @@ public final class ViewSupport {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setForeground(View view, Drawable foreground) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
return;
|
||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
ViewAccessorICS.setForeground(view, foreground);
|
||||
} else {
|
||||
view.setForeground(foreground);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
static class ViewAccessorJB {
|
||||
static void setBackground(final View view, final Drawable background) {
|
||||
@ -119,6 +130,17 @@ public final class ViewSupport {
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
static class ViewAccessorICS {
|
||||
static void setForeground(final View view, final Drawable foreground) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) return;
|
||||
if (view instanceof FrameLayout) {
|
||||
//noinspection RedundantCast
|
||||
((FrameLayout) view).setForeground(foreground);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
static class ViewAccessorJBMR2 {
|
||||
static boolean isInLayout(final View view) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user