Пример #1
0
        @Override
        public boolean handleMessage(Message msg) {

          onBeforeRun(msg.what, (JsonObject) msg.obj);
          switch (msg.what) {
            case ARCHIVE:
              if (archive != null) {
                runArchive();
              }
              break;
            case UPLOAD:
              if (archive != null && upload != null && uploader != null) {
                uploader.run(archive, upload);
              }
              break;
            case UPDATE:
              if (update != null) {
                update.run(name, manager);
              }
              break;
            case DATA:
              String name = ((JsonObject) msg.obj).get("name").getAsString();
              IJsonObject data = (IJsonObject) ((JsonObject) msg.obj).get("value");
              writeData(name, data);
              break;
            default:
              break;
          }
          onAfterRun(msg.what, (JsonObject) msg.obj);
          return false;
        }
Пример #2
0
  @Override
  public void onDestroy() {

    for (JsonElement dataRequest : data) {
      manager.unrequestData(this, dataRequest);
    }
    for (Map.Entry<String, Schedule> schedule : schedules.entrySet()) {
      manager.unregisterPipelineAction(this, schedule.getKey());
    }
    if (uploader != null) {
      uploader.stop();
    }
    looper.quit();
    enabled = false;
  }
Пример #3
0
  @Override
  public void onCreate(FunfManager manager) {

    if (archive == null) {
      archive = new DefaultArchive(manager, name);
    }
    if (uploader == null) {
      uploader = new UploadService(manager);
      uploader.start();
    }
    this.manager = manager;
    reloadDbHelper(manager);
    HandlerThread thread = new HandlerThread(getClass().getName());
    thread.start();
    this.looper = thread.getLooper();
    this.handler = new Handler(looper, callback);
    enabled = true;
    for (JsonElement dataRequest : data) {
      manager.requestData(this, dataRequest);
    }
    for (Map.Entry<String, Schedule> schedule : schedules.entrySet()) {
      manager.registerPipelineAction(this, schedule.getKey(), schedule.getValue());
    }
  }