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;
  }
Exemplo n.º 2
0
  // How about using the Container's panel?? TODO
  public WF_Table(
      String id,
      boolean isVisible,
      WF_Context ctx,
      String namePrefix,
      String variatorColumn,
      View tableV) {
    super(id, isVisible, ctx, tableV);
    this.tableView = (TableLayout) tableV.findViewById(R.id.table);
    ;
    myContext = ctx;
    gs = GlobalState.getInstance();
    o = gs.getLogger();
    al = gs.getVariableConfiguration();
    myVariator = variatorColumn;
    // myTable = new GridView(ctx.getContext());

    // Create rows.
    inflater = (LayoutInflater) ctx.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Add the header.
    headerRow =
        new WF_Table_Row(
            tableView,
            ColHeadId,
            inflater.inflate(R.layout.header_table_row, null),
            myContext,
            true);
    // Add a first empty cell
    headerRow.addEmptyCell(id);
    tableView.addView(headerRow.getWidget());

    varNamePrefix = namePrefix;

    allInstances = gs.getDb().preFetchValues(myContext.getKeyHash(), namePrefix, myVariator);
    Log.d(
        "nils",
        "in update entry fields. AllInstances contain "
            + allInstances.size()
            + ": "
            + allInstances.toString());
    tableView.setStretchAllColumns(true);
    addSorter(new WF_Alphanumeric_Sorter());
  }
  public WF_Not_ClickableField_SumAndCountOfVariables(
      String header,
      String descriptionT,
      WF_Context myContext,
      String myTarget,
      String pattern,
      Type sumOrCount,
      boolean isVisible,
      String textColor,
      String bgColor) {
    super(
        header,
        descriptionT,
        myContext,
        LayoutInflater.from(myContext.getContext())
            .inflate(R.layout.selection_field_normal_colored, null),
        isVisible);
    this.myContext = myContext;
    o = GlobalState.getInstance().getLogger();
    targetList = myContext.getList(myTarget);
    myType = sumOrCount;
    myPattern = pattern;
    allMatchingVariables = new HashSet<Variable>();
    TextView text = (TextView) getWidget().findViewById(R.id.editfieldtext);
    LinearLayout bg = (LinearLayout) getWidget().findViewById(R.id.background);
    if (bgColor != null) bg.setBackgroundColor(Color.parseColor(bgColor));
    if (textColor != null) text.setTextColor(Color.parseColor(textColor));

    if (targetList == null) {
      o.addRow("");
      o.addRedText(
          "Couldn't create " + header + " since target list: " + myTarget + " does not exist");
      Log.e(
          "parser",
          "couldn't create SumAndCountOfVariables - could not find target list " + myTarget);
    } else {

      for (Listable l : targetList.getList()) {
        Set<Variable> vars = l.getAssociatedVariables();
        for (Variable v : vars) {
          if (v.getId().matches(myPattern)) allMatchingVariables.add(v);
        }
      }

      myContext.addEventListener(this, EventType.onRedraw);
    }
  }
Exemplo n.º 4
0
  private void loadImageMetaFromFile(
      final String fileName, String serverFileRootDir, final String cacheFolder) {

    // cut the .jpg type ending.
    String[] tmp = fileName.split("\\.");

    if (tmp != null && tmp.length != 0) {
      final String metaFileName = tmp[0];
      Log.d("vortex", "metafilename: " + metaFileName);
      final ConfigurationModule meta =
          new AirPhotoMetaData(
              GlobalState.getInstance().getGlobalPreferences(),
              GlobalState.getInstance().getPreferences(),
              Source.internet,
              serverFileRootDir,
              metaFileName,
              "");
      if (meta.thaw().errCode != ErrorCode.thawed) {
        Log.d("vortex", "no frozen metadata. will try to download.");
        new WebLoader(
                null,
                null,
                new FileLoadedCb() {
                  @Override
                  public void onFileLoaded(LoadResult res) {

                    if (res.errCode == ErrorCode.frozen) {
                      PhotoMeta pm = (PhotoMeta) meta.getEssence();
                      Log.d(
                          "vortex",
                          "img N, W, S, E " + pm.N + "," + pm.W + "," + pm.S + "," + pm.E);
                      createAfterLoad(pm, cacheFolder + fileName);
                    } else {
                      o.addRow("");
                      o.addRedText("Could not find GIS image " + metaFileName);
                      Log.e(
                          "vortex", "Failed to parse image meta. Errorcode " + res.errCode.name());
                      cb.abortExecution(
                          "Could not load GIS image meta file ["
                              + metaFileName
                              + "]. Likely reason: File missing under 'extras' folder or no connection");
                    }
                  }

                  @Override
                  public void onFileLoaded(ErrorCode errCode, String version) {
                    Log.e("vortex", "Error loading foto metadata! ErrorCode: " + errCode);
                  }

                  @Override
                  public void onUpdate(Integer... args) {}
                },
                "No control")
            .execute(meta);
      } else {
        Log.d("vortex", "Found frozen metadata. Will use it");
        PhotoMeta pm = (PhotoMeta) meta.getEssence();
        Log.d("vortex", "img N, W, S, E " + pm.N + "," + pm.W + "," + pm.S + "," + pm.E);
        createAfterLoad(pm, cacheFolder + fileName);
      }
    }
  }