<commit_before>import application = require("tns-core-modules/application");

import common = require("./map-view-common");

import {
    MapViewBase, BoundsBase, CircleBase,
    MarkerBase, PolygonBase, PolylineBase, ProjectionBase,
    PositionBase, ShapeBase, latitudeProperty, VisibleRegionBase,
    longitudeProperty, bearingProperty, zoomProperty,
    tiltProperty, StyleBase, UISettingsBase, getColorHue
} from "./map-view-common";
import { Image } from "tns-core-modules/ui/image";
import { Color } from "tns-core-modules/color";
import { Point } from "tns-core-modules/ui/core/view";
import imageSource = require("tns-core-modules/image-source");

export * from "./map-view-common";

declare const com: any;
declare const android: any;

export class MapView extends MapViewBase {

    protected _markers: Array<Marker> = new Array<Marker>();
    public _context: any;
    private _pendingCameraUpdate: boolean;

    onLoaded() {
        super.onLoaded();

        application.android.on(application.AndroidApplication.activityPausedEvent, this.onActivityPaused, this);
        application.android.on(application.AndroidApplication.activityResumedEvent, this.onActivityResumed, this);
        application.android.on(application.AndroidApplication.saveActivityStateEvent, this.onActivitySaveInstanceState, this);
        application.android.on(application.AndroidApplication.activityDestroyedEvent, this.onActivityDestroyed, this);
    }

    onUnloaded() {
        super.onUnloaded();

        application.android.off(application.AndroidApplication.activityPausedEvent, this.onActivityPaused, this);
        application.android.off(application.AndroidApplication.activityResumedEvent, this.onActivityResumed, this);
        application.android.off(application.AndroidApplication.saveActivityStateEvent, this.onActivitySaveInstanceState, this);
        application.android.off(application.AndroidApplication.activityDestroyedEvent, this.onActivityDestroyed, this);
    }

    public disposeNativeView() {
        this._context = undefined;
        this._gMap = undefined;
        this._markers = undefined;
        this._shapes = undefined;
        super.disposeNativeView();
    };

    private onActivityPaused(args) {
        if (!this.nativeView || this._context != args.activity) return;
        this.nativeView.onPause();
    }

    private onActivityResumed(args) {
        if (!this.nativeView || this._context != args.activity) return;
        this.nativeView.onResume();
    }

    private onActivitySaveInstanceState(args) {<commit_msg>Added ondestroy call to dispose event.<commit_after>import application = require("tns-core-modules/application");

import common = require("./map-view-common");

import {
    MapViewBase, BoundsBase, CircleBase,
    MarkerBase, PolygonBase, PolylineBase, ProjectionBase,
    PositionBase, ShapeBase, latitudeProperty, VisibleRegionBase,
    longitudeProperty, bearingProperty, zoomProperty,
    tiltProperty, StyleBase, UISettingsBase, getColorHue
} from "./map-view-common";
import { Image } from "tns-core-modules/ui/image";
import { Color } from "tns-core-modules/color";
import { Point } from "tns-core-modules/ui/core/view";
import imageSource = require("tns-core-modules/image-source");

export * from "./map-view-common";

declare const com: any;
declare const android: any;

export class MapView extends MapViewBase {

    protected _markers: Array<Marker> = new Array<Marker>();
    public _context: any;
    private _pendingCameraUpdate: boolean;

    onLoaded() {
        super.onLoaded();

        application.android.on(application.AndroidApplication.activityPausedEvent, this.onActivityPaused, this);
        application.android.on(application.AndroidApplication.activityResumedEvent, this.onActivityResumed, this);
        application.android.on(application.AndroidApplication.saveActivityStateEvent, this.onActivitySaveInstanceState, this);
        application.android.on(application.AndroidApplication.activityDestroyedEvent, this.onActivityDestroyed, this);
    }

    onUnloaded() {
        super.onUnloaded();

        application.android.off(application.AndroidApplication.activityPausedEvent, this.onActivityPaused, this);
        application.android.off(application.AndroidApplication.activityResumedEvent, this.onActivityResumed, this);
        application.android.off(application.AndroidApplication.saveActivityStateEvent, this.onActivitySaveInstanceState, this);
        application.android.off(application.AndroidApplication.activityDestroyedEvent, this.onActivityDestroyed, this);
    }

    public disposeNativeView() {
        if(this.nativeView){
            this.nativeView.onDestroy();
        }
        if(this._gMap){
            this._gMap.setMyLocationEnabled(false);
            this._gMap.clear();
        }
        this._context = undefined;
        this._gMap = undefined;
        this._markers = undefined;
        this._shapes = undefined;
        super.disposeNativeView();
    };

    private onActivityPaused(args) {
        if (!this.nativeView || this._context != args.activity) return;
        this.nativeView.onPause();
    }

    private onActivityResumed(args) {
        if (!this.nativeView || this._context != args.activity) return;
        this.nativeView.onResume();
    }

    private onActivitySaveInstanceState(args) {
{'fraction_non_alphanumeric': 0.10654661414368786, 'fraction_numerical': 0.0, 'mean_word_length': 4.00187617260788, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6095091', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1413, 'n_words': 262}