List of usage examples for android.database Cursor getShort
short getShort(int columnIndex);
From source file:info.curtbinder.reefangel.phone.StatusActivity.java
public void updateDisplay() { Uri uri = Uri.parse(StatusProvider.CONTENT_URI + "/" + StatusProvider.PATH_LATEST); Cursor c = getContentResolver().query(uri, null, null, null, StatusTable.COL_ID + " DESC"); String updateStatus;//from ww w .ja v a 2 s . c om String[] values; String[] pwme; String[] rf; String[] vt; String[] ai; String[] io; String[] custom; String[] scpwme; short r, ron, roff, newEM, newEM1, newREM, apValue, dpValue, af, sf; short[] pwmeValues = new short[Controller.MAX_PWM_EXPANSION_PORTS]; short[] radionValues = new short[Controller.MAX_RADION_LIGHT_CHANNELS]; short[] aiValues = new short[Controller.MAX_AI_CHANNELS]; short[] expr = new short[Controller.MAX_EXPANSION_RELAYS]; short[] expron = new short[Controller.MAX_EXPANSION_RELAYS]; short[] exproff = new short[Controller.MAX_EXPANSION_RELAYS]; short[] vtValues = new short[Controller.MAX_VORTECH_VALUES]; short[] scpwmeValues = new short[Controller.MAX_SCPWM_EXPANSION_PORTS]; if (c.moveToFirst()) { updateStatus = c.getString(c.getColumnIndex(StatusTable.COL_LOGDATE)); values = getControllerValues(c); apValue = c.getShort(c.getColumnIndex(StatusTable.COL_AP)); dpValue = c.getShort(c.getColumnIndex(StatusTable.COL_DP)); pwme = getPWMETextValues(c); pwmeValues = getPWMEValues(c); scpwme = getSCPWMETextValues(c); scpwmeValues = getSCPWMEValues(c); rf = getRadionTextValues(c); radionValues = getRadionValues(c); vt = getVortechTextValues(c); vtValues = getVortechValues(c); ai = getAITextValues(c); aiValues = getAIValues(c); io = getIOValues(c); custom = getCustomValues(c); r = c.getShort(c.getColumnIndex(StatusTable.COL_RDATA)); ron = c.getShort(c.getColumnIndex(StatusTable.COL_RONMASK)); roff = c.getShort(c.getColumnIndex(StatusTable.COL_ROFFMASK)); expr[0] = c.getShort(c.getColumnIndex(StatusTable.COL_R1DATA)); expron[0] = c.getShort(c.getColumnIndex(StatusTable.COL_R1ONMASK)); exproff[0] = c.getShort(c.getColumnIndex(StatusTable.COL_R1OFFMASK)); expr[1] = c.getShort(c.getColumnIndex(StatusTable.COL_R2DATA)); expron[1] = c.getShort(c.getColumnIndex(StatusTable.COL_R2ONMASK)); exproff[1] = c.getShort(c.getColumnIndex(StatusTable.COL_R2OFFMASK)); expr[2] = c.getShort(c.getColumnIndex(StatusTable.COL_R3DATA)); expron[2] = c.getShort(c.getColumnIndex(StatusTable.COL_R3ONMASK)); exproff[2] = c.getShort(c.getColumnIndex(StatusTable.COL_R3OFFMASK)); expr[3] = c.getShort(c.getColumnIndex(StatusTable.COL_R4DATA)); expron[3] = c.getShort(c.getColumnIndex(StatusTable.COL_R4ONMASK)); exproff[3] = c.getShort(c.getColumnIndex(StatusTable.COL_R4OFFMASK)); expr[4] = c.getShort(c.getColumnIndex(StatusTable.COL_R5DATA)); expron[4] = c.getShort(c.getColumnIndex(StatusTable.COL_R5ONMASK)); exproff[4] = c.getShort(c.getColumnIndex(StatusTable.COL_R5OFFMASK)); expr[5] = c.getShort(c.getColumnIndex(StatusTable.COL_R6DATA)); expron[5] = c.getShort(c.getColumnIndex(StatusTable.COL_R6ONMASK)); exproff[5] = c.getShort(c.getColumnIndex(StatusTable.COL_R6OFFMASK)); expr[6] = c.getShort(c.getColumnIndex(StatusTable.COL_R7DATA)); expron[6] = c.getShort(c.getColumnIndex(StatusTable.COL_R7ONMASK)); exproff[6] = c.getShort(c.getColumnIndex(StatusTable.COL_R7OFFMASK)); expr[7] = c.getShort(c.getColumnIndex(StatusTable.COL_R8DATA)); expron[7] = c.getShort(c.getColumnIndex(StatusTable.COL_R8ONMASK)); exproff[7] = c.getShort(c.getColumnIndex(StatusTable.COL_R8OFFMASK)); newEM = c.getShort(c.getColumnIndex(StatusTable.COL_EM)); newEM1 = c.getShort(c.getColumnIndex(StatusTable.COL_EM1)); newREM = c.getShort(c.getColumnIndex(StatusTable.COL_REM)); sf = c.getShort(c.getColumnIndex(StatusTable.COL_SF)); af = c.getShort(c.getColumnIndex(StatusTable.COL_AF)); } else { updateStatus = getString(R.string.messageNever); values = getNeverValues(Controller.MAX_CONTROLLER_VALUES); pwme = getNeverValues(Controller.MAX_PWM_EXPANSION_PORTS); scpwme = getNeverValues(Controller.MAX_SCPWM_EXPANSION_PORTS); rf = getNeverValues(Controller.MAX_RADION_LIGHT_CHANNELS); vt = getNeverValues(Controller.MAX_VORTECH_VALUES); ai = getNeverValues(Controller.MAX_AI_CHANNELS); io = getNeverValues(Controller.MAX_IO_CHANNELS); custom = getNeverValues(Controller.MAX_CUSTOM_VARIABLES); r = ron = roff = newEM = newEM1 = newREM = apValue = dpValue = sf = af = 0; int i; for (i = 0; i < Controller.MAX_EXPANSION_RELAYS; i++) { expr[i] = expron[i] = exproff[i] = 0; } for (i = 0; i < Controller.MAX_PWM_EXPANSION_PORTS; i++) { pwmeValues[i] = 0; } for (i = 0; i < Controller.MAX_SCPWM_EXPANSION_PORTS; i++) { scpwmeValues[i] = 0; } for (i = 0; i < Controller.MAX_RADION_LIGHT_CHANNELS; i++) { radionValues[i] = 0; } for (i = 0; i < Controller.MAX_AI_CHANNELS; i++) { aiValues[i] = 0; } for (i = 0; i < Controller.MAX_VORTECH_VALUES; i++) { vtValues[i] = 0; } } c.close(); updateTime.setText(updateStatus); pageController.updateDisplay(values); pageController.updatePWMValues(apValue, dpValue); pageFlags.updateStatus(sf); pageFlags.updateAlert(af); pageDimming.updateDisplay(pwme); pageDimming.updatePWMValues(pwmeValues); pageSCDimming.updateDisplay(scpwme); pageSCDimming.updatePWMValues(scpwmeValues); pageRadion.updateDisplay(rf); pageRadion.updatePWMValues(radionValues); pageVortech.updateDisplay(vt); pageVortech.updateValues(vtValues); pageAI.updateDisplay(ai); pageAI.updatePWMValues(aiValues); pageIO.updateDisplay(io); pageCustom.updateDisplay(custom); boolean fUseMask = rapp.raprefs.isCommunicateController(); pageMain.updateRelayValues(new Relay(r, ron, roff), fUseMask); for (int i = 0; i < rapp.raprefs.getExpansionRelayQuantity(); i++) { pageExpRelays[i].updateRelayValues(new Relay(expr[i], expron[i], exproff[i]), fUseMask); } if (rapp.raprefs.isAutoUpdateModulesEnabled()) { // update the screen / pages if necessary checkDeviceModules(newEM, newEM1, newREM); } }
From source file:com.elpstudio.player.EqualizerActivity.java
/** * Builds the "Load Preset" dialog. Does not call the show() method, so this * should be done manually after calling this method. * /*from w w w . j a v a 2s . co m*/ * @return A fully built AlertDialog reference. */ private AlertDialog buildLoadPresetDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); //Get a cursor with the list of EQ presets. final Cursor cursor = mApp.getDBAccessHelper().getAllEQPresets(); //Set the dialog title. builder.setTitle("Load Preset"); builder.setCursor(cursor, new DialogInterface.OnClickListener() { @SuppressWarnings("unchecked") @Override public void onClick(DialogInterface dialog, int which) { cursor.moveToPosition(which); //Close the dialog. dialog.dismiss(); //Pass on the equalizer values to the appropriate fragment. fiftyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_50_HZ)); oneThirtyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_130_HZ)); threeTwentyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_320_HZ)); eightHundredHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_800_HZ)); twoKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_2000_HZ)); fiveKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_5000_HZ)); twelvePointFiveKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_12500_HZ)); virtualizerLevel = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.VIRTUALIZER)); bassBoostLevel = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.BASS_BOOST)); reverbSetting = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.REVERB)); //Save the new equalizer settings to the DB. @SuppressWarnings({ "rawtypes" }) AsyncTask task = new AsyncTask() { @Override protected Object doInBackground(Object... arg0) { setEQValuesForSong(Music.musicService.currentSong.getId() + ""); return null; } @Override public void onPostExecute(Object result) { super.onPostExecute(result); //Reinitialize the UI elements to apply the new equalizer settings. new AsyncInitSlidersTask().execute(); } }; task.execute(); if (cursor != null) cursor.close(); } }, DBAccessHelper.PRESET_NAME); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.EqualizerActivity.EqualizerActivity.java
/** * Builds the "Load Preset" dialog. Does not call the show() method, so this * should be done manually after calling this method. * /*from w w w . ja v a 2 s . co m*/ * @return A fully built AlertDialog reference. */ private AlertDialog buildLoadPresetDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); //Get a cursor with the list of EQ presets. final Cursor cursor = mApp.getDBAccessHelper().getAllEQPresets(); //Set the dialog title. builder.setTitle(R.string.load_preset); builder.setCursor(cursor, new DialogInterface.OnClickListener() { @SuppressWarnings("unchecked") @Override public void onClick(DialogInterface dialog, int which) { cursor.moveToPosition(which); //Close the dialog. dialog.dismiss(); //Pass on the equalizer values to the appropriate fragment. fiftyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_50_HZ)); oneThirtyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_130_HZ)); threeTwentyHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_320_HZ)); eightHundredHertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_800_HZ)); twoKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_2000_HZ)); fiveKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_5000_HZ)); twelvePointFiveKilohertzLevel = cursor.getInt(cursor.getColumnIndex(DBAccessHelper.EQ_12500_HZ)); virtualizerLevel = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.VIRTUALIZER)); bassBoostLevel = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.BASS_BOOST)); reverbSetting = cursor.getShort(cursor.getColumnIndex(DBAccessHelper.REVERB)); //Save the new equalizer settings to the DB. @SuppressWarnings({ "rawtypes" }) AsyncTask task = new AsyncTask() { @Override protected Object doInBackground(Object... arg0) { setEQValuesForSong(mApp.getService().getCurrentSong().getId()); return null; } @Override public void onPostExecute(Object result) { super.onPostExecute(result); //Reinitialize the UI elements to apply the new equalizer settings. new AsyncInitSlidersTask().execute(); } }; task.execute(); if (cursor != null) cursor.close(); } }, DBAccessHelper.PRESET_NAME); return builder.create(); }
From source file:com.binomed.showtime.android.screen.search.CineShowTimeSearchFragment.java
public void initDB() { try {/*from ww w .j a v a2 s . c o m*/ openDB(); if (mDbHelper.isOpen()) { // Init requests Cursor cursorRequestHistory = mDbHelper.fetchAllMovieRequest(); String cityName, movieName; if (cursorRequestHistory.moveToFirst()) { int columnIndex = 0; model.getRequestList().clear(); model.getRequestMovieList().clear(); do { columnIndex = cursorRequestHistory .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_CITY_NAME); try { cityName = cursorRequestHistory.getString(columnIndex); if (cityName != null) { model.getRequestList() .add(URLDecoder.decode(cityName, CineShowTimeEncodingUtil.getEncoding())); } columnIndex = cursorRequestHistory .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_MOVIE_NAME); movieName = cursorRequestHistory.getString(columnIndex); if (movieName != null) { model.getRequestMovieList() .add(URLDecoder.decode(movieName, CineShowTimeEncodingUtil.getEncoding())); } } catch (Exception e) { Log.e(TAG, "Encode Error", e); } } while (cursorRequestHistory.moveToNext()); } cursorRequestHistory.close(); // else we just look at previous request in order to check it's time Cursor cursorLastResult = mDbHelper.fetchLastMovieRequest(); if (cursorLastResult.moveToFirst()) { Calendar calendarLastRequest = Calendar.getInstance(); long timeLastRequest = cursorLastResult .getLong(cursorLastResult.getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_TIME)); calendarLastRequest.setTimeInMillis(timeLastRequest); // Init localisation from data base Location location = new Location(SpecialChars.EMPTY); int columnIndex = cursorLastResult .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_LATITUDE); location.setLatitude(cursorLastResult.getDouble(columnIndex)); columnIndex = cursorLastResult .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_LONGITUDE); location.setLongitude(cursorLastResult.getDouble(columnIndex)); model.setLocalisation(location); fragmentInteraction.setLastRequestDate(calendarLastRequest); try { columnIndex = cursorLastResult .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_CITY_NAME); cityName = cursorLastResult.getString(columnIndex); // Manage case of saved bundle if (cityName != null) { model.setLastRequestCity( URLDecoder.decode(cityName, CineShowTimeEncodingUtil.getEncoding())); } columnIndex = cursorLastResult .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_MOVIE_NAME); movieName = cursorLastResult.getString(columnIndex); // Manage case of saved bundle if (movieName != null) { model.setLastRequestMovie( URLDecoder.decode(movieName, CineShowTimeEncodingUtil.getEncoding())); } columnIndex = cursorLastResult .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_THEATER_ID); model.setLastRequestTheaterId(cursorLastResult.getString(columnIndex)); columnIndex = cursorLastResult .getColumnIndex(CineShowtimeDbAdapter.KEY_MOVIE_REQUEST_NULL_RESULT); fragmentInteraction.setNullResult(cursorLastResult.getShort(columnIndex) == 1); } catch (Exception e) { Log.e(TAG, "Encode Error", e); } } cursorLastResult.close(); } } catch (SQLException e) { Log.e(TAG, "error during getting fetching informations", e); //$NON-NLS-1$ } }
From source file:info.curtbinder.reefangel.service.NotificationService.java
private float getLeftValue(int id, Cursor l) { float f;//from w ww .ja v a 2 s .co 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; }