Repository: NativeScript/NativeScript
File: packages/core/ui/core/view/index.android.ts (TypeScript)

Code before:

		const stateListAnimator = new (<any>android.animation).StateListAnimator();
		stateListAnimator.addState([statePressed, stateEnabled], pressedSet);
		stateListAnimator.addState([stateEnabled], notPressedSet);
		stateListAnimator.addState([], defaultSet);

		const currentAnimator = nativeView.getStateListAnimator();
		if (currentAnimator) {
			currentAnimator.jumpToCurrentState();
		}
		nativeView.setStateListAnimator(stateListAnimator);
	}

	[horizontalAlignmentProperty.getDefault](): HorizontalAlignment {
		return <HorizontalAlignment>org.nativescript.widgets.ViewHelper.getHorizontalAlignment(this.nativeViewProtected);
	}
	[horizontalAlignmentProperty.setNative](value: HorizontalAlignment) {
		const nativeView = this.nativeViewProtected;
		const lp: any = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams();
		const gravity = lp.gravity;
		const weight = lp.weight;
		// Set only if params gravity exists.
		if (lp.gravity !== undefined) {
			switch (value) {
				case 'left':
					lp.gravity = 3 | (gravity & VERTICAL_GRAVITY_MASK); // android.view.Gravity.LEFT
					if (weight < 0) {
						lp.weight = -2;
					}
					break;
				case 'center':
					lp.gravity = 1 | (gravity & VERTICAL_GRAVITY_MASK); // android.view.Gravity.CENTER_HORIZONTAL
					if (weight < 0) {
						lp.weight = -2;
					}
					break;
				case 'right':
					lp.gravity = 5 | (gravity & VERTICAL_GRAVITY_MASK); // android.view.Gravity.RIGHT
					if (weight < 0) {
						lp.weight = -2;
					}
					break;
				case 'stretch':
					lp.gravity = 7 | (gravity & VERTICAL_GRAVITY_MASK); // android.view.Gravity.FILL_HORIZONTAL
					if (weight < 0) {
						lp.weight = -1;
					}
					break;
			}
			nativeView.setLayoutParams(lp);
		}

Review comment (suggestion):
What is `3`, `1`, `5`, `7`.   Definitely would be better to create the `const` at the top so that the code is easier to read.   

Code after:
			}
		}
	}

	[accessibilityStateProperty.setNative](value: AccessibilityState): void {
		this.accessibilityState = value;
		updateAccessibilityProperties(this);
	}

	[accessibilityMediaSessionProperty.setNative](): void {
		updateAccessibilityProperties(this);
	}

	[androidElevationProperty.getDefault](): number {
		return this.getDefaultElevation();
	}
	[androidElevationProperty.setNative](value: number) {
		if (sdkVersion() < 21) {
			return;
		}

		this.refreshStateListAnimator();
	}

	[androidDynamicElevationOffsetProperty.getDefault](): number {
		return this.getDefaultDynamicElevationOffset();
	}
	[androidDynamicElevationOffsetProperty.setNative](value: number) {
		if (sdkVersion() < 21) {
			return;
		}

		this.refreshStateListAnimator();
	}

	protected getDefaultElevation(): number {
		if (sdkVersion() < 21) {
			return 0;
		}

		// NOTE: overriden in Button implementation as for widgets with StateListAnimator (Button)
		// nativeView.getElevation() returns 0 at the time of the getDefault() query
		return layout.toDeviceIndependentPixels((<any>this.nativeViewProtected).getElevation());
	}

	protected getDefaultDynamicElevationOffset() {
		// NOTE: overriden in Button implementation
		return 0;
	}

	private refreshStateListAnimator() {