List of usage examples for android.database Cursor getFloat
float getFloat(int columnIndex);
From source file:com.example.shutapp.DatabaseHandler.java
/** * Reads the database for all chatrooms. * @return A list of all chatrooms./*w ww. jav a 2 s . c o m*/ */ public List<Chatroom> getAllChatrooms() { List<Chatroom> chatroomList = new ArrayList<Chatroom>(); // Select All Query String selectQuery = "SELECT * FROM " + TABLE_CHATROOMS; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); // looping through all rows and adding to list if (cursor.moveToFirst()) { do { Chatroom chatroom = new Chatroom(); chatroom.setName(cursor.getString(0)); chatroom.setLatitude(cursor.getDouble(2)); chatroom.setLongitude(cursor.getDouble(StringLiterals.THREE)); chatroom.setRadius(cursor.getFloat(StringLiterals.FOUR)); // Adding chatroom to list chatroomList.add(chatroom); } while (cursor.moveToNext()); } // return contact list return chatroomList; }
From source file:com.developers.pnp.lilly.app.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { // Read weather condition ID from cursor String type = data.getString(COL_PLACE_TYPE); String formattedType = Utility.getFormattedType(type); // Use placeholder ImagetoString mIconView.setImageResource(Utility.getImageFromType(type)); String name = data.getString(COL_PLACE_NAME); mNameView.setText(name);// www . j a v a 2 s .c om mIconView.setContentDescription(name); mTypeView.setText(formattedType); Float rating = data.getFloat(COL_PLACE_RATING); mRatingView.setText("Rating: " + String.format("%.1f", rating)); mRatingBarView.setRating(rating); mRatingBarView.setVisibility(View.VISIBLE); String lat = data.getString(COL_PLACE_LAT); String lng = data.getString(COL_PLACE_LNG); mLatLngView.setText("Geolocation: " + lat + ", " + lng); LatLng latlng = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)); mGoogleMapFrag.getView().setVisibility(View.VISIBLE); GoogleMap mGoogleMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)) .getMap(); mGoogleMap.setMyLocationEnabled(true); mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 16)); Marker newmarker = mGoogleMap.addMarker(new MarkerOptions().position(latlng).title(name) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_icon2))); UiSettings uiSettings = mGoogleMap.getUiSettings(); uiSettings.setMapToolbarEnabled(true); // We still need this for the share intent mPlace = String.format("Check out %s %s place. It has %s stars and I'm near it!", name, Utility.getFormattedType(type), rating); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createSharePlacetIntent()); } } }
From source file:com.meiste.tempalarm.ui.CurrentTemp.java
/** * Move the Cursor returned by the query into the ListView adapter. This refreshes the existing * UI with the data in the Cursor.//w ww. j a v a2 s.co m */ @Override public void onLoadFinished(final Loader<Cursor> loader, final Cursor cursor) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mLightThreshold = prefs.getInt(AppConstants.PREF_THRES_LIGHT, 0); mGraph.removeAllSeries(); final List<GraphView.GraphViewData> data = new ArrayList<>(); cursor.moveToLast(); while (cursor.moveToPrevious()) { data.add(new GraphView.GraphViewData(cursor.getLong(COLUMN_TIMESTAMP), cursor.getFloat(COLUMN_DEGF))); } final GraphViewSeries exampleSeries = new GraphViewSeries( data.toArray(new GraphView.GraphViewData[data.size()])); mGraph.addSeries(exampleSeries); mAdapter.changeCursor(cursor); }
From source file:info.curtbinder.reefangel.service.NotificationService.java
private float getLeftValue(int id, Cursor l) { float f;/*from w w w. j a v a 2s . c o m*/ paramPrecision = "%.0f"; switch (id) { case Globals.paramT1: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_T1)); paramPrecision = "%.1f"; break; } case Globals.paramT2: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_T2)); paramPrecision = "%.1f"; break; } case Globals.paramT3: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_T3)); paramPrecision = "%.1f"; break; } case Globals.paramPH: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PH)); paramPrecision = "%.2f"; break; } case Globals.paramPHExpansion: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PHE)); paramPrecision = "%.2f"; break; } case Globals.paramDaylightPWM: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_DP)); break; } case Globals.paramActinicPWM: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_AP)); break; } case Globals.paramSalinity: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_SAL)); paramPrecision = "%.1f"; break; } case Globals.paramORP: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_ORP)); break; } case Globals.paramWaterLevel: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_WL)); break; } case Globals.paramATOHigh: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_ATOHI)); break; } case Globals.paramATOLow: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_ATOLO)); break; } case Globals.paramPWMExp0: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PWME0)); break; } case Globals.paramPWMExp1: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PWME1)); break; } case Globals.paramPWMExp2: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PWME2)); break; } case Globals.paramPWMExp3: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PWME3)); break; } case Globals.paramPWMExp4: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PWME4)); break; } case Globals.paramPWMExp5: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_PWME5)); break; } case Globals.paramAIWhite: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_AIW)); break; } case Globals.paramAIBlue: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_AIB)); break; } case Globals.paramAIRoyalBlue: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_AIRB)); break; } case Globals.paramVortechMode: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFM)); break; } case Globals.paramVortechSpeed: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFS)); break; } case Globals.paramVortechDuration: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFD)); break; } case Globals.paramRadionWhite: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFW)); break; } case Globals.paramRadionRoyalBlue: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFRB)); break; } case Globals.paramRadionRed: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFR)); break; } case Globals.paramRadionGreen: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFG)); break; } case Globals.paramRadionBlue: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFB)); break; } case Globals.paramRadionIntensity: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_RFI)); break; } case Globals.paramIOCh0: case Globals.paramIOCh1: case Globals.paramIOCh2: case Globals.paramIOCh3: case Globals.paramIOCh4: case Globals.paramIOCh5: { short io = l.getShort(l.getColumnIndex(StatusTable.COL_IO)); byte ch = (byte) (id - Globals.paramIOCh0); // getIOChannel returns TRUE if the value is 1 // and FALSE if the value is 0 if (Controller.getIOChannel(io, ch)) { f = 1; } else { f = 0; } break; } case Globals.paramCustom0: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C0)); break; } case Globals.paramCustom1: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C1)); break; } case Globals.paramCustom2: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C2)); break; } case Globals.paramCustom3: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C3)); break; } case Globals.paramCustom4: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C4)); break; } case Globals.paramCustom5: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C5)); break; } case Globals.paramCustom6: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C6)); break; } case Globals.paramCustom7: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_C7)); break; } case Globals.paramWaterLevel1: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_WL1)); break; } case Globals.paramWaterLevel2: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_WL2)); break; } case Globals.paramWaterLevel3: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_WL3)); break; } case Globals.paramWaterLevel4: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_WL4)); break; } case Globals.paramHumidity: { f = l.getFloat(l.getColumnIndex(StatusTable.COL_HUM)); break; } default: { f = 0; break; } } return f; }
From source file:org.jumpmind.symmetric.android.AndroidSqlTemplate.java
@SuppressWarnings("unchecked") protected <T> T get(Cursor cursor, Class<T> clazz, int columnIndex) { Object result = null;// w ww. j a v a2 s .c o m if (clazz.equals(String.class)) { result = (String) cursor.getString(columnIndex); } else if (clazz.equals(Integer.class)) { result = (Integer) cursor.getInt(columnIndex); } else if (clazz.equals(Integer.class)) { result = (Double) cursor.getDouble(columnIndex); } else if (clazz.equals(Float.class)) { result = (Float) cursor.getFloat(columnIndex); } else if (clazz.equals(Long.class)) { result = (Long) cursor.getLong(columnIndex); } else if (clazz.equals(Date.class) || clazz.equals(Timestamp.class)) { String dateString = cursor.getString(columnIndex); if (dateString.contains("-")) { result = Timestamp.valueOf(dateString); } else { result = new Timestamp(Long.parseLong(dateString)); } } else if (clazz.equals(Short.class)) { result = (Short) cursor.getShort(columnIndex); } else if (clazz.equals(byte[].class)) { result = (byte[]) cursor.getBlob(columnIndex); } else { throw new IllegalArgumentException("Unsupported class: " + clazz.getName()); } return (T) result; }
From source file:com.fitforbusiness.nafc.dashboard.DashBoardFragment.java
private void setBusinessAlerts() { ArrayList<Map<String, String>> mapArrayList = new ArrayList<Map<String, String>>(); SQLiteDatabase sqlDB = null;/*from www . j a v a 2 s . c o m*/ try { sqlDB = DatabaseHelper.instance().getReadableDatabase(); String query = "select julianday(pt_license_renewal_date)-julianday('now') as pt_license, " + " julianday(first_aid_cert_renewal_date)-julianday('now') as first_aid, " + " julianday(cpr_cert_renewal_date)-julianday('now') as cpr_cert, " + " julianday(aed_cert_renewal_date)-julianday('now') as aed_cert from trainer"; Log.d("query is ", query); Cursor cursor = sqlDB.rawQuery(query, null); LinkedHashMap<String, String> row; if (cursor.moveToFirst()) { if (cursor.getFloat(cursor.getColumnIndex("pt_license")) < 90) { row = new LinkedHashMap<String, String>(); if (cursor.getFloat(cursor.getColumnIndex("pt_license")) < 0) { row.put("title", "PT License is overdue."); } else { row.put("title", "PT License is due for renewal."); } row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("pt_license")) + " day"); mapArrayList.add(row); } if (cursor.getFloat(cursor.getColumnIndex("first_aid")) < 90) { row = new LinkedHashMap<String, String>(); if (cursor.getFloat(cursor.getColumnIndex("first_aid")) < 0) { row.put("title", "First Aid is overdue."); } else { row.put("title", "First Aid is due for renewal."); } row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("first_aid")) + " day"); mapArrayList.add(row); } if (cursor.getFloat(cursor.getColumnIndex("cpr_cert")) < 90) { row = new LinkedHashMap<String, String>(); if (cursor.getFloat(cursor.getColumnIndex("cpr_cert")) < 0) { row.put("title", "CPR Certificate is overdue."); } else { row.put("title", "CPR Certificate is due for renewal."); } row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("cpr_cert")) + " day"); mapArrayList.add(row); } if (cursor.getFloat(cursor.getColumnIndex("aed_cert")) < 90) { row = new LinkedHashMap<String, String>(); if (cursor.getFloat(cursor.getColumnIndex("aed_cert")) < 0) { row.put("title", "AED Certificate is overdue."); } else { row.put("title", "AED Certificate is due for renewal."); } row.put("no_of_days", (int) cursor.getFloat(cursor.getColumnIndex("aed_cert")) + " day"); mapArrayList.add(row); } } cursor.close(); } catch (Exception e) { e.printStackTrace(); } finally { } adapter = new SimpleAdapter(getActivity(), mapArrayList, R.layout.custom_list_row_assesssment, new String[] { "title", "no_of_days" }, new int[] { R.id.tvFormName, R.id.tvNoOfFields }); }
From source file:org.chromium.chrome.browser.util.CompatibilityFileProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { Cursor source = super.query(uri, projection, selection, selectionArgs, sortOrder); String[] columnNames = source.getColumnNames(); String[] newColumnNames = columnNamesWithData(columnNames); if (columnNames == newColumnNames) return source; MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount()); source.moveToPosition(-1);/* w w w.j a v a 2 s. co m*/ while (source.moveToNext()) { MatrixCursor.RowBuilder row = cursor.newRow(); for (int i = 0; i < columnNames.length; i++) { switch (source.getType(i)) { case Cursor.FIELD_TYPE_INTEGER: row.add(source.getInt(i)); break; case Cursor.FIELD_TYPE_FLOAT: row.add(source.getFloat(i)); break; case Cursor.FIELD_TYPE_STRING: row.add(source.getString(i)); break; case Cursor.FIELD_TYPE_BLOB: row.add(source.getBlob(i)); break; case Cursor.FIELD_TYPE_NULL: default: row.add(null); break; } } } source.close(); return cursor; }
From source file:com.bydavy.card.receipts.fragments.ReceiptEditFragment.java
private void fromCursorToData(Cursor c) { mValidReceipt = c.moveToFirst();//w w w .j ava2s. c o m if (mValidReceipt) { final int shopColumnIndex = c.getColumnIndex(Receipts.COLUMN_NAME_SHOP); final int noteColumnIndex = c.getColumnIndex(Receipts.COLUMN_NAME_NOTE); final int totalColumnIndex = c.getColumnIndex(Receipts.COLUMN_NAME_TOTAL); final int dateColumnIndex = c.getColumnIndex(Receipts.COLUMN_NAME_DATE); mShop = c.getString(shopColumnIndex); mNote = c.getString(noteColumnIndex); mTotal = c.getFloat(totalColumnIndex); mDate.setTimeInMillis(c.getInt(dateColumnIndex) * 1000L); } }
From source file:com.textuality.lifesaver.Columns.java
public JSONObject cursorToJSON(Cursor cursor) { setColumns(cursor);//from w w w . j av a 2s .c om JSONObject json = new JSONObject(); try { for (int i = 0; i < names.length; i++) { int col = columns[i]; if (cursor.isNull(col)) continue; switch (types[i]) { case STRING: json.put(names[i], cursor.getString(col)); break; case INT: json.put(names[i], cursor.getInt(col)); break; case LONG: json.put(names[i], cursor.getLong(col)); break; case FLOAT: json.put(names[i], cursor.getFloat(col)); break; case DOUBLE: json.put(names[i], cursor.getDouble(col)); break; } } } catch (JSONException e) { throw new RuntimeException(e); } return json; }
From source file:org.sensapp.android.sensappdroid.activities.GraphDisplayerActivity.java
private void refreshOptionTables(Cursor c) { for (int i = 0; c.moveToNext(); i++) { graphSensorIDs[i] = c.getLong(c.getColumnIndex((SensAppContract.GraphSensor.ID))); sensorNames[i] = c.getString(c.getColumnIndex(SensAppContract.GraphSensor.SENSOR)); graphTitles[i] = c.getString(c.getColumnIndex(SensAppContract.GraphSensor.TITLE)); graphStyles[i] = c.getInt(c.getColumnIndex(SensAppContract.GraphSensor.STYLE)); graphColors[i] = c.getInt(c.getColumnIndex(SensAppContract.GraphSensor.COLOR)); graphHighests[i] = c.getFloat(c.getColumnIndex(SensAppContract.GraphSensor.MAX)); graphLowests[i] = c.getFloat(c.getColumnIndex(SensAppContract.GraphSensor.MIN)); }/*from w w w.j a va2 s. c o m*/ }