sarriaroman / photoviewer

PhotoViewer Cordova Plugin
MIT License
157 stars 216 forks source link

Prevent Android devices from crashing when options is not well structured #167

Closed anatoly-spb closed 5 years ago

anatoly-spb commented 5 years ago

Prevent Android devices from crashing when options is not well structured.

Not well structured options can be passed simply:

photoViewer.show(url, "title", {share: true})

PhotoViewer.js shows this. Well structured options are passed only when user does not specify options at all:

var PhotoViewer = /** @class */ (function () {
    function PhotoViewer() {
    }
    PhotoViewer.show = function (url, title, options) {
        if (title === void 0) { title = ''; }
        if (options === void 0) { options = {
            share: false,
            closeButton: true,
            copyToReference: false,
            headers: '',
            piccasoOptions: {
                fit: true,
                centerInside: true,
                centerCrop: false
            }
        }; }
        if (url && url.trim() == '') {
            // Do nothing
            return;
        }
        var args = [url, title, options.share, options.closeButton, options.copyToReference, options.headers, options.piccasoOptions];
        exec(function () { }, function () { }, "PhotoViewer", "show", args);
    };
    return PhotoViewer;
}());

In other case PhotoActivity.java gives wrong options.