List of usage examples for android.database Cursor getDouble
double getDouble(int columnIndex);
From source file:edu.auburn.ppl.cyclecolumbus.NoteUploader.java
/****************************************************************************************** * Generates JSONObject form of a note to be uploaded ****************************************************************************************** * @param noteId Unique note ID to be uploaded * @return JSONObject of the note//from www.ja v a 2 s. c o m * @throws JSONException ******************************************************************************************/ private JSONObject getNoteJSON(long noteId) throws JSONException { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); mDb.openReadOnly(); Cursor noteCursor = mDb.fetchNote(noteId); Map<String, Integer> fieldMap = new HashMap<String, Integer>(); fieldMap.put(NOTE_RECORDED, noteCursor.getColumnIndex(DbAdapter.K_NOTE_RECORDED)); fieldMap.put(NOTE_LAT, noteCursor.getColumnIndex(DbAdapter.K_NOTE_LAT)); fieldMap.put(NOTE_LGT, noteCursor.getColumnIndex(DbAdapter.K_NOTE_LGT)); fieldMap.put(NOTE_HACC, noteCursor.getColumnIndex(DbAdapter.K_NOTE_ACC)); fieldMap.put(NOTE_VACC, noteCursor.getColumnIndex(DbAdapter.K_NOTE_ACC)); fieldMap.put(NOTE_ALT, noteCursor.getColumnIndex(DbAdapter.K_NOTE_ALT)); fieldMap.put(NOTE_SPEED, noteCursor.getColumnIndex(DbAdapter.K_NOTE_SPEED)); fieldMap.put(NOTE_TYPE, noteCursor.getColumnIndex(DbAdapter.K_NOTE_TYPE)); fieldMap.put(NOTE_DETAILS, noteCursor.getColumnIndex(DbAdapter.K_NOTE_DETAILS)); fieldMap.put(NOTE_IMGURL, noteCursor.getColumnIndex(DbAdapter.K_NOTE_IMGURL)); JSONObject note = new JSONObject(); note.put(NOTE_RECORDED, df.format(noteCursor.getDouble(fieldMap.get(NOTE_RECORDED)))); note.put(NOTE_LAT, noteCursor.getDouble(fieldMap.get(NOTE_LAT)) / 1E6); note.put(NOTE_LGT, noteCursor.getDouble(fieldMap.get(NOTE_LGT)) / 1E6); note.put(NOTE_HACC, noteCursor.getDouble(fieldMap.get(NOTE_HACC))); note.put(NOTE_VACC, noteCursor.getDouble(fieldMap.get(NOTE_VACC))); note.put(NOTE_ALT, noteCursor.getDouble(fieldMap.get(NOTE_ALT))); note.put(NOTE_SPEED, noteCursor.getDouble(fieldMap.get(NOTE_SPEED))); note.put(NOTE_TYPE, noteCursor.getInt(fieldMap.get(NOTE_TYPE))); note.put(NOTE_DETAILS, noteCursor.getString(fieldMap.get(NOTE_DETAILS))); note.put(NOTE_IMGURL, noteCursor.getString(fieldMap.get(NOTE_IMGURL))); if (noteCursor.getString(fieldMap.get(NOTE_IMGURL)).equals("")) { imageDataNull = true; } else { imageDataNull = false; imageData = noteCursor.getBlob(noteCursor.getColumnIndex(DbAdapter.K_NOTE_IMGDATA)); } noteCursor.close(); mDb.close(); return note; }
From source file:com.arminsam.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(COL_WEATHER_CONDITION_ID); 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);// w ww . j a va 2 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 = 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.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);// w w w .java2 s . com // 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.craftloom.android.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 placeholder Image //mIconView.setImageResource(R.drawable.ic_launcher); // 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);//w w w.jav a2 s . c om // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(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.example.locationprovider.app.SendMockLocationService.java
private TestLocation[] buildTestLocationArray() { Cursor cursor = getContentResolver().query(MockLocationProvider.uri, null, null, null, null); cursor.moveToFirst();/*ww w . j a v a2 s. co m*/ // Temporary array of location data TestLocation[] location_array = new TestLocation[cursor.getCount()]; /* * Iterate through all the arrays of data. This loop assumes that the arrays * all have the same length. */ for (int index = 0; index < cursor.getCount(); index++) { /* * For each location, create a new location storage object. Set the "provider" * value to a number that identifies the location. This allows the tester or the * app under test to identify a particular location */ location_array[index] = new TestLocation(Integer.toString(index), cursor.getDouble(cursor.getColumnIndex("latitude")), cursor.getDouble(cursor.getColumnIndex("longitude")), (float) cursor.getDouble(cursor.getColumnIndex("accuracy"))); cursor.moveToNext(); } // Return the temporary array return location_array; }
From source file:org.xbmc.kore.ui.sections.video.TVShowDetailsFragment.java
/** * Display the tv show details//from ww w . j av a 2 s .c o m * * @param cursor Cursor with the data */ private void displayTVShowDetails(Cursor cursor) { LogUtils.LOGD(TAG, "displayTVShowDetails"); cursor.moveToFirst(); tvshowTitle = cursor.getString(TVShowDetailsQuery.TITLE); mediaTitle.setText(tvshowTitle); int numEpisodes = cursor.getInt(TVShowDetailsQuery.EPISODE), watchedEpisodes = cursor.getInt(TVShowDetailsQuery.WATCHEDEPISODES); setMediaUndertitle(numEpisodes, watchedEpisodes); setMediaPremiered(cursor.getString(TVShowDetailsQuery.PREMIERED), cursor.getString(TVShowDetailsQuery.STUDIO)); mediaGenres.setText(cursor.getString(TVShowDetailsQuery.GENRES)); setMediaRating(cursor.getDouble(TVShowDetailsQuery.RATING)); mediaDescription.setText(cursor.getString(TVShowDetailsQuery.PLOT)); Resources resources = getActivity().getResources(); TypedArray styledAttributes = getActivity().getTheme() .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse }); final int iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0), R.drawable.ic_expand_less_white_24dp); final int iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_expand_more_white_24dp); styledAttributes.recycle(); mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mediaDescription.toggle(); mediaShowAll.setImageResource(mediaDescription.isExpanded() ? iconCollapseResId : iconExpandResId); } }); // // IMDB button // imdbButton.setTag(cursor.getString(TVShowDetailsQuery.IMDBNUMBER)); // Images DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height); UIUtils.loadImageWithCharacterAvatar(getActivity(), getHostManager(), cursor.getString(TVShowDetailsQuery.THUMBNAIL), tvshowTitle, mediaPoster, posterWidth, posterHeight); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height); UIUtils.loadImageIntoImageview(getHostManager(), cursor.getString(TVShowDetailsQuery.FANART), mediaArt, displayMetrics.widthPixels, artHeight); }
From source file:com.xeon.amar.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(COL_WEATHER_CONDITION_ID); // Use placeholder Image // mIconView.setImageResource(R.drawable.ic_launcher); // 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 . jav a2s . c o m*/ // Read description from cursor and update view String description = data.getString(COL_WEATHER_DESC); mDescriptionView.setText(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.wildplot.android.ankistats.ReviewCount.java
public boolean calculateDone(int type, boolean reps) { mType = type;/*from w w w. j a va 2 s .c o m*/ mBackwards = true; if (reps) { mTitle = R.string.stats_review_count; mAxisTitles = new int[] { type, R.string.stats_answers, R.string.stats_cumulative_answers }; } else { mTitle = R.string.stats_review_time; } mValueLabels = new int[] { R.string.statistics_learn, R.string.statistics_relearn, R.string.statistics_young, R.string.statistics_mature, R.string.statistics_cram }; mColors = new int[] { R.color.stats_learn, R.color.stats_relearn, R.color.stats_young, R.color.stats_mature, R.color.stats_cram }; int num = 0; int chunk = 0; switch (type) { case Utils.TYPE_MONTH: num = 31; chunk = 1; break; case Utils.TYPE_YEAR: num = 52; chunk = 7; break; case Utils.TYPE_LIFE: num = -1; chunk = 30; break; } ArrayList<String> lims = new ArrayList<String>(); if (num != -1) { lims.add("id > " + ((mCollectionData.getDayCutoff() - ((num + 1) * chunk * 86400)) * 1000)); } String lim = _revlogLimitWholeOnly().replaceAll("[\\[\\]]", ""); if (lim.length() > 0) { lims.add(lim); } if (lims.size() > 0) { lim = "WHERE "; while (lims.size() > 1) { lim += lims.remove(0) + " AND "; } lim += lims.remove(0); } else { lim = ""; } String ti; String tf; if (!reps) { ti = "time/1000"; if (mType == 0) { tf = "/60.0"; // minutes mAxisTitles = new int[] { type, R.string.stats_minutes, R.string.stats_cumulative_time_minutes }; } else { tf = "/3600.0"; // hours mAxisTitles = new int[] { type, R.string.stats_hours, R.string.stats_cumulative_time_hours }; } } else { ti = "1"; tf = ""; } ArrayList<double[]> list = new ArrayList<double[]>(); Cursor cur = null; String query = "SELECT (cast((id/1000 - " + mCollectionData.getDayCutoff() + ") / 86400.0 AS INT))/" + chunk + " AS day, " + "sum(CASE WHEN type = 0 THEN " + ti + " ELSE 0 END)" + tf + ", " // lrn + "sum(CASE WHEN type = 1 AND lastIvl < 21 THEN " + ti + " ELSE 0 END)" + tf + ", " // yng + "sum(CASE WHEN type = 1 AND lastIvl >= 21 THEN " + ti + " ELSE 0 END)" + tf + ", " // mtr + "sum(CASE WHEN type = 2 THEN " + ti + " ELSE 0 END)" + tf + ", " // lapse + "sum(CASE WHEN type = 3 THEN " + ti + " ELSE 0 END)" + tf // cram + " FROM revlog " + lim + " GROUP BY day ORDER BY day"; Log.d(AnkiStatsApplication.TAG, "ReviewCount query: " + query); try { cur = mAnkiDb.getDatabase().rawQuery(query, null); while (cur.moveToNext()) { list.add(new double[] { cur.getDouble(0), cur.getDouble(1), cur.getDouble(4), cur.getDouble(2), cur.getDouble(3), cur.getDouble(5) }); } } finally { if (cur != null && !cur.isClosed()) { cur.close(); } } // small adjustment for a proper chartbuilding with achartengine if (type != Utils.TYPE_LIFE && (list.size() == 0 || list.get(0)[0] > -num)) { list.add(0, new double[] { -num, 0, 0, 0, 0, 0 }); } else if (type == Utils.TYPE_LIFE && list.size() == 0) { list.add(0, new double[] { -12, 0, 0, 0, 0, 0 }); } if (list.get(list.size() - 1)[0] < 0) { list.add(new double[] { 0, 0, 0, 0, 0, 0 }); } mSeriesList = new double[6][list.size()]; for (int i = 0; i < list.size(); i++) { double[] data = list.get(i); mSeriesList[0][i] = data[0]; // day mSeriesList[1][i] = data[1] + data[2] + data[3] + data[4] + data[5]; // lrn mSeriesList[2][i] = data[2] + data[3] + data[4] + data[5]; // relearn mSeriesList[3][i] = data[3] + data[4] + data[5]; // young mSeriesList[4][i] = data[4] + data[5]; // mature mSeriesList[5][i] = data[5]; // cram if (mSeriesList[1][i] > mMaxCards) mMaxCards = (int) Math.round(data[1] + data[2] + data[3] + data[4] + data[5]); if (data[5] >= 0.999) mFoundCramCards = true; if (data[1] >= 0.999) mFoundLearnCards = true; if (data[2] >= 0.999) mFoundRelearnCards = true; if (data[0] > mLastElement) mLastElement = data[0]; if (data[0] < mFirstElement) mFirstElement = data[0]; if (data[0] == 0) { mZeroIndex = i; } } mMaxElements = list.size() - 1; return list.size() > 0; }
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);/* w w w .ja va 2 s . com*/ // 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.binomed.showtime.android.screen.search.CineShowTimeSearchFragment.java
public void initDB() { try {/* w w w . j a v a 2s. co 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$ } }