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.sagar.sunshine.ItemChoiceManager.java

public void onClick(RecyclerView.ViewHolder vh) {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE)
        return;//from  ww w  .jav  a2s . c  o  m

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();

    if (position == RecyclerView.NO_POSITION) {
        Log.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {
            for (int i = 0; i < checkedItemCount; i++) {
                mAdapter.notifyItemChanged(mCheckStates.keyAt(i));
            }
            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);
        }
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager.");
    }
    }
}

From source file:ru.arturvasilov.udacity.sunshinewatches.ItemChoiceManager.java

@SuppressWarnings("unchecked")
public void onClick(RecyclerView.ViewHolder vh) {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE)
        return;//from w  w  w . ja  va2 s.com

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();

    if (position == RecyclerView.NO_POSITION) {
        Log.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {
            for (int i = 0; i < checkedItemCount; i++) {
                mAdapter.notifyItemChanged(mCheckStates.keyAt(i));
            }
            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);
        }
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager.");
    }
    }
}

From source file:cn.wjh1119.bestnews.ui.fragment.ListItemChoiceManager.java

public void onClick(RecyclerView.ViewHolder vh) {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE)
        return;//from  w  w  w. j a v a2s.  com

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();

    if (position == RecyclerView.NO_POSITION) {
        Logger.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {
            for (int i = 0; i < checkedItemCount; i++) {
                mAdapter.notifyItemChanged(mCheckStates.keyAt(i));
            }
            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);
        }
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ListItemChoiceManager.");
    }
    }
}

From source file:app.com.example.android.sunshine.ItemChoiceManager.java

public void onClick(RecyclerView.ViewHolder vh) {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE)
        return;// w w  w  .  j  av  a 2s. c  om

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();

    if (position == RecyclerView.NO_POSITION) {
        Log.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {
            for (int i = 0; i < checkedItemCount; i++) {
                mAdapter.notifyItemChanged(mCheckStates.keyAt(i));
            }
            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);
        }
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager.");
    }
    }
}

From source file:com.example.radioplayer.adapter.ItemChoiceManager.java

public void onClick(RecyclerView.ViewHolder vh) {

    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE) {
        return;/* w w  w.  j  av a  2s  .  c  om*/
    }

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();
    if (position == RecyclerView.NO_POSITION) {
        Log.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {
            for (int i = 0; i < checkedItemCount; i++) {
                mAdapter.notifyItemChanged(mCheckStates.keyAt(i));
            }
            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);
        }
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager.");
    }
    }
}

From source file:com.hangulo.xyzreader2.ui.ItemChoiceManager.java

public void onClick(RecyclerView.ViewHolder vh) {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE)
        return;/*  w w w  . j a  v  a 2 s .  co m*/

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();

    if (position == RecyclerView.NO_POSITION) {
        Log.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {
            //                    for (int i = 0; i < checkedItemCount; i++) {
            //                        mAdapter.notifyItemChanged(mCheckStates.keyAt(i)); // this original code is occured some UI delay problem, so I've changed to notifyDataSetChanged().
            //                    }

            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);

            mAdapter.notifyDataSetChanged(); // select & unselect
        }
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager.");
    }
    }
}

From source file:com.myapps.xyzreader.ui.ItemChoiceManager.java

public void onClick(RecyclerView.ViewHolder vh) {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE)
        return;//from w  ww  .  j av  a2 s.  co  m

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();

    if (position == RecyclerView.NO_POSITION) {
        Log.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {

            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);

            mAdapter.notifyDataSetChanged(); // select & unselect
        }
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position);
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager.");
    }
    }
}

From source file:com.harlie.android.sunshine.app.ItemChoiceManager.java

@SuppressWarnings("unchecked")
public void onClick(RecyclerView.ViewHolder vh) {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE)
        return;//from w w  w .j a  va2s. c o  m

    int checkedItemCount = mCheckStates.size();
    int position = vh.getAdapterPosition();

    if (position == RecyclerView.NO_POSITION) {
        Log.d(LOG_TAG, "Unable to Set Item State");
        return;
    }

    switch (mChoiceMode) {
    case AbsListView.CHOICE_MODE_NONE:
        break;
    case AbsListView.CHOICE_MODE_SINGLE: {
        boolean checked = mCheckStates.get(position, false);
        if (!checked) {
            for (int i = 0; i < checkedItemCount; i++) {
                mAdapter.notifyItemChanged(mCheckStates.keyAt(i));
            }
            mCheckStates.clear();
            mCheckStates.put(position, true);
            mCheckedIdStates.clear();
            mCheckedIdStates.put(mAdapter.getItemId(position), position);
        }
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position); // warning: Unchecked call to 'onBindViewHolder(VH, int)' as a member of raw type 'android.support.v7.widget.RecyclerView.Adapter'
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE: {
        boolean checked = mCheckStates.get(position, false);
        mCheckStates.put(position, !checked);
        // We directly call onBindViewHolder here because notifying that an item has
        // changed on an item that has the focus causes it to lose focus, which makes
        // keyboard navigation a bit annoying
        mAdapter.onBindViewHolder(vh, position); // warning: Unchecked call to 'onBindViewHolder(VH, int)' as a member of raw type 'android.support.v7.widget.RecyclerView.Adapter'
        break;
    }
    case AbsListView.CHOICE_MODE_MULTIPLE_MODAL: {
        throw new RuntimeException("Multiple Modal not implemented in ItemChoiceManager.");
    }
    }
}

From source file:nz.ac.otago.psyanlab.common.PaleListFragment.java

public void setActivateOnItemClick(boolean activateOnItemClick) {
    getListView()/*w w  w. jav a  2 s .com*/
            .setChoiceMode(activateOnItemClick ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE);
    mActivateOnItemClick = activateOnItemClick;
}

From source file:de.mprengemann.hwr.timetabel.fragments.SubjectListFragment.java

@AfterViews
public void initViews() {
    setHasOptionsMenu(true);/*  www  .ja  v  a 2 s  .  c  o m*/
    listView.setFastScrollEnabled(true);

    mAdapter = new SubjectsAdapter(getActivity(), application);
    mAdapter.setOnDataChangeListener(new OnDataChangeListener() {

        @Override
        public void onDataChange(int size, final String text) {
            if (size == 0) {
                empty.setVisibility(View.VISIBLE);
                empty.post(new Runnable() {

                    @Override
                    public void run() {
                        empty.setText(text);
                    }

                });
            } else {
                empty.setVisibility(View.GONE);
            }
        }

    });

    application.setOnTimetableDataListener(new OnTimetableDataListener() {

        @Override
        public void onLoadingFinished(final List<Events> result) {
            Log.i(TAG, "End!!");

            mAdapter.setLoading(false);
            mAdapter.setItems(result);
            if (menuItemToShow != null) {
                menuItemToShow.setVisible(true);
            }

            getSherlockActivity().setSupportProgressBarIndeterminateVisibility(false);
        }

        @Override
        public void onLoadingStarted() {
            Log.i(TAG, "Start!!");

            mAdapter.setLoading(true);

            if (getSherlockActivity() != null) {
                getSherlockActivity().setSupportProgressBarIndeterminateVisibility(true);
                getSherlockActivity().setSupportProgress(Window.PROGRESS_END);
            }
        }

    });

    listView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mAdapter.getItem(position) != null) {
                if (actionMode != null) {
                    mTimetableActionModeCallback.setSelected(mAdapter.getItem(position));
                    mAdapter.setSelection(mAdapter.getItem(position));
                    return;
                }
            }

            if (onItemClickListener != null) {
                if (mAdapter.getItem(position) != null) {
                    onItemClickListener.onClick(view, mAdapter.getItem(position).getSubjectId(),
                            mAdapter.getItem(position).getId());
                }

            }
        }
    });
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            if (mAdapter.getItem(position) != null) {
                if (actionMode != null) {
                    mAdapter.setSelection(mAdapter.getItem(position));
                    return true;
                }
                mTimetableActionModeCallback = new TimetableActionMode();
                mTimetableActionModeCallback.setSelected(mAdapter.getItem(position));
                actionMode = getSherlockActivity().startActionMode(mTimetableActionModeCallback);
                listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
                mAdapter.setSelection(mAdapter.getItem(position));
            }

            if (onItemClickListener != null) {
                if (mAdapter.getItem(position) != null) {
                    return onItemClickListener.onLongClick(view, mAdapter.getItem(position).getSubjectId(),
                            mAdapter.getItem(position).getId());
                }
            }
            return false;
        }

    });

    fillList();
}