List of usage examples for android.database Cursor getPosition
int getPosition();
From source file:org.adawaycn.util.HostsSourcesCursorAdapter.java
/** * Bind cursor to view using the checkboxes */// w ww. j a v a 2 s . c om @Override public void bindView(View v, Context context, Cursor cursor) { CheckBox cBox = (CheckBox) v.findViewById(R.id.checkbox_list_two_checkbox); TextView hostnameTextView = (TextView) v.findViewById(R.id.checkbox_list_two_text); TextView lastModifiedTextView = (TextView) v.findViewById(R.id.checkbox_list_two_subtext); if (cBox != null) { // bind cursor position to tag of list item int cursorPosition = cursor.getPosition(); cBox.setTag("checkbox_" + cursorPosition); hostnameTextView.setTag("url_" + cursorPosition); lastModifiedTextView.setTag("last_modified_" + cursorPosition); int enabledCol = cursor.getColumnIndexOrThrow(HostsSources.ENABLED); String enabled = cursor.getString(enabledCol); if (Integer.parseInt(enabled) == 1) { cBox.setChecked(true); } else { cBox.setChecked(false); } // set hostname int urlCol = cursor.getColumnIndex(HostsSources.URL); String url = cursor.getString(urlCol); hostnameTextView.setText(url); // set last modified int lastModifiedLocalCol = cursor.getColumnIndexOrThrow(HostsSources.LAST_MODIFIED_LOCAL); long lastModifiedLocal = cursor.getLong(lastModifiedLocalCol); int lastModifiedOnlineCol = cursor.getColumnIndexOrThrow(HostsSources.LAST_MODIFIED_ONLINE); long lastModifiedOnline = cursor.getLong(lastModifiedOnlineCol); lastModifiedTextView.setText(context.getString(R.string.hosts_last_modified_local) + " " + org.adawaycn.util.DateUtils.longToDateString(context, lastModifiedLocal) + ", " + context.getString(R.string.hosts_last_modified_online) + " " + DateUtils.longToDateString(context, lastModifiedOnline)); } }
From source file:com.jackie.sunshine.app.ForecastAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ViewHolder viewHolder = (ViewHolder) view.getTag(); // Read weather icon ID from cursor int weatherId = cursor.getInt(ForecastFragment.COL_WEATHER_CONDITION_ID); // Use placeholder image for now @DrawableRes// w w w . j av a 2 s . c om int iconRes = R.drawable.art_clear; switch (getItemViewType(cursor.getPosition())) { case VIEW_TYPE_TODAY: iconRes = Utility.getArtResourceForWeatherCondition(weatherId); break; case VIEW_TYPE_FUTURE_DAY: iconRes = Utility.getIconResourceForWeatherCondition(weatherId); break; } viewHolder.iconView.setImageResource(iconRes); // Read date from cursor long dataInMillis = cursor.getLong(ForecastFragment.COL_WEATHER_DATE); // Find TextView and set formatted date on it viewHolder.dateView.setText(Utility.getFriendlyDayString(context, dataInMillis)); // Read weather forecast from cursor String description = cursor.getString(ForecastFragment.COL_WEATHER_DESC); // Find TextView and set weather forecast on it viewHolder.descriptionView.setText(description); viewHolder.iconView.setContentDescription(description); // Read user preference for metric or imperial temperature units boolean isMetric = Utility.isMetric(context); // Read high temperature from cursor double high = cursor.getDouble(ForecastFragment.COL_WEATHER_MAX_TEMP); viewHolder.highView.setText(Utility.formatTemperature(context, high)); // Read low temperature from cursor double low = cursor.getDouble(ForecastFragment.COL_WEATHER_MIN_TEMP); viewHolder.lowView.setText(Utility.formatTemperature(context, low)); }
From source file:com.conferenceengineer.android.iosched.ui.TracksAdapter.java
private void updateSpecialItemPositions(Cursor cursor) { mFirstLevel2CursorPosition = -1;/*from w ww.j av a2 s.c om*/ if (cursor != null && !cursor.isClosed()) { cursor.moveToFirst(); while (cursor.moveToNext()) { if (cursor.getInt(TracksQuery.TRACK_LEVEL) == 2) { mFirstLevel2CursorPosition = cursor.getPosition(); break; } } } }
From source file:com.socialdisasters.other.MessageAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { if (view instanceof MessageItem) { long msgId = cursor.getLong(mColumnsMap.mColumnId); Message msg = getCachedMessage(msgId, cursor); if (msg != null) { MessageItem mli = (MessageItem) view; int position = cursor.getPosition(); mli.bind(msg, position);/* ww w. ja v a 2s.c o m*/ } } }
From source file:tw.idv.palatis.danboorugallery.siteapi.ShimmieAPI.java
@Override public Post getPostFromCursor(Host host, Cursor post_cursor, Cursor tags_cursor) { String[] tags;//from ww w . j a va 2s . c om if (tags_cursor != null) { tags_cursor.moveToPosition(-1); tags = new String[tags_cursor.getCount()]; while (tags_cursor.moveToNext()) tags[tags_cursor.getPosition()] = tags_cursor.getString(PostTagsView.INDEX_KEY_POST_TAG_TAG_NAME); } else tags = new String[0]; return new ShimmiePost(host, post_cursor.getInt(PostsTable.INDEX_POST_POST_ID), post_cursor.getInt(PostsTable.INDEX_POST_IMAGE_WIDTH), post_cursor.getInt(PostsTable.INDEX_POST_IMAGE_HEIGHT), new Date(post_cursor.getLong(PostsTable.INDEX_POST_CREATED_AT)), new Date(post_cursor.getLong(PostsTable.INDEX_POST_UPDATED_AT)), post_cursor.getInt(PostsTable.INDEX_POST_FILE_SIZE), post_cursor.getString(PostsTable.INDEX_POST_FILE_URL), post_cursor.getString(PostsTable.INDEX_POST_LARGE_FILE_URL), post_cursor.getString(PostsTable.INDEX_POST_PREVIEW_FILE_URL), tags, post_cursor.getString(PostsTable.INDEX_POST_RATING), post_cursor.getString(PostsTable.INDEX_POST_EXTRA_INFO)); }
From source file:com.socialdisasters.other.RosterAdapter.java
@SuppressLint("NewApi") @Override//from w w w . j a v a2 s . com public void bindView(View view, Context context, Cursor cursor) { if (view instanceof RosterItem) { long buddyId = cursor.getLong(mColumnsMap.mColumnId); Buddy buddy = getCachedBuddy(buddyId, cursor); if (buddy != null) { RosterItem bli = (RosterItem) view; int position = cursor.getPosition(); bli.bind(buddy, position); if (buddy.getId().equals(mSelectedBuddyId)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { bli.setActivated(true); } } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { bli.setActivated(false); } } } } }
From source file:me.futuretechnology.util.ui.AltCursorAdapter.java
@Override public View newDropDownView(Context context, Cursor cursor, ViewGroup parent) { int type = getItemViewType(cursor.getPosition()); // Log.i("ACA", "getItemViewType: " + type + ", position: " + cursor.getPosition()); return mInflater.inflate(mDropDownLayouts[type], parent, false); }
From source file:me.futuretechnology.util.ui.AltCursorAdapter.java
/** * Inflates view(s) from the specified XML file. * * @see android.widget.CursorAdapter#newView(android.content.Context, android.database.Cursor, ViewGroup) */// w w w . jav a2 s .com @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { int type = getItemViewType(cursor.getPosition()); // Log.i("ACA", "getItemViewType: " + type + ", position: " + cursor.getPosition()); return mInflater.inflate(mLayouts[type], parent, false); }
From source file:p1.nd.khan.jubair.mohammadd.popularmovies.adapter.MovieDetailsAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { View view = null;/*from w w w . j av a 2 s . c o m*/ int viewType = getItemViewType(cursor.getPosition()); switch (viewType) { case MOVIE: view = LayoutInflater.from(context).inflate(R.layout.fragment_movie_detail, parent, false); MovieHolder movieHolder = new MovieHolder(view); view.setTag(movieHolder); mFab = movieHolder.mFavoriteFab; mTrailerIcon = movieHolder.mPlayTrailer; break; case TRAILER: view = LayoutInflater.from(context).inflate(R.layout.list_row_trailer, parent, false); TrailerHolder trailerHolder = new TrailerHolder(view); view.setTag(trailerHolder); break; case REVIEW: view = LayoutInflater.from(context).inflate(R.layout.list_row_review, parent, false); ReviewHolder reviewHolder = new ReviewHolder(view); view.setTag(reviewHolder); } return view; }
From source file:com.nadmm.airports.utils.SectionedCursorAdapter.java
private void setSections() { Cursor c = getCursor(); if (c.moveToFirst()) { ArrayList<Section> sections = new ArrayList<Section>(); String last = ""; int offset = 0; // offset positions for the headers we're adding do {/*from w w w . j a v a2 s.c o m*/ String cur = getSectionName(); if (!cur.contentEquals(last)) { Section section = new Section(c.getPosition(), cur); section.sectionedPosition = section.firstPosition + offset; mSections.append(section.sectionedPosition, section); ++offset; last = cur; } } while (c.moveToNext()); } }