Пример #1
0
  public Element toXML() {
    Element result = new Element("timer");

    XMLUtil.createElement("title", getTitle(), result);
    XMLUtil.createElement("started", started == null ? "" : started.toString(), result);
    XMLUtil.createElement("total", period.toString(), result);
    XMLUtil.createElement("speed", update_speed, result);

    XMLUtil.createElement("x", getX(), result);
    XMLUtil.createElement("y", getY(), result);
    XMLUtil.createElement("width", getWidth(), result);
    XMLUtil.createElement("height", getHeight(), result);

    XMLUtil.createElement(
        "foreground", String.format("%08x", total.getForeground().getRGB()), result);
    XMLUtil.createElement(
        "background", String.format("%08x", panel.getBackground().getRGB()), result);

    XMLUtil.createElement("visible", isVisible(), result);

    Element times = new Element("times");
    for (TimeSpan ts : this.times) {
      times.addContent(ts.toXML());
    }
    result.addContent(times);
    return result;
  }
Пример #2
0
 public static void blockUntil(String tag, DateTime startAt, long sleepTime) {
   PeriodFormatter pf =
       new PeriodFormatterBuilder()
           .printZeroAlways()
           .appendHours()
           .appendLiteral("小时")
           .appendMinutes()
           .appendLiteral("分")
           .appendSeconds()
           .appendLiteral("秒")
           .toFormatter();
   while (true) {
     DateTime now = DateTime.now();
     Period p = new Period(now, startAt);
     if (now.isAfter(startAt)) {
       System.out.println("时间到了, 启动!");
       break;
     } else {
       System.out.println("[" + tag + "]" + " 距离开始还有 " + p.toString(pf));
     }
     try {
       Thread.sleep(sleepTime);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
   System.out.println("执行...");
 }
Пример #3
0
 private void updateStats() {
   TextView view = (TextView) findViewById(R.id.manualClicks);
   view.setText(String.valueOf(Button.getManualClicks()));
   period = new Period(startTime, new DateTime());
   view = (TextView) findViewById(R.id.timeDisplay);
   view.setText(period.toString());
 }