Java Code Examples for android.widget.RatingBar#setVisibility()

The following examples show how to use android.widget.RatingBar#setVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KinoListAdapter.java    From CineLog with GNU General Public License v3.0 5 votes vote down vote up
private void initRating(View convertView, RatingBar kinoRatingRatingBar, KinoDto movie) {
    TextView kinoRatingRatingBarAsText = (TextView) convertView.findViewById(R.id.main_result_kino_rating_bar_as_text);
    TextView kinoRatingRatingBarMaxAsText = (TextView) convertView.findViewById(R.id.main_result_kino_rating_bar_max_as_text);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

    int maxRating;
    if (movie.getMaxRating() == null) {
        String defaultMaxRateValue = prefs.getString("default_max_rate_value", "5");
        maxRating = Integer.parseInt(defaultMaxRateValue);
    } else {
        maxRating = movie.getMaxRating();
    }

    if (maxRating <= 5) {
        kinoRatingRatingBarAsText.setVisibility(View.INVISIBLE);
        kinoRatingRatingBarMaxAsText.setVisibility(View.INVISIBLE);
        kinoRatingRatingBar.setVisibility(View.VISIBLE);

        kinoRatingRatingBar.setStepSize(0.5f);
        kinoRatingRatingBar.setNumStars(maxRating);

        if (movie.getRating() != null) {
            kinoRatingRatingBar.setRating(movie.getRating());
        } else {
            kinoRatingRatingBar.setRating(0);
        }
    } else {
        kinoRatingRatingBar.setVisibility(View.INVISIBLE);
        kinoRatingRatingBarAsText.setVisibility(View.VISIBLE);
        kinoRatingRatingBarMaxAsText.setVisibility(View.VISIBLE);

        kinoRatingRatingBarAsText.setText(String.format("%s", movie.getRating()));
        kinoRatingRatingBarMaxAsText.setText(String.format("/%s", maxRating));
    }
}
 
Example 2
Source File: SendFeedBack.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_send_feed_back);
    send_url = getString(R.string.wserviceurl) + "/joh-feedback";

    myrating = (RatingBar) findViewById(R.id.ratingBar);
    ratingtext = (TextView) findViewById(R.id.ratingtext);
    contact = (EditText) findViewById(R.id.contactText);
    contact.setText(PersistentStore.getString(FEEDBACK_CONTACT_REFERENCE));

    Intent intent = getIntent();
    if (intent != null) {
        final Bundle bundle = intent.getExtras();
        if (bundle != null) {
            // TODO this probably should just use generic text method
            final String str = bundle.getString("request_translation");
            if (str != null) {
                // don't extract string - english only
                ((EditText) findViewById(R.id.yourText)).setText("Dear developers, please may I request that you add translation capability for: " + str + "\n\n");
                type_of_message = "Language request";

            }
            final String str2 = bundle.getString("generic_text");
            if (str2 != null) {
                log_data = str2;
                ((EditText) findViewById(R.id.yourText)).setText("\n\nPlease describe what you think these logs may show? Explain the problem if there is one.\n\nAttached " + log_data.length() + " characters of log data. (hidden)\n\n");
                type_of_message = "Log Push";
                myrating.setVisibility(View.GONE);
                ratingtext.setVisibility(View.GONE);
            }
        }
    }
    if (type_of_message.equals("Unknown")) {
        askType();
    }

}
 
Example 3
Source File: SendFeedBack.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_send_feed_back);
    send_url = getString(R.string.wserviceurl) + "/joh-feedback";

    myrating = (RatingBar) findViewById(R.id.ratingBar);
    ratingtext = (TextView) findViewById(R.id.ratingtext);
    contact = (EditText) findViewById(R.id.contactText);
    contact.setText(PersistentStore.getString(FEEDBACK_CONTACT_REFERENCE));

    Intent intent = getIntent();
    if (intent != null) {
        final Bundle bundle = intent.getExtras();
        if (bundle != null) {
            // TODO this probably should just use generic text method
            final String str = bundle.getString("request_translation");
            if (str != null) {
                // don't extract string - english only
                ((EditText) findViewById(R.id.yourText)).setText("Dear developers, please may I request that you add translation capability for: " + str + "\n\n");
                type_of_message = "Language request";

            }
            final String str2 = bundle.getString("generic_text");
            if (str2 != null) {
                log_data = str2;
                ((EditText) findViewById(R.id.yourText)).setText("\n\nPlease describe what you think these logs may show? Explain the problem if there is one.\n\nAttached " + log_data.length() + " characters of log data. (hidden)\n\n");
                type_of_message = "Log Push";
                myrating.setVisibility(View.GONE);
                ratingtext.setVisibility(View.GONE);
            }
        }
    }
    if (type_of_message.equals("Unknown")) {
        askType();
    }

}
 
Example 4
Source File: FavouriteProductFragment.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public void setRating(Long rating) {
    RatingBar product_rating_bar = (RatingBar) mFavouriteProductView.findViewById(R.id.favourite_product_rating_bar);
    product_rating_bar.setRating(rating);
    SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(mFavouriteProductView.getContext());
    boolean ratingDisplayCheck = SP.getBoolean("ratingButton", true);
    if(ratingDisplayCheck == false)
        product_rating_bar.setVisibility(View.INVISIBLE);
    Log.d(TAG + " ratingDisplayCheck", ratingDisplayCheck + "");
}
 
Example 5
Source File: OwnProductFragment.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public void setRating(Long rating) {
    RatingBar product_rating_bar = (RatingBar) mOwnProductView.findViewById(R.id.own_product_rating_bar);
    product_rating_bar.setRating(rating);
    SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(mOwnProductView.getContext());
    boolean ratingDisplayCheck = SP.getBoolean("ratingButton", true);
    if (ratingDisplayCheck == false)
        product_rating_bar.setVisibility(View.INVISIBLE);
    Log.d(TAG + " ratingDisplayCheck", ratingDisplayCheck + "");
}
 
Example 6
Source File: ProductRecommentationActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public void setRating(Long rating) {
            RatingBar product_rating_bar = (RatingBar) mView.findViewById(R.id.product_rating_bar);
            product_rating_bar.setVisibility(View.GONE);
//            SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
//            boolean ratingDisplayCheck = SP.getBoolean("ratingButton", true);
//            if (ratingDisplayCheck == false)
//                product_rating_bar.setVisibility(View.INVISIBLE);
//            Log.d(TAG + " ratingDisplayCheck", ratingDisplayCheck + "");
        }
 
Example 7
Source File: MainActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public void setRating(Long rating) {
    RatingBar product_rating_bar = (RatingBar) mView.findViewById(R.id.product_rating_bar);
    product_rating_bar.setRating(rating);
    SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
    boolean ratingDisplayCheck = SP.getBoolean("ratingButton", true);
    if (ratingDisplayCheck == false)
        product_rating_bar.setVisibility(View.INVISIBLE);
    Log.d(TAG + " ratingDisplayCheck", ratingDisplayCheck + "");
}
 
Example 8
Source File: TimelineAdapter.java    From aptoide-client with GNU General Public License v2.0 4 votes vote down vote up
public void inflateAd(NativeAd nativeAd, View adView, Context context) {
    // Create native UI using the ad metadata.

    ImageView nativeAdIcon = (ImageView) adView.findViewById(R.id.nativeAdIcon);
    TextView nativeAdTitle = (TextView) adView.findViewById(R.id.nativeAdTitle);
    TextView nativeAdTitleRating = (TextView) adView.findViewById(R.id.nativeAdTitleRating);
    TextView nativeAdBody = (TextView) adView.findViewById(R.id.nativeAdBody);

    ImageView nativeAdImage = (ImageView) adView.findViewById(R.id.nativeAdImage);
    TextView nativeAdSocialContext = (TextView) adView.findViewById(R.id.nativeAdSocialContext);
    FaceBookAdButton nativeAdCallToAction = (FaceBookAdButton) adView.findViewById(R.id.nativeAdCallToAction);
    RatingBar nativeAdStarRating = (RatingBar) adView.findViewById(R.id.nativeAdStarRating);

    // Setting the Text
    nativeAdSocialContext.setText(nativeAd.getAdSocialContext());
    nativeAdCallToAction.setText(nativeAd.getAdCallToAction());
    nativeAdTitle.setText(nativeAd.getAdTitle());
    nativeAdTitleRating.setText(nativeAd.getAdTitle());
    nativeAdBody.setText(nativeAd.getAdBody());

    // Downloading and setting the ad icon.
    NativeAd.Image adIcon = nativeAd.getAdIcon();
    NativeAd.downloadAndDisplayImage(adIcon, nativeAdIcon);

    // Downloading and setting the cover image.
    NativeAd.Image adCoverImage = nativeAd.getAdCoverImage();
    int bannerWidth = adCoverImage.getWidth();
    int bannerHeight = adCoverImage.getHeight();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);
    int screenWidth = metrics.widthPixels;
    int screenHeight = metrics.heightPixels;
    nativeAdImage.setLayoutParams(new LinearLayout.LayoutParams(
            screenWidth,
            Math.min((int) (((double) screenWidth / (double) bannerWidth) * bannerHeight), screenHeight / 3)
    ));
    NativeAd.downloadAndDisplayImage(adCoverImage, nativeAdImage);

    NativeAd.Rating rating = nativeAd.getAdStarRating();
    if (rating != null) {
        nativeAdStarRating.setVisibility(View.VISIBLE);
        nativeAdStarRating.setNumStars((int) rating.getScale());
        nativeAdStarRating.setRating((float) rating.getValue());
    } else {
        nativeAdStarRating.setVisibility(View.GONE);
    }

    // Wire up the View with the native ad, the whole nativeAdContainer will be clickable
    //nativeAd.registerViewForInteraction(adView);


    // Or you can replace the above call with the following function to specify the clickable areas.
    nativeAd.registerViewForInteraction(adView, Arrays.asList(nativeAdCallToAction));

}