List of usage examples for android.database Cursor getDouble
double getDouble(int columnIndex);
From source file:org.xbmc.kore.ui.MovieDetailsFragment.java
/** * Display the movie details//from w w w . j a va2s.co m * * @param cursor Cursor with the data */ private void displayMovieDetails(Cursor cursor) { LogUtils.LOGD(TAG, "Refreshing movie details"); cursor.moveToFirst(); movieTitle = cursor.getString(MovieDetailsQuery.TITLE); mediaTitle.setText(movieTitle); mediaUndertitle.setText(cursor.getString(MovieDetailsQuery.TAGLINE)); setMediaYear(cursor.getInt(MovieDetailsQuery.RUNTIME) / 60, cursor.getInt(MovieDetailsQuery.YEAR)); mediaGenres.setText(cursor.getString(MovieDetailsQuery.GENRES)); double rating = cursor.getDouble(MovieDetailsQuery.RATING); if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); mediaRatingVotes.setVisibility(View.VISIBLE); setMediaRating(rating); String votes = cursor.getString(MovieDetailsQuery.VOTES); mediaRatingVotes .setText((TextUtils.isEmpty(votes)) ? "" : String.format(getString(R.string.votes), votes)); } else { mediaRating.setVisibility(View.INVISIBLE); mediaMaxRating.setVisibility(View.INVISIBLE); mediaRatingVotes.setVisibility(View.INVISIBLE); } mediaDescription.setText(cursor.getString(MovieDetailsQuery.PLOT)); mediaDirectors.setText(cursor.getString(MovieDetailsQuery.DIRECTOR)); // IMDB button imdbButton.setTag(cursor.getString(MovieDetailsQuery.IMDBNUMBER)); setupSeenButton(cursor.getInt(MovieDetailsQuery.PLAYCOUNT)); // Images Resources resources = getActivity().getResources(); 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(MovieDetailsQuery.THUMBNAIL), movieTitle, mediaPoster, posterWidth, posterHeight); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height); UIUtils.loadImageIntoImageview(getHostManager(), cursor.getString(MovieDetailsQuery.FANART), mediaArt, displayMetrics.widthPixels, artHeight); // Setup movie download info movieDownloadInfo = new FileDownloadHelper.MovieInfo(movieTitle, cursor.getString(MovieDetailsQuery.FILE)); // Check if downloaded file exists if (movieDownloadInfo.downloadFileExists()) { Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent }); downloadButton.setColorFilter( styledAttributes.getColor(0, getActivity().getResources().getColor(R.color.accent_default))); styledAttributes.recycle(); } else { downloadButton.clearColorFilter(); } }
From source file:org.openbmap.soapclient.GpxSerializer.java
/** * Iterates on track points and write them. * * @param bw//from w w w.j a v a 2 s.c o m * Writer to the target file. */ private void writeWaypoints(final BufferedWriter bw) throws IOException { Log.i(TAG, "Writing trackpoints"); //@formatter:off Cursor c = mDbHelper.getReadableDatabase().rawQuery(WAYPOINT_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(0) }); //@formatter:on final int colLatitude = c.getColumnIndex(Schema.COL_LATITUDE); final int colLongitude = c.getColumnIndex(Schema.COL_LONGITUDE); final int colAltitude = c.getColumnIndex(Schema.COL_ALTITUDE); final int colTimestamp = c.getColumnIndex(Schema.COL_TIMESTAMP); long outer = 0; while (!c.isAfterLast()) { c.moveToFirst(); while (!c.isAfterLast()) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("<wpt lat=\""); stringBuilder.append(String.valueOf(c.getDouble(colLatitude))); stringBuilder.append("\" "); stringBuilder.append("lon=\""); stringBuilder.append(String.valueOf(c.getDouble(colLongitude))); stringBuilder.append("\">"); stringBuilder.append("<ele>"); stringBuilder.append(String.valueOf(c.getDouble(colAltitude))); stringBuilder.append("</ele>"); stringBuilder.append("<time>"); // time stamp conversion to ISO 8601 stringBuilder.append(getGpxDate(c.getLong(colTimestamp))); stringBuilder.append("</time>"); stringBuilder.append("</wpt>"); bw.write(stringBuilder.toString()); bw.flush(); //in case of exception we don't lose data c.moveToNext(); } // fetch next CURSOR_SIZE records outer += CURSOR_SIZE; c.close(); //@formatter:off c = mDbHelper.getReadableDatabase().rawQuery(WAYPOINT_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(outer) }); //@formatter:on } c.close(); }
From source file:com.adkdevelopment.earthquakesurvival.ui.PagerActivity.java
/** * Method to populate geofence list with data from the database *///from w w w. ja va 2 s.com public void populateGeofenceList() { Cursor cursor = getContentResolver().query(EarthquakeColumns.CONTENT_URI, null, EarthquakeColumns.MAG + " >= ?", new String[] { String.valueOf(Utilities.getMagnitudePrefs(getBaseContext())) }, null); if (cursor != null && cursor.getCount() > 0) { mGeofenceList = new ArrayList<>(); int i = 0; int radius = Utilities.getDistancePrefs(getBaseContext()); if (radius > 0) { while (cursor.moveToNext() && i < 80) { // Geofence limit is around 80 per device String url = cursor.getString(cursor.getColumnIndex(EarthquakeColumns.URL)); double lat = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.LATITUDE)); double lng = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.LONGITUDE)); mGeofenceList.add(new Geofence.Builder().setRequestId(url).setCircularRegion(lat, lng, radius) .setExpirationDuration(LocationUtils.EXP_MILLIS) .setTransitionTypes( Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) .build()); i++; } } cursor.close(); } }
From source file:com.example.shoe.DirectionsTest.java
public LatLng getDestinationCoordinates(String picID) { // call DB method DatabaseHandler mDB = new DatabaseHandler(this); try {// www .jav a2 s.c o m mDB.createDatabase(); } catch (IOException ioe) { throw new Error("Unable to create database"); } try { mDB.openDatabase(); } catch (SQLException sqle) { throw sqle; } double mLat = 0; double mLon = 0; String place = null; Cursor mPlaces = mDB.fetchPicforId(picID); if (mPlaces != null) { mPlaces.moveToFirst(); // misnamed the columns ... FIX int mLatCol = mPlaces.getColumnIndex("longitude"); mLat = mPlaces.getDouble(mLatCol); // misnamed the columns ... FIX int mLonCol = mPlaces.getColumnIndex("latitude"); mLon = mPlaces.getDouble(mLonCol); int placeCol = mPlaces.getColumnIndex("name"); place = mPlaces.getString(placeCol); } mDB.close(); // get lat //double lat_value = Double.parseDouble(mLat); // get lon //double lon_value = Double.parseDouble(mLon); LatLng mDestination = new LatLng(mLat, mLon); //mDestination.latitude = 45.123456; Context context = getApplicationContext(); CharSequence text = "Your place is " + mDestination.latitude + " , " + mDestination.longitude + "\n" + "Place : " + place; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.show(); //getLocation(); //mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapFrag)).getMap(); //LatLng destMarker = new LatLng(mDestination.latitude, mDestination.longitude); return mDestination; }
From source file:org.openbmap.soapclient.GpxExporter.java
/** * Iterates on way points and write them. * @param bw Writer to the target file./*from www. ja va 2s . c om*/ * @param c Cursor to way points. * @throws IOException */ private void writeWifis(final BufferedWriter bw) throws IOException { Log.i(TAG, "Writing wifi waypoints"); Cursor c = mDbHelper.getReadableDatabase().rawQuery(WIFI_POINTS_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(0) }); //Log.i(TAG, WIFI_POINTS_SQL_QUERY); final int colLatitude = c.getColumnIndex(Schema.COL_LATITUDE); final int colLongitude = c.getColumnIndex(Schema.COL_LONGITUDE); final int colAltitude = c.getColumnIndex(Schema.COL_ALTITUDE); final int colTimestamp = c.getColumnIndex(Schema.COL_TIMESTAMP); final int colSsid = c.getColumnIndex(Schema.COL_SSID); long outer = 0; while (!c.isAfterLast()) { c.moveToFirst(); //StringBuffer out = new StringBuffer(); while (!c.isAfterLast()) { bw.write("\t<wpt lat=\""); bw.write(String.valueOf(c.getDouble(colLatitude))); bw.write("\" "); bw.write("lon=\""); bw.write(String.valueOf(c.getDouble(colLongitude))); bw.write("\">\n"); bw.write("\t\t<ele>"); bw.write(String.valueOf(c.getDouble(colAltitude))); bw.write("</ele>\n"); bw.write("\t\t<time>"); // time stamp conversion to ISO 8601 bw.write(getGpxDate(c.getLong(colTimestamp))); bw.write("</time>\n"); bw.write("\t\t<name>"); bw.write(StringEscapeUtils.escapeXml(c.getString(colSsid))); bw.write("</name>\n"); bw.write("\t</wpt>\n"); c.moveToNext(); } //bw.write(out.toString()); //out = null; // fetch next CURSOR_SIZE records outer += CURSOR_SIZE; c.close(); c = mDbHelper.getReadableDatabase().rawQuery(WIFI_POINTS_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(outer) }); } c.close(); System.gc(); }
From source file:planets.position.EclipseData.java
private void fillSolarData() { String eclType, localData, globalData; int val; Cursor eclipseCursor; if (localEcl) { eclipseCursor = cr.query(Uri.withAppendedPath(PlanetsDbProvider.SOLAR_URI, String.valueOf(eclipseNum)), sel_projection, null, null, null); } else {//from www . j av a 2 s . c om eclipseCursor = cr.query(Uri.withAppendedPath(PlanetsDbProvider.SOLAR_URI, String.valueOf(eclipseNum)), se_projection, null, null, null); } eclipseCursor.moveToFirst(); eclTypeText .setText(eclipseCursor.getString(eclipseCursor.getColumnIndexOrThrow("eclipseType")) + " Eclipse"); eclDateText.setText(eclipseCursor.getString(eclipseCursor.getColumnIndexOrThrow("eclipseDate"))); globalData = "Eclipse Times (UTC)\n";// -------------------\n"; globalData += String.format("%-16s%13s\n", "Eclipse Start", convertDate( eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("globalBeginTime")), false)); globalData += String.format("%-16s%13s\n", "Totality Start", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("globalTotBegin")), false)); globalData += String.format("%-16s%13s\n", "Maximum Eclipse", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("globalMaxTime")), false)); globalData += String.format("%-16s%13s\n", "Totality End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("globalTotEnd")), false)); globalData += String.format("%-16s%13s", "Eclipse End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("globalEndTime")), false)); eclGlobalDataText.setText(globalData); if (localEcl) { // local eclipse val = eclipseCursor.getInt(eclipseCursor.getColumnIndexOrThrow("localType")); if ((val & 4) == 4) // SE_ECL_TOTAL eclType = "Total Eclipse"; else if ((val & 8) == 8) // SE_ECL_ANNULAR eclType = "Annular Eclipse"; else if ((val & 16) == 16) // SE_ECL_PARTIAL eclType = "Partial Eclipse"; else if ((val & 32) == 32) // SE_ECL_ANNULAR_TOTAL eclType = "Hybrid Eclipse"; else eclType = "Other Eclipse"; localData = "Local Eclipse Data\n";// ------------------\n"; localData += "Type: " + eclType + "\n"; localData += String.format("%-16s%13s\n", "Eclipse Start", convertDate( eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("localFirstTime")), true)); localData += String.format("%-16s%13s\n", "Totality Start", convertDate( eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("localSecondTime")), true)); localData += String.format("%-16s%13s\n", "Maximum Eclipse", convertDate( eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("localMaxTime")), true)); localData += String.format("%-16s%13s\n", "Totality End", convertDate( eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("localThirdTime")), true)); localData += String.format("%-16s%13s\n\n", "Eclipse End", convertDate( eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("localFourthTime")), true)); localData += "Sun Position @ Max Eclipse\n"; localData += String.format("%-17s%8.1f\u00b0\n", "Azimuth", eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("sunAz"))); localData += String.format("%-17s%8.1f\u00b0\n\n", "Altitude", eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("sunAlt"))); localData += String.format("%-16s%7.1f%%\n", "Sun Coverage", eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("fracCover")) * 100); localData += String.format("%-16s%8.1f\n", "Magnitude", eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("localMag"))); localData += String.format("%-16s%8d\n", "Saros Number", eclipseCursor.getInt(eclipseCursor.getColumnIndexOrThrow("sarosNum"))); localData += String.format("%-16s%8d", "Saros Member #", eclipseCursor.getInt(eclipseCursor.getColumnIndexOrThrow("sarosMemNum"))); eclLocalDataText.setText(localData); } else { eclLocalDataText.setVisibility(View.GONE); } }
From source file:planets.position.EclipseData.java
private void fillLunarData() { String localData, globalData; Cursor eclipseCursor; if (localEcl) { eclipseCursor = cr.query(Uri.withAppendedPath(PlanetsDbProvider.LUNAR_URI, String.valueOf(eclipseNum)), lel_projection, null, null, null); } else {//from w ww .j a v a 2s . c om eclipseCursor = cr.query(Uri.withAppendedPath(PlanetsDbProvider.LUNAR_URI, String.valueOf(eclipseNum)), le_projection, null, null, null); } eclipseCursor.moveToFirst(); eclTypeText .setText(eclipseCursor.getString(eclipseCursor.getColumnIndexOrThrow("eclipseType")) + " Eclipse"); eclDateText.setText(eclipseCursor.getString(eclipseCursor.getColumnIndexOrThrow("eclipseDate"))); globalData = "Eclipse Times (UTC)\n";// -------------------\n"; globalData += String.format("%-16s%13s\n", "Penumbral Start", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("penBegin")), false)); globalData += String.format("%-16s%13s\n", "Partial Start", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("partBegin")), false)); globalData += String.format("%-16s%13s\n", "Totality Start", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("totBegin")), false)); globalData += String.format("%-16s%13s\n", "Maximum Eclipse", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("maxEclTime")), false)); globalData += String.format("%-16s%13s\n", "Totality End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("totEnd")), false)); globalData += String.format("%-16s%13s\n", "Partial End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("partEnd")), false)); globalData += String.format("%-16s%13s", "Penumbral End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("penEnd")), false)); eclGlobalDataText.setText(globalData); if (localEcl) { // local eclipse localData = "Local Eclipse Data\n";// ------------------\n"; localData += String.format("%-16s%13s\n", "Penumbral Start", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("penBegin")), true)); localData += String.format("%-16s%13s\n", "Partial Start", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("partBegin")), true)); localData += String.format("%-16s%13s\n", "Totality Start", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("totBegin")), true)); localData += String.format("%-16s%13s\n", "Maximum Eclipse", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("maxEclTime")), true)); localData += String.format("%-16s%13s\n", "Totality End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("totEnd")), true)); localData += String.format("%-16s%13s\n", "Partial End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("partEnd")), true)); localData += String.format("%-16s%13s\n\n", "Penumbral End", convertDate(eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("penEnd")), true)); localData += "Moon Position @ Max Eclipse\n"; localData += String.format("%-17s%8.1f\u00b0\n", "Azimuth", eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("moonAz"))); localData += String.format("%-17s%8.1f\u00b0\n\n", "Altitude", eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("moonAlt"))); // localData += String.format( // "%-13s%13s\n", // "Moon Rise", // convertDate(planetCur.getDouble(planetCur // .getColumnIndexOrThrow("rTime")), true)); // localData += String.format( // "%-13s%13s\n", // "Moon Set", // convertDate(planetCur.getDouble(planetCur // .getColumnIndexOrThrow("sTime")), true)); localData += String.format("%-18s%8.1f\n", "Magnitude", eclipseCursor.getDouble(eclipseCursor.getColumnIndexOrThrow("eclipseMag"))); localData += String.format("%-18s%8d\n", "Saros Number", eclipseCursor.getInt(eclipseCursor.getColumnIndexOrThrow("sarosNum"))); localData += String.format("%-18s%8d", "Saros Member #", eclipseCursor.getInt(eclipseCursor.getColumnIndexOrThrow("sarosMemNum"))); eclLocalDataText.setText(localData); } else { eclLocalDataText.setVisibility(View.GONE); } // planetDbHelper.close(); }
From source file:org.openbmap.soapclient.GpxSerializer.java
/** * Iterates on way points and write them. * * @param bw//from ww w. j a v a2s. com * Writer to the target file. */ private void writeCells(final BufferedWriter bw) throws IOException { Log.i(TAG, "Writing cell waypoints"); //@formatter:off Cursor c = mDbHelper.getReadableDatabase().rawQuery(CELL_POINTS_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(0) }); //@formatter:on final int colLatitude = c.getColumnIndex(Schema.COL_LATITUDE); final int colLongitude = c.getColumnIndex(Schema.COL_LONGITUDE); final int colAltitude = c.getColumnIndex(Schema.COL_ALTITUDE); final int colTimestamp = c.getColumnIndex(Schema.COL_TIMESTAMP); final int colName = c.getColumnIndex("name"); long outer = 0; while (!c.isAfterLast()) { c.moveToFirst(); while (!c.isAfterLast()) { StringBuffer out = new StringBuffer(); out.append("<wpt lat=\""); out.append(String.valueOf(c.getDouble(colLatitude))); out.append("\" "); out.append("lon=\""); out.append(String.valueOf(c.getDouble(colLongitude))); out.append("\">"); out.append("<ele>"); out.append(String.valueOf(c.getDouble(colAltitude))); out.append("</ele>"); out.append("<time>"); // time stamp conversion to ISO 8601 out.append(getGpxDate(c.getLong(colTimestamp))); out.append("</time>"); out.append("<name>"); out.append(StringEscapeUtils.escapeXml10(c.getString(colName))); out.append("</name>"); out.append("</wpt>"); bw.write(out.toString()); bw.flush(); c.moveToNext(); } //bw.write(out.toString()); //out = null; // fetch next CURSOR_SIZE records outer += CURSOR_SIZE; c.close(); //@formatter:off c = mDbHelper.getReadableDatabase().rawQuery(CELL_POINTS_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(outer) }); //@formatter:on } c.close(); }
From source file:org.xbmc.kore.ui.AlbumDetailsFragment.java
/** * Display the album details//w ww . j a va2s . co m * * @param cursor Cursor with the data */ private void displayAlbumDetails(Cursor cursor) { final Resources resources = getActivity().getResources(); cursor.moveToFirst(); albumTitle = cursor.getString(AlbumDetailsQuery.TITLE); albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST); mediaTitle.setText(albumTitle); mediaUndertitle.setText(albumDisplayArtist); setMediaYear(cursor.getString(AlbumDetailsQuery.GENRE), cursor.getInt(AlbumDetailsQuery.YEAR)); double rating = cursor.getDouble(AlbumDetailsQuery.RATING); if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); setMediaRating(rating); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); } String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION); if (!TextUtils.isEmpty(description)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(description); final int maxLines = resources.getInteger(R.integer.description_max_lines); Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme .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) { if (!isDescriptionExpanded) { mediaDescription.setMaxLines(Integer.MAX_VALUE); mediaShowAll.setImageResource(iconExpandResId); } else { mediaDescription.setMaxLines(maxLines); mediaShowAll.setImageResource(iconCollapseResId); } isDescriptionExpanded = !isDescriptionExpanded; } }); } else { mediaDescriptionContainer.setVisibility(View.GONE); } // Images DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); String fanart = cursor.getString(AlbumDetailsQuery.FANART), poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height), artWidth = displayMetrics.widthPixels; int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth); UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, albumTitle, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth, artHeight); }
From source file:org.openbmap.soapclient.GpxSerializer.java
/** * Iterates on way points and write them. * * @param bw//from w ww. j a va 2 s. c o m * Writer to the target file. */ private void writeWifis(final BufferedWriter bw) throws IOException { Log.i(TAG, "Writing wifi waypoints"); //@formatter:off Cursor c = mDbHelper.getReadableDatabase().rawQuery(WIFI_POINTS_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(0) }); //@formatter:on final int colLatitude = c.getColumnIndex(Schema.COL_LATITUDE); final int colLongitude = c.getColumnIndex(Schema.COL_LONGITUDE); final int colAltitude = c.getColumnIndex(Schema.COL_ALTITUDE); final int colTimestamp = c.getColumnIndex(Schema.COL_TIMESTAMP); final int colSsid = c.getColumnIndex(Schema.COL_SSID); long outer = 0; while (!c.isAfterLast()) { c.moveToFirst(); while (!c.isAfterLast()) { StringBuffer out = new StringBuffer(); out.append("<wpt lat=\""); out.append(String.valueOf(c.getDouble(colLatitude))); out.append("\" "); out.append("lon=\""); out.append(String.valueOf(c.getDouble(colLongitude))); out.append("\">"); out.append("<ele>"); out.append(String.valueOf(c.getDouble(colAltitude))); out.append("</ele>\n"); out.append("<time>"); // time stamp conversion to ISO 8601 out.append(getGpxDate(c.getLong(colTimestamp))); out.append("</time>"); out.append("<name>"); out.append(StringEscapeUtils.escapeXml10(c.getString(colSsid))); out.append("</name>"); out.append("</wpt>"); bw.write(out.toString()); bw.flush(); c.moveToNext(); } // fetch next CURSOR_SIZE records outer += CURSOR_SIZE; c.close(); //@formatter:off c = mDbHelper.getReadableDatabase().rawQuery(WIFI_POINTS_SQL_QUERY, new String[] { String.valueOf(mSession), String.valueOf(outer) }); //@formatter:on } c.close(); }