List of usage examples for android.database Cursor getDouble
double getDouble(int columnIndex);
From source file:com.gaba.alex.trafficincidents.Adapter.IncidentsAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { super.bindView(view, context, cursor); final int type = cursor.getInt(cursor.getColumnIndexOrThrow(IncidentsColumns.TYPE)); final int severity = cursor.getInt(cursor.getColumnIndexOrThrow(IncidentsColumns.SEVERITY)); final double lat = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.LAT)); final double lng = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.LNG)); final double toLat = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.TO_LAT)); final double toLng = cursor.getDouble(cursor.getColumnIndexOrThrow(IncidentsColumns.TO_LNG)); final long dateInMillis = Long .parseLong(cursor.getString(cursor.getColumnIndexOrThrow(IncidentsColumns.END_DATE))); final boolean roadClosed = Boolean .valueOf(cursor.getString(cursor.getColumnIndexOrThrow(IncidentsColumns.ROAD_CLOSED))); final String description = cursor.getString(cursor.getColumnIndexOrThrow(IncidentsColumns.DESCRIPTION)); TextView typeTextView = (TextView) view.findViewById(R.id.incident_type); if (typeTextView != null) { typeTextView.setText(Utility.getIncidentType(mContext, type)); }/* ww w .j a va 2s .c o m*/ TextView severityTextView = (TextView) view.findViewById(R.id.incident_severity); if (severityTextView != null) { severityTextView.setText(Utility.getIncidentSeverity(mContext, severity)); severityTextView.setTextColor(ContextCompat.getColor(mContext, Utility.getIncidentColor(severity))); } TextView roadClosedTextView = (TextView) view.findViewById(R.id.incident_road_closed); if (roadClosedTextView != null) { roadClosedTextView.setText(String.format("%s: ", mContext.getString(R.string.road_closed))); } TextView roadClosedContentTextView = (TextView) view.findViewById(R.id.incident_road_closed_content); if (roadClosedContentTextView != null) { roadClosedContentTextView .setText(roadClosed ? mContext.getString(R.string.yes) : mContext.getString(R.string.no)); roadClosedContentTextView.setTextColor(ContextCompat.getColor(mContext, roadClosed ? android.R.color.holo_red_light : android.R.color.holo_green_dark)); } TextView dateTextView = (TextView) view.findViewById(R.id.incident_end_date); if (dateTextView != null) { dateTextView.setText(String.format("%s: ", mContext.getString(R.string.estimated_end_date))); } TextView dateContentTextView = (TextView) view.findViewById(R.id.incident_end_date_content); if (dateContentTextView != null) { dateContentTextView.setText(DateFormat.getDateInstance().format(new Date(dateInMillis))); } TextView descriptionTextView = (TextView) view.findViewById(R.id.incident_description); if (descriptionTextView != null) { descriptionTextView.setText(String.format("%s: ", mContext.getString(R.string.local_description))); } TextView descriptionContentTextView = (TextView) view.findViewById(R.id.incident_description_content); if (descriptionContentTextView != null) { descriptionContentTextView.setText(description); } ImageView showOnMapImageView = (ImageView) view.findViewById(R.id.show_on_map_button); showOnMapImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = Utility.buildShowOnMapIntent(mContext, lat, lng, toLat, toLng, severity, description); if (intent.resolveActivity(mContext.getPackageManager()) != null) { mContext.startActivity(intent); } } }); ImageView shareImageView = (ImageView) view.findViewById(R.id.share_button); shareImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); String shareText = Utility.getIncidentType(mContext, type) + "\n\n" + mContext.getString(R.string.local_description) + ": " + description + "\n\n" + mContext.getString(R.string.severity) + ": " + Utility.getIncidentSeverity(mContext, severity) + "\n\n" + mContext.getString(R.string.road_closed) + ": " + (roadClosed ? mContext.getString(R.string.yes) : mContext.getString(R.string.no)) + "\n\n" + mContext.getString(R.string.provided_by) + ": " + mContext.getString(R.string.app_name); intent.putExtra(Intent.EXTRA_TEXT, shareText); if (intent.resolveActivity(mContext.getPackageManager()) != null) { mContext.startActivity(intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } } }); }
From source file:planets.position.NewLoc.java
/** * Loads location data into the fields.// w w w .j a v a2 s .c o m */ private void loadData() { Cursor locCur = cr.query(Uri.withAppendedPath(PlanetsDbProvider.LOCATION_URI, String.valueOf(0)), projection, null, null, null); locCur.moveToFirst(); latitude = locCur.getDouble(locCur.getColumnIndexOrThrow("lat")); if (latitude != -1.0) { newLatText.setText(String.format("%.8f", locCur.getDouble(locCur.getColumnIndexOrThrow("lat")))); newLongText.setText(String.format("%.8f", locCur.getDouble(locCur.getColumnIndexOrThrow("lng")))); newElevationText .setText(String.format("%.1f", locCur.getDouble(locCur.getColumnIndexOrThrow("elevation")))); offset = locCur.getDouble(locCur.getColumnIndexOrThrow("offset")); String off = ""; if (offset < 0) off += "-"; else if (offset > 0) off += "+"; int h = (int) Math.abs(offset); off += h + ":"; int m = (int) ((Math.abs(offset) - h) * 60); if (m > 0) off += m; else off += "00"; offsetButton.setText(off); } }
From source file:edu.asu.bscs.csiebler.waypointdatabase.Waypoint.java
/** * Constructor// w ww. j av a 2s.c o m * * @param cursor */ public Waypoint(Cursor cursor) { this.name = cursor.getString(0); this.address = cursor.getString(1); this.category = Category.valueOf(cursor.getString(2)); this.elevation = cursor.getDouble(3); this.latitude = cursor.getDouble(4); this.longitude = cursor.getDouble(5); }
From source file:com.yammy.meter.MainActivity.java
private void checkJarak() { double maxval; dbHelper = new MySQLHelper(getApplicationContext()); SQLiteDatabase jdb = dbHelper.getReadableDatabase(); Cursor cursor = jdb.rawQuery("SELECT maxlength FROM kendaraan WHERE _id=" + idkendaraan, null); if (cursor.moveToFirst()) { maxval = cursor.getDouble(0); double temp; temp = (totalJarakDitempuhKendaraan % maxval); //simple if, need 'mbengkel' data for details //cursor = jdb.rawQuery("SELECT jarak FROM latest_mbengkel WHERE id_kendaraan="+idkendaraan, null); if (temp >= maxval * 90 / 100) { showAlert();//w ww .ja v a 2 s. c om } } jdb.close(); }
From source file:cn.loveapple.client.android.database.impl.TemperatureDaoImpl.java
/** * //w w w . j a va2s .c o m * @param cursor * @return */ private TemperatureEntity getTemperatureEntity(Cursor cursor) { if (cursor.getCount() < 1) { return null; } TemperatureEntity result = new TemperatureEntity(); result.setDate(cursor.getString(0)); result.setTimestamp(cursor.getString(1)); result.setTemperature(cursor.getDouble(2)); result.setCoitusFlg(cursor.getString(3)); result.setMenstruationFlg(cursor.getString(4)); result.setDysmenorrheaFlg(cursor.getString(5)); result.setLeukorrhea(cursor.getString(6)); result.setMenstruationLevel(cursor.getString(7)); result.setMenstruationCycle(cursor.getInt(8)); return result; }
From source file:io.ordunaleon.lumios.adapter.PriceListAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ViewHolder viewHolder = (ViewHolder) view.getTag(); String dateStr = cursor.getString(PriceListFragment.COL_DATE); String date = null;//from w ww. j ava2 s. co m try { date = DateUtils.formatDateFromUtcIso(context, dateStr, FORMAT_SHOW_TIME); } catch (ParseException e) { LOGE(LOG_TAG, "error while getting field from ISO 8601 date in string format ", e); } double price = cursor.getDouble(PriceListFragment.COL_PRICE); double avg = cursor.getDouble(PriceListFragment.COL_AVG); double increase = cursor.getDouble(PriceListFragment.COL_INCREASE); viewHolder.hourView.setText(date); viewHolder.avgView.setText(context.getString(R.string.item_price_list_avg, avg)); viewHolder.priceView.setText(context.getString(R.string.item_price_list_price, price)); viewHolder.increaseView.setText(context.getString(R.string.item_price_list_increase, increase)); }
From source file:org.xbmc.kore.ui.sections.audio.AlbumInfoFragment.java
/** {@inheritDoc} */ @Override/*from ww w . j a v a 2 s . c om*/ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { if (cursor != null && cursor.getCount() > 0) { switch (cursorLoader.getId()) { case LOADER_ALBUM: cursor.moveToFirst(); DataHolder dataHolder = getDataHolder(); dataHolder.setRating(cursor.getDouble(AlbumDetailsQuery.RATING)); dataHolder.setTitle(cursor.getString(AlbumDetailsQuery.TITLE)); dataHolder.setUndertitle(cursor.getString(AlbumDetailsQuery.DISPLAYARTIST)); dataHolder.setDescription(cursor.getString(AlbumDetailsQuery.DESCRIPTION)); dataHolder.setFanArtUrl(cursor.getString(AlbumInfoFragment.AlbumDetailsQuery.FANART)); dataHolder.setPosterUrl(cursor.getString(AlbumInfoFragment.AlbumDetailsQuery.THUMBNAIL)); int year = cursor.getInt(AlbumDetailsQuery.YEAR); String genres = cursor.getString(AlbumDetailsQuery.GENRE); dataHolder.setDetails( (year > 0) ? (!TextUtils.isEmpty(genres) ? genres + " | " + String.valueOf(year) : String.valueOf(year)) : genres); FileDownloadHelper.SongInfo songInfo = new FileDownloadHelper.SongInfo(dataHolder.getUnderTitle(), dataHolder.getTitle(), 0, 0, null, null); setDownloadButtonState(songInfo.downloadDirectoryExists()); updateView(dataHolder); break; } } }
From source file:de.stadtrallye.rallyesoft.model.map.MapManager.java
private void readDatabase(List<Node> nodes, List<Edge> edges) { Cursor c = getDb().query(Nodes.TABLE, Nodes.COLS, null, null, null, null, null); while (c.moveToNext()) { nodes.add(new Node((int) c.getLong(0), c.getString(1), new LatLng(c.getDouble(2), c.getDouble(3)), c.getString(4)));/* w w w . ja v a2s . co m*/ } c.close(); c = getDb().query(Edges.TABLE, Edges.COLS, null, null, null, null, null); while (c.moveToNext()) { edges.add(new Edge(nodes.get((int) c.getLong(0)), nodes.get((int) c.getLong(1)), c.getString(2))); } c.close(); }
From source file:com.nadmm.airports.wx.WxCursorAdapter.java
protected void showMetarInfo(View view, Cursor c, Metar metar) { ViewHolder holder = getViewHolder(view); if (metar != null && metar.isValid) { // We have METAR for this station double lat = c.getDouble(c.getColumnIndex(Wxs.STATION_LATITUDE_DEGREES)); double lon = c.getDouble(c.getColumnIndex(Wxs.STATION_LONGITUDE_DEGREES)); Location location = new Location(""); location.setLatitude(lat);//from w w w.j a va2s . c o m location.setLongitude(lon); float declination = GeoUtils.getMagneticDeclination(location); WxUtils.setColorizedWxDrawable(holder.stationName, metar, declination); StringBuilder info = new StringBuilder(); info.append(metar.flightCategory); if (metar.visibilitySM < Float.MAX_VALUE) { info.append(", "); info.append(FormatUtils.formatStatuteMiles(metar.visibilitySM)); } if (metar.windSpeedKnots < Integer.MAX_VALUE) { info.append(", "); if (metar.windSpeedKnots == 0) { info.append("calm"); } else if (metar.windGustKnots < Integer.MAX_VALUE) { info.append(String.format("%dG%dKT", metar.windSpeedKnots, metar.windGustKnots)); } else { info.append(String.format("%dKT", metar.windSpeedKnots)); } if (metar.windSpeedKnots > 0 && metar.windDirDegrees >= 0 && metar.windDirDegrees < Integer.MAX_VALUE) { info.append("/"); info.append(FormatUtils.formatDegrees(metar.windDirDegrees)); } } if (metar.wxList.size() > 0) { for (WxSymbol wx : metar.wxList) { if (!wx.getSymbol().equals("NSW")) { info.append(", "); info.append(wx.toString().toLowerCase(Locale.US)); } } } holder.stationWx.setVisibility(View.VISIBLE); holder.stationWx.setText(info.toString()); info.setLength(0); SkyCondition sky = WxUtils.getCeiling(metar.skyConditions); int ceiling = sky.getCloudBaseAGL(); String skyCover = sky.getSkyCover(); if (skyCover.equals("OVX")) { info.append("Ceiling indefinite"); } else if (!skyCover.equals("NSC")) { info.append("Ceiling "); info.append(skyCover); info.append(" "); info.append(FormatUtils.formatFeet(ceiling)); } else { if (!metar.skyConditions.isEmpty()) { sky = metar.skyConditions.get(0); skyCover = sky.getSkyCover(); if (skyCover.equals("CLR") || skyCover.equals("SKC")) { info.append("Sky clear"); } else if (!skyCover.equals("SKM")) { info.append(skyCover); info.append(" "); info.append(FormatUtils.formatFeet(sky.getCloudBaseAGL())); } } } if (info.length() > 0) { info.append(", "); } // Do some basic sanity checks on values if (metar.tempCelsius < Float.MAX_VALUE && metar.dewpointCelsius < Float.MAX_VALUE) { info.append(FormatUtils.formatTemperatureF(metar.tempCelsius)); info.append("/"); info.append(FormatUtils.formatTemperatureF(metar.dewpointCelsius)); info.append(", "); } if (metar.altimeterHg < Float.MAX_VALUE) { info.append(FormatUtils.formatAltimeterHg(metar.altimeterHg)); } holder.stationWx2.setVisibility(View.VISIBLE); holder.stationWx2.setText(info.toString()); holder.reportAge.setVisibility(View.VISIBLE); holder.reportAge.setText(TimeUtils.formatElapsedTime(metar.observationTime)); } else { WxUtils.setColorizedWxDrawable(holder.stationName, metar, 0); if (metar != null) { holder.stationWx.setText("Unable to fetch Wx data"); } else { holder.stationWx.setText("Wx not fetched"); } holder.stationWx2.setVisibility(View.GONE); holder.reportAge.setVisibility(View.GONE); } }
From source file:com.fbartnitzek.tasteemall.showentry.ShowLocationFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { Log.v(LOG_TAG, "onLoadFinished, hashCode=" + this.hashCode() + ", " + "loader = [" + loader + "], data = [" + data + "]"); if (data != null && data.moveToFirst()) { mLocationAddressView//from w ww.j a va 2s . c o m .setText(data.getString(QueryColumns.LocationFragment.ShowQuery.COL_FORMATTED_ADDRESS)); double lat = data.getDouble(QueryColumns.LocationFragment.ShowQuery.COL_LATITUDE); mLocationLongitudeView.setText(Double.toString(lat)); double longitude = data.getDouble(QueryColumns.LocationFragment.ShowQuery.COL_LONGITUDE); mLocationLatitudeView.setText(Double.toString(longitude)); mLocationDescriptionView .setText(data.getString(QueryColumns.LocationFragment.ShowQuery.COL_DESCRIPTION)); mLocationInputView.setText(data.getString(QueryColumns.LocationFragment.ShowQuery.COL_INPUT)); mLocationCountryView.setText(data.getString(QueryColumns.LocationFragment.ShowQuery.COL_COUNTRY)); mLocationIdView.setText(data.getString(QueryColumns.LocationFragment.ShowQuery.COL_ID)); mLatLng = new LatLng(lat, longitude); updateToolbar(); updateAndMoveToMarker(); } }