public boolean onItemLongClick(GridView l, View v, int position, long id) {
    // We disable long click during import mode.
    if (mode == MODE_IMPORT || mode == MODE_PICK) {
      return false;
    }

    Node n = (Node) l.getItemAtPosition(position);
    boolean b = true;
    if (n instanceof NodePlaceHolder) {
      getActivity()
          .startActivity(
              new Intent(IntentIntegrator.ACTION_DISPLAY_OPERATIONS)
                  .putExtra(
                      IntentIntegrator.EXTRA_ACCOUNT_ID,
                      SessionUtils.getAccount(getActivity()).getId()));
      b = false;
    } else {
      l.setItemChecked(position, true);
      b = startSelection(n);
      if (DisplayUtils.hasCentralPane(getActivity())) {
        FragmentDisplayer.removeFragment(
            getActivity(), DisplayUtils.getCentralFragmentId(getActivity()));
        FragmentDisplayer.removeFragment(getActivity(), android.R.id.tabcontent);
      }
    }
    return b;
  };
Exemplo n.º 2
0
  // ///////////////////////////////////////////////////////////////////////////
  // LIST ACTIONS
  // ///////////////////////////////////////////////////////////////////////////
  public void onListItemClick(GridView l, View v, int position, long id) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    String nodeId = cursor.getString(SyncContentSchema.COLUMN_NODE_ID_ID);
    String documentName = cursor.getString(SyncContentSchema.COLUMN_TITLE_ID);

    if (DisplayUtils.hasCentralPane(getActivity())) {
      FragmentDisplayer.with(getActivity())
          .remove(DisplayUtils.getCentralFragmentId(getActivity()));
    }

    Boolean hideDetails = false;
    if (!selectedItems.isEmpty()) {
      hideDetails = selectedItems.get(0).equals(nodeId);
    }
    l.setItemChecked(position, true);

    if (nActions != null) {
      nActions.selectNode(nodeId);
      if (selectedItems.size() == 0) {
        hideDetails = true;
      }
    } else {
      selectedItems.clear();
      if (!hideDetails && DisplayUtils.hasCentralPane(getActivity())) {
        selectedItems.add(nodeId);
      }
    }

    if (hideDetails) {
      selectedItems.clear();
      displayTitle();
    } else if (nActions == null) {
      if (SyncContentManager.isFolder(cursor)) {
        selectedItems.clear();
        if (SyncContentManager.getInstance(getActivity()).hasActivateSync(acc)) {
          // GO TO Local subfolder
          SyncFragment.with(getActivity())
              .mode(getMode())
              .folderIdentifier(nodeId)
              .folderName(documentName)
              .display();
        } else {
          DocumentFolderBrowserFragment.with(getActivity())
              .folderIdentifier(nodeId)
              .shortcut(true)
              .display();
        }
      } else {
        if (!ConnectivityUtils.hasInternetAvailable(getActivity())) {
          NodeDetailsFragment.with(getActivity())
              .node(getOfflineNode(nodeId))
              .isFavorite(true)
              .display();
        } else {
          NodeDetailsFragment.with(getActivity()).nodeId(nodeId).isFavorite(true).display();
        }
      }
    }
    adapter.notifyDataSetChanged();
  }
  // ///////////////////////////////////////////////////////////////////////////
  // LIST ACTIONS
  // ///////////////////////////////////////////////////////////////////////////
  public void onListItemClick(GridView l, View v, int position, long id) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    String nodeId = cursor.getString(SynchroSchema.COLUMN_NODE_ID_ID);
    String documentName = cursor.getString(SynchroSchema.COLUMN_TITLE_ID);

    if (DisplayUtils.hasCentralPane(getActivity())) {
      FragmentDisplayer.removeFragment(
          getActivity(), DisplayUtils.getCentralFragmentId(getActivity()));
    }

    Boolean hideDetails = false;
    if (!selectedItems.isEmpty()) {
      hideDetails = selectedItems.get(0).equals(nodeId);
    }
    l.setItemChecked(position, true);

    if (nActions != null) {
      nActions.selectNode(nodeId);
      if (selectedItems.size() == 0) {
        hideDetails = true;
      }
    } else {
      selectedItems.clear();
      if (!hideDetails && DisplayUtils.hasCentralPane(getActivity())) {
        selectedItems.add(nodeId);
      }
    }

    if (hideDetails) {
      selectedItems.clear();
    } else if (nActions == null) {
      if (SynchroManager.isFolder(cursor)) {
        selectedItems.clear();
        if (SynchroManager.getInstance(getActivity()).hasActivateSync(acc)) {
          // GO TO Local subfolder
          Fragment syncFrag = FavoritesSyncFragment.newInstance(getMode(), nodeId, documentName);
          FragmentDisplayer.replaceFragment(
              getActivity(),
              syncFrag,
              DisplayUtils.getLeftFragmentId(getActivity()),
              FavoritesSyncFragment.TAG,
              true);
        } else {
          ((MainActivity) getActivity()).addNavigationFragmentById(nodeId);
        }
      } else {
        // Show properties
        ((MainActivity) getActivity()).addPropertiesFragment(true, nodeId);
        DisplayUtils.switchSingleOrTwo(getActivity(), true);
      }
    }
    adapter.notifyDataSetChanged();
  }
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
    Node item = (Node) l.getItemAtPosition(position);

    Boolean hideDetails = false;
    if (!selectedItems.isEmpty()) {
      hideDetails = selectedItems.get(0).equals(item);
    }
    l.setItemChecked(position, true);

    selectedItems.clear();

    if (nActions != null) {
      selectedItems.clear();
      selectedItems.add(item);
      nActions.addNode(selectedItems.get(0));
      ((MainActivity) getActivity()).addPropertiesFragment(item);
      return;
    }

    if (item.isDocument() && DisplayUtils.hasCentralPane(getActivity())) {
      selectedItems.add(item);
    }

    if (hideDetails) {
      if (DisplayUtils.hasCentralPane(getActivity())) {
        FragmentDisplayer.removeFragment(
            getActivity(), DisplayUtils.getCentralFragmentId(getActivity()));
        FragmentDisplayer.removeFragment(getActivity(), android.R.id.tabcontent);
      }
      selectedItems.clear();
    } else {
      if (item.isFolder()) {
        // Browse
        ((MainActivity) getActivity()).addNavigationFragment((Folder) item);
      } else {
        // Show properties
        ((MainActivity) getActivity()).addPropertiesFragment(item);
        DisplayUtils.switchSingleOrTwo(getActivity(), true);
      }
    }
  }
  // //////////////////////////////////////////////////////////////////////
  // LIST ACTIONS
  // //////////////////////////////////////////////////////////////////////
  @Override
  public void onListItemClick(GridView l, View v, int position, long id) {
    Node item = (Node) l.getItemAtPosition(position);

    if (item instanceof NodePlaceHolder) {
      l.setItemChecked(position, false);
      return;
    }

    // In case of import mode, we disable selection of document.
    // It's only possible to select a folder for navigation purpose.
    if (mode == MODE_IMPORT && getActivity() instanceof PublicDispatcherActivity) {
      l.setChoiceMode(GridView.CHOICE_MODE_NONE);
      if (item.isFolder()) {
        ((PublicDispatcherActivity) getActivity()).addNavigationFragment((Folder) item);
      }
      return;
    }

    // In case of pick mode, we allow multiSelection
    if (mode == MODE_PICK && getActivity() instanceof PrivateDialogActivity && item.isDocument()) {
      l.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE);
      if (selectedMapItems.containsKey(item.getIdentifier())) {
        selectedMapItems.remove(item.getIdentifier());
      } else {
        selectedMapItems.put(item.getIdentifier(), (Document) item);
      }
      l.setItemChecked(position, true);
      checkValidationButton();
      return;
    }

    // In other case, listing mode
    Boolean hideDetails = false;
    if (!selectedItems.isEmpty()) {
      hideDetails = selectedItems.get(0).getIdentifier().equals(item.getIdentifier());
    }
    l.setItemChecked(position, true);

    if (nActions != null) {
      nActions.selectNode(item);
      if (selectedItems.size() == 0) {
        hideDetails = true;
      }
    } else {
      selectedItems.clear();
      if (!hideDetails && item.isDocument() && DisplayUtils.hasCentralPane(getActivity())) {
        selectedItems.add(item);
      }
    }

    if (hideDetails) {
      if (DisplayUtils.hasCentralPane(getActivity())) {
        FragmentDisplayer.removeFragment(
            getActivity(), DisplayUtils.getCentralFragmentId(getActivity()));
        FragmentDisplayer.removeFragment(getActivity(), android.R.id.tabcontent);
      }
    } else if (nActions == null) {
      if (item.isFolder()) {
        ((BaseActivity) getActivity())
            .addNavigationFragment(currentSiteParameter, (Folder) item, isShortcut());
      } else {
        // Show properties
        ((MainActivity) getActivity()).addPropertiesFragment(item);
        DisplayUtils.switchSingleOrTwo(getActivity(), true);
      }
    }
  }