Example #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;
  }
Example #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());
  }