<commit_before>﻿import types = require("utils/types");
import trace = require("trace");
import view = require("ui/core/view");
import border = require("ui/border");
import constants = require("utils/android_constants");
import style = require("ui/styling/style");
import definition = require("ui/styling");
import stylersCommon = require("ui/styling/stylers-common");
import enums = require("ui/enums");
import utils = require("utils/utils");
import styleModule = require("ui/styling/style");
import imageSource = require("image-source");

// merge the exports of the common file with the exports of this file
declare var exports;
require("utils/module-merge").merge(stylersCommon, exports);

class BorderGradientDrawable extends android.graphics.drawable.GradientDrawable {
    private _density = utils.layout.getDisplayDensity();

    constructor() {
        super();

        return global.__native(this);
    }

    private _borderWidth: number;
    get borderWidth(): number {
        return this._borderWidth;
    }
    set borderWidth(value: number) {
        if (this._borderWidth !== value) {
            this._borderWidth = value;

            this.setStroke(this._borderWidth * this._density, this._borderColor);
        }
    }

    private _cornerRadius: number;
    get cornerRadius(): number {
        return this._cornerRadius;
    }
    set cornerRadius(value: number) {
        if (this._cornerRadius !== value) {
            this._cornerRadius = value;

            this.setCornerRadius(this._cornerRadius);
        }
    }

    private _borderColor: number;
    get borderColor(): number {
        return this._borderColor;
    }
    set borderColor(value: number) {
        if (this._borderColor !== value) {
            this._borderColor = value;

            this.setStroke(this._borderWidth * this._density, this._borderColor);
        }
    }

    private _backgroundColor: number;
    get backgroundColor(): number {
        return this._backgroundColor;
    }
    set backgroundColor(value: number) {
        if (this._backgroundColor !== value) {
            this._backgroundColor = value;

            this.setColor(this._backgroundColor);
        }
    }

    private _bitmap: android.graphics.Bitmap
    get bitmap(): android.graphics.Bitmap {
        return this._bitmap;
    }
    set bitmap(value: android.graphics.Bitmap) {
        if (this._bitmap !== value) {
            this._bitmap = value;

            this.invalidateSelf();
        }
    }

    public draw(canvas: android.graphics.Canvas): void {
        if (this.bitmap) {
            this.setColor(android.graphics.Color.TRANSPARENT);

            var stroke = this._borderWidth * this._density;
            canvas.drawBitmap(this.bitmap, stroke, stroke, undefined);
        }
        super.draw(canvas);
    }
}

function onBorderPropertyChanged(v: view.View) {
    if (!v._nativeView) {
        return;
    }

    var value = <imageSource.ImageSource>v.style._getValue(styleModule.backgroundImageSourceProperty);

    if ((v.borderWidth === 0 && v.borderRadius === 0) || types.isNullOrUndefined(v.backgroundColor) || types.isNullOrUndefined(value)) {
        return;
    }

    var nativeView = <android.view.View>v._nativeView;

    var bkg = <BorderGradientDrawable>nativeView.getBackground();

    if (!(bkg instanceof BorderGradientDrawable)) {
        bkg = new BorderGradientDrawable();
        nativeView.setBackground(bkg);
    }

    var padding = v.borderWidth * utils.layout.getDisplayDensity();

    nativeView.setPadding(padding, padding, padding, padding);

    bkg.borderWidth = v.borderWidth;
    bkg.cornerRadius = v.borderRadius;
    bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
    bkg.backgroundColor = v.backgroundColor ? v.backgroundColor.android : android.graphics.Color.TRANSPARENT;

    bkg.bitmap = value ? value.android : undefined;<commit_msg>condition fixed<commit_after>﻿import types = require("utils/types");
import trace = require("trace");
import view = require("ui/core/view");
import border = require("ui/border");
import constants = require("utils/android_constants");
import style = require("ui/styling/style");
import definition = require("ui/styling");
import stylersCommon = require("ui/styling/stylers-common");
import enums = require("ui/enums");
import utils = require("utils/utils");
import styleModule = require("ui/styling/style");
import imageSource = require("image-source");

// merge the exports of the common file with the exports of this file
declare var exports;
require("utils/module-merge").merge(stylersCommon, exports);

class BorderGradientDrawable extends android.graphics.drawable.GradientDrawable {
    private _density = utils.layout.getDisplayDensity();

    constructor() {
        super();

        return global.__native(this);
    }

    private _borderWidth: number;
    get borderWidth(): number {
        return this._borderWidth;
    }
    set borderWidth(value: number) {
        if (this._borderWidth !== value) {
            this._borderWidth = value;

            this.setStroke(this._borderWidth * this._density, this._borderColor);
        }
    }

    private _cornerRadius: number;
    get cornerRadius(): number {
        return this._cornerRadius;
    }
    set cornerRadius(value: number) {
        if (this._cornerRadius !== value) {
            this._cornerRadius = value;

            this.setCornerRadius(this._cornerRadius);
        }
    }

    private _borderColor: number;
    get borderColor(): number {
        return this._borderColor;
    }
    set borderColor(value: number) {
        if (this._borderColor !== value) {
            this._borderColor = value;

            this.setStroke(this._borderWidth * this._density, this._borderColor);
        }
    }

    private _backgroundColor: number;
    get backgroundColor(): number {
        return this._backgroundColor;
    }
    set backgroundColor(value: number) {
        if (this._backgroundColor !== value) {
            this._backgroundColor = value;

            this.setColor(this._backgroundColor);
        }
    }

    private _bitmap: android.graphics.Bitmap
    get bitmap(): android.graphics.Bitmap {
        return this._bitmap;
    }
    set bitmap(value: android.graphics.Bitmap) {
        if (this._bitmap !== value) {
            this._bitmap = value;

            this.invalidateSelf();
        }
    }

    public draw(canvas: android.graphics.Canvas): void {
        if (this.bitmap) {
            this.setColor(android.graphics.Color.TRANSPARENT);

            var stroke = this._borderWidth * this._density;
            canvas.drawBitmap(this.bitmap, stroke, stroke, undefined);
        }
        super.draw(canvas);
    }
}

function onBorderPropertyChanged(v: view.View) {
    if (!v._nativeView) {
        return;
    }

    var value = <imageSource.ImageSource>v.style._getValue(styleModule.backgroundImageSourceProperty);

    if (v.borderWidth === 0 || v.borderRadius === 0 || types.isNullOrUndefined(v.backgroundColor) || types.isNullOrUndefined(value)) {
        return;
    }

    var nativeView = <android.view.View>v._nativeView;

    var bkg = <BorderGradientDrawable>nativeView.getBackground();

    if (!(bkg instanceof BorderGradientDrawable)) {
        bkg = new BorderGradientDrawable();
        nativeView.setBackground(bkg);
    }

    var padding = v.borderWidth * utils.layout.getDisplayDensity();

    nativeView.setPadding(padding, padding, padding, padding);

    bkg.borderWidth = v.borderWidth;
    bkg.cornerRadius = v.borderRadius;
    bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
    bkg.backgroundColor = v.backgroundColor ? v.backgroundColor.android : android.graphics.Color.TRANSPARENT;

    bkg.bitmap = value ? value.android : undefined;
{'fraction_non_alphanumeric': 0.11638591117917305, 'fraction_numerical': 0.0005104645227156713, 'mean_word_length': 2.9540867810292633, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6789692', 'n_tokens_mistral': 2207, 'n_tokens_neox': 2161, 'n_words': 450}