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.granita.tasks.utils.ExpandableGroupDescriptorAdapter.java

@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
    reloadGroup(groupCursor.getPosition());
    return null;
}

From source file:p1.nd.khan.jubair.mohammadd.popularmovies.adapter.MovieAdapter.java

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    View view = null;/*  w w w . java 2 s .c  om*/
    int viewType = getItemViewType(cursor.getPosition());
    switch (viewType) {
    case MOVIE_LIST:
        int layoutId = R.layout.list_item_movie_poster;
        view = LayoutInflater.from(context).inflate(layoutId, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        view.setTag(viewHolder);
        break;
    }
    return view;
}

From source file:com.google.android.demos.jamendo.widget.TrackListAdapter.java

private void bindTrackNumber(View view, Cursor cursor) {
    TextView textView = (TextView) view.findViewById(R.id.jamendo_track_number);
    textView.setText(String.valueOf(cursor.getPosition() + 1));
}

From source file:net.naonedbus.widget.adapter.CursorSectionAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    bindSectionHeader(view, cursor.getPosition());
}

From source file:com.jackie.sunshine.app.ForecastAdapter.java

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    int viewType = getItemViewType(cursor.getPosition());
    int layoutId;
    if (viewType == VIEW_TYPE_TODAY) {
        layoutId = R.layout.list_item_forecast_today;
    } else {/*from  w  w w. ja v a  2s.co  m*/
        layoutId = R.layout.list_item_forecast;
    }
    View view = LayoutInflater.from(context).inflate(layoutId, parent, false);
    ViewHolder viewHolder = new ViewHolder(view);
    view.setTag(viewHolder);

    return view;
}

From source file:li.barter.adapters.ChatDetailAdapter.java

@Override
public View newView(final Context context, final Cursor cursor, final ViewGroup parent) {

    final int viewType = getItemViewType(cursor.getPosition());
    View view = null;/* w  w w . j av a2s  .  c om*/
    if (viewType == INCOMING_MESSAGE) {
        view = LayoutInflater.from(context).inflate(R.layout.layout_incoming_chat, parent, false);
        view.setTag(R.id.chat_ack, view.findViewById(R.id.chat_ack));
    } else if (viewType == OUTGOING_MESSAGE) {
        view = LayoutInflater.from(context).inflate(R.layout.layout_outgoing_chat, parent, false);
        view.setTag(R.id.chat_ack, view.findViewById(R.id.chat_ack));
    }

    view.setTag(R.id.image_user, view.findViewById(R.id.image_user));
    view.setTag(R.id.text_chat_message, view.findViewById(R.id.text_chat_message));
    return view;
}

From source file:com.fede.Utilities.GeneralUtils.java

public static String[] getContactNumbers(String contact, Context c) throws NameNotFoundException {
    // Find a contact using a partial name match
    Uri lookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, contact);
    Cursor idCursor = c.getContentResolver().query(lookupUri, null, null, null, null);
    String id = null;// ww w  .j ava  2 s  . c  om
    if (idCursor.moveToFirst()) { // I try with the first record
        int idIdx = idCursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID);
        id = idCursor.getString(idIdx);

    }
    idCursor.close();

    if (id == null)
        throw new NameNotFoundException(c.getString(R.string.name_not_found));

    // Return all the contact details of type PHONE for the contact we found

    String where = ContactsContract.Data.CONTACT_ID + " = " + id + " AND " + ContactsContract.Data.MIMETYPE
            + " = '" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "'";

    Cursor dataCursor = c.getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, where, null,
            null);
    // Use the convenience properties to get the index of the columns
    int nameIdx = dataCursor.getColumnIndexOrThrow(ContactsContract.Data.DISPLAY_NAME);
    int phoneIdx = dataCursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER);

    String[] result = new String[dataCursor.getCount()];

    if (dataCursor.getCount() == 0)
        throw new NameNotFoundException(c.getString(R.string.name_not_valid_numbers));

    if (dataCursor.moveToFirst())
        do {
            // Extract the name.
            String name = dataCursor.getString(nameIdx);
            // Extract the phone number.
            String number = dataCursor.getString(phoneIdx);
            int position = dataCursor.getPosition();
            if (position == 0) // I put the name only in the first record to save space
                result[position] = name + " (" + number + ")";
            else
                result[position] = " (" + number + ")";

        } while (dataCursor.moveToNext());
    dataCursor.close();
    return result;

}

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

private Bitmap loadBitmap(Cursor cursor) {
    LogUtils.d("Position: " + cursor.getPosition());
    String filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA));
    //        int orientation = getOrientationFromExif(filePath);
    //        LogUtils.d("orientation: " + orientation);
    LogUtils.d(filePath);//from  ww  w.  j ava  2  s .c o m
    Bitmap bitmap = BitmapUtils.createBitmapFromFile(filePath);
    //        bitmap = BitmapUtils.rotate(bitmap, orientation);
    return bitmap;
}

From source file:org.mariotaku.twidere.adapter.AccountsAdapter.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    final int color = cursor.getInt(mUserColorIdx);
    final int position = cursor.getPosition();
    final AccountViewHolder holder = (AccountViewHolder) view.getTag();
    holder.screen_name.setText("@" + cursor.getString(mScreenNameIdx));
    holder.checkbox.setVisibility(mMultiSelectEnabled ? View.VISIBLE : View.GONE);
    holder.checkbox.setChecked(mCheckedItems.get(position));
    holder.setAccountColor(color);/*ww w. ja  v  a2s. c  om*/
    holder.setIsDefault(mDefaultAccountId != -1 && mDefaultAccountId == cursor.getLong(mAccountIdIdx));
    if (mDisplayProfileImage) {
        final String profile_image_url_string = cursor.getString(mProfileImageIdx);
        if (mDisplayHiResProfileImage) {
            mProfileImageLoader.displayImage(holder.profile_image,
                    getBiggerTwitterProfileImage(profile_image_url_string));
        } else {
            mProfileImageLoader.displayImage(holder.profile_image, profile_image_url_string);
        }
    } else {
        holder.profile_image.setImageResource(R.drawable.ic_profile_image_default);
    }
    super.bindView(view, context, cursor);
}

From source file:com.DGSD.Teexter.UI.Recipient.RecipientAlternatesAdapter.java

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

    TextView display = (TextView) view.findViewById(android.R.id.title);
    ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
    RecipientEntry entry = getRecipientEntry(position);
    if (position == 0) {
        display.setText(cursor.getString(EmailQuery.NAME));
        display.setVisibility(View.VISIBLE);
        imageView.setImageURI(entry.getPhotoThumbnailUri());
        imageView.setVisibility(View.VISIBLE);
    } else {/*from   w w  w .  ja  v  a  2  s. c  o  m*/
        display.setVisibility(View.GONE);
        imageView.setVisibility(View.GONE);
    }
    TextView destination = (TextView) view.findViewById(android.R.id.text1);
    destination.setText(cursor.getString(EmailQuery.ADDRESS));

    TextView destinationType = (TextView) view.findViewById(android.R.id.text2);
    if (destinationType != null) {
        destinationType
                .setText(Email.getTypeLabel(context.getResources(), cursor.getInt(EmailQuery.ADDRESS_TYPE),
                        cursor.getString(EmailQuery.ADDRESS_LABEL)).toString().toUpperCase());
    }
}