List of usage examples for android.database Cursor getShort
short getShort(int columnIndex);
From source file:org.teleportr.Ride.java
private void load(Cursor cursor, Context ctx) { cv.put(_ID, cursor.getLong(COLUMNS.ID)); type(cursor.getInt(COLUMNS.TYPE));/* w w w.ja va 2 s . co m*/ from(cursor.getInt(COLUMNS.FROM_ID)); to(cursor.getInt(COLUMNS.TO_ID)); dep(cursor.getLong(COLUMNS.DEPARTURE)); arr(cursor.getLong(COLUMNS.ARRIVAL)); price(cursor.getInt(COLUMNS.PRICE)); seats(cursor.getInt(COLUMNS.SEATS)); cv.put(DIRTY, cursor.getInt(COLUMNS.DIRTY)); if (cursor.getShort(COLUMNS.MARKED) == 1) marked(); if (cursor.getShort(COLUMNS.ACTIVE) == 1) activate(); String val = cursor.getString(COLUMNS.WHO); if (val != null && !val.equals(EMPTY)) who(val); val = cursor.getString(COLUMNS.REF); if (val != null && !val.equals(EMPTY)) ref(val); else Log.e(RidesProvider.TAG, "REF is NULL! " + this); try { details = new JSONObject(cursor.getString(COLUMNS.DETAILS)); mode(Mode.valueOf(cursor.getString(COLUMNS.MODE))); } catch (Exception e) { } Cursor sub_cursor = ctx.getContentResolver().query(RidesProvider.getSubRidesUri(ctx, cursor.getInt(0)), null, null, null, null); subrides = new ArrayList<ContentValues>(); for (int i = 0; i < sub_cursor.getCount(); i++) { sub_cursor.moveToPosition(i); subrides.add(new Ride(sub_cursor, ctx).cv); } sub_cursor.close(); this.ctx = ctx; }
From source file:org.droidparts.persist.sql.EntityManager.java
protected Object readFromCursor(Cursor cursor, int columnIndex, Class<?> valType, Class<?> arrCollItemType) throws IllegalArgumentException { if (cursor.isNull(columnIndex)) { return null; } else if (isBoolean(valType)) { return cursor.getInt(columnIndex) == 1; } else if (isByte(valType)) { return Byte.valueOf(cursor.getString(columnIndex)); } else if (isByteArray(valType)) { return cursor.getBlob(columnIndex); } else if (isDouble(valType)) { return cursor.getDouble(columnIndex); } else if (isFloat(valType)) { return cursor.getFloat(columnIndex); } else if (isInteger(valType)) { return cursor.getInt(columnIndex); } else if (isLong(valType)) { return cursor.getLong(columnIndex); } else if (isShort(valType)) { return cursor.getShort(columnIndex); } else if (isString(valType)) { return cursor.getString(columnIndex); } else if (isUUID(valType)) { return UUID.fromString(cursor.getString(columnIndex)); } else if (isDate(valType)) { return new Date(cursor.getLong(columnIndex)); } else if (isBitmap(valType)) { byte[] arr = cursor.getBlob(columnIndex); return BitmapFactory.decodeByteArray(arr, 0, arr.length); } else if (isJsonObject(valType) || isJsonArray(valType)) { String str = cursor.getString(columnIndex); try {//from w w w . ja va 2s . c o m return isJsonObject(valType) ? new JSONObject(str) : new JSONArray(str); } catch (JSONException e) { throw new IllegalArgumentException(e); } } else if (isEnum(valType)) { return instantiateEnum(valType, cursor.getString(columnIndex)); } else if (isEntity(valType)) { long id = cursor.getLong(columnIndex); @SuppressWarnings("unchecked") Entity entity = instantiate((Class<Entity>) valType); entity.id = id; return entity; } else if (isArray(valType) || isCollection(valType)) { String str = cursor.getString(columnIndex); String[] parts = (str.length() > 0) ? str.split("\\" + SEP) : new String[0]; if (isArray(valType)) { return toTypeArr(arrCollItemType, parts); } else { @SuppressWarnings("unchecked") Collection<Object> coll = (Collection<Object>) instantiate(valType); coll.addAll(toTypeColl(arrCollItemType, parts)); return coll; } } else { throw new IllegalArgumentException("Need to manually read " + valType.getName() + " from cursor."); } }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private short[] getAIValues(Cursor c) { short[] v = new short[Controller.MAX_AI_CHANNELS]; v[0] = c.getShort(c.getColumnIndex(StatusTable.COL_AIW)); v[1] = c.getShort(c.getColumnIndex(StatusTable.COL_AIB)); v[2] = c.getShort(c.getColumnIndex(StatusTable.COL_AIRB)); return v;//from w ww. ja va 2s. com }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private short[] getPWMEValues(Cursor c) { short[] v = new short[Controller.MAX_PWM_EXPANSION_PORTS]; v[0] = c.getShort(c.getColumnIndex(StatusTable.COL_PWME0)); v[1] = c.getShort(c.getColumnIndex(StatusTable.COL_PWME1)); v[2] = c.getShort(c.getColumnIndex(StatusTable.COL_PWME2)); v[3] = c.getShort(c.getColumnIndex(StatusTable.COL_PWME3)); v[4] = c.getShort(c.getColumnIndex(StatusTable.COL_PWME4)); v[5] = c.getShort(c.getColumnIndex(StatusTable.COL_PWME5)); return v;/*from w w w . ja v a 2s . c o m*/ }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private short[] getRadionValues(Cursor c) { short[] v = new short[Controller.MAX_RADION_LIGHT_CHANNELS]; v[0] = c.getShort(c.getColumnIndex(StatusTable.COL_RFW)); v[1] = c.getShort(c.getColumnIndex(StatusTable.COL_RFRB)); v[2] = c.getShort(c.getColumnIndex(StatusTable.COL_RFR)); v[3] = c.getShort(c.getColumnIndex(StatusTable.COL_RFG)); v[4] = c.getShort(c.getColumnIndex(StatusTable.COL_RFB)); v[5] = c.getShort(c.getColumnIndex(StatusTable.COL_RFI)); return v;/* w ww . ja va2 s . co m*/ }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private String[] getIOValues(Cursor c) { String[] sa = new String[Controller.MAX_IO_CHANNELS]; short io = c.getShort(c.getColumnIndex(StatusTable.COL_IO)); String s;//w ww. ja v a 2 s .c om for (byte i = 0; i < Controller.MAX_IO_CHANNELS; i++) { if (Controller.getIOChannel(io, i)) { s = getString(R.string.labelOFF); } else { s = getString(R.string.labelON); } sa[i] = s; } return sa; }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private short[] getSCPWMEValues(Cursor c) { short[] v = new short[Controller.MAX_SCPWM_EXPANSION_PORTS]; v[0] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME0)); v[1] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME1)); v[2] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME2)); v[3] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME3)); v[4] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME4)); v[5] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME5)); v[6] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME6)); v[7] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME7)); v[8] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME8)); v[9] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME9)); v[10] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME10)); v[11] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME11)); v[12] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME12)); v[13] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME13)); v[14] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME14)); v[15] = c.getShort(c.getColumnIndex(StatusTable.COL_SCPWME15)); return v;// w ww . j a va 2 s . com }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private short[] getVortechValues(Cursor c) { short[] v = new short[Controller.MAX_VORTECH_VALUES]; v[Controller.VORTECH_MODE] = c.getShort(c.getColumnIndex(StatusTable.COL_RFM)); v[Controller.VORTECH_SPEED] = c.getShort(c.getColumnIndex(StatusTable.COL_RFS)); v[Controller.VORTECH_DURATION] = c.getShort(c.getColumnIndex(StatusTable.COL_RFD)); return v;//from www . j av a 2 s. c o m }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private String[] getPWMETextValues(Cursor c) { String[] sa = new String[Controller.MAX_PWM_EXPANSION_PORTS]; sa[0] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_PWME0)), c.getShort(c.getColumnIndex(StatusTable.COL_PWME0O))); sa[1] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_PWME1)), c.getShort(c.getColumnIndex(StatusTable.COL_PWME1O))); sa[2] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_PWME2)), c.getShort(c.getColumnIndex(StatusTable.COL_PWME2O))); sa[3] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_PWME3)), c.getShort(c.getColumnIndex(StatusTable.COL_PWME3O))); sa[4] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_PWME4)), c.getShort(c.getColumnIndex(StatusTable.COL_PWME4O))); sa[5] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_PWME5)), c.getShort(c.getColumnIndex(StatusTable.COL_PWME5O))); return sa;/*from ww w .j av a 2s .c o m*/ }
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
private String[] getRadionTextValues(Cursor c) { String[] sa = new String[Controller.MAX_RADION_LIGHT_CHANNELS]; sa[0] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_RFW)), c.getShort(c.getColumnIndex(StatusTable.COL_RFWO))); sa[1] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_RFRB)), c.getShort(c.getColumnIndex(StatusTable.COL_RFRBO))); sa[2] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_RFR)), c.getShort(c.getColumnIndex(StatusTable.COL_RFRO))); sa[3] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_RFG)), c.getShort(c.getColumnIndex(StatusTable.COL_RFGO))); sa[4] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_RFB)), c.getShort(c.getColumnIndex(StatusTable.COL_RFBO))); sa[5] = Controller.getPWMDisplayValue(c.getShort(c.getColumnIndex(StatusTable.COL_RFI)), c.getShort(c.getColumnIndex(StatusTable.COL_RFIO))); return sa;/*from w w w .j ava 2 s .c o m*/ }