Example usage for android.widget GridView setItemChecked

List of usage examples for android.widget GridView setItemChecked

Introduction

In this page you can find the example usage for android.widget GridView setItemChecked.

Prototype

public void setItemChecked(int position, boolean value) 

Source Link

Document

Sets the checked state of the specified position.

Usage

From source file:org.alfresco.mobile.android.application.fragments.activitystream.ActivityFeedFragment.java

@Override
public void onListItemClick(GridView g, View v, int position, long id) {
    ActivityEntry entry = (ActivityEntry) g.getItemAtPosition(position);

    Boolean hideDetails = false;//w ww  .  ja va  2s  .com
    if (!selectedEntry.isEmpty()) {
        hideDetails = selectedEntry.get(0).equals(entry);
    }
    g.setItemChecked(position, true);

    selectedEntry.clear();
    if (!hideDetails && DisplayUtils.hasCentralPane(getActivity())) {
        selectedEntry.add(entry);
    }

    if (hideDetails) {
        selectedEntry.clear();
        onItemUnselected(entry);
        displayTitle();
    } else {
        onItemSelected(entry);
    }
    adapter.notifyDataSetChanged();
}

From source file:org.alfresco.mobile.android.application.fragments.workflow.process.ProcessesFragment.java

@Override
public void onListItemClick(GridView l, View v, int position, long id) {
    Process item = (Process) l.getItemAtPosition(position);

    Boolean hideDetails = false;//from   w w w . j  a  v a  2s .  c o  m
    if (!selectedItems.isEmpty()) {
        hideDetails = selectedItems.get(0).equals(item);
    }
    l.setItemChecked(position, true);

    selectedItems.clear();
    if (!hideDetails && DisplayUtils.hasCentralPane(getActivity())) {
        selectedItems.add(item);
    }

    if (hideDetails) {
        if (DisplayUtils.hasCentralPane(getActivity())) {
            FragmentDisplayer.with(getActivity()).remove(DisplayUtils.getCentralFragmentId(getActivity()));
        }
        selectedItems.clear();
    } else {
        // Show properties
        TaskDetailsFragment.with(getActivity()).process(item).display();
    }
    adapter.notifyDataSetChanged();
}

From source file:org.alfresco.mobile.android.application.fragments.workflow.task.TasksFragment.java

public void onListItemClick(GridView l, View v, int position, long id) {
    Task item = (Task) l.getItemAtPosition(position);

    Boolean hideDetails = false;/*w w w .ja v a2  s .c  o m*/
    if (!selectedItems.isEmpty()) {
        hideDetails = selectedItems.get(0).equals(item);
    }
    l.setItemChecked(position, true);

    selectedItems.clear();
    if (!hideDetails && DisplayUtils.hasCentralPane(getActivity())) {
        selectedItems.add(item);
    }

    if (hideDetails) {
        if (DisplayUtils.hasCentralPane(getActivity())) {
            FragmentDisplayer.with(getActivity()).remove(DisplayUtils.getCentralFragmentId(getActivity()));
        }
        selectedItems.clear();
    } else {
        TaskDetailsFragment.with(getActivity()).task(item).display();
    }

    if (adapter != null) {
        adapter.notifyDataSetChanged();
    }
}

From source file:org.alfresco.mobile.android.application.fragments.user.UsersFragment.java

@Override
public void onListItemClick(GridView l, View v, int position, long id) {
    Person item = (Person) l.getItemAtPosition(position);

    Boolean hideDetails = false;// w  ww . j a  va2s  .com
    if (!selectedItems.isEmpty()) {
        hideDetails = selectedItems.containsKey(item.getIdentifier());
        selectedItems.clear();
    }
    l.setChoiceMode(GridView.CHOICE_MODE_SINGLE);
    l.setItemChecked(position, true);
    v.setSelected(true);

    if (DisplayUtils.hasCentralPane(getActivity())) {
        selectedItems.put(item.getIdentifier(), item);
    }

    if (hideDetails) {
        if (DisplayUtils.hasCentralPane(getActivity())) {
            FragmentDisplayer.with(getActivity()).remove(DisplayUtils.getCentralFragmentId(getActivity()));
        }
        selectedItems.clear();
    } else {
        if (getArguments().containsKey(ConfigurationConstant.ON_ITEM_SELECTED)) {
            ConfigManager configurationManager = ConfigManager.getInstance(getActivity());
            if (configurationManager != null && configurationManager.hasConfig(getAccount().getId())) {
                Bundle b = new Bundle();
                b.putString("personId", item.getIdentifier());

                // TODO Configuration ONItemSelected
                /*
                 * FragmentTemplateConfigurator config = new
                 * FragmentTemplateConfigurator(getActivity(),
                 * configurationManager
                 * .getConfig(SessionUtils.getAccount(getActivity())),
                 * getArguments()
                 * .getString(ConfigurationConstant.ON_ITEM_SELECTED));
                 * config.displayFragment(b);
                 */
            }
        } else {
            // Show properties
            UserProfileFragment.with(getActivity()).accountId(getAccount().getId())
                    .personId(item.getIdentifier()).display();
        }
    }
}

From source file:org.alfresco.mobile.android.application.fragments.node.favorite.FavoritesFragment.java

@Override
public void onListItemClick(GridView g, View v, int position, long id) {
    Node item = (Node) g.getItemAtPosition(position);

    // In other case, listing mode
    Boolean hideDetails = false;/*from   w  ww.  j a v a 2  s .co  m*/
    if (!selectedItems.isEmpty()) {
        hideDetails = selectedItems.get(0).getIdentifier().equals(item.getIdentifier());
    }
    g.setItemChecked(position, true);

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

    if (hideDetails) {
        FragmentDisplayer.clearCentralPane(getActivity());
        if (nActions != null && !nActions.hasMultiSelectionEnabled()) {
            nActions.finish();
        }
    } else if (nActions == null || (nActions != null && !nActions.hasMultiSelectionEnabled())) {
        if (item.isFolder()) {
            FragmentDisplayer.clearCentralPane(getActivity());
            DocumentFolderBrowserFragment.with(getActivity()).folder((Folder) item).shortcut(true).display();
        } else {
            NodeDetailsFragment.with(getActivity()).nodeId(item.getIdentifier()).display();
        }
    }

    if (nActions != null && nActions.hasMultiSelectionEnabled()) {
        adapter.notifyDataSetChanged();
    }
}

From source file:org.alfresco.mobile.android.application.fragments.node.favorite.FavoritesFragment.java

public boolean onListItemLongClick(GridView l, View v, int position, long id) {
    // We disable long click during import mode.
    if (mode == MODE_IMPORT || mode == MODE_PICK) {
        return false;
    }//  w ww.j av  a 2 s  .com

    if (nActions != null && nActions instanceof NodeDetailsActionMode) {
        nActions.finish();
    }

    Node n = (Node) l.getItemAtPosition(position);
    boolean b;
    l.setItemChecked(position, true);
    b = startSelection(n);
    if (DisplayUtils.hasCentralPane(getActivity())) {
        FragmentDisplayer.with(getActivity()).remove(DisplayUtils.getCentralFragmentId(getActivity()));
        FragmentDisplayer.with(getActivity()).remove(android.R.id.tabcontent);
    }
    return b;
}

From source file:org.alfresco.mobile.android.application.fragments.node.search.DocumentFolderSearchFragment.java

public void onListItemClick(GridView g, View v, int position, long id) {
    Node item = (Node) g.getItemAtPosition(position);

    // In other case, listing mode
    Boolean hideDetails = false;/*from  w w w  .j  a  v a 2 s . co  m*/
    if (!selectedItems.isEmpty()) {
        hideDetails = selectedItems.get(0).getIdentifier().equals(item.getIdentifier());
    }
    g.setItemChecked(position, true);

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

    if (hideDetails) {
        FragmentDisplayer.clearCentralPane(getActivity());
        if (nActions != null && !nActions.hasMultiSelectionEnabled()) {
            nActions.finish();
        }
    } else if (nActions == null || (nActions != null && !nActions.hasMultiSelectionEnabled())) {
        if (item.isFolder()) {
            FragmentDisplayer.clearCentralPane(getActivity());
            DocumentFolderBrowserFragment.with(getActivity()).folder((Folder) item).shortcut(true).display();
        } else {
            NodeDetailsFragment.with(getActivity()).nodeId(item.getIdentifier()).display();
        }
    }

    if (nActions != null && nActions.hasMultiSelectionEnabled()) {
        adapter.notifyDataSetChanged();
    }
}

From source file:org.alfresco.mobile.android.application.fragments.search.SearchFragment.java

@Override
public boolean onListItemLongClick(GridView l, View v, int position, long id) {
    if (nActions != null && nActions instanceof HistorySearchActions) {
        nActions.finish();//from  w w  w  . ja v  a  2 s. c  o m
    }

    Cursor c = (Cursor) l.getItemAtPosition(position);
    long searchId = c.getLong(HistorySearchSchema.COLUMN_ID_ID);
    boolean b = true;
    l.setItemChecked(position, true);
    b = startSelection(searchId);
    refreshListView();
    return b;
}

From source file:org.alfresco.mobile.android.application.fragments.search.SearchFragment.java

@Override
public void onListItemClick(GridView l, View v, int position, long id) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    long searchId = cursor.getLong(HistorySearchSchema.COLUMN_ID_ID);

    // In other case, listing mode
    Boolean hideDetails = false;//from w  w w.j  a v a 2  s. co m
    if (!selectedItems.isEmpty()) {
        hideDetails = selectedItems.contains(searchId);
    }
    l.setItemChecked(position, true);

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

    if (hideDetails) {
        if (nActions != null && !nActions.hasMultiSelectionEnabled()) {
            nActions.finish();
        }
    } else if (nActions == null || (nActions != null && !nActions.hasMultiSelectionEnabled())) {
        String keywords = cursor.getString(HistorySearchSchema.COLUMN_QUERY_ID);
        search(keywords, HistorySearchManager.createHistorySearch(cursor));
    }
    refreshListView();
}

From source file:org.alfresco.mobile.android.application.fragments.favorites.FavoritesSyncFragment.java

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()));
    }/*from   w  w  w . j a va2  s.co  m*/

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