List of usage examples for android.database Cursor getFloat
float getFloat(int columnIndex);
From source file:org.ohmage.reminders.types.location.LocTrigService.java
private void populateLocList() { mLocList.clear();/*from w w w.j av a2 s . c o m*/ LocTrigDB db = new LocTrigDB(this); db.open(); Cursor c = db.getAllLocations(); Log.v(TAG, "LocTrigService: populating loc list with " + c.getCount() + " locations"); if (c.moveToFirst()) { do { int latE6 = c.getInt(c.getColumnIndexOrThrow(LocTrigDB.KEY_LAT)); int longE6 = c.getInt(c.getColumnIndexOrThrow(LocTrigDB.KEY_LONG)); int cId = c.getInt(c.getColumnIndexOrThrow(LocTrigDB.KEY_CATEGORY_ID)); float r = c.getFloat(c.getColumnIndexOrThrow(LocTrigDB.KEY_RADIUS)); Log.v(TAG, "LocTrigService: adding to the list the location: " + latE6 + ", " + longE6 + ", category id = " + cId + ", radius = " + r); mLocList.add(new LocListItem(latE6, longE6, cId, r)); } while (c.moveToNext()); } c.close(); db.close(); }
From source file:com.djkong.android.greatweather.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);//ww w . j ava 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); 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 www. j a v 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.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 www .j a v 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, 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:org.ohmage.triggers.types.location.LocTrigService.java
private void populateLocList() { mLocList.clear();/*from w ww . j a va2 s . com*/ LocTrigDB db = new LocTrigDB(this); db.open(); Cursor c = db.getAllLocations(); Log.i(DEBUG_TAG, "LocTrigService: populating loc list with " + c.getCount() + " locations"); if (c.moveToFirst()) { do { int latE6 = c.getInt(c.getColumnIndexOrThrow(LocTrigDB.KEY_LAT)); int longE6 = c.getInt(c.getColumnIndexOrThrow(LocTrigDB.KEY_LONG)); int cId = c.getInt(c.getColumnIndexOrThrow(LocTrigDB.KEY_CATEGORY_ID)); float r = c.getFloat(c.getColumnIndexOrThrow(LocTrigDB.KEY_RADIUS)); Log.i(DEBUG_TAG, "LocTrigService: adding to the list the location: " + latE6 + ", " + longE6 + ", category id = " + cId + ", radius = " + r); mLocList.add(new LocListItem(latE6, longE6, cId, r)); } while (c.moveToNext()); } c.close(); db.close(); }
From source file:com.example.asaf.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(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID)); // Use weather art image mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT)); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);//from ww w . ja v a2s . co m // Read description from cursor and update view String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC)); mDescriptionView.setText(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP)); String highString = Utility.formatTemperature(getActivity(), high, isMetric); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP)); String lowString = Utility.formatTemperature(getActivity(), low, isMetric); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY)); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED)); float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES)); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_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.robotodojo.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(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID)); int imageResource = Utility.getArtResourceForWeatherCondition(weatherId); mIconView.setImageResource(imageResource); // Read date from cursor and update views for day of week and date String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT)); String friendlyDateText = Utility.getDayName(getActivity(), date); String dateText = Utility.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);//from ww w. j a v a 2s . c om // Read description from cursor and update view String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC)); mDescriptionView.setText(description); // Read high temperature from cursor and update view boolean isMetric = Utility.isMetric(getActivity()); double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP)); String highString = Utility.formatTemperature(getActivity(), high, isMetric); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP)); String lowString = Utility.formatTemperature(getActivity(), low, isMetric); mLowTempView.setText(lowString); // Read humidity from cursor and update view float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY)); mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity)); // Read wind speed and direction from cursor and update view float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED)); float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES)); mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr)); // Read pressure from cursor and update view float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_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); Log.v(LOG_TAG, "Forecast String: " + mForecast); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:com.katamaditya.apps.weather4u.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(WeatherUtil.getArtResourceForWeatherCondition(weatherId)); // Read date from cursor and update views for day of week and date long date = data.getLong(COL_WEATHER_DATE); String friendlyDateText = WeatherUtil.getDayName(getActivity(), date); String dateText = WeatherUtil.getFormattedMonthDay(getActivity(), date); mFriendlyDateView.setText(friendlyDateText); mDateView.setText(dateText);//from ww w. ja v a2 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 = WeatherUtil.isMetric(getActivity()); double high = data.getDouble(COL_WEATHER_MAX_TEMP); String highString = WeatherUtil.formatTemperature(getActivity(), high); mHighTempView.setText(highString); // Read low temperature from cursor and update view double low = data.getDouble(COL_WEATHER_MIN_TEMP); String lowString = WeatherUtil.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(WeatherUtil.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.simonvt.cathode.ui.fragment.EpisodeFragment.java
private void updateEpisodeViews(final Cursor cursor) { if (cursor.moveToFirst()) { loaded = true;/*ww w.jav a2s. c o m*/ episodeTitle = cursor.getString(cursor.getColumnIndex(EpisodeColumns.TITLE)); title.setText(episodeTitle); overview.setText(cursor.getString(cursor.getColumnIndex(EpisodeColumns.OVERVIEW))); screenshot.setImage(cursor.getString(cursor.getColumnIndex(EpisodeColumns.SCREENSHOT))); firstAired.setText(DateUtils.millisToString(getActivity(), cursor.getLong(cursor.getColumnIndex(EpisodeColumns.FIRST_AIRED)), true)); season = cursor.getInt(cursor.getColumnIndex(EpisodeColumns.SEASON)); watched = cursor.getInt(cursor.getColumnIndex(EpisodeColumns.WATCHED)) == 1; collected = cursor.getInt(cursor.getColumnIndex(EpisodeColumns.IN_COLLECTION)) == 1; inWatchlist = cursor.getInt(cursor.getColumnIndex(EpisodeColumns.IN_WATCHLIST)) == 1; watching = cursor.getInt(cursor.getColumnIndex(EpisodeColumns.WATCHING)) == 1; checkedIn = cursor.getInt(cursor.getColumnIndex(EpisodeColumns.CHECKED_IN)) == 1; watchedView.setVisibility(watched ? View.VISIBLE : View.GONE); inCollectionView.setVisibility(collected ? View.VISIBLE : View.GONE); inWatchlistView.setVisibility(inWatchlist ? View.VISIBLE : View.GONE); currentRating = cursor.getInt(cursor.getColumnIndex(EpisodeColumns.USER_RATING)); final float ratingAll = cursor.getFloat(cursor.getColumnIndex(EpisodeColumns.RATING)); rating.setValue(ratingAll); setContentVisible(true); createMenu(toolbar); updateTitle(); } }
From source file:edu.cens.loci.provider.LociDbUtils.java
/** * //from www . java 2 s .co m * @param start * @param end * @param filter * @return */ public ArrayList<LociLocation> getTrack(long start, long end, int filter) { String[] columns = new String[] { Tracks._ID, Tracks.TIME, Tracks.LATITUDE, Tracks.LONGITUDE, Tracks.ALTITUDE, Tracks.SPEED, Tracks.BEARING, Tracks.ACCURACY }; String selection = Tracks.TIME + ">=" + start + " AND " + Tracks.TIME + " <= " + end; final SQLiteDatabase db = mDbHelper.getWritableDatabase(); Cursor cursor = db.query(Tables.TRACKS, columns, selection, null, null, null, null); ArrayList<LociLocation> track = new ArrayList<LociLocation>(); if (cursor.moveToFirst()) { do { LociLocation loc = new LociLocation(LocationManager.GPS_PROVIDER); loc.setTime(cursor.getLong(cursor.getColumnIndex(Tracks.TIME))); loc.setLatitude(cursor.getDouble(cursor.getColumnIndex(Tracks.LATITUDE))); loc.setLongitude(cursor.getDouble(cursor.getColumnIndex(Tracks.LONGITUDE))); loc.setAltitude(cursor.getDouble(cursor.getColumnIndex(Tracks.ALTITUDE))); loc.setSpeed(cursor.getFloat(cursor.getColumnIndex(Tracks.SPEED))); loc.setBearing(cursor.getFloat(cursor.getColumnIndex(Tracks.BEARING))); loc.setAccuracy(cursor.getFloat(cursor.getColumnIndex(Tracks.ACCURACY))); track.add(loc); } while (cursor.moveToNext()); } cursor.close(); return track; }