示例#1
0
 public String getPageContents() {
   StringBuffer buffer = new StringBuffer();
   SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd");
   buffer
       .append("== {{int:filedesc}} ==\n")
       .append("{{Information\n")
       .append("|description=")
       .append(description)
       .append("\n")
       .append("|source=")
       .append("{{own}}\n")
       .append("|author=[[User:"******"]]\n");
   if (dateCreated != null) {
     buffer
         .append("|date={{According to EXIF data|")
         .append(isoFormat.format(dateCreated))
         .append("}}\n");
   }
   buffer
       .append("}}")
       .append("\n")
       .append("== {{int:license-header}} ==\n")
       .append("{{self|cc-by-sa-3.0}}\n\n")
       .append("{{Uploaded from Mobile|platform=Android|version=")
       .append(CommonsApplication.APPLICATION_VERSION)
       .append("}}\n")
       .append("{{subst:unc}}"); // Remove when we have categorization
   return buffer.toString();
 }
  private void saveData(TelemetryData data) {
    PrintWriter out;
    boolean newFile = false;

    if (saveCnt > 25000) {
      File logFile;
      int i;

      logFile = new File(telemetryDir + 99 + ".log");
      logFile.delete();
      newFile = true;

      for (i = 99; i > 0; i--) {
        logFile = new File(telemetryDir + (i - 1) + ".log");
        logFile.renameTo(new File(telemetryDir + i + ".log"));
      }
      saveCnt = 0;
    }

    try {
      String text = "";
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);

      saveCnt++;
      out = new PrintWriter(new FileOutputStream(telemetryDir + "0.log", true));
      if (newFile) {
        text =
            "Time\tLatitude\tLongitude\tSpeed\tAcceleration X\tAcceleration Y\tAcceleration Z\tCoG\tOrientation Y\tOrientation Z\n\n";
        out.print(text);
      }
      text = dateFormat.format(new Date(System.currentTimeMillis())) + "\t";
      if (posValid) text = text + lastLat + "\t" + lastLon + "\t" + m_lastSpeed + "\t";
      else text = text + "-\t-\t-\t";
      text =
          text
              + data.getAccelX()
              + "\t"
              + data.getAccelY()
              + "\t"
              + data.getAccelZ()
              + "\t"
              + data.CoG
              + "\t"
              + data.getOrientY()
              + "\t"
              + data.getOrientZ()
              + "\n\n";
      out.print(text);
      out.close();
    } catch (IOException ioe) {
    }
  }