Example usage for android.widget AbsListView CHOICE_MODE_NONE

List of usage examples for android.widget AbsListView CHOICE_MODE_NONE

Introduction

In this page you can find the example usage for android.widget AbsListView CHOICE_MODE_NONE.

Prototype

int CHOICE_MODE_NONE

To view the source code for android.widget AbsListView CHOICE_MODE_NONE.

Click Source Link

Document

Normal list that does not indicate choices

Usage

From source file:com.tomeokin.lspush.ui.widget.dialog.BaseDialogFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (hasListItemClickListener) {
        OnListItemClickListener listener = getDialogListener(OnListItemClickListener.class);
        if (listener != null) {
            listener.onItemClick(getDialog(), requestCode, parent, view, position, id);
        } else {// w  ww.ja  v  a  2  s. c  om
            Intent data = new Intent();
            data.putExtra(BaseDialogBuilder.EXTRA_LIST_ITEM_CLICK_POSITION, position);
            setResult(requestCode, Activity.RESULT_OK, data);
        }

        ListView listView = (ListView) parent;
        if (listView.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {
            getDialog().dismiss();
        }
    }
}

From source file:com.rsegismont.androlife.programlist.FragmentListProgrammes.java

public void onViewCreated(View paramView, Bundle paramBundle) {
    super.onViewCreated(paramView, paramBundle);
    getListView().setOnItemClickListener(this);
    if (SdkUtils.isTabletLandscape(getActivity())) {
        getListView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    } else {//  www.j  a  v a  2 s  .com
        getListView().setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    }

    getListView().setDividerHeight(0);

    getListView().setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == SCROLL_STATE_FLING)
                getAndrolifeActivity().getImageDownloader().setPauseWork(true);
            else {
                getAndrolifeActivity().getImageDownloader().setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }
    });

    getListView().setCacheColorHint(getResources().getColor(R.color.background));

}

From source file:de.geeksfactory.opacclient.frontend.StarredFragment.java

/**
 * Turns on activate-on-click mode. When this mode is on, list items will be given the
 * 'activated' state when touched./*from w  w  w  .j  av a  2 s . c  o m*/
 */
private void setActivateOnItemClick(boolean activateOnItemClick) {
    // When setting CHOICE_MODE_SINGLE, ListView will automatically
    // give items the 'activated' state when touched.
    listView.setChoiceMode(activateOnItemClick ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE);
}

From source file:dev.dworks.apps.anexplorer.fragment.DirectoryFragment.java

@Override
public void onDestroyView() {
    super.onDestroyView();

    // Cancel any outstanding thumbnail requests
    final ViewGroup target = (mListView.getAdapter() != null) ? mListView : mGridView;
    final int count = target.getChildCount();
    for (int i = 0; i < count; i++) {
        final View view = target.getChildAt(i);
        mRecycleListener.onMovedToScrapHeap(view);
    }/*  w w  w  .j  a v a2  s . com*/

    // Tear down any selection in progress
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    mGridView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
}

From source file:com.docd.purefm.ui.fragments.BrowserFragment.java

private void initList(@NonNull final LayoutInflater inflater, @NonNull final View parent) {
    final AbstractBrowserActivity context = getBrowserActivity();

    if (mListView != null) {
        final View emptyView = mListView.getEmptyView();
        if (emptyView != null) {
            emptyView.setVisibility(View.GONE);
        }// www . j a va  2s  .  co m
        mListView.setVisibility(View.GONE);
    }

    final Settings settings = Settings.getInstance(context);

    final ViewGroup listContainer = (ViewGroup) parent.findViewById(R.id.list_container);
    if (listContainer == null) {
        throw new RuntimeException("parent should contain ViewGroup with id R.id.list_container");
    }

    final View swipeRefreshList;
    switch (settings.getListAppearance()) {
    case LIST:
        swipeRefreshList = inflater.inflate(R.layout.browser_listview, listContainer);
        break;

    case GRID:
        swipeRefreshList = inflater.inflate(R.layout.browser_gridview, listContainer);
        break;

    default:
        throw new IllegalArgumentException("Unexpected ListAppearance: " + settings.getListAppearance());
    }

    if (swipeRefreshList == null) {
        throw new RuntimeException("Inflated View is null");
    }

    mMainProgress = parent.findViewById(android.R.id.progress);
    mSwipeRefreshLayoutList = (SwipeRefreshLayout) swipeRefreshList
            .findViewById(R.id.browser_list_swipe_refresh);

    mSwipeRefreshLayoutEmpty = (SwipeRefreshLayout) parent.findViewById(android.R.id.empty);

    mListView = (AbsListView) mSwipeRefreshLayoutList.getChildAt(0);
    if (mListView instanceof ListView) {
        mAdapter = new BrowserListAdapter(context);
    } else {
        mAdapter = new BrowserGridAdapter(context);
    }

    menuController.setBrowserAdapter(this.mAdapter);

    mListView.setEmptyView(parent.findViewById(android.R.id.empty));
    mListView.setAdapter(this.mAdapter);
    final View emptyView = mListView.getEmptyView();
    if (emptyView != null) {
        emptyView.setVisibility(View.GONE);
    }
    mListView.setVisibility(View.GONE);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> av, View v, int pos, long id) {
            final GenericFile target = (GenericFile) (av.getItemAtPosition(pos));
            if (target == null) {
                throw new RuntimeException("onItemClick(): item at position is null");
            }
            if (target.isDirectory()) {
                mBrowser.navigate(target, true);
            } else {
                final AbstractBrowserActivity activity = getBrowserActivity();
                if (activity.getGetContentMimeType() == null) {
                    PFMFileUtils.openFileInExternalApp(activity, target.toFile());
                } else {
                    final Intent intent = new Intent();
                    intent.setData(getResultUriForFileFromIntent(activity.getContentResolver(), target.toFile(),
                            activity.getIntent()));
                    activity.setResult(Activity.RESULT_OK, intent);
                    activity.finish();
                }
            }
        }

        /*
         * Copyright (C) 2013 The CyanogenMod Project
         *
         * Licensed under the Apache License, Version 2.0 (the "License");
         * you may not use this file except in compliance with the License.
         * You may obtain a copy of the License at
         *
         *      http://www.apache.org/licenses/LICENSE-2.0
         *
         * Unless required by applicable law or agreed to in writing, software
         * distributed under the License is distributed on an "AS IS" BASIS,
         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         * See the License for the specific language governing permissions and
         * limitations under the License.
         */
        private Uri getResultUriForFileFromIntent(ContentResolver cr, File src, Intent intent) {
            // Try to find the preferred uri scheme
            Uri result = MediaHelper.fileToContentUri(cr, src);
            if (result == null) {
                result = Uri.fromFile(src);
            }

            if (Intent.ACTION_PICK.equals(intent.getAction()) && intent.getData() != null) {
                final String scheme = intent.getData().getScheme();
                if (scheme != null) {
                    result = result.buildUpon().scheme(scheme).build();
                }
            }

            return result;
        }
    });

    mListView.setChoiceMode(context.getGetContentMimeType() == null ? AbsListView.CHOICE_MODE_MULTIPLE_MODAL
            : AbsListView.CHOICE_MODE_NONE);

    mSwipeRefreshLayoutList.setOnRefreshListener(this);
    mSwipeRefreshLayoutEmpty.setOnRefreshListener(this);

    final int color2resId = settings.getTheme() == Settings.Theme.LIGHT ? R.color.holo_light_window_background
            : R.color.holo_dark_window_background;
    mSwipeRefreshLayoutList.setColorScheme(R.color.holo_light_selected, color2resId,
            R.color.holo_light_selected, color2resId);
    mSwipeRefreshLayoutEmpty.setColorScheme(R.color.holo_light_selected, color2resId,
            R.color.holo_light_selected, color2resId);
}

From source file:com.commonsware.cwac.masterdetail.MasterDetailHelper.java

int getDefaultChoiceMode() {
    return (strategy.isActivatedStyle() ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void clearListViewChoices(final AbsListView view) {
    if (view == null)
        return;//from  www  .  j a v  a  2s  .co m
    final ListAdapter adapter = view.getAdapter();
    if (adapter == null)
        return;
    view.clearChoices();
    view.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    // Workaround for Android bug
    // http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode
    final int position = view.getFirstVisiblePosition(), offset = Utils.getFirstChildOffset(view);
    view.setAdapter(adapter);
    Utils.scrollListToPosition(view, position, offset);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void clearListViewChoices(final StaggeredGridView view) {
    if (view == null)
        return;//from ww w . j a  va2s.  c  o  m
    final ListAdapter adapter = view.getAdapter();
    if (adapter == null)
        return;
    view.clearChoices();
    view.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    view.invalidateViews();
    // Workaround for Android bug
    // http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode
    // final int position = view.getFirstVisiblePosition();
    // view.setAdapter(adapter);
    // Utils.scrollListToPosition(view, position);
}

From source file:nl.mpcjanssen.simpletask.Simpletask.java

private void updateRightDrawer() {
    ArrayList<String> names = new ArrayList<String>();
    final ArrayList<ActiveFilter> filters = getSavedFilter();
    Collections.sort(filters, new Comparator<ActiveFilter>() {
        public int compare(@NotNull ActiveFilter f1, @NotNull ActiveFilter f2) {
            return f1.getName().compareToIgnoreCase(f2.getName());
        }//ww  w .ja va 2s . com
    });
    for (ActiveFilter f : filters) {
        names.add(f.getName());
    }
    m_rightDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, names));
    m_rightDrawerList.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    m_rightDrawerList.setLongClickable(true);
    m_rightDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mFilter = filters.get(position);
            Intent intent = getIntent();
            mFilter.saveInIntent(intent);
            setIntent(intent);
            mFilter.saveInPrefs(TodoApplication.getPrefs());
            m_adapter.setFilteredTasks();
            if (m_drawerLayout != null) {
                m_drawerLayout.closeDrawer(Gravity.RIGHT);
            }
            finishActionmode();
            updateDrawers();
        }
    });
    m_rightDrawerList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final ActiveFilter filter = filters.get(position);
            final String prefsName = filter.getPrefName();
            PopupMenu popupMenu = new PopupMenu(Simpletask.this, view);
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(@NotNull MenuItem item) {
                    int menuid = item.getItemId();
                    switch (menuid) {
                    case R.id.menu_saved_filter_delete:
                        deleteSavedFilter(prefsName);
                        break;
                    case R.id.menu_saved_filter_shortcut:
                        createFilterShortcut(filter);
                        break;
                    case R.id.menu_saved_filter_rename:
                        renameSavedFilter(prefsName);
                        break;
                    case R.id.menu_saved_filter_update:
                        updateSavedFilter(prefsName);
                        break;
                    default:
                        break;
                    }
                    return true;
                }
            });
            MenuInflater inflater = popupMenu.getMenuInflater();
            inflater.inflate(R.menu.saved_filter, popupMenu.getMenu());
            popupMenu.show();
            return true;
        }
    });
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void clearListViewChoices(final AbsListView view) {
    if (view == null)
        return;/*from   w  ww. j a v  a 2s .co m*/
    final ListAdapter adapter = view.getAdapter();
    if (adapter == null)
        return;
    view.clearChoices();
    for (int i = 0, j = view.getChildCount(); i < j; i++) {
        view.setItemChecked(i, false);
    }
    view.post(new Runnable() {
        @Override
        public void run() {
            view.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
        }
    });
    // Workaround for Android bug
    // http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode
    //        final int position = view.getFirstVisiblePosition(), offset = Utils.getFirstChildOffset(view);
    //        view.setAdapter(adapter);
    //        Utils.scrollListToPosition(view, position, offset);
}