List of usage examples for android.database Cursor getDouble
double getDouble(int columnIndex);
From source file:info.staticfree.android.units.Units.java
@Override public boolean onContextItemSelected(MenuItem item) { final ContextMenuInfo ctxMenuInfo = item.getMenuInfo(); int position = history.getCount() - 1; if (ctxMenuInfo instanceof AdapterContextMenuInfo) { position = ((AdapterContextMenuInfo) ctxMenuInfo).position; }// www . j ava 2 s .c om final Uri itemUri = ContentUris.withAppendedId(HistoryEntry.CONTENT_URI, mHistoryAdapter.getItemId(position)); switch (item.getItemId()) { case MENU_COPY: { final CharSequence itemText = getEntryAsCharSequence(itemUri); final ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(itemText); Toast.makeText(this, getString(R.string.toast_copy, itemText), Toast.LENGTH_SHORT).show(); } break; case MENU_REEDIT: { setCurrentEntry(itemUri); setHistoryVisible(false); } break; case MENU_SEND: { final CharSequence itemText = getEntryAsCharSequence(itemUri); startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, itemText), getText(R.string.ctx_menu_send_title))); } break; case MENU_USE_RESULT: { final Cursor c = getContentResolver().query(itemUri, PROJECTION_LOAD_FROM_HISTORY, null, null, null); if (c.moveToFirst()) { final int resultCol = c.getColumnIndex(HistoryEntry._RESULT); setCurrentEntry((c.isNull(resultCol) ? "" : (c.getDouble(resultCol) + " ")) + c.getString(c.getColumnIndex(HistoryEntry._WANT)), ""); setHistoryVisible(false); } c.close(); } break; } return super.onContextItemSelected(item); }
From source file:com.syncedsynapse.kore2.ui.AlbumDetailsFragment.java
/** * Display the album details//from w ww. ja v a 2 s. c om * * @param cursor Cursor with the data */ private void displayAlbumDetails(Cursor cursor) { final Resources resources = getActivity().getResources(); cursor.moveToFirst(); albumTitle = cursor.getString(AlbumDetailsQuery.TITLE); albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST); mediaTitle.setText(albumTitle); mediaUndertitle.setText(albumDisplayArtist); int year = cursor.getInt(AlbumDetailsQuery.YEAR); String genres = cursor.getString(AlbumDetailsQuery.GENRE); String label = (year > 0) ? (!TextUtils.isEmpty(genres) ? genres + " | " + String.valueOf(year) : String.valueOf(year)) : genres; mediaYear.setText(label); double rating = cursor.getDouble(AlbumDetailsQuery.RATING); if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); mediaRating.setText(String.format("%01.01f", rating)); mediaMaxRating.setText(getString(R.string.max_rating_music)); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); } String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION); if (!TextUtils.isEmpty(description)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(description); final int maxLines = resources.getInteger(R.integer.description_max_lines); Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse }); final int iconCollapseResId = styledAttributes.getResourceId(0, R.drawable.ic_expand_less_white_24dp); final int iconExpandResId = styledAttributes.getResourceId(1, R.drawable.ic_expand_more_white_24dp); styledAttributes.recycle(); mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isDescriptionExpanded) { mediaDescription.setMaxLines(Integer.MAX_VALUE); mediaShowAll.setImageResource(iconExpandResId); } else { mediaDescription.setMaxLines(maxLines); mediaShowAll.setImageResource(iconCollapseResId); } isDescriptionExpanded = !isDescriptionExpanded; } }); } else { mediaDescriptionContainer.setVisibility(View.GONE); } // Images DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); String fanart = cursor.getString(AlbumDetailsQuery.FANART), poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height), artWidth = displayMetrics.widthPixels; if (!TextUtils.isEmpty(fanart)) { int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth); mediaPoster.setVisibility(View.VISIBLE); UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, albumTitle, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, fanart, mediaArt, artWidth, artHeight); } else { // No fanart, just present the poster mediaPoster.setVisibility(View.GONE); UIUtils.loadImageIntoImageview(hostManager, poster, mediaArt, artWidth, artHeight); // Reset padding int paddingLeft = mediaTitle.getPaddingRight(), paddingRight = mediaTitle.getPaddingRight(), paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom(); mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } }
From source file:vn.alovoice.sunshine.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); // Use placeholder Image //mIconView.setImageResource(R.drawable.ic_launcher); mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);/* w w w .j a v a 2 s. co m*/ // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(description); mIconView.setContentDescription(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(getActivity(), high); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(getActivity(), low); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure)); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:com.example.dickchang.sunshine.app.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); // Use weather art image mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);/*from w w w. j av a2 s . co m*/ // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(description); // For accessibility, add a content description to the icon field mIconView.setContentDescription(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(getActivity(), high); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(getActivity(), low); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure)); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:app.com.oz_heng.android.sunshine.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); // Use weather art image mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);//from w ww.j a v a 2 s . co m // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(description); // For accessibility, add a content description to the icon field mIconView.setContentDescription(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(getActivity(), high); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(getActivity(), low); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure)); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:com.vishalg.sunshine.app.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); // Use weather art image mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);//from ww w . j a va2s . c o m // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(description); //For accessibility, add a content description to the icon field mIconView.setContentDescription(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(getActivity(), high, isMetric); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(getActivity(), low, isMetric); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure)); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:com.example.kacyn.watchfacetest.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); // Use weather art image mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);/*from ww w . j av a 2s. c o m*/ // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(description); // For accessibility, add a content description to the icon field mIconView.setContentDescription(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(getActivity(), high, isMetric); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(getActivity(), low, isMetric); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure)); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:com.fulltoast.android.sunshine.app.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // Read weather condition ID from cursor int weatherId = data.getInt(COL_WEATHER_CONDITION_ID); // Use weather art image mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); //mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);//from w w w . ja v a 2 s . c om // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(description); // For accessibility, add a content description to the icon field mIconView.setContentDescription(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = Utility.formatTemperature(getActivity(), high); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = Utility.formatTemperature(getActivity(), low); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(COL_WEATHER_HUMIDITY); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED); float windDirStr = data.getFloat(COL_WEATHER_DEGREES); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(COL_WEATHER_PRESSURE); mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure)); // We still need this for the share intent mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:net.e_fas.oss.tabijiman.MapsActivity.java
public void setMarker(String cat) { Cursor cursor; MarkerOptions options;//from w w w.j a v a2s . c o m if (mMap != null) { if (cat.equals("frame")) { cursor = db.rawQuery("SELECT * FROM frame ORDER BY _id", null); cursor.moveToFirst(); while (cursor.moveToNext()) { options = new MarkerOptions(); LatLng location = new LatLng(cursor.getDouble(cursor.getColumnIndex("lat")), cursor.getDouble(cursor.getColumnIndex("lng"))); options.position(location); options.title(cursor.getString(cursor.getColumnIndex("name"))); BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.top_pin_flame); options.icon(icon); FrameMarkerOptions.add(options); FrameMarker.add(mMap.addMarker(options)); } cursor.close(); } else if (cat.equals("place")) { cursor = db.rawQuery("SELECT * FROM place ORDER BY _id", null); cursor.moveToFirst(); while (cursor.moveToNext()) { options = new MarkerOptions(); LatLng location = new LatLng(cursor.getDouble(cursor.getColumnIndex("lat")), cursor.getDouble(cursor.getColumnIndex("lng"))); options.position(location); options.title(cursor.getString(cursor.getColumnIndex("name"))); options.snippet(cursor.getString(cursor.getColumnIndex("address"))); BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.top_pin_info); options.icon(icon); PlaceMarkerOptions.add(options); PlaceMarker.add(mMap.addMarker(options)); } cursor.close(); } } else { print("mMap >> NULL"); } }
From source file:com.sf.tracem.db.DBManager.java
private List<MeasurementPoint> getMeasurementPoitsFrom(Cursor cursor) { List<MeasurementPoint> points = new ArrayList<MeasurementPoint>(); if (cursor.moveToFirst()) { Map<String, Integer> map = getColumnMap(cursor, MeasurementPoint.COLUMN_NAMES); do {//from w w w .ja v a2 s . co m MeasurementPoint point = new MeasurementPoint(); point.setAufnr(cursor.getString(map.get(MeasurementPoint.AUFNR))); point.setEqunr(cursor.getString(map.get(MeasurementPoint.EQUNR))); point.setPoint(cursor.getString(map.get(MeasurementPoint.POINT))); point.setRead(cursor.getDouble(map.get(MeasurementPoint.READ))); point.setUnit(cursor.getString(map.get(MeasurementPoint.UNIT))); point.setDescription(cursor.getString(map.get(MeasurementPoint.DESCRIPTION))); point.setNotes(cursor.getString(map.get(MeasurementPoint.NOTES))); point.setCommited(cursor.getInt(map.get(MeasurementPoint.COMMITED))); points.add(point); } while (cursor.moveToNext()); } return points; }