3 Replies Latest reply: Jan 27, 2009 4:33 AM by 843851 RSS

    User Input for Numbers > 9

    843851
      I'm trying to read number with more than one digit.

      If I receive a Number I start a Thread to wait for another one.
      It works fine in WinDVD but on my player everything takes so long
      I have to wait for more than a second...

      Has anyone tried that and knows a more userfriendly solution?

      Thanks a lot elBob
        • 1. Re: User Input for Numbers > 9
          843851
          Post yout code and maybe we can help you with it.

          I think the thread starting whenever you need it, is a good idea.
          • 2. Re: User Input for Numbers > 9
            843851
            Update: I found out this works fine on many players...
                 public void addDigit(int digit) {
                            // put that in because I only need numbers lower than 30
                      if(inputDigitCount == 0 && digit > 2) {
                           numericKeyEvent.receiveNumericKeyEvent(digit);
                           return;
                      }
                      addedDigit = digit;
                            // if this is the first number
                      if(!waiting) {
                           inputDigitCount = 0;
                           waitTimeCounter = new Thread(this);
                           waitTimeCounter.start();
                      }
                           // adding new number starting wait thread again
                      else {
                           waitTimeCounter.interrupt();
                           waitTimeCounter = new Thread(this);
                           waitTimeCounter.start();
                      }
                 }
            
                 public void run() {
                      synchronized(inputNumber) {               
                           inputNumber[inputDigitCount++] = addedDigit;
                           try {
                                if(inputDigitCount < supportedDigitNumber) {
                                waiting = true;
                                Thread.sleep(waitTimeMillis);
                                }
                                int finalNumber = 0;
                                for(int i=0;i<inputDigitCount;i++) {
                                     finalNumber += (int) Math.pow(10, inputDigitCount-(i+1)) * inputNumber;
                                }
                                numericKeyEvent.receiveNumericKeyEvent(finalNumber);
                                waiting = false;
                           } catch (InterruptedException e) {
                                waiting = false;
                           }     
                      }
                 }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            • 3. Re: User Input for Numbers > 9
              843851
              what do you think community :)
              I have problems on players that do some kind of "two digit processing" on their own...

              maybe we can create sth better together.

              elBoB