예제 #1
0
 public void onNmeaReceived(long timestamp, String nmeaString) {
   // #debug info
   logger.info("Using extra NMEA info in Android location provider: " + nmeaString);
   // FIXME combine to one, duplicated in Jsr179Input and AndroidLocationInput
   if (nmeaString != null) {
     if (rawDataLogger != null) {
       try {
         rawDataLogger.write(nmeaString.getBytes());
         rawDataLogger.flush();
       } catch (IOException ioe) {
         logger.exception(
             Locale.get("jsr179input.CouldNotWriteGPSLog") /*Could not write raw GPS log*/, ioe);
       }
     }
     Vector messages = StringTokenizer.getVector(nmeaString, "$");
     if (messages != null) {
       for (int i = 0; i < messages.size(); i++) {
         String nmeaMessage = (String) messages.elementAt(i);
         if (nmeaMessage == null) {
           continue;
         }
         if (nmeaMessage.startsWith("$")) {
           // Cut off $GP from the start
           nmeaMessage = nmeaMessage.substring(3);
         } else if (nmeaMessage.startsWith("GP")) {
           // Cut off GP from the start
           nmeaMessage = nmeaMessage.substring(2);
         }
         int delimiterIdx = nmeaMessage.indexOf("*");
         if (delimiterIdx > 0) {
           // remove the checksum
           nmeaMessage = nmeaMessage.substring(0, delimiterIdx);
         }
         delimiterIdx = nmeaMessage.indexOf(" ");
         if (delimiterIdx > 0) {
           // remove trailing whitespace because some mobiles like HTC Touch Diamond 2 with JavaFX
           // receive NMEA sentences terminated by a space instead of a star followed by the
           // checksum
           nmeaMessage = nmeaMessage.substring(0, delimiterIdx);
         }
         // #debug info
         logger.info("Decoding: " + nmeaMessage);
         if ((nmeaMessage != null) && (nmeaMessage.length() > 5)) {
           smsg.decodeMessage(nmeaMessage, false, false);
           // get *DOP from the message
           pos.pdop = smsg.getPosition().pdop;
           pos.hdop = smsg.getPosition().hdop;
           pos.vdop = smsg.getPosition().vdop;
           // disable for now if we have a fix; could be this is incorrect for devices with GPS &
           // GLONASS, and we get this from getGpsStatus()
           if (!hasFix) {
             numSatellites = smsg.getMAllSatellites();
             updateSolution(LocationProvider.TEMPORARILY_UNAVAILABLE);
           }
         }
       }
     }
   }
 }
예제 #2
0
  public FsDiscover(
      GpsMidDisplayable parent,
      SelectionListener sl,
      String initUrl,
      int chooseType,
      String suffix,
      String title) {
    // orgTitle=Display.getDisplay(GpsMid.getInstance()).getCurrent().getTitle
    // ();
    this.parent = parent;
    this.sl = sl;
    this.chooseType = chooseType;
    // multiple suffixes separated by ; can be given
    if (suffix != null) {
      suffixes = StringTokenizer.getVector(suffix, ";");
    }
    this.orgTitle = title;
    urlList = new Vector();
    files = new Vector();
    dirs = new Vector();
    // #if polish.api.pdaapi
    // avoid NullPointer exception
    if (initUrl == null) {
      initUrl = "";
    }
    if (initUrl.length() >= 9) { // file:///
      // if url is file get dir only
      if (!initUrl.endsWith("/")) {
        initUrl =
            initUrl.substring(0, initUrl.substring(0, initUrl.length() - 1).lastIndexOf('/') + 1);
      }
    }
    // start browsing at initial url
    url = initUrl;
    // if no initial dir usable use root
    if (url.length() < 9) { // file:///
      url = "file:///";
    }
    // #endif

    this.list = createEmptyList();
    processorThread = new Thread(this);
    processorThread.start();
  }