Example usage for android.database Cursor moveToPosition

List of usage examples for android.database Cursor moveToPosition

Introduction

In this page you can find the example usage for android.database Cursor moveToPosition.

Prototype

boolean moveToPosition(int position);

Source Link

Document

Move the cursor to an absolute position.

Usage

From source file:com.zns.comicdroid.adapter.GroupedItemAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Cursor cursor = getCursor();
    if (cursor.moveToPosition(position)) {
        GroupedItemHolder holder;/*w w  w .ja v  a  2 s.c o m*/

        if (convertView == null) {
            convertView = mLayoutInflater.inflate(mLayout, null);
            holder = new GroupedItemHolder();
            holder.tvName = (TextView) convertView.findViewById(R.id.list_groupedrow_tvName);
            holder.tvCount = (TextView) convertView.findViewById(R.id.list_groupedrow_tvCount);

            convertView.setTag(holder);
        } else {
            holder = (GroupedItemHolder) convertView.getTag();
        }

        String name = cursor.getString(1);
        int count = cursor.getInt(2);
        if (name == null || name.length() == 0) {
            name = mNameNA;
        }
        holder.tvName.setText(name);
        holder.tvCount.setText(Integer.toString(count));
    }

    return convertView;
}

From source file:io.pivotal.arca.fragments.ArcaItemSupportFragment.java

public void bindViewAtPosition(final int position) {
    final CursorAdapter adapter = getCursorAdapter();
    final Cursor cursor = adapter.getCursor();
    if (cursor != null && cursor.moveToPosition(position)) {
        adapter.bindView(getView(), getActivity(), cursor);
    }//from  w w w. j  a  va2 s . co m
}

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

public String getData(int position, int columnIndex) {
    Cursor c = getCursor();
    if (c.moveToPosition(position)) {
        return c.getString(columnIndex);
    }// w  w  w  .j ava 2  s . c o  m
    return null;
}

From source file:com.tingtingapps.securesms.contacts.ContactSelectionListAdapter.java

@Override
public long getHeaderId(int i) {
    Cursor cursor = getCursor();
    cursor.moveToPosition(i);

    return cursor.getInt(cursor.getColumnIndexOrThrow(ContactsDatabase.CONTACT_TYPE_COLUMN));
}

From source file:org.mozilla.gecko.home.MultiTypeCursorAdapter.java

/**
 * @return Cursor for the given position.
 *//*from ww w . j  a  va  2s  . c  o m*/
public final Cursor getCursor(int position) {
    final Cursor cursor = getCursor();
    if (cursor == null || !cursor.moveToPosition(position)) {
        throw new IllegalStateException("Couldn't move cursor to position " + position);
    }

    return cursor;
}

From source file:org.thoughtcrime.SMP.contacts.ContactSelectionListAdapter.java

@Override
public long getHeaderId(int i) {
    Cursor cursor = getCursor();
    cursor.moveToPosition(i);

    return cursor.getInt(cursor.getColumnIndexOrThrow(ContactsDatabase.TYPE_COLUMN));
}

From source file:com.example.ami1.LabelDetailsActivity.java

@Override
public void onItemClicked(int position) {
    // Get the cursor from the adapter
    final Cursor cursor = mAdapter.getCursor();

    cursor.moveToPosition(position);

    // get the uri
    final Uri labelUri = Uri.parse(cursor.getString(cursor.getColumnIndex(GmailContract.Labels.URI)));

    final Intent intent = new Intent(Intent.ACTION_VIEW, labelUri);
    startActivity(intent);/*  w  w  w. j  av  a 2  s .com*/
}

From source file:can.yrt.onebusaway.MyRouteListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Get the cursor and fetch the stop ID from that.
    SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter();
    Cursor c = cursorAdapter.getCursor();
    c.moveToPosition(position - l.getHeaderViewsCount());
    final String routeId = c.getString(COL_ID);
    final String routeName = c.getString(COL_SHORTNAME);

    if (isShortcutMode()) {
        final Intent shortcut = UIHelp.makeShortcut(getActivity(), routeName,
                RouteInfoActivity.makeIntent(getActivity(), routeId));

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();/*from   w ww  . jav  a2 s . co m*/

    } else {
        RouteInfoActivity.start(getActivity(), routeId);
    }
}

From source file:org.onebusaway.android.ui.MyRouteListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Get the cursor and fetch the route ID from that.
    SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter();
    Cursor c = cursorAdapter.getCursor();
    c.moveToPosition(position - l.getHeaderViewsCount());
    final String routeId = c.getString(COL_ID);
    final String routeName = c.getString(COL_SHORTNAME);

    if (isShortcutMode()) {
        final Intent shortcut = UIUtils.makeShortcut(getActivity(), routeName,
                RouteInfoActivity.makeIntent(getActivity(), routeId));

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();//from w w  w.j  a  va  2s  .  c  o  m

    } else {
        RouteInfoActivity.start(getActivity(), routeId);
    }
}

From source file:com.emuneee.nctrafficcams.ui.adapters.DefaultCamerasAdapter.java

public Camera getCamera(int position) {
    Camera trafficCamera = null;//from w  ww . java 2s .co  m
    Cursor cursor = getCursor();
    int oldPos = cursor.getPosition();
    if (cursor.moveToPosition(position)) {
        trafficCamera = CameraDBHelper.cursorToCamera(cursor);
    }
    cursor.moveToPosition(oldPos);
    return trafficCamera;
}