Example usage for android.database Cursor getFloat

List of usage examples for android.database Cursor getFloat

Introduction

In this page you can find the example usage for android.database Cursor getFloat.

Prototype

float getFloat(int columnIndex);

Source Link

Document

Returns the value of the requested column as a float.

Usage

From source file:com.mycompany.popularmovies.DetailActivity.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    if (cursorLoader == mGeneralInfoLoader) {
        if (cursor != null && cursor.moveToFirst()) {
            int columnIndexPosterPath = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_POSTER_PATH);
            String posterPath = MovieAdapter.POSTER_BASE_URL_W185 + cursor.getString(columnIndexPosterPath);
            Picasso picasso = Picasso.with(getActivity());
            picasso.load(posterPath).into(mPosterImageView);

            int columnIndexTitle = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_TITLE);
            String title = cursor.getString(columnIndexTitle);
            mTitleTextView.setText(title);

            int columnIndexIsFavorite = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_FAVORITED);
            int isFavorite = cursor.getInt(columnIndexIsFavorite);
            mHeartImageView/*from  ww  w.j a  v a 2  s.c  om*/
                    .setImageResource(isFavorite == 1 ? R.drawable.heart_active : R.drawable.heart_inactive);
            mHeartImageView.setOnClickListener(this);

            int columnIndexReleaseDate = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_RELEASE_DATE);
            String releaseDateText = cursor.getString(columnIndexReleaseDate);
            String releaseYearText = releaseDateText.substring(0, Math.min(releaseDateText.length(), 4));
            mReleaseYearTextView.setText(releaseYearText);

            int columnIndexVoteAverage = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_VOTE_AVERAGE);
            float vote_average = cursor.getFloat(columnIndexVoteAverage);
            mRatingBar.setRating(vote_average);

            int columnIndexSynopsis = cursor.getColumnIndex(MovieContract.MovieTable.COLUMN_SYNOPSIS);
            mSynopsisTextView.setText(cursor.getString(columnIndexSynopsis));

            // If onCreateOptionsMenu has already happened, we need to update the share intent now.
            if (mShareActionProvider != null) {
                mShareText = title;
                mShareActionProvider.setShareIntent(createShareIntent());
            }
        } else {
            Log.e(LOG_TAG, "Cursor to populate general info was empty or null!");
        }
    } else if (cursorLoader == mTrailerLoader) {
        if (cursor == null || !cursor.moveToFirst()) {
            mTrailerListTitle.setVisibility(View.INVISIBLE);
        } else {
            mTrailerListTitle.setVisibility(View.VISIBLE);
            for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) {
                int columnIndexName = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_NAME);
                String trailerName = cursor.getString(columnIndexName);

                int columnIndexLanguageCode = cursor
                        .getColumnIndex(MovieContract.TrailersTable.COLUMN_LANGUAGE_CODE);
                String trailerLanguageCode = cursor.getString(columnIndexLanguageCode);

                String trailer_summary = String.format("%s (%s)", trailerName,
                        trailerLanguageCode.toUpperCase());

                int columnIndexSite = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_SITE);
                String site = cursor.getString(columnIndexSite);

                int columnIndexKey = cursor.getColumnIndex(MovieContract.TrailersTable.COLUMN_KEY);
                String key = cursor.getString(columnIndexKey);

                String link = null;
                if (site.compareTo("YouTube") == 0) {
                    link = "https://www.youtube.com/watch?v=" + key;
                } else {
                    Log.e(LOG_TAG, "Unsupported site: " + site);
                }

                ImageView trailerThumbnail = (ImageView) mActivity.getLayoutInflater()
                        .inflate(R.layout.detail_fragment_trailer_item, null, false);
                if (site.compareTo("YouTube") == 0) {
                    Picasso picasso = Picasso.with(mActivity);
                    String youtubeThumbnailPath = String.format("http://img.youtube.com/vi/%s/mqdefault.jpg",
                            key);
                    picasso.load(youtubeThumbnailPath).into(trailerThumbnail);
                    trailerThumbnail.setTag(link);
                    trailerThumbnail.setOnClickListener(this);
                }

                mTrailerList.addView(trailerThumbnail);
            }
        }
    } else if (cursorLoader == mReviewLoader) {
        if (cursor == null || !cursor.moveToFirst()) {
            mReviewListTitle.setVisibility(View.INVISIBLE);
        } else {
            mReviewListTitle.setVisibility(View.VISIBLE);
            String colors[] = { "#00BFFF", "#00CED1", "#FF8C00", "#00FA9A", "#9400D3" };
            for (cursor.moveToFirst(); cursor.getPosition() < cursor.getCount(); cursor.moveToNext()) {
                int columnIndexAuthor = cursor.getColumnIndex(MovieContract.ReviewsTable.COLUMN_AUTHOR);
                String author = cursor.getString(columnIndexAuthor);
                String authorAbbreviation = author != null && author.length() >= 1 ? author.substring(0, 1)
                        : "?";

                int columnIndexReviewText = cursor
                        .getColumnIndex(MovieContract.ReviewsTable.COLUMN_REVIEW_TEXT);
                String reviewText = cursor.getString(columnIndexReviewText);

                RelativeLayout review = (RelativeLayout) mActivity.getLayoutInflater()
                        .inflate(R.layout.detail_fragment_review_item, null, false);
                review.setOnClickListener(this);
                review.setTag(TAG_REVIEW_COLLAPSED);

                TextView authorIcon = (TextView) review.findViewById(R.id.author_icon);
                authorIcon.setText(authorAbbreviation);
                int color = Color.parseColor(colors[cursor.getPosition() % colors.length]);
                authorIcon.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

                TextView authorFullName = (TextView) review.findViewById(R.id.author_full_name);
                authorFullName.setText(author);

                TextView reviewTextView = (TextView) review.findViewById(R.id.review_text);
                reviewTextView.setText(reviewText);

                mReviewList.addView(review);
            }
        }
    }
}

From source file:com.example.android.spotifystreamer.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 weather art image
        //mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

        //      Picasso.with(context).load("https://i.scdn.co/image/264d935b124541a0755b6c4723a08ca51f036e21").into(mIconView);

        // 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);/*from   w  ww . j av  a 2s  .  co m*/

        // 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);
        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.demo.weather.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);/*from ww w.  j  av a  2s.c om*/

        // Read description from cursor and update view
        String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_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(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP));
        String highString = Utility.formatTemperature(getActivity(), high);
        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);
        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.digitalconstruction.myapplication.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 .j a va2  s . com

        // Read description from cursor and update view
        String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
        // For accessibility, add a content description to the icon field
        mIconView.setContentDescription(description);
        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);
        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);
        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));
        Log.d("MARK", "wind: 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.nadmm.airports.afd.AirportDetailsFragment.java

protected void showAwosDetails(Cursor[] result) {
    LinearLayout layout = (LinearLayout) findViewById(R.id.detail_awos_layout);
    Cursor awos1 = result[7];
    if (awos1.moveToFirst()) {
        do {//from   ww w  .  ja v a  2  s  . co m
            if (awos1.getPosition() == MAX_WX_STATIONS) {
                break;
            }
            String icaoCode = awos1.getString(awos1.getColumnIndex(Wxs.STATION_ID));
            String sensorId = awos1.getString(awos1.getColumnIndex(Awos1.WX_SENSOR_IDENT));
            if (icaoCode == null || icaoCode.isEmpty()) {
                icaoCode = "K" + sensorId;
            }
            String type = awos1.getString(awos1.getColumnIndex(Awos1.WX_SENSOR_TYPE));
            String freq = awos1.getString(awos1.getColumnIndex(Awos1.STATION_FREQUENCY));
            if (freq == null || freq.isEmpty()) {
                freq = awos1.getString(awos1.getColumnIndex(Awos1.SECOND_STATION_FREQUENCY));
            }
            String phone = awos1.getString(awos1.getColumnIndex(Awos1.STATION_PHONE_NUMBER));
            String name = awos1.getString(awos1.getColumnIndex(Wxs.STATION_NAME));
            float distance = awos1.getFloat(awos1.getColumnIndex("DISTANCE"));
            float bearing = awos1.getFloat(awos1.getColumnIndex("BEARING"));

            final Bundle extras = new Bundle();
            extras.putString(NoaaService.STATION_ID, icaoCode);
            extras.putString(Awos1.WX_SENSOR_IDENT, sensorId);

            Runnable runnable = new Runnable() {

                @Override
                public void run() {
                    cacheMetars();
                    Intent intent = new Intent(getActivity(), WxDetailActivity.class);
                    intent.putExtras(extras);
                    startActivity(intent);
                }
            };
            addAwosRow(layout, icaoCode, name, type, freq, phone, distance, bearing, runnable);
        } while (awos1.moveToNext());

        if (!awos1.isAfterLast()) {
            Intent intent = new Intent(getActivity(), NearbyWxActivity.class);
            intent.putExtra(LocationColumns.LOCATION, mLocation);
            intent.putExtra(LocationColumns.RADIUS, mRadius);
            addClickableRow(layout, "More...", intent);
        }
    } else {
        addRow(layout, "No Wx stations found nearby.");
    }
}

From source file:com.aafr.alfonso.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(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 . j  av  a  2  s. c  o m*/

        // Read description from cursor and update view
        String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_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(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.example.android.ennis.barrett.popularmovies.DetailFragment.java

/**
 * Sets all the views to related id./*w ww. ja v a  2 s. c o  m*/
 * @param _id The id of the movie
 */
private void setDetails(long _id) {
    /*
     * get references
     */
    TextView title = (TextView) mRootView.findViewById(R.id.original_title);
    TextView overview = (TextView) mRootView.findViewById(R.id.overview);
    TextView date = (TextView) mRootView.findViewById(R.id.date);
    TextView voteAverage2 = (TextView) mRootView.findViewById(R.id.vote_average2);
    ImageView poster = (ImageView) mRootView.findViewById(R.id.poster);
    RatingBar voteAverage = (RatingBar) mRootView.findViewById(R.id.vote_average);
    LinearLayout videos = (LinearLayout) mRootView.findViewById(R.id.videos);
    LinearLayout reviews = (LinearLayout) mRootView.findViewById(R.id.reviews);
    CompoundButton isFavorite = (CompoundButton) mRootView.findViewById(R.id.favorite);

    ContentResolver contentResolver = getActivity().getContentResolver();

    /*
     * Queries the movies table
     */
    Cursor cursor = contentResolver.query(TMDbContract.Movies.URI, null, TMDbContract.Movies.ID + " = ?",
            new String[] { mID + "" }, null);
    cursor.moveToFirst();

    /*
     * sets most views to the movie
     */
    title.setText(cursor.getString(cursor.getColumnIndex(TMDbContract.Movies.ORIGINAL_TITLE)));

    overview.setText(cursor.getString(cursor.getColumnIndex(TMDbContract.Movies.OVERVIEW)));

    date.setText(cursor.getString(cursor.getColumnIndex(TMDbContract.Movies.RELEASE_DATE)));

    // Setups up the poster
    String posterURLString = "http://image.tmdb.org/t/p/w185/"
            + cursor.getString(cursor.getColumnIndex(TMDbContract.Movies.POSTER));
    Log.v(TAG, posterURLString);
    Picasso.with(getActivity()).load(posterURLString).into(poster);

    String bool = cursor.getString(cursor.getColumnIndex(TMDbContract.Movies.IS_FAVORITE));

    isFavorite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ContentValues value = new ContentValues();
            String isFavorite = "0";
            if (((CompoundButton) v).isChecked()) {
                isFavorite = "1";
            }

            value.put(TMDbContract.Movies.IS_FAVORITE, isFavorite);
            int num = getActivity().getContentResolver().update(TMDbContract.Movies.URI, value,
                    TMDbContract.Movies._ID + " = ?", new String[] { Long.toString(mID) });
        }
    });

    //short circuit logic stops app from crashing..So don't reverse the expression
    if (bool != null && bool.equals("1")) {
        isFavorite.setChecked(true);
    } else {
        isFavorite.setChecked(false);
    }

    //Set up the RatingBar and the TextView with the rating
    float vote = cursor.getFloat(cursor.getColumnIndex(TMDbContract.Movies.VOTE_AVERAGE));
    voteAverage2.setText(vote + " / 10 ");
    vote /= 2;
    Log.v(TAG, vote + "");
    voteAverage.setRating(vote);
    Log.v(TAG, voteAverage.getRating() + "");

    /*
     * Set up the videos LinearLayout.
     * Queries the table and then creates TextViews to display the results
     */
    Cursor cursorVideos = contentResolver.query(TMDbContract.Videos.URI, null,
            TMDbContract.Videos.MOVIE_IDS + " = ?",
            new String[] { cursor.getString(cursor.getColumnIndex(TMDbContract.Movies.MOVIE_ID)) }, null);
    VideoCursorAdapter adapter = new VideoCursorAdapter(getActivity(), R.layout.video_card, cursorVideos);

    //loop to create TextViews to display the results
    for (int i = 0; i < adapter.getCount(); i++) {
        View view = adapter.getView(i, null, null);
        view.setOnClickListener(this);
        videos.addView(view);
    }

    /*
     * Set up the reviews LinearLayout.
     * Queries the table and then creates TextViews to display the results
     */
    Cursor cursorReviews = contentResolver.query(TMDbContract.Reviews.URI, null,
            TMDbContract.Reviews.MOVIE_IDS + " = ?",
            new String[] { cursor.getString(cursor.getColumnIndex(TMDbContract.Movies.MOVIE_ID)) }, null);

    if (cursorReviews.getCount() == 0) {
        mRootView.findViewById(R.id.reviews_header).setVisibility(View.GONE);
    } else {
        ReviewCursorAdapter adapter2 = new ReviewCursorAdapter(getActivity(), R.layout.review_card,
                cursorReviews);
        for (int i = 0; i < adapter2.getCount(); i++) {
            View view = adapter2.getView(i, null, null);
            reviews.addView(view);
        }
    }
}

From source file:com.sagar.sunshine.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        ViewParent vp = getView().getParent();
        if (vp instanceof CardView) {
            ((View) vp).setVisibility(View.VISIBLE);
        }/*  w  w w .  j  a va2 s.co m*/

        int weatherId = data.getInt(COL_WEATHER_CONDITION_ID);

        if (Utility.usingLocalGraphics(getActivity())) {
            mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));
        } else {
            Glide.with(this).load(Utility.getArtUrlForWeatherCondition(getActivity(), weatherId))
                    .error(Utility.getArtResourceForWeatherCondition(weatherId)).crossFade().into(mIconView);
        }

        long date = data.getLong(COL_WEATHER_DATE);
        String dateText = Utility.getFullFriendlyDayString(getActivity(), date);
        mDateView.setText(dateText);

        String description = Utility.getStringForWeatherCondition(getActivity(), weatherId);
        mDescriptionView.setText(description);
        mDescriptionView.setContentDescription(getString(R.string.a11y_forecast, description));

        mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description));

        boolean isMetric = Utility.isMetric(getActivity());

        double high = data.getDouble(COL_WEATHER_MAX_TEMP);
        String highString = Utility.formatTemperature(getActivity(), high);
        mHighTempView.setText(highString);
        mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, highString));

        double low = data.getDouble(COL_WEATHER_MIN_TEMP);
        String lowString = Utility.formatTemperature(getActivity(), low);
        mLowTempView.setText(lowString);
        mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, lowString));

        float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
        mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));
        mHumidityView.setContentDescription(getString(R.string.a11y_humidity, mHumidityView.getText()));
        mHumidityLabelView.setContentDescription(mHumidityView.getContentDescription());

        float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
        float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
        mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));
        mWindView.setContentDescription(getString(R.string.a11y_wind, mWindView.getText()));
        mWindLabelView.setContentDescription(mWindView.getContentDescription());

        float pressure = data.getFloat(COL_WEATHER_PRESSURE);
        mPressureView.setText(getString(R.string.format_pressure, pressure));
        mPressureView.setContentDescription(getString(R.string.a11y_pressure, mPressureView.getText()));
        mPressureLabelView.setContentDescription(mPressureView.getContentDescription());

        mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

    }
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    Toolbar toolbarView = (Toolbar) getView().findViewById(R.id.toolbar);

    if (mTransitionAnimation) {
        activity.supportStartPostponedEnterTransition();

        if (null != toolbarView) {
            activity.setSupportActionBar(toolbarView);

            activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
            activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    } else {
        if (null != toolbarView) {
            Menu menu = toolbarView.getMenu();
            if (null != menu)
                menu.clear();
            toolbarView.inflateMenu(R.menu.detailfragment);
            finishCreatingMenu(toolbarView.getMenu());
        }
    }
}

From source file:com.sf.tracem.db.DBManager.java

/**
 * //from  www .java  2s .  c  om
 * @param cursor
 *            Cursor with orders
 * @return A list of orders
 */
private List<Order> getOrdersFrom(Cursor cursor) {
    List<Order> orders = new ArrayList<Order>();

    Map<String, Integer> columnsMap = new ArrayMap<String, Integer>();

    for (String column : Order.COLUMN_NAMES) {
        columnsMap.put(column, cursor.getColumnIndex(column));
    }

    if (cursor.moveToFirst()) {
        do {
            Order order = new Order();
            order.setADDRESS(cursor.getString(columnsMap.get(Order.ADDRESS)));
            // order.setASSIGNED_STATUS(cursor.getShort(columnsMap
            // .get(OrdersTable.ASSIGNED_STATUS)));
            order.setAUFART(cursor.getString(columnsMap.get(Order.AUFART)));
            order.setAUFNR(cursor.getString(columnsMap.get(Order.AUFNR)));
            order.setAUFTEXT(cursor.getString(columnsMap.get(Order.AUFTEXT)));
            order.setCO_GSTRP(cursor.getString(columnsMap.get(Order.CO_GSTRP)));
            order.setEXP_DAYS(cursor.getString(columnsMap.get(Order.EXP_DAYS)));
            order.setEXP_STATUS(cursor.getString(columnsMap.get(Order.EXP_STATUS)));
            // order.setID_PROGRAM(cursor.getString(8));
            order.setORDER_STATUS(cursor.getInt(columnsMap.get(Order.ORDER_STATUS)));
            order.setPARTNER(cursor.getString(columnsMap.get(Order.PARTNER)));
            order.setZHOURS(cursor.getFloat(columnsMap.get(Order.ZHOURS)));
            orders.add(order);
        } while (cursor.moveToNext());
    }

    return orders;
}

From source file:ca.qc.bdeb.info.horus.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 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);//from ww w . ja  v  a2s  . c o m

        // 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());
        if (isMetric) {
            conversion = " C";
        } else {
            conversion = " F";
        }

        mScrollView.setBackgroundResource(Utility.getColorRessourceForWeatherCondition(weatherId));

        double high = data.getDouble(COL_WEATHER_MAX_TEMP);
        String highString = Utility.formatTemperature(getActivity(), high);
        mHighTempView.setText(highString + conversion);

        // 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 + conversion);

        // 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());
        }

        if (weatherId > 199 && weatherId < 782) {
            changerTexteCouleur();
        }
    }
}