List of usage examples for android.widget GridView setChoiceMode
public void setChoiceMode(int choiceMode)
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); }/* ww w . ja va 2 s . com*/ 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); }/* w w w . j a v a 2 s . co 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.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 w w . j ava2s. c om*/ 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.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); }/* w w w . j a v a 2s . 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:com.google.devrel.samples.memedroid.app.CreateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.translate_in_top, R.anim.translate_out_top); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_create); if (getActionBar() != null) { getActionBar().setDisplayHomeAsUpEnabled(true); }/*from w ww . j av a 2s.com*/ mHandler = new Handler(); ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); GridView gridView = (GridView) findViewById(R.id.template_grid); if (viewPager != null) { PagerAdapter adapter = new MemeTemplatePagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(adapter); mAdapter = (TemplateAdapter) adapter; viewPager.setOffscreenPageLimit(3); viewPager.setPageMargin(-54); viewPager.setOnPageChangeListener(this); mCurrentView = viewPager; findViewById(R.id.meme_template_number).setVisibility(View.VISIBLE); } else if (gridView != null) { ListAdapter adapter = new MemeTemplateAdapter(this, R.layout.fragment_meme); gridView.setAdapter(adapter); mAdapter = (TemplateAdapter) adapter; mCurrentView = gridView; gridView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); gridView.setOnItemClickListener(this); } else { throw new IllegalStateException("No valid layout found."); } getSupportLoaderManager().initLoader(MEME_TEMPLATE_LIST, null, this); if (savedInstanceState != null) { mHasText = savedInstanceState.getBoolean(STATE_TEXT, false); getSupportLoaderManager().restartLoader(MEME_TEMPLATE_LIST, null, CreateActivity.this); } EditText et = (EditText) findViewById(R.id.top_text); et.addTextChangedListener(this); setProgressBarIndeterminateVisibility(true); }
From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = null;//from w ww .jav a2 s. c o m // In case of Import mode, we wrap the listing with buttons. if (getActivity() instanceof PublicDispatcherActivity || getActivity() instanceof PrivateDialogActivity) { v = inflater.inflate(R.layout.app_browser_import, container, false); init(v, emptyListMessageId); validationButton = (Button) v.findViewById(R.id.action_validation); GridView gridView = (GridView) v.findViewById(R.id.gridview); if (getActivity() instanceof PrivateDialogActivity) { validationButton.setText(R.string.done); gridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); } else { gridView.setChoiceMode(GridView.CHOICE_MODE_SINGLE); } gridView.setClickable(true); } else { v = super.onCreateView(inflater, container, savedInstanceState); GridView gridView = (GridView) v.findViewById(R.id.gridview); gridView.setChoiceMode(GridView.CHOICE_MODE_SINGLE); gridView.setClickable(true); gridView.setBackgroundColor(getResources().getColor(R.color.grey_lighter)); } return v; }
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 va 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) { 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.node.browser.DocumentFolderBrowserFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v;/*from ww w . ja v a 2s . c om*/ // In case of Import mode, we wrap the listing with buttons. if (getActivity() instanceof PublicDispatcherActivity || getActivity() instanceof PrivateDialogActivity || getActivity() instanceof BaseShortcutActivity) { setRootView(inflater.inflate(R.layout.app_browser_import, container, false)); init(getRootView(), emptyListMessageId); validationButton = (Button) viewById(R.id.action_validation); GridView gridView = (GridView) viewById(R.id.gridview); if (getActivity() instanceof PrivateDialogActivity) { validationButton.setText(R.string.done); gridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); } else if (getActivity() instanceof BaseShortcutActivity) { validationButton.setText(R.string.select_folder); gridView.setChoiceMode(GridView.CHOICE_MODE_SINGLE); } else { gridView.setChoiceMode(GridView.CHOICE_MODE_SINGLE); } gridView.setClickable(true); v = getRootView(); } else { v = super.onCreateView(inflater, container, savedInstanceState); GridView gridView = (GridView) v.findViewById(R.id.gridview); gridView.setChoiceMode(GridView.CHOICE_MODE_SINGLE); gridView.setClickable(true); gridView.setBackgroundColor(getResources().getColor(R.color.grey_lighter)); } return v; }
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 ww w. ja v a2 s . co 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(); } } }