Ejemplo n.º 1
0
  @Override
  public void refresh() {
    if (!ConnectivityUtils.hasNetwork(getActivity())) {
      if (mi != null) {
        mi.setActionView(null);
      }
      if (!ConnectivityUtils.hasNetwork(getActivity())) {
        Crouton.cancelAllCroutons();
        Crouton.showText(
            getActivity(),
            Html.fromHtml(
                getString(org.alfresco.mobile.android.foundation.R.string.error_session_nodata)),
            Style.INFO,
            (ViewGroup) (getRootView().getParent()));
      }
      refreshHelper.setRefreshComplete();
      return;
    }

    SyncContentManager.getInstance(getActivity()).sync(acc);
    if (mi != null) {
      // Display spinning wheel instead of refresh
      mi.setActionView(R.layout.app_spinning);
    }

    if (adapter != null) {
      ((SyncCursorAdapter) adapter).refresh();
      gv.setAdapter(adapter);
    }
  }
Ejemplo 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();
  }