Example usage for android.database Cursor getPosition

List of usage examples for android.database Cursor getPosition

Introduction

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

Prototype

int getPosition();

Source Link

Document

Returns the current position of the cursor in the row set.

Usage

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

@Override
public ArrayList<Camera> getCameras() {
    Cursor cursor = getCursor();
    int oldPos = cursor.getPosition();
    ArrayList<Camera> cameras = CameraDBHelper.cursorToCameras(cursor);
    cursor.moveToPosition(oldPos);//from   ww w  .  ja  va  2 s .co  m
    return cameras;
}

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

public Camera getCamera(int position) {
    Camera trafficCamera = null;/*from   w  w w. j a v a2s. c  om*/
    Cursor cursor = getCursor();
    int oldPos = cursor.getPosition();
    if (cursor.moveToPosition(position)) {
        trafficCamera = CameraDBHelper.cursorToCamera(cursor);
    }
    cursor.moveToPosition(oldPos);
    return trafficCamera;
}

From source file:com.espian.ticktock.TitleCursorPagerAdapter.java

@Override
public void swapCursor(Cursor c) {
    mTitles.clear();//from   w w  w  .  j  a  v a 2s  .  c o m
    while (c.moveToNext()) {
        mTitles.put(c.getPosition(), c.getString(1));
    }
    c.moveToFirst();
    super.swapCursor(c);
}

From source file:com.akhbulatov.wordkeeper.adapter.WordAdapter.java

@Override
public void onBindViewHolder(WordViewHolder viewHolder, Cursor cursor) {
    viewHolder.bind(cursor, isSelected(cursor.getPosition()), mListener);
}

From source file:at.wada811.gammacorrection.MainActivity.java

private Bitmap loadBitmap(Cursor cursor) {
    LogUtils.d("Position: " + cursor.getPosition());
    String filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA));
    LogUtils.d(filePath);//from w ww .  ja  va2s.  c o  m
    Bitmap bitmap = BitmapUtils.createBitmapFromFile(filePath, 640, 480);
    return bitmap;
}

From source file:de.hska.iam.presentationapp.fragments.adapters.ThumbnailAdapter.java

private void restoreViewSelection(final View view, final Cursor cursor) {
    int position = cursor.getPosition();
    if (isItemPositionSelected(position)) {
        selectView(view);//from w  w w  .ja v  a 2s.co  m
    } else {
        deselectView(view);
    }
}

From source file:com.bttendance.adapter.kit.InstantCursorAdapter.java

/**
 * {@inheritDoc}/*from  w  w  w.  j  av a2  s.  c o  m*/
 */
@Override
public final void bindView(final View view, final Context context, final Cursor cursor) {
    T instance = getInstance(cursor);
    mInstantAdapterCore.bindToView(null, view, instance, cursor.getPosition());
}

From source file:de.hska.iam.presentationapp.fragments.adapters.ThumbnailAdapter.java

@Override
public Media getItem(final int position) {
    Cursor cursor = getCursor();
    int oldPosition = cursor.getPosition();
    cursor.moveToPosition(position);/*  www.  j a v  a2 s .  c  om*/
    Media media = helper.getMedia(cursor);
    cursor.moveToPosition(oldPosition);
    return media;
}

From source file:org.deafsapps.sordomartinezpabloluismarspics.util.MyListAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    if (cursor != null) {
        final int position = cursor.getPosition();

        MyListAdapterViewHolder viewHolder = (MyListAdapterViewHolder) view.getTag();

        viewHolder.getmTextViewDate().setText(
                cursor.getString(cursor.getColumnIndex(MarsPicsContract.PicItemEntry.COLUMN_ITEM_DATE)));
        viewHolder.getmTextViewCameraFullName().setText(cursor
                .getString(cursor.getColumnIndex(MarsPicsContract.PicItemEntry.COLUMN_ITEM_CAMERA_FULL_NAME)));
        Picasso.with(context)//from   w w  w. ja va 2 s . c  o  m
                .load(cursor
                        .getString(cursor.getColumnIndex(MarsPicsContract.PicItemEntry.COLUMN_ITEM_IMAGE_LINK)))
                .into(viewHolder.getmImageViewImageLink());

        boolean isOddRow = (position % 2) == 0; // positions are zero-indexed
        if (isOddRow) {
            view.setBackground(ContextCompat.getDrawable(context, R.drawable.bg_odd_key));
        }
    }
}

From source file:at.wada811.gammacorrection.MainActivity.java

private void initCursorLoader() {
    getSupportLoaderManager().initLoader(0, null, new LoaderCallbacks<Cursor>() {

        @Override//from w w w. j a va 2s .co  m
        public Loader<Cursor> onCreateLoader(int id, Bundle data) {
            Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            return new CursorLoader(self, uri, null, null, null, null);
        }

        @Override
        public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
            LogUtils.d("Position: " + cursor.getPosition());
            boolean moveToFirst = cursor.moveToFirst();
            LogUtils.d("moveToFirst: " + moveToFirst);
            LogUtils.d("Position: " + cursor.getPosition());
            cursor.moveToNext();
            mBitmap = loadBitmap(cursor);
            mImageView.setImageBitmap(mBitmap);
        }

        @Override
        public void onLoaderReset(Loader<Cursor> loader) {

        }
    });
}