Example usage for android.support.v4.widget CursorAdapter getItemId

List of usage examples for android.support.v4.widget CursorAdapter getItemId

Introduction

In this page you can find the example usage for android.support.v4.widget CursorAdapter getItemId.

Prototype

public long getItemId(int position) 

Source Link

Usage

From source file:th.in.ffc.widget.SearchableSpinner.java

private static final int binarySearch(CursorAdapter adapter, long id, int min, int max) {
    if (max < min) {
        return 0;
    }/*from   ww  w  .  j  av  a2  s . co m*/
    int mid = (max + min) / 2;

    long curId = adapter.getItemId(mid);
    if (curId > id)
        return binarySearch(adapter, id, min, mid - 1);
    else if (curId < id)
        return binarySearch(adapter, id, mid + 1, max);
    else
        return mid;
}

From source file:com.sip.pwc.sipphone.ui.filters.AccountFiltersListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view -- reuse the one of accounts_edit_list
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);//w w  w.j a  v a2  s. co m
    // Setup the drop listener
    lv.setOnDropListener(new DragnDropListView.DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            ContentResolver cr = getActivity().getContentResolver();
            for (i = 0; i < orderedList.size(); i++) {
                Uri uri = ContentUris.withAppendedId(SipManager.FILTER_ID_URI_BASE, orderedList.get(i));
                ContentValues cv = new ContentValues();
                cv.put(Filter.FIELD_PRIORITY, i);
                cr.update(uri, cv, null, null);
            }
        }
    });

    OnClickListener addClickButtonListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickAddFilter();
        }
    };
    // Header view
    mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    mHeaderView.setOnClickListener(addClickButtonListener);
    ((TextView) mHeaderView.findViewById(R.id.text)).setText(R.string.add_filter);

    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);
    bt.setText(R.string.add_filter);
    bt.setOnClickListener(addClickButtonListener);

    return v;
}

From source file:com.csipsimple.ui.filters.AccountFiltersListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view -- reuse the one of accounts_edit_list
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);/* w ww . j  a v a2 s  .  co m*/
    // Setup the drop listener
    lv.setOnDropListener(new DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            ContentResolver cr = getActivity().getContentResolver();
            for (i = 0; i < orderedList.size(); i++) {
                Uri uri = ContentUris.withAppendedId(SipManager.FILTER_ID_URI_BASE, orderedList.get(i));
                ContentValues cv = new ContentValues();
                cv.put(Filter.FIELD_PRIORITY, i);
                cr.update(uri, cv, null, null);
            }
        }
    });

    OnClickListener addClickButtonListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickAddFilter();
        }
    };
    // Header view
    mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    mHeaderView.setOnClickListener(addClickButtonListener);
    ((TextView) mHeaderView.findViewById(R.id.text)).setText(R.string.add_filter);

    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);
    bt.setText(R.string.add_filter);
    bt.setOnClickListener(addClickButtonListener);

    return v;
}

From source file:com.fututel.ui.filters.AccountFiltersListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view -- reuse the one of accounts_edit_list
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);/*from  w  w  w .  j a  v a2 s.co  m*/
    // Setup the drop listener
    lv.setOnDropListener(new DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            ContentResolver cr = getActivity().getContentResolver();
            for (i = 0; i < orderedList.size(); i++) {
                Uri uri = ContentUris.withAppendedId(SipManager.FILTER_ID_URI_BASE, orderedList.get(i));
                ContentValues cv = new ContentValues();
                cv.put(Filter.FIELD_PRIORITY, i);
                cr.update(uri, cv, null, null);
            }
        }
    });

    OnClickListener addClickButtonListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickAddFilter();
        }
    };
    // Header view
    mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    mHeaderView.setOnClickListener(addClickButtonListener); //rangdong
    ((TextView) mHeaderView.findViewById(R.id.text)).setText(R.string.add_filter);

    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);
    bt.setText(R.string.add_filter);
    bt.setOnClickListener(addClickButtonListener);

    return v;
}

From source file:com.roamprocess1.roaming4world.ui.filters.AccountFiltersListFragment.java

@SuppressLint("WrongViewCast")
@Override//from   w ww . j ava  2 s  .  co  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view -- reuse the one of accounts_edit_list
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);
    // Setup the drop listener
    lv.setOnDropListener(new DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            ContentResolver cr = getActivity().getContentResolver();
            for (i = 0; i < orderedList.size(); i++) {
                Uri uri = ContentUris.withAppendedId(SipManager.FILTER_ID_URI_BASE, orderedList.get(i));
                ContentValues cv = new ContentValues();
                cv.put(Filter.FIELD_PRIORITY, i);
                cr.update(uri, cv, null, null);
            }
        }
    });

    OnClickListener addClickButtonListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickAddFilter();
        }
    };
    // Header view
    mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    mHeaderView.setOnClickListener(addClickButtonListener);
    ((TextView) mHeaderView.findViewById(R.id.text)).setText(R.string.add_filter);

    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);
    bt.setText(R.string.add_filter);
    bt.setOnClickListener(addClickButtonListener);

    return v;
}

From source file:com.abcvoipsip.ui.account.AccountsEditListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);
    lv.setGrabberId(R.id.grabber);//from w ww  . j  a  v  a2 s  .c o m
    // Setup the drop listener
    lv.setOnDropListener(new DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            ContentResolver cr = getActivity().getContentResolver();
            for (i = 0; i < orderedList.size(); i++) {
                Uri uri = ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, orderedList.get(i));
                ContentValues cv = new ContentValues();
                cv.put(SipProfile.FIELD_PRIORITY, i);
                cr.update(uri, cv, null, null);
            }
        }
    });

    return v;
}

From source file:com.roamprocess1.roaming4world.ui.account.AccountsEditListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);/*  w w w  .j av a2  s.  c o  m*/
    // Setup the drop listener
    lv.setOnDropListener(new DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            if (getActivity() != null) {
                ContentResolver cr = getActivity().getContentResolver();
                for (i = 0; i < orderedList.size(); i++) {
                    Uri uri = ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, orderedList.get(i));
                    ContentValues cv = new ContentValues();
                    cv.put(SipProfile.FIELD_PRIORITY, i);
                    cr.update(uri, cv, null, null);
                }
            }
        }
    });

    // OnClickListener addClickButtonListener = new OnClickListener() {
    //  @Override
    // public void onClick(View v) {
    //onClickAddAccount();
    // }
    // };
    // Header view
    //mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    //mHeaderView.setOnClickListener(addClickButtonListener);

    // Empty view
    //Button bt = (Button) v.findViewById(android.R.id.empty);
    //bt.setOnClickListener(addClickButtonListener);

    return v;
}

From source file:com.sip.pwc.sipphone.ui.account.AccountsEditListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);//w w w.  j  ava  2 s  .co  m
    // Setup the drop listener
    lv.setOnDropListener(new DragnDropListView.DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            if (getActivity() != null) {
                ContentResolver cr = getActivity().getContentResolver();
                for (i = 0; i < orderedList.size(); i++) {
                    Uri uri = ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, orderedList.get(i));
                    ContentValues cv = new ContentValues();
                    cv.put(SipProfile.FIELD_PRIORITY, i);
                    cr.update(uri, cv, null, null);
                }
            }
        }
    });

    OnClickListener addClickButtonListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickAddAccount();
        }
    };
    // Header view
    mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    mHeaderView.setOnClickListener(addClickButtonListener);

    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);
    bt.setOnClickListener(addClickButtonListener);

    return v;
}

From source file:com.csipsimple.ui.account.AccountsEditListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);//from   w  w w . j av a  2 s.  c  om
    // Setup the drop listener
    lv.setOnDropListener(new DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            if (getActivity() != null) {
                ContentResolver cr = getActivity().getContentResolver();
                for (i = 0; i < orderedList.size(); i++) {
                    Uri uri = ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, orderedList.get(i));
                    ContentValues cv = new ContentValues();
                    cv.put(SipProfile.FIELD_PRIORITY, i);
                    cr.update(uri, cv, null, null);
                }
            }
        }
    });

    OnClickListener addClickButtonListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickAddAccount();
        }
    };
    // Header view
    mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    mHeaderView.setOnClickListener(addClickButtonListener);

    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);
    bt.setOnClickListener(addClickButtonListener);

    return v;
}

From source file:com.fututel.ui.account.AccountsEditListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Use custom drag and drop view
    View v = inflater.inflate(R.layout.accounts_edit_list, container, false);

    final DragnDropListView lv = (DragnDropListView) v.findViewById(android.R.id.list);

    lv.setGrabberId(R.id.grabber);/*ww  w  .  j av  a  2  s .  c o  m*/
    // Setup the drop listener
    lv.setOnDropListener(new DropListener() {
        @Override
        public void drop(int from, int to) {
            Log.d(THIS_FILE, "Drop from " + from + " to " + to);
            int hvC = lv.getHeaderViewsCount();
            from = Math.max(0, from - hvC);
            to = Math.max(0, to - hvC);

            int i;
            // First of all, compute what we get before move
            ArrayList<Long> orderedList = new ArrayList<Long>();
            CursorAdapter ad = (CursorAdapter) getListAdapter();
            for (i = 0; i < ad.getCount(); i++) {
                orderedList.add(ad.getItemId(i));
            }
            // Then, invert in the current list the two items ids
            Long moved = orderedList.remove(from);
            orderedList.add(to, moved);

            // Finally save that in db
            if (getActivity() != null) {
                ContentResolver cr = getActivity().getContentResolver();
                for (i = 0; i < orderedList.size(); i++) {
                    Uri uri = ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, orderedList.get(i));
                    ContentValues cv = new ContentValues();
                    cv.put(SipProfile.FIELD_PRIORITY, i);
                    cr.update(uri, cv, null, null);
                }
            }
        }
    });

    OnClickListener addClickButtonListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickAddAccount();
        }
    };
    // Header view
    //mHeaderView = inflater.inflate(R.layout.generic_add_header_list, container, false);
    //mHeaderView.setOnClickListener(addClickButtonListener); //rangdong

    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);
    bt.setOnClickListener(addClickButtonListener);

    return v;
}