jasonmamy / cordova-wheel-selector-plugin

Wheel selector for Cordova (Android/iOS)
MIT License
65 stars 36 forks source link

Plugin should use a background thread. No show wheel elements #47

Open Bezlepkin opened 5 years ago

Bezlepkin commented 5 years ago

Clear install Cordova version: 8.1.2

var app = {
  // Application Constructor
  initialize: function() {
      document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
  },

  // deviceready Event Handler
  //
  // Bind any cordova events here. Common events are:
  // 'pause', 'resume', etc.
  onDeviceReady: function() {

    var data = {
        numbers: [
            {description: "1"},
            {description: "2"},
            {description: "3"},
            {description: "4"},
            {description: "5"},
            {description: "6"},
            {description: "7"},
            {description: "8"},
            {description: "9"},
            {description: "10"}
        ]
    };

    var config = {
      title: "Select a quantity",
      items:[
          data.numbers
      ],
      positiveButtonText: "Done",
      negativeButtonText: "Cancel"
    };

    window.SelectorCordovaPlugin.showSelector(config, function(result) {
      console.log("result: " + JSON.stringify(result) );
      console.log('User chose number: ' + result[0].description + ' at array index: ' + result[0].index);

      //note: as of now in iOS result[1] is ignored
      console.log('User chose fruit: ' + result[1].description + ' at array index: ' + result[1].index);
      }, function() {
        console.log('Canceled');
    });

    this.receivedEvent('deviceready');
  },

  // Update DOM on a Received Event
  receivedEvent: function(id) {
      var parentElement = document.getElementById(id);
      var listeningElement = parentElement.querySelector('.listening');
      var receivedElement = parentElement.querySelector('.received');

      listeningElement.setAttribute('style', 'display:none;');
      receivedElement.setAttribute('style', 'display:block;');

      console.log('Received Event: ' + id);
  }
};

app.initialize();

2019-02-01_10-19-38

BorisKingma commented 5 years ago

I have the same issue, in addition, Android throws this error:

java.lang.IllegalArgumentException: maxValue must be >= 0 at android.widget.NumberPicker.setMaxValue(NumberPicker.java:1464)

-- cordova version Cordova 8.1.2 (cordova-lib@8.1.1)

jasonmamy commented 5 years ago

Try this: items: [ [data.numbers] ]

It's an error in the docs that was recently fixed

On Wed, Feb 13, 2019 at 8:07 AM Boris notifications@github.com wrote:

I have the same issue, in addition, Android throws this error:

java.lang.IllegalArgumentException: maxValue must be >= 0 at android.widget.NumberPicker.setMaxValue(NumberPicker.java:1464)

-- cordova version Cordova 8.1.2 (cordova-lib@8.1.1)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jasonmamy/cordova-wheel-selector-plugin/issues/47#issuecomment-463258449, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ9UxlheNZyB1ad1xk1kWgahoCQ4VTQwks5vNDhcgaJpZM4adyST .