Example #1
0
  public void addData(String hint, String text, DocNode node, int flag) {
    String plainText = node == null ? Util.stripHtml(text) : node.getText();
    csvField(plainText);
    dbField(mColIdx, plainText);

    if (mColIdx == 0) {
      mRow = new TableRow();
      mBody.add(mRow);
      if (mNextRowStyle != null) {
        mRow.setStyle(mNextRowStyle);
        mNextRowStyle = null;
      }
      if (mNextRowId != null) {
        mRow.setId(mNextRowId);
        mNextRowId = null;
      }
    }
    TableCell cell = new TableCell(hint, text, node);
    mRow.add(cell);
    Column c = mColumns.get(mColIdx);
    if (0 != (c.flag & FLAG_ALIGN_RIGHT)) {
      cell.addStyle("right");
    }
    mColIdx = (mColIdx + 1) % mColumns.size();
    if (mColIdx == 0) {
      csvEOL();
      dbEOL();
    }
    mEmpty = false;
  }
Example #2
0
  private void addTableRow(String key, String val) {
    TableLayout tl = (TableLayout) findViewById(R.id.data_table);
    TableRow tr = new TableRow(this);
    MarginLayoutParams params =
        new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN);
    tr.setLayoutParams(params);
    tr.setBackgroundColor(Color.BLACK);
    TextView name = new TextView(this);
    name.setGravity(Gravity.RIGHT);
    name.setText(key + ": ");
    TextView value = new TextView(this);
    value.setGravity(Gravity.LEFT);
    value.setText(val);
    tr.addView(name);
    tr.addView(value);
    tl.addView(
        tr, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    /*
     * TODO remove this hack
     *
     * let's define a limit number of rows
     */
    if (tl.getChildCount() > 10) tl.removeViewAt(0);
  }
  private void creaSeccionEntrada(String urlPublic) {
    Block entradaBlock = withNewBlock();

    EntradaReportStyle style = new EntradaReportStyle();
    BaseTable entradaTable = new BaseTable(style, 2, "11.8cm", "6.1cm");

    entradaTable.withNewRow();

    TableCell cellIzquierda = entradaTable.withNewCell(createEntradaIzquierda(urlPublic));
    cellIzquierda.setPadding("0.3cm");
    cellIzquierda.setPaddingTop("0.0cm");
    cellIzquierda.setBackgroundColor(FONDO_GRIS);

    TableCell cellDerecha = entradaTable.withNewCell(createEntradaDerecha());
    cellDerecha.setPadding("0.3cm");
    cellDerecha.setPaddingTop("0.3cm");
    cellDerecha.setBackgroundColor(FONDO_GRIS);
    cellDerecha.setBorderLeftWidth("0.03cm");
    cellDerecha.setBorderLeftColor("white");
    cellDerecha.setBorderLeftStyle(BorderStyleType.DOTTED);

    TableRow rowAbajo = entradaTable.withNewRow();
    rowAbajo.setBackgroundColor(FONDO_GRIS);
    entradaTable.withNewCell(ResourceProperties.getProperty(locale, "entrada.entradaValida"), "2");

    entradaBlock.getContent().add(entradaTable);
  }
Example #4
0
 /**
  * Returns the keep-together strength for this element. Note: The keep strength returned does not
  * take the parent table's keeps into account!
  *
  * @return the keep-together strength
  */
 public Keep getKeepTogether() {
   TableRow row = getTableRow();
   Keep keep = Keep.KEEP_AUTO;
   if (row != null) {
     keep = Keep.getKeep(row.getKeepTogether());
   }
   return keep;
 }
  /**
   * Erzeugt eine TableView mit den Daten aus der Datenbank.
   *
   * @return Eine TableView mit Polizist Daten
   */
  private Node getPolizistAnsichtInnereTabelle() {
    refreshPolizistAnsicht();

    // Name Spalte
    TableColumn<PolizistDaten, String> SpalteName = new TableColumn<>("Name");
    SpalteName.setMinWidth(200);
    SpalteName.setCellValueFactory(new PropertyValueFactory<>("Name"));

    // GebDatum Spalte
    TableColumn<PolizistDaten, String> SpalteDatum = new TableColumn<>("Geburtsdatum");
    SpalteDatum.setMinWidth(200);
    SpalteDatum.setCellValueFactory(new PropertyValueFactory<>("GebDatum"));

    // Nationalitaet Spalte
    TableColumn<PolizistDaten, String> SpalteNation = new TableColumn<>("Nationalität");
    SpalteNation.setMinWidth(200);
    SpalteNation.setCellValueFactory(new PropertyValueFactory<>("Nation"));

    // Geschlecht Spalte
    TableColumn<PolizistDaten, String> SpalteGeschlecht = new TableColumn<>("Geschlecht");
    SpalteGeschlecht.setMinWidth(200);
    SpalteGeschlecht.setCellValueFactory(new PropertyValueFactory<>("Geschlecht"));

    // Todesdatum Spalte
    TableColumn<PolizistDaten, String> SpalteTod = new TableColumn<>("Todesdatum");
    SpalteTod.setMinWidth(200);
    SpalteTod.setCellValueFactory(new PropertyValueFactory<>("TodDatum"));

    // Dienstgrad Spalte
    TableColumn<PolizistDaten, String> SpalteGrad = new TableColumn<>("Dienstgrad");
    SpalteGrad.setMinWidth(200);
    SpalteGrad.setCellValueFactory(new PropertyValueFactory<>("Dienstgrad"));

    Tabelle.setItems(PolizistDatenListe);
    Tabelle.getColumns().add(SpalteName);
    Tabelle.getColumns().add(SpalteDatum);
    Tabelle.getColumns().add(SpalteNation);
    Tabelle.getColumns().add(SpalteGeschlecht);
    Tabelle.getColumns().add(SpalteTod);
    Tabelle.getColumns().add(SpalteGrad);

    Tabelle.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    // Doppelklicke auf Spalten sollen Detailansichten oeffnen:
    Tabelle.setRowFactory(
        param -> {
          TableRow<PolizistDaten> Spalte = new TableRow<>();
          Spalte.setOnMouseClicked(
              event -> {
                if (event.getClickCount() == 2 && (!Spalte.isEmpty())) {
                  erzeugeDetailAnsicht(Spalte.getItem());
                }
              });
          return Spalte;
        });

    return Tabelle;
  }
 private List<TableFieldFilling> getAllTableFieldFillings(List<Program> programs) {
   List<TableFieldFilling> tableFielFillingdList = new ArrayList<>();
   for (Program program : programs)
     for (TableTemplate tableTemplate : program.getTableTemplateList())
       for (TableRow tableRow : tableTemplate.getTableRowList())
         for (TableField tableField : tableRow.getTableFieldList())
           for (TableFieldFilling tableFieldFilling : tableField.getTableFieldFillingList())
             tableFielFillingdList.add(tableFieldFilling);
   return tableFielFillingdList;
 }
  // @see
  // org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, org.gudy.azureus2.ui.swt.views.table.TableCellSWT)
  public void cellPaint(GC gc, TableCellSWT cell) {
    VuzeActivitiesEntry entry = (VuzeActivitiesEntry) cell.getDataSource();
    if (entry == null) {
      return;
    }

    TableRow row = cell.getTableRow();
    if (row == null) {
      return;
    }
    String text = (String) row.getData("text");

    if (text != null && text.length() > 0) {
      if (font == null) {
        FontData[] fontData = gc.getFont().getFontData();
        fontData[0].setStyle(SWT.BOLD);
        font = new Font(gc.getDevice(), fontData);
      }
      gc.setFont(font);

      Rectangle bounds = getDrawBounds(cell);

      GCStringPrinter sp = new GCStringPrinter(gc, text, bounds, true, true, SWT.WRAP | SWT.CENTER);

      sp.calculateMetrics();

      if (sp.hasHitUrl()) {
        URLInfo[] hitUrlInfo = sp.getHitUrlInfo();
        for (int i = 0; i < hitUrlInfo.length; i++) {
          URLInfo info = hitUrlInfo[i];
          // handle fake row when showing in column editor

          info.urlUnderline = cell.getTableRow() == null || cell.getTableRow().isSelected();
          if (info.urlUnderline) {
            info.urlColor = null;
          } else {
            info.urlColor = colorLinkNormal;
          }
        }
        int[] mouseOfs = cell.getMouseOffset();
        if (mouseOfs != null) {
          Rectangle realBounds = cell.getBounds();
          URLInfo hitUrl = sp.getHitUrl(mouseOfs[0] + realBounds.x, mouseOfs[1] + realBounds.y);
          if (hitUrl != null) {
            hitUrl.urlColor = colorLinkHover;
          }
        }
      }

      sp.printString();
    }
  }
Example #8
0
 /**
  * Returns the strength of the keep constraint if the enclosing (if any) fo:table-row element of
  * this row, or if any of the cells starting on this row, have keep-with-previous set.
  *
  * @return the strength of the keep-with-previous constraint
  */
 public Keep getKeepWithPrevious() {
   Keep keep = Keep.KEEP_AUTO;
   TableRow row = getTableRow();
   if (row != null) {
     keep = Keep.getKeep(row.getKeepWithPrevious());
   }
   for (Iterator iter = gridUnits.iterator(); iter.hasNext(); ) {
     GridUnit gu = (GridUnit) iter.next();
     if (gu.isPrimary()) {
       keep = keep.compare(gu.getPrimary().getKeepWithPrevious());
     }
   }
   return keep;
 }
  /**
   * called to refresh the file list
   *
   * @param content an ArrayList of the file/folders in the current directory.
   */
  public void setFileList(ArrayList<String> content) {
    if (mDataSource.equals(content)) {
      return;
    }
    if (!mDataSource.isEmpty()) mDataSource.clear();

    mDataSource.addAll(content);

    /*
     * File list have been change,so clear the thumbnail
     */
    mDelegate.clearThumbnail();
    mDelegate.notifyDataSetChanged();
  }
Example #10
0
 /**
  * Returns the strength of the keep constraint if the enclosing (if any) fo:table-row element of
  * this row, or if any of the cells ending on this row, have keep-with-next set.
  *
  * @return the strength of the keep-with-next constraint
  */
 public Keep getKeepWithNext() {
   Keep keep = Keep.KEEP_AUTO;
   TableRow row = getTableRow();
   if (row != null) {
     keep = Keep.getKeep(row.getKeepWithNext());
   }
   for (Iterator iter = gridUnits.iterator(); iter.hasNext(); ) {
     GridUnit gu = (GridUnit) iter.next();
     if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) {
       keep = keep.compare(gu.getPrimary().getKeepWithNext());
     }
   }
   return keep;
 }
Example #11
0
  /**
   * called to update the file contents as the user navigates there phones file system.
   *
   * @param content an ArrayList of the file/folders in the current directory.
   */
  public void updateDirectory(ArrayList<String> content) {
    if (!mDataSource.isEmpty()) mDataSource.clear();

    for (String data : content) mDataSource.add(data);

    mDelegate.notifyDataSetChanged();
  }
 private int addNextRow(final TableRow row) {
   rows.add(row);
   currentRow = rows.size();
   row.setRowIndex(currentRow);
   nextColumn = 1;
   return currentRow;
 }
Example #13
0
 private TableRow buildAmenityTableRow(Context ctx, Amenity amenity) {
   TextView textView = new TextView(ctx);
   String amName = amenity.name();
   int id = getResources().getIdentifier(ctx.getPackageName() + ":string/" + amName, null, null);
   String value = ctx.getString(id);
   textView.setText(value);
   textView.setGravity(Gravity.RIGHT);
   CheckBox checkBox = new CheckBox(ctx);
   checkBox.setChecked(false);
   checkBox.setOnCheckedChangeListener(new AmenityOnCheckChangeListener(this.amenities, amenity));
   TableRow tableRow = new TableRow(ctx);
   TableRow.LayoutParams layoutParams = new TableRow.LayoutParams();
   layoutParams.setMargins(0, 0, 10, 0);
   tableRow.addView(textView, layoutParams);
   tableRow.addView(checkBox);
   return tableRow;
 }
Example #14
0
  private TableRow createRow(String key, String value) {
    TableRow row = new TableRow(context);
    TextView pinName = new TextView(context);
    TextView pinValue = new TextView(context);

    row.setLayoutParams(
        new TableLayout.LayoutParams(
            TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
    pinName.setText(key);
    pinName.setLayoutParams(new TableRow.LayoutParams(MP, WC, 1));
    pinName.setTextSize(textSize);
    pinValue.setText(value);
    pinValue.setLayoutParams(new TableRow.LayoutParams(MP, WC, 1));
    pinValue.setTextSize(textSize);

    row.addView(pinName);
    row.addView(pinValue);
    return row;
  }
 public String classify(TableRow row) {
   Object o = row.get(columnName);
   if (o == null) return missingLabel;
   double value;
   if (o instanceof Number) value = ((Number) o).doubleValue();
   else value = Double.valueOf(o.toString());
   if (o instanceof Number)
     for (int i = 0; i < points.length; ++i) {
       if (value < points[i]) return labels[i];
     }
   // TODO: if labels.length == points.length, then add a default last label
   return labels[points.length];
 }
  /**
   * Sets up the entire TableView with all its functionalities.
   *
   * @return The created TableView.
   */
  private TableView<FilterInput> setUpTableView() {
    // Set up table view
    final TableView<FilterInput> tableView = new TableView<>();
    tableView.setEditable(true);
    tableView.setMinWidth(522);
    tableView.setMinHeight(280);

    // Set up columns
    setUpFilterColumn(tableView);
    setUpTypeColumn(tableView);
    setUpOriginColumn(tableView);
    setUpColorColumn(tableView);
    setUpPriorityColumn(tableView);
    setUpLegalityColumn(tableView);
    setUpActiveColumn(tableView);

    // Insert data from database into table
    tableView.setItems(data);

    // Set select/deselect on mouse click
    tableView.setRowFactory(
        tableViewLambda -> {
          final TableRow<FilterInput> row = new TableRow<>();
          row.addEventFilter(
              MouseEvent.MOUSE_PRESSED,
              event -> {
                final int index = row.getIndex();
                if (index >= 0
                    && index < tableView.getItems().size()
                    && tableView.getSelectionModel().isSelected(index)) {
                  tableView.getSelectionModel().clearSelection();
                  event.consume();
                }
              });
          return row;
        });

    return tableView;
  }
Example #17
0
  public void multiselect_button() {
    if (getMode() != TREEVIEW_MODE) {
      return;
    }

    if (multi_select_flag) {
      mDelegate.killMultiSelect(true);

    } else {
      LinearLayout hidden_lay =
          (LinearLayout) ((Activity) mContext).findViewById(R.id.hidden_buttons);

      multi_select_flag = true;
      hidden_lay.setVisibility(LinearLayout.VISIBLE);
    }
  }
Example #18
0
  public void putImage(int b_size) {
    LinearLayout map = (LinearLayout) findViewById(R.id.map);
    int[][] things = arrayMap.getArray(); // 获得二维数组
    ImageView[] hole = new ImageView[16];
    // 图片直接使用位图缩放

    Bitmap test2 =
        Bitmap.createScaledBitmap(
            BitmapFactory.decodeResource(this.getBaseContext().getResources(), R.drawable.testbmp),
            b_size,
            b_size,
            true);
    Bitmap test1 =
        Bitmap.createScaledBitmap(
            BitmapFactory.decodeResource(this.getBaseContext().getResources(), R.drawable.testbmp2),
            b_size,
            b_size,
            true);
    Bitmap test3 =
        Bitmap.createScaledBitmap(
            BitmapFactory.decodeResource(this.getBaseContext().getResources(), R.drawable.testbmp3),
            b_size,
            b_size,
            true);

    for (int rowC = 0; rowC < 21; rowC++) {
      TableRow tr = new TableRow(this);
      for (int colC = 0; colC < hole.length; colC++) {
        hole[colC] = new ImageView(this);
        LayoutParams lparam = (LayoutParams) hole[colC].getLayoutParams();
        hole[colC].setLayoutParams(new LayoutParams(32, 32));
        hole[colC].setAdjustViewBounds(false); // 设置边界对齐
        hole[colC].setScaleType(ImageView.ScaleType.CENTER_CROP); // 设置刻度的类型
        hole[colC].setPadding(0, 0, 0, 0); // 设置间距
        if (rowC == 0 && colC == 0) {
          firstBlock = hole[colC];
        }

        hole[0].setId(rowC);
        int temp;

        switch (things[rowC][colC]) {
          case 0: // 没有东西
            // hole[colC].setImageResource(R.drawable.test5);
            hole[colC].setImageBitmap(test1);
            break;
          case 1: // 墙
            // hole[colC].setImageResource(R.drawable.test3);
            break;
          case 2: // 洞
            // hole[colC].setImageResource(R.drawable.test2);
            hole[colC].setImageBitmap(test2);
            break;
          case 3: // 终点
            // hole[colC].setImageResource(R.drawable.test4);
            hole[colC].setImageBitmap(test3);
            break;
        }

        TableRow.LayoutParams lp =
            new TableRow.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        tr.addView(hole[colC], lp);
        // size = hole[colC].getRight() - hole[colC].getLeft() ;
      }
      map.addView(tr);
    }
    map = (LinearLayout) findViewById(R.id.map);
    map.bringChildToFront(image);
  }
 @Override
 public void removeColumn(int index) {
   for (TableRow row : ListSequence.fromList(getRows())) {
     row.removeCell(index);
   }
 }
Example #20
0
  /** Displays a human readable summary of the preferences chosen by the user on the main form */
  private void ShowPreferencesSummary() {
    Utilities.LogDebug("GpsMainActivity.ShowPreferencesSummary");
    try {
      TextView txtLoggingTo = (TextView) findViewById(R.id.txtLoggingTo);
      TextView txtFrequency = (TextView) findViewById(R.id.txtFrequency);
      TextView txtDistance = (TextView) findViewById(R.id.txtDistance);
      TextView txtAutoEmail = (TextView) findViewById(R.id.txtAutoEmail);

      if (!AppSettings.shouldLogToKml() && !AppSettings.shouldLogToGpx()) {
        txtLoggingTo.setText(R.string.summary_loggingto_screen);

      } else if (AppSettings.shouldLogToGpx() && AppSettings.shouldLogToKml()) {
        txtLoggingTo.setText(R.string.summary_loggingto_both);
      } else {
        txtLoggingTo.setText((AppSettings.shouldLogToGpx() ? "GPX" : "KML"));
      }

      if (AppSettings.getMinimumSeconds() > 0) {
        String descriptiveTime =
            Utilities.GetDescriptiveTimeString(
                AppSettings.getMinimumSeconds(), getApplicationContext());

        txtFrequency.setText(descriptiveTime);
      } else {
        txtFrequency.setText(R.string.summary_freq_max);
      }

      if (AppSettings.getMinimumDistanceInMeters() > 0) {
        if (AppSettings.shouldUseImperial()) {
          int minimumDistanceInFeet =
              Utilities.MetersToFeet(AppSettings.getMinimumDistanceInMeters());
          txtDistance.setText(
              ((minimumDistanceInFeet == 1)
                  ? getString(R.string.foot)
                  : String.valueOf(minimumDistanceInFeet) + getString(R.string.feet)));
        } else {
          txtDistance.setText(
              ((AppSettings.getMinimumDistanceInMeters() == 1)
                  ? getString(R.string.meter)
                  : String.valueOf(AppSettings.getMinimumDistanceInMeters())
                      + getString(R.string.meters)));
        }
      } else {
        txtDistance.setText(R.string.summary_dist_regardless);
      }

      if (AppSettings.isAutoEmailEnabled()) {
        String autoEmailResx;

        if (AppSettings.getAutoEmailDelay() == 0) {
          autoEmailResx = "autoemail_frequency_whenistop";
        } else {

          autoEmailResx =
              "autoemail_frequency_"
                  + String.valueOf(AppSettings.getAutoEmailDelay()).replace(".", "");
        }

        String autoEmailDesc =
            getString(getResources().getIdentifier(autoEmailResx, "string", getPackageName()));

        txtAutoEmail.setText(autoEmailDesc);
      } else {
        TableRow trAutoEmail = (TableRow) findViewById(R.id.trAutoEmail);
        trAutoEmail.setVisibility(View.INVISIBLE);
      }

      onFileName(Session.getCurrentFileName());
    } catch (Exception ex) {
      Utilities.LogError("ShowPreferencesSummary", ex);
    }
  }
Example #21
0
  /** This method, handles the button presses of the top buttons found in the Main activity. */
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.home_sdcard_button:
        mFileMang.canMkdir = true;
        refreshFocus(preView, v);
        if (mFileMang.whichRoot() == FileManager.ROOT_SDCARD && mlistmode == TREEVIEW_MODE) {
          break;
        }
        mlistmode = TREEVIEW_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        updateDirectory(mFileMang.getHomeDir(FileManager.ROOT_SDCARD));
        if (mPathLabel != null)
          mPathLabel.setText(
              mFileMang.getCurrentDir().substring(5, mFileMang.getCurrentDir().length()));
        break;

      case R.id.home_usbhost_button:
        mFileMang.canMkdir = true;
        refreshFocus(preView, v);
        if (mFileMang.whichRoot() == FileManager.ROOT_USBHOST && mlistmode == TREEVIEW_MODE) {
          break;
        }
        mlistmode = TREEVIEW_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        updateDirectory(mFileMang.getHomeDir(FileManager.ROOT_USBHOST));
        if (mPathLabel != null)
          mPathLabel.setText(
              mFileMang.getCurrentDir().substring(5, mFileMang.getCurrentDir().length()));
        break;

      case R.id.home_flash_button:
        mFileMang.canMkdir = true;
        refreshFocus(preView, v);
        if (mFileMang.whichRoot() == FileManager.ROOT_FLASH && mlistmode == TREEVIEW_MODE) {
          break;
        }
        mlistmode = TREEVIEW_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        updateDirectory(mFileMang.getHomeDir(FileManager.ROOT_FLASH));
        if (mPathLabel != null)
          mPathLabel.setText(
              mFileMang.getCurrentDir().substring(5, mFileMang.getCurrentDir().length()));
        break;

      case R.id.music_button:
        mFileMang.canMkdir = false;
        mlistmode = CATALOG_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        setFileList(mCataList.SetFileTyp(CatalogList.TYPE_MUSIC));
        if (mPathLabel != null)
          mPathLabel.setText(mContext.getResources().getString(R.string.music));
        refreshFocus(preView, v);
        break;

      case R.id.image_button:
        mFileMang.canMkdir = false;
        mlistmode = CATALOG_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        setFileList(mCataList.SetFileTyp(CatalogList.TYPE_PICTURE));
        if (mPathLabel != null)
          mPathLabel.setText(mContext.getResources().getString(R.string.picture));
        refreshFocus(preView, v);
        break;

      case R.id.movie_button:
        mFileMang.canMkdir = false;
        mlistmode = CATALOG_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        setFileList(mCataList.SetFileTyp(CatalogList.TYPE_MOVIE));
        if (mPathLabel != null)
          mPathLabel.setText(mContext.getResources().getString(R.string.movie));
        refreshFocus(preView, v);
        break;

      case R.id.ebook_button:
        mFileMang.canMkdir = false;
        mlistmode = CATALOG_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        setFileList(mCataList.SetFileTyp(CatalogList.TYPE_EBOOK));
        if (mPathLabel != null)
          mPathLabel.setText(mContext.getResources().getString(R.string.ebook));
        refreshFocus(preView, v);
        break;

      case R.id.apk_button:
        mFileMang.canMkdir = false;
        mlistmode = CATALOG_MODE;
        if (multi_select_flag) {
          mDelegate.killMultiSelect(true);
          mFileMang.mHoldingFile = false;
          mFileMang.mAllowSelectAll = false;
          mInfoLabel.setText("");
          mFileMang.moveOrCopyFile = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.Multi_select_off),
                  Toast.LENGTH_SHORT)
              .show();
        }
        setFileList(mCataList.SetFileTyp(CatalogList.TYPE_APK));
        if (mPathLabel != null) mPathLabel.setText(mContext.getResources().getString(R.string.apk));
        refreshFocus(preView, v);
        break;

      case R.id.hidden_move:
      case R.id.hidden_copy:
        if (mMultiSelectData == null || mMultiSelectData.isEmpty()) {
          mDelegate.killMultiSelect(true);
          mFileMang.moveOrCopyFile = false;
          mFileMang.mAllowSelectAll = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.no_select),
                  Toast.LENGTH_SHORT)
              .show();
          break;
        }

        mFileMang.mCopyOrMoveSize = 0;
        for (String s : mMultiSelectData) {
          System.out.println("--->" + s);
          mFileMang.mCopyOrMoveSize += mFileMang.getDirOrFileSize(s);
        }

        if (v.getId() == R.id.hidden_move) delete_after_copy = true;

        mInfoLabel.setText(
            mContext.getResources().getString(R.string.Holding)
                + " "
                + mMultiSelectData.size()
                + " "
                + mContext.getResources().getString(R.string.files));
        mFileMang.mHoldingFile = true;
        mFileMang.mAllowSelectAll = false;

        mDelegate.killMultiSelect(false);
        break;

      case R.id.hidden_delete:
        /* check if user selected objects before going further */
        if (!mFileMang.moveOrCopyFile) {
          mMultiSelectData = null;
        }
        if (mMultiSelectData == null || mMultiSelectData.isEmpty()) {
          mDelegate.killMultiSelect(true);
          mFileMang.moveOrCopyFile = false;
          mFileMang.mAllowSelectAll = false;
          Toast.makeText(
                  mContext,
                  mContext.getResources().getString(R.string.no_select),
                  Toast.LENGTH_SHORT)
              .show();
          break;
        }

        final String[] data = new String[mMultiSelectData.size()];
        int at = 0;

        for (String string : mMultiSelectData) data[at++] = string;

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(
            mContext.getResources().getString(R.string.delete_msg1)
                + " "
                + data.length
                + " "
                + mContext.getResources().getString(R.string.delete_msg2));
        builder.setCancelable(false);
        builder.setPositiveButton(
            mContext.getResources().getString(R.string.Delete),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                new BackgroundWork(DELETE_TYPE).execute(data);
                mDelegate.killMultiSelect(true);
                mFileMang.moveOrCopyFile = false;
                mFileMang.mAllowSelectAll = false;
              }
            });
        builder.setNegativeButton(
            mContext.getResources().getString(R.string.Cancel),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                mDelegate.killMultiSelect(true);
                mFileMang.moveOrCopyFile = false;
                mFileMang.mAllowSelectAll = false;
                dialog.cancel();
              }
            });

        builder.create().show();
        break;
    }
  }
Example #22
0
    @Override
    protected void onPostExecute(List<Action> actions) {
      if (actions == null) {
        statusLabel.setText("Unable to get actions");
        return;
      }

      // all is ok, replace start pane
      LinearLayout contentPane = (LinearLayout) findViewById(R.id.contentPane);
      contentPane.removeView(startPane);

      LinearLayout buttonsLayout = new LinearLayout(getApplicationContext());
      buttonsLayout.setGravity(Gravity.CENTER);

      TableLayout buttonsTable = new TableLayout(getApplicationContext());
      TableRow currentTableRow = new TableRow(getApplicationContext());

      TableRow.LayoutParams buttonMarginParams =
          new TableRow.LayoutParams(
              TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
      int marginPx =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics());
      buttonMarginParams.setMargins(marginPx, marginPx, marginPx, marginPx);

      for (final Action action : actions) {
        ImageButton actionButton = new ImageButton(getApplicationContext());
        int drawableId = getResources().getIdentifier(action.icon, "drawable", getPackageName());
        actionButton.setImageDrawable(getResources().getDrawable(drawableId));
        actionButton.setContentDescription(action.description);
        actionButton.setLayoutParams(buttonMarginParams);
        actionButton.setBackgroundResource(R.drawable.button);
        actionButton.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                new PerformActionAsyncTask().execute(action.name);
              }
            });

        currentTableRow.addView(actionButton);
        if (currentTableRow.getChildCount() == 3) {
          buttonsTable.addView(currentTableRow);
          currentTableRow = new TableRow(getApplicationContext());
        }
      }

      if (currentTableRow.getChildCount() > 0) {
        buttonsTable.addView(currentTableRow);
      }

      buttonsLayout.addView(buttonsTable);

      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      contentPane.addView(buttonsLayout, params);

      runStatusUpdateTimer();
    }