refactor: remove obsolete ViewHelper.setBackground method (#6240)

This commit is contained in:
Manol Donev
2018-09-05 17:35:59 +03:00
committed by GitHub
parent f54f71bc60
commit ca0043701b
4 changed files with 7 additions and 7 deletions

View File

@ -785,7 +785,7 @@ export class View extends ViewCommon {
androidBackground.onBackgroundOrBorderPropertyChanged(this); androidBackground.onBackgroundOrBorderPropertyChanged(this);
} else { } else {
const nativeView = this.nativeViewProtected; const nativeView = this.nativeViewProtected;
org.nativescript.widgets.ViewHelper.setBackground(nativeView, value); nativeView.setBackground(value);
const style = this.style; const style = this.style;
const paddingTop = paddingTopProperty.isSet(style) ? this.effectivePaddingTop : this._defaultPaddingTop; const paddingTop = paddingTopProperty.isSet(style) ? this.effectivePaddingTop : this._defaultPaddingTop;

View File

@ -205,7 +205,7 @@ export class SearchBar extends SearchBarBase {
if (value instanceof Color) { if (value instanceof Color) {
textView.setBackgroundColor(value.android); textView.setBackgroundColor(value.android);
} else { } else {
org.nativescript.widgets.ViewHelper.setBackground(textView, value); textView.setBackground(value);
} }
} }
[textFieldHintColorProperty.getDefault](): number { [textFieldHintColorProperty.getDefault](): number {

View File

@ -157,7 +157,7 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
if (apiLevel > 21 && backgroundDrawable) { if (apiLevel > 21 && backgroundDrawable) {
const newDrawable = tryCloneDrawable(backgroundDrawable, nativeView.getResources()); const newDrawable = tryCloneDrawable(backgroundDrawable, nativeView.getResources());
newDrawable.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN); newDrawable.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN);
org.nativescript.widgets.ViewHelper.setBackground(viewGroup, newDrawable); viewGroup.setBackground(newDrawable);
} else { } else {
const stateDrawable = new android.graphics.drawable.StateListDrawable(); const stateDrawable = new android.graphics.drawable.StateListDrawable();
const colorDrawable: android.graphics.drawable.ColorDrawable = new org.nativescript.widgets.SegmentedBarColorDrawable(color, selectedIndicatorThickness); const colorDrawable: android.graphics.drawable.ColorDrawable = new org.nativescript.widgets.SegmentedBarColorDrawable(color, selectedIndicatorThickness);
@ -165,11 +165,11 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
arr[0] = R_ATTR_STATE_SELECTED; arr[0] = R_ATTR_STATE_SELECTED;
stateDrawable.addState(arr, colorDrawable); stateDrawable.addState(arr, colorDrawable);
stateDrawable.setBounds(0, 15, viewGroup.getRight(), viewGroup.getBottom()); stateDrawable.setBounds(0, 15, viewGroup.getRight(), viewGroup.getBottom());
org.nativescript.widgets.ViewHelper.setBackground(viewGroup, stateDrawable); viewGroup.setBackground(stateDrawable);
} }
} else { } else {
const backgroundDrawable = tryCloneDrawable(value, nativeView.getResources()); const backgroundDrawable = tryCloneDrawable(value, nativeView.getResources());
org.nativescript.widgets.ViewHelper.setBackground(viewGroup, backgroundDrawable); viewGroup.setBackground(backgroundDrawable);
} }
} }
} }

View File

@ -65,7 +65,7 @@ export module ad {
if (!(drawable instanceof org.nativescript.widgets.BorderDrawable)) { if (!(drawable instanceof org.nativescript.widgets.BorderDrawable)) {
backgroundDrawable = new org.nativescript.widgets.BorderDrawable(layout.getDisplayDensity(), view.toString()); backgroundDrawable = new org.nativescript.widgets.BorderDrawable(layout.getDisplayDensity(), view.toString());
refreshBorderDrawable(view, backgroundDrawable); refreshBorderDrawable(view, backgroundDrawable);
org.nativescript.widgets.ViewHelper.setBackground(nativeView, backgroundDrawable); nativeView.setBackground(backgroundDrawable);
} else { } else {
refreshBorderDrawable(view, backgroundDrawable); refreshBorderDrawable(view, backgroundDrawable);
} }
@ -80,7 +80,7 @@ export module ad {
defaultDrawable = null; defaultDrawable = null;
} }
org.nativescript.widgets.ViewHelper.setBackground(nativeView, defaultDrawable); nativeView.setBackground(defaultDrawable);
// TODO: Do we need to clear the drawable here? Can't we just reuse it again? // TODO: Do we need to clear the drawable here? Can't we just reuse it again?
androidView._cachedDrawable = undefined; androidView._cachedDrawable = undefined;
} }