List of usage examples for android.widget GridView setItemChecked
public void setItemChecked(int position, boolean value)
From source file:com.activiti.android.ui.fragments.form.picker.UserPickerFragment.java
@Override public void onListItemClick(GridView l, View v, int position, long id) { LightUserRepresentation item = (LightUserRepresentation) l.getItemAtPosition(position); if (mode == MODE_PICK && !singleChoice) { l.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); } else if (mode == MODE_PICK && !singleChoice) { l.setChoiceMode(GridView.CHOICE_MODE_SINGLE); } else if (mode == MODE_LISTING && DisplayUtils.hasCentralPane(getActivity())) { l.setChoiceMode(GridView.CHOICE_MODE_SINGLE); }//from w ww.j a v a 2 s . c o m Boolean hideDetails = false; if (!selectedItems.isEmpty()) { hideDetails = selectedItems.containsKey(item.getEmail()); if (mode == MODE_PICK && !singleChoice) { selectedItems.remove(item.getEmail()); } else { selectedItems.clear(); } } l.setItemChecked(position, true); v.setSelected(true); selectedItems.put(item.getEmail(), item); if (hideDetails) { if (mode == MODE_PICK) { selectedItems.remove(item.getEmail()); updatePickButton(); } else if (mode == MODE_LISTING && DisplayUtils.hasCentralPane(getActivity())) { FragmentDisplayer.with(getActivity()).remove(DisplayUtils.getCentralFragmentId(getActivity())); selectedItems.clear(); } } else { if (mode == MODE_LISTING) { // Show properties // UserProfileFragment.with(getActivity()).personId(item.getIdentifier()).display(); } else if (mode == MODE_PICK) { validation.setEnabled(true); updatePickButton(); } } }
From source file:com.activiti.android.ui.fragments.form.picker.UserGroupPickerFragment.java
@Override public void onListItemClick(GridView l, View v, int position, long id) { LightGroupRepresentation item = (LightGroupRepresentation) l.getItemAtPosition(position); if (mode == MODE_PICK && !singleChoice) { l.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); } else if (mode == MODE_PICK && !singleChoice) { l.setChoiceMode(GridView.CHOICE_MODE_SINGLE); } else if (mode == MODE_LISTING && DisplayUtils.hasCentralPane(getActivity())) { l.setChoiceMode(GridView.CHOICE_MODE_SINGLE); }/*from w w w .j av a2 s. c o m*/ Boolean hideDetails = false; if (!selectedItems.isEmpty()) { hideDetails = selectedItems.containsKey(item.getId()); if (mode == MODE_PICK && !singleChoice) { selectedItems.remove(item.getId()); } else { selectedItems.clear(); } } l.setItemChecked(position, true); v.setSelected(true); selectedItems.put(item.getId(), item); if (hideDetails) { if (mode == MODE_PICK) { selectedItems.remove(item.getId()); updatePickButton(); } else if (mode == MODE_LISTING && DisplayUtils.hasCentralPane(getActivity())) { FragmentDisplayer.with(getActivity()).remove(DisplayUtils.getCentralFragmentId(getActivity())); selectedItems.clear(); } } else { if (mode == MODE_LISTING) { // Show properties // UserProfileFragment.with(getActivity()).personId(item.getIdentifier()).display(); } else if (mode == MODE_PICK) { validation.setEnabled(true); updatePickButton(); } } }
From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java
@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;//w w w . ja v a 2 s. c om } // 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); } } }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.LibraryFragment.java
@Override public void onListItemClick(GridView l, View v, int position, long id) { Cursor cursor = (Cursor) l.getItemAtPosition(position); File selectedFile = new File(cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA))); if (getMode() == MODE_PICK) { if (nActions != null) { nActions.selectFile(selectedFile); adapter.notifyDataSetChanged(); } else {//from w w w . jav a2 s . c o m Intent pickResult = new Intent(); pickResult.setData(Uri.fromFile(selectedFile)); getActivity().setResult(FragmentActivity.RESULT_OK, pickResult); getActivity().finish(); } return; } Boolean hideDetails = false; if (!selectedItems.isEmpty()) { hideDetails = selectedItems.get(0).getPath().equals(selectedFile.getPath()); } l.setItemChecked(position, true); if (nActions != null) { nActions.selectFile(selectedFile); if (selectedItems.size() == 0) { hideDetails = true; } } else { selectedItems.clear(); if (!hideDetails && DisplayUtils.hasCentralPane(getActivity())) { selectedItems.add(selectedFile); } } if (hideDetails) { selectedItems.clear(); } else if (nActions == null) { new MaterialDialog.Builder(getActivity()).iconRes(R.drawable.ic_application_logo) .title(R.string.error_unable_open_file_title) .content(Html.fromHtml(getString(R.string.error_unable_open_file))) .positiveText(android.R.string.ok).show(); selectedItems.clear(); } adapter.notifyDataSetChanged(); }
From source file:org.alfresco.mobile.android.application.fragments.user.UserSearchFragment.java
@Override public void onListItemClick(GridView l, View v, int position, long id) { Person item = (Person) l.getItemAtPosition(position); if (mode == MODE_PICK && !singleChoice) { l.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); } else if (mode == MODE_PICK && !singleChoice) { l.setChoiceMode(GridView.CHOICE_MODE_SINGLE); } else if (mode == MODE_LISTING && DisplayUtils.hasCentralPane(getActivity())) { l.setChoiceMode(GridView.CHOICE_MODE_SINGLE); }//from ww w . ja v a2s. c o m Boolean hideDetails = false; if (!selectedItems.isEmpty()) { hideDetails = selectedItems.containsKey(item.getIdentifier()); if (mode == MODE_PICK && !singleChoice) { selectedItems.remove(item.getIdentifier()); } else { selectedItems.clear(); } } l.setItemChecked(position, true); v.setSelected(true); selectedItems.put(item.getIdentifier(), item); if (hideDetails) { if (mode == MODE_PICK) { selectedItems.remove(item.getIdentifier()); updatePickButton(); } else if (mode == MODE_LISTING && DisplayUtils.hasCentralPane(getActivity())) { FragmentDisplayer.with(getActivity()).remove(DisplayUtils.getCentralFragmentId(getActivity())); selectedItems.clear(); } } else { if (mode == MODE_LISTING) { // Show properties UserProfileFragment.with(getActivity()).personId(item.getIdentifier()).display(); } else if (mode == MODE_PICK) { validation.setEnabled(true); updatePickButton(); } } }
From source file:org.alfresco.mobile.android.application.fragments.sync.SyncFragment.java
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())); }/* www .ja v a 2 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(); 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(); }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileExplorerFragment.java
@Override public void onListItemClick(GridView l, View v, int position, long id) { final File file = (File) l.getItemAtPosition(position); if (getMode() == MODE_PICK) { if (nActions != null) { nActions.selectFile(file);/*from w ww .j a v a2 s . c om*/ adapter.notifyDataSetChanged(); } else { if (file.isDirectory()) { displayNavigation(file, true); } else { Intent pickResult = new Intent(); pickResult.setData(Uri.fromFile(file)); getActivity().setResult(FragmentActivity.RESULT_OK, pickResult); getActivity().finish(); } } return; } Boolean hideDetails = false; if (!selectedItems.isEmpty()) { hideDetails = selectedItems.get(0).getPath().equals(file.getPath()); } l.setItemChecked(position, true); if (nActions != null) { nActions.selectFile(file); if (selectedItems.size() == 0) { hideDetails = true; } } else { selectedItems.clear(); } if (hideDetails) { return; } else if (nActions == null) { if (file.isDirectory()) { displayNavigation(file, true); } else { ActionUtils.actionView(this, file, new ActionManagerListener() { @Override public void onActivityNotFoundException(ActivityNotFoundException e) { OpenAsDialogFragment.newInstance(file).show(getActivity().getSupportFragmentManager(), OpenAsDialogFragment.TAG); } }); } } adapter.notifyDataSetChanged(); }
From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java
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; }/*from w w w .j a va 2 s . c o m*/ 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; }
From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java
@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;/*from w w w . j a v a 2 s . c o m*/ } // 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 || getActivity() instanceof BaseShortcutActivity) { l.setChoiceMode(GridView.CHOICE_MODE_NONE); if (item.isFolder()) { DocumentFolderBrowserFragment.with(getActivity()).folder((Folder) item).shortcut(isShortcut()) .display(); } 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 (pickedNodes.containsKey(item.getIdentifier())) { pickedNodes.remove(item.getIdentifier()); } else { pickedNodes.put(item.getIdentifier(), 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.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(); } getActivity().supportInvalidateOptionsMenu(); displayPathShortcut(true); } else if (nActions == null || (nActions != null && !nActions.hasMultiSelectionEnabled())) { if (item.isFolder()) { FragmentDisplayer.clearCentralPane(getActivity()); DocumentFolderBrowserFragment.with(getActivity()).site(site).folder((Folder) item) .shortcut(isShortcut()).display(); } else { NodeDetailsFragment.with(getActivity()).parentFolder(parentFolder).node(item).display(); } } }
From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.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 w w.j av a 2s. c om*/ if (nActions != null && nActions instanceof NodeDetailsActionMode) { nActions.finish(); } Node n = (Node) l.getItemAtPosition(position); boolean b; if (n instanceof NodePlaceHolder) { getActivity().startActivity(new Intent(PrivateIntent.ACTION_DISPLAY_OPERATIONS) .putExtra(PrivateIntent.EXTRA_ACCOUNT_ID, SessionUtils.getAccount(getActivity()).getId())); b = false; } else { 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; }