List of usage examples for android.database Cursor getPosition
int getPosition();
From source file:net.etuldan.sparss.adapter.FiltersCursorAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { TextView isAcceptRuleTextView = (TextView) view.findViewById(android.R.id.text1); TextView filterTextTextView = (TextView) view.findViewById(android.R.id.text2); TextView isAppliedToTitleTextView = (TextView) view.findViewById(R.id.text3); if (cursor.getPosition() == mSelectedFilter) { view.setBackgroundResource(//from w w w.ja v a 2s .c o m PrefUtils.getBoolean(PrefUtils.LIGHT_THEME, true) ? R.color.light_accent_color : R.color.dark_accent_color); } else { view.setBackgroundResource(android.R.color.transparent); } boolean isAcceptRule = cursor.getInt(mIsAcceptRulePosition) == 1; isAcceptRuleTextView.setText(isAcceptRule ? R.string.accept : R.string.reject); isAcceptRuleTextView.setTextColor(isAcceptRule ? ContextCompat.getColor(context, R.color.green) : ContextCompat.getColor(context, R.color.red)); filterTextTextView.setText(cursor.getString(mFilterTextColumnPosition)); isAppliedToTitleTextView .setText(cursor.getInt(mIsAppliedToTitleColumnPosition) == 1 ? R.string.filter_apply_to_title : R.string.filter_apply_to_content); }
From source file:com.android.ex.chips.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(Queries.Query.NAME)); display.setVisibility(View.VISIBLE); byte[] photoBytes = mPhotoCacheMap.get(entry.getPhotoThumbnailUri()); if (photoBytes != null && imageView != null) { Bitmap photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length); imageView.setImageBitmap(photo); } else {/*from www. java 2 s. c o m*/ imageView.setImageResource(R.drawable.ic_contact_picture); if (entry.getPhotoThumbnailUri() != null) fetchPhotoAsync(entry, entry.getPhotoThumbnailUri()); } imageView.setVisibility(View.VISIBLE); } else { display.setVisibility(View.GONE); imageView.setVisibility(View.GONE); } TextView destination = (TextView) view.findViewById(android.R.id.text1); destination.setText(cursor.getString(Queries.Query.DESTINATION)); TextView destinationType = (TextView) view.findViewById(android.R.id.text2); if (destinationType != null) { destinationType.setText( mQuery.getTypeLabel(context.getResources(), cursor.getInt(Queries.Query.DESTINATION_TYPE), cursor.getString(Queries.Query.DESTINATION_LABEL)).toString().toUpperCase()); } }
From source file:com.cattle.adapters.UserPhotosViewPagerAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { final PhotoUpload upload = MediaStoreCursorHelper .photosCursorToSelection(MediaStoreCursorHelper.MEDIA_STORE_CONTENT_URI, cursor); PhotoTagItemLayout view = new PhotoTagItemLayout(mContext, mController, upload, mFriendPickRequestListener); view.setPosition(cursor.getPosition()); if (null != upload) { upload.setFaceDetectionListener(view); MultiTouchImageView imageView = view.getImageView(); imageView.requestFullSize(upload, true, null); imageView.setSingleTapListener(mTapListener); }/*from w w w . j a v a 2s.co m*/ return view; }
From source file:net.news.inrss.adapter.FiltersCursorAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { TextView isAcceptRuleTextView = (TextView) view.findViewById(android.R.id.text1); TextView filterTextTextView = (TextView) view.findViewById(android.R.id.text2); TextView isAppliedToTitleTextView = (TextView) view.findViewById(R.id.text3); if (cursor.getPosition() == mSelectedFilter) { view.setBackgroundResource(/*from w ww . ja va 2 s.c o m*/ PrefUtils.getBoolean(PrefUtils.LIGHT_THEME, true) ? R.color.light_accent_color : R.color.dark_accent_color); } else { view.setBackgroundResource(android.R.color.transparent); } boolean isAcceptRule = cursor.getInt(mIsAcceptRulePosition) == 1; isAcceptRuleTextView.setText(isAcceptRule ? R.string.accept : R.string.reject); isAcceptRuleTextView.setTextColor(isAcceptRule ? ContextCompat.getColor(context, R.color.green) : ContextCompat.getColor(context, R.color.red)); filterTextTextView.setText(cursor.getString(mFilterTextColumnPosition)); isAppliedToTitleTextView .setText(cursor.getInt(mIsAppliedToTitleColumnPosition) == 1 ? R.string.filter_apply_to_title : R.string.filter_apply_to_content); Activity mActivity = (context instanceof Activity) ? (Activity) context : null; if (mActivity != null) { if (!isZero) { mActivity.findViewById(R.id.empty).setVisibility(View.GONE); } else { mActivity.findViewById(R.id.empty).setVisibility(View.VISIBLE); } } }
From source file:com.getchute.android.photopickerplus.ui.adapter.BaseCursorAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ViewHolder holder = (ViewHolder) view.getTag(); String path = cursor.getString(dataIndex); holder.imageViewTick.setTag(path);/*from w w w . j a va 2 s .com*/ if (shouldLoadImages) { loadImageView(holder.imageViewThumb, cursor); } if (tick.containsKey(cursor.getPosition())) { holder.imageViewTick.setVisibility(View.VISIBLE); holder.viewSelect.setVisibility(View.VISIBLE); view.setBackgroundColor(context.getResources().getColor(R.color.sky_blue)); } else { holder.imageViewTick.setVisibility(View.GONE); holder.viewSelect.setVisibility(View.GONE); view.setBackgroundColor(context.getResources().getColor(R.color.gray_light)); } holder.imageViewVideo.setVisibility(View.VISIBLE); setViewClickListener(view, path, cursor.getPosition()); setPlayButtonVisibility(holder.imageViewVideo); }
From source file:com.money.manager.ex.investment.StocksCursorAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { // take a holder StocksDataViewHolder holder = (StocksDataViewHolder) view.getTag(); // header index int accountId = cursor.getInt(cursor.getColumnIndex(StockFields.HELDAT)); if (!mHeadersAccountIndex.containsKey(accountId)) { mHeadersAccountIndex.put(accountId, cursor.getPosition()); }/*from w w w . jav a2 s . c o m*/ // symbol String symbol = cursor.getString(cursor.getColumnIndex(StockFields.SYMBOL)); holder.symbolTextView.setText(symbol); // name String name = cursor.getString(cursor.getColumnIndex(StockFields.STOCKNAME)); holder.nameTextView.setText(name); // price String price = cursor.getString(cursor.getColumnIndex(StockFields.CURRENTPRICE)); holder.priceTextView.setText(price); // check if item is checked if (mCheckedPosition.get(cursor.getPosition(), false)) { view.setBackgroundResource(R.color.material_green_100); } else { view.setBackgroundResource(android.R.color.transparent); } }
From source file:com.rsegismont.androlife.programlist.FragmentListProgrammes.java
private void setSelection(long date) { int index = -1; final Cursor cursor = getCursor(); final int columnDateIndex = cursor.getColumnIndex(DatabaseColumn.DATE_UTC.stringValue); final int initialPosition = cursor.getPosition(); for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i);/* ww w.ja v a 2 s . co m*/ if (date == cursor.getLong(columnDateIndex)) { index = i; break; } } if (initialPosition >= 0) cursor.moveToPosition(initialPosition); final int finalIndex = index; try { getListView().post(new Runnable() { @Override public void run() { getListView().setItemChecked(finalIndex, true); getListView().setSelectionFromTop(finalIndex, 0); } }); } catch (Throwable e) { } }
From source file:com.ultramegasoft.flavordex2.widget.EntryListAdapter.java
@Override public Cursor swapCursor(Cursor newCursor) { mItemPositions.clear();// w w w.j a v a 2 s. c o m if (newCursor != null) { while (newCursor.moveToNext()) { mItemPositions.put(newCursor.getLong(newCursor.getColumnIndex(Tables.Entries._ID)), newCursor.getPosition()); } } return super.swapCursor(newCursor); }
From source file:com.money.manager.ex.investment.PortfolioCursorAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { // take a holder PortfolioItemDataViewHolder holder = (PortfolioItemDataViewHolder) view.getTag(); // header index int accountId = cursor.getInt(cursor.getColumnIndex(StockFields.HELDAT)); if (!mHeadersAccountIndex.containsKey(accountId)) { mHeadersAccountIndex.put(accountId, cursor.getPosition()); }//from w w w . j ava 2 s . c o m // symbol String symbol = cursor.getString(cursor.getColumnIndex(StockFields.SYMBOL)); holder.symbolTextView.setText(symbol); // number of shares String numberOfShares = cursor.getString(cursor.getColumnIndex(StockFields.NUMSHARES)); holder.numSharesView.setText(numberOfShares); // price String price = cursor.getString(cursor.getColumnIndex(StockFields.CURRENTPRICE)); holder.priceTextView.setText(price); // check if item is checked if (mCheckedPosition.get(cursor.getPosition(), false)) { view.setBackgroundResource(R.color.material_green_100); } else { view.setBackgroundResource(android.R.color.transparent); } }
From source file:com.udacity.movietimes.adapter.MovieDetailAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { // Choose the layout type int viewType = getItemViewType(cursor.getPosition()); int layoutId = -1; View view = null;// w w w . ja va2 s . c om switch (viewType) { case VIEW_TYPE_MOVIE_BODY: { layoutId = R.layout.movie_fragment_movie; view = LayoutInflater.from(context).inflate(layoutId, parent, false); ViewHolder viewHolder = new MovieViewHolder(view); view.setTag(viewHolder); break; } case VIEW_TYPE_MOVIE_REVIEW: { layoutId = R.layout.movie_fragment_review; view = LayoutInflater.from(context).inflate(layoutId, parent, false); ViewHolder viewHolder = new ReviewVeiwHolder(view); view.setTag(viewHolder); break; } case VIEW_TYPE_MOVIE_TRAILER: { layoutId = R.layout.movie_fragment_trailer; view = LayoutInflater.from(context).inflate(layoutId, parent, false); ViewHolder viewHolder = new TrailerVeiwHolder(view); view.setTag(viewHolder); break; } } return view; }