コード例 #1
0
  @Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
      case R.id.action_edit:
        selectionListener.onEdit(selectedNode);
        stopActionMode();
        return true;

      case R.id.action_delete:
        selectionListener.onDelete(selectedNode);
        stopActionMode();
        return true;

      case R.id.action_rename:
        uiUtils
            .createInputDialog(
                activity.getString(R.string.rename_title),
                selectedNode.getPath(),
                new UiUtils.OnInputListener() {
                  @Override
                  public void onInput(String newFileName) {
                    selectionListener.onRename(selectedNode, newFileName);
                    stopActionMode();
                  }
                })
            .show();
        return true;

      case R.id.action_move:
        selectionListener.onMoveTo(selectedNode);
        stopActionMode();
        return true;
    }
    return false;
  }
コード例 #2
0
ファイル: JekyllManager.java プロジェクト: buyaoshushu/MrHyde
  /** Tries reading one particular file as a post. */
  public Optional<Post> parsePost(FileNode node) {
    String fileName = node.getPath();

    // check for match
    Matcher matcher = POST_TITLE_PATTERN.matcher(fileName);
    if (!matcher.matches()) return Optional.absent();

    try {
      // get date
      int year = Integer.valueOf(matcher.group(1));
      int month = Integer.valueOf(matcher.group(2)) - 1; // java Calendar is 0 based
      int day = Integer.valueOf(matcher.group(3));
      Calendar calendar = Calendar.getInstance();
      calendar.set(year, month, day);

      // get title
      String title = formatTitle(matcher.group(4));

      return Optional.of(new Post(title, calendar.getTime(), node));

    } catch (NumberFormatException nfe) {
      Timber.w(nfe, "failed to parse post tile \"" + fileName + "\"");
      return Optional.absent();
    }
  }
コード例 #3
0
ファイル: JekyllManager.java プロジェクト: buyaoshushu/MrHyde
  /** Tries reading one particular file as a draft. */
  public Optional<Draft> parseDraft(FileNode node) {
    // check for match
    Matcher matcher = DRAFT_TITLE_PATTERN.matcher(node.getPath());
    if (!matcher.matches()) return Optional.absent();

    // get title
    String title = formatTitle(matcher.group(1));

    return Optional.of(new Draft(title, node));
  }