Merge branch 'android_background_again' of github.com:Akylas/NativeScript

# Conflicts:
#	packages/core/ui/action-bar/index.android.ts
#	packages/core/ui/button/index.android.ts
#	packages/core/ui/core/view/index.android.ts
This commit is contained in:
Martin Guillon
2021-02-17 17:08:47 +01:00
4 changed files with 39 additions and 8 deletions

View File

@ -225,7 +225,15 @@ export class ActionBar extends ActionBarBase {
const nativeView = this.nativeViewProtected;
if (backgroundDrawable && onlyColor && sdkVersion() >= 21) {
if (isBorderDrawable && (<any>nativeView)._cachedDrawable) {
backgroundDrawable = (<any>nativeView)._cachedDrawable.newDrawable(nativeView.getResources());
backgroundDrawable = (<any>nativeView)._cachedDrawable;
// we need to duplicate the drawable or we lose the "default" cached drawable
const constantState = backgroundDrawable.getConstantState();
if (constantState) {
try {
backgroundDrawable = constantState.newDrawable(nativeView.getResources());
// eslint-disable-next-line no-empty
} catch {}
}
nativeView.setBackground(backgroundDrawable);
}

View File

@ -62,10 +62,17 @@ export class Button extends ButtonBase {
public _applyBackground(background: Background, isBorderDrawable, onlyColor: boolean, backgroundDrawable: any) {
const nativeView = this.nativeViewProtected;
console.log('_applyBackground', nativeView, backgroundDrawable, onlyColor, isBorderDrawable);
if (backgroundDrawable && onlyColor) {
if (isBorderDrawable && (<any>nativeView)._cachedDrawable) {
backgroundDrawable = (<any>nativeView)._cachedDrawable.newDrawable(nativeView.getResources());
backgroundDrawable = (<any>nativeView)._cachedDrawable;
// we need to duplicate the drawable or we lose the "default" cached drawable
const constantState = backgroundDrawable.getConstantState();
if (constantState) {
try {
backgroundDrawable = constantState.newDrawable(nativeView.getResources());
// eslint-disable-next-line no-empty
} catch {}
}
nativeView.setBackground(backgroundDrawable);
}

View File

@ -1009,7 +1009,7 @@ export class View extends ViewCommon {
if (constantState) {
try {
drawable = constantState.newDrawable(nativeView.getResources());
// eslint-disable-next-line no-empty
// eslint-disable-next-line no-empty
} catch {}
}
}