Exemplo n.º 1
0
  /**
   * @param myContext
   * @param cb
   * @return true if loaded. False if executor should pause.
   */
  public boolean create(WF_Context myContext, final AsyncResumeExecutorI cb) {

    Context ctx = myContext.getContext();
    gs = GlobalState.getInstance();
    o = gs.getLogger();
    this.cb = cb;
    this.myContext = myContext;
    PersistenceHelper ph = gs.getPreferences();
    PersistenceHelper globalPh = gs.getGlobalPreferences();

    final String serverFileRootDir =
        server(globalPh.get(PersistenceHelper.SERVER_URL))
            + globalPh.get(PersistenceHelper.BUNDLE_NAME).toLowerCase()
            + "/extras/";
    final String cacheFolder =
        Constants.VORTEX_ROOT_DIR + globalPh.get(PersistenceHelper.BUNDLE_NAME) + "/cache/";

    if (source == null || source.length() == 0) {
      Log.e("vortex", "Pic url null! GisImageView will not load");
      o.addRow("");
      o.addRedText("GisImageView failed to load. No picture defined");
      // continue execution immediately.
      return true;
    }

    final String picName = Tools.parseString(source);
    Log.d("vortex", "ParseString result: " + picName);
    // Load asynchronously. Put up a loadbar.

    Tools.onLoadCacheImage(
        serverFileRootDir,
        picName,
        cacheFolder,
        new WebLoaderCb() {

          @Override
          public void progress(int bytesRead) {
            Log.d("vortex", "progress: " + bytesRead);
          }

          @Override
          public void loaded(Boolean result) {
            if (result) loadImageMetaData(picName, serverFileRootDir, cacheFolder);
            else {
              Log.e("vortex", "Pic url null! GisImageView will not load");
              o.addRow("");
              o.addRedText(
                  "GisImageView failed to load. File not found: " + serverFileRootDir + picName);
              cb.abortExecution(
                  "GisImageView failed to load. File not found: " + serverFileRootDir + picName);
            }
          }
        });

    return false;
  }