Disable recycling, refactoring & fixes (#4705)

* Added tests for native view recycling
Disabled android native view recycling
Move toString from view-common to view-base
Fix crash on application restore and navigation back on API26
Added setAsRootView method
Added missing logo into perf-tests/recycling app

* additional fix for image-source-tests. ios is case sensitive.

* Add @private to some internal properties
Fix where padding is not respected when background is reset.
This commit is contained in:
Hristo Hristov
2017-08-17 09:15:35 +03:00
committed by GitHub
parent 2701ea3c1e
commit bba7a82bdf
18 changed files with 532 additions and 251 deletions

View File

@@ -2,9 +2,6 @@
import { View as ViewDefinition, Point, Size, Color, dip } from ".";
import { HorizontalAlignment, VerticalAlignment, Visibility, Length, PercentLength } from "../../styling/style-properties";
// Types.
import { Source } from "../../../utils/debug";
import {
ViewBase, Property, booleanConverter, EventData, layout,
getEventOrGestureName, traceEnabled, traceWrite, traceCategories
@@ -747,21 +744,6 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
super.resetNativeView();
}
public toString(): string {
let str = this.typeName;
if (this.id) {
str += `<${this.id}>`;
} else {
str += `(${this._domId})`;
}
let source = Source.get(this);
if (source) {
str += `@${source};`;
}
return str;
}
public _setNativeViewFrame(nativeView: any, frame: any) {
//
}

View File

@@ -7,7 +7,8 @@ import { CacheLayerType } from "../../../utils/utils";
import { Background, ad as androidBackground } from "../../styling/background";
import {
ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty,
traceEnabled, traceWrite, traceCategories, traceNotifyEvent
traceEnabled, traceWrite, traceCategories, traceNotifyEvent,
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty
} from "./view-common";
import {
@@ -486,7 +487,18 @@ export class View extends ViewCommon {
} else {
const nativeView = this.nativeViewProtected;
org.nativescript.widgets.ViewHelper.setBackground(nativeView, value);
nativeView.setPadding(this._defaultPaddingLeft, this._defaultPaddingTop, this._defaultPaddingRight, this._defaultPaddingBottom);
const style = this.style;
const paddingTop = paddingTopProperty.isSet(style) ? this.effectivePaddingTop : this._defaultPaddingTop;
const paddingRight = paddingRightProperty.isSet(style) ? this.effectivePaddingRight : this._defaultPaddingRight;
const paddingBottom = paddingBottomProperty.isSet(style) ? this.effectivePaddingBottom : this._defaultPaddingBottom;
const paddingLeft = paddingLeftProperty.isSet(style) ? this.effectivePaddingLeft : this._defaultPaddingLeft;
if (this._isPaddingRelative) {
nativeView.setPaddingRelative(paddingLeft, paddingTop, paddingRight, paddingBottom);
} else {
nativeView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
}
(<any>nativeView).background = undefined;
const cache = <CacheLayerType><any>nativeView;