Search in sources :

Example 26 with RatingBar

use of android.widget.RatingBar in project Detours-Android by TeamDetours.

the class GasStation_NavDrawer_Activity method CreateBarRating.

// *******************************************************************
// Rating bar for rating of gas station (Helper function for CreateGasStationObject)
// *******************************************************************
private RatingBar CreateBarRating(String Rating) {
    RatingBar RatingsForGasStationVisual = new RatingBar(this);
    RatingsForGasStationVisual.setNumStars(5);
    RatingsForGasStationVisual.setRating(Float.parseFloat(Rating));
    RatingsForGasStationVisual.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    RatingsForGasStationVisual.setScaleX(.5f);
    RatingsForGasStationVisual.setScaleY(.5f);
    RatingsForGasStationVisual.setPivotX(0);
    RatingsForGasStationVisual.setPivotY(0);
    RatingsForGasStationVisual.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
    return RatingsForGasStationVisual;
}
Also used : RatingBar(android.widget.RatingBar) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout) MotionEvent(android.view.MotionEvent)

Example 27 with RatingBar

use of android.widget.RatingBar in project Detours-Android by TeamDetours.

the class Cafe_NavDrawer_Activity method CreateCafeObject.

/**
 ********************************************************************
 * Purpose: This function creates a custom layout of UI elements based
 * on the info for each Cafe. Then it adds it to the parent layout so it
 * can be displayed on the page, correctly formatted.
 *
 * Pre-condition: Cafe info is not managed.
 *
 * Post-condition: Cafe info is managed and displayed.
 ***********************************************************************
 */
public void CreateCafeObject(String Name, final String Rating, final String Address, final String Openness, String Price_level, String photo_url) {
    // *******************************************************************
    // Vertical layout for Cafe info
    // *******************************************************************
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    // *******************************************************************
    // Vertical layout for image info
    // *******************************************************************
    LinearLayout IMGlayout = new LinearLayout(this);
    IMGlayout.setOrientation(LinearLayout.VERTICAL);
    IMGlayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    // *******************************************************************
    // Horizontal layout for Cafe object
    // *******************************************************************
    LinearLayout Horzlayout = new LinearLayout(this);
    Horzlayout.setOrientation(LinearLayout.HORIZONTAL);
    Horzlayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    // *******************************************************************
    // Textview for name of Cafe
    // *******************************************************************
    final TextView NameView = new TextView(this);
    NameView.setText(Name);
    NameView.setTypeface(null, Typeface.BOLD);
    // *******************************************************************
    // Rating bar for rating of Cafe call to helper
    // *******************************************************************
    final RatingBar RatingsForCafeVisual = CreateBarRating(Rating);
    // *******************************************************************
    // Create Image of Cafe call to helper
    // *******************************************************************
    final ImageView ImageForcafe = CreateCafeImage(Address);
    if (photo_url.equals("N/A")) {
        ImageForcafe.setImageResource(R.drawable.ecafe);
    } else {
        Picasso.with(this).load(photo_url).transform(new CircleTransform()).into(ImageForcafe);
    }
    // *******************************************************************
    // Textview for address of Cafe
    // *******************************************************************
    final TextView AddressView = new TextView(this);
    AddressView.setText(Address);
    // *******************************************************************
    // Textview for openness of Cafe
    // *******************************************************************
    final TextView OpennessView = new TextView(this);
    OpennessView.setText(Openness);
    // *******************************************************************
    // Textview for price level of Cafe
    // *******************************************************************
    final TextView PriceLevel = new TextView(this);
    if (Price_level != null) {
        for (int i = 0; i < Double.parseDouble(Price_level); i++) {
            PriceLevel.setText(PriceLevel.getText() + "$");
        }
    } else {
        PriceLevel.setText("N/A");
    }
    // *******************************************************************
    // Add to the layouts to create the object.
    // *******************************************************************
    IMGlayout.addView(ImageForcafe);
    layout.addView(NameView);
    layout.addView(AddressView);
    layout.addView(OpennessView);
    layout.addView(PriceLevel);
    layout.addView(RatingsForCafeVisual);
    Horzlayout.addView(IMGlayout);
    Horzlayout.addView(layout);
    Horzlayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent ExpandIntent = new Intent(Cafe_NavDrawer_Activity.this, Expanded_Attraction_Activity.class);
            Bundle extras = new Bundle();
            extras.putString("Name", NameView.getText().toString());
            extras.putString("Address", AddressView.getText().toString());
            extras.putString("PriceLevel", PriceLevel.getText().toString());
            extras.putDouble("RatingVal", Float.parseFloat(Rating));
            extras.putString("Openness", Openness);
            ExpandIntent.putExtra("PlaceIDHash", PlaceIdHashMap);
            ExpandIntent.putExtras(extras);
            startActivity(ExpandIntent);
        }
    });
    ParentLinearLayout.addView(Horzlayout);
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) RatingBar(android.widget.RatingBar) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 28 with RatingBar

use of android.widget.RatingBar in project countly-sdk-android by Countly.

the class CountlyStarRating method showStarRatingCustom.

/**
 * Method that created the star rating dialog
 * @param context
 * @param title
 * @param message
 * @param cancelText
 * @param isCancellable
 * @param callback
 */
public static void showStarRatingCustom(final Context context, final String title, final String message, final String cancelText, final boolean isCancellable, final CountlyStarRating.RatingCallback callback) {
    if (!(context instanceof Activity)) {
        if (Countly.sharedInstance().isLoggingEnabled()) {
            Log.e(Countly.TAG, "Can't show star rating dialog, the provided context is not based off a activity");
        }
        return;
    }
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogLayout = inflater.inflate(R.layout.star_rating_layout, null);
    RatingBar ratingBar = (RatingBar) dialogLayout.findViewById(R.id.ratingBar);
    final AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(title).setMessage(message).setCancelable(isCancellable).setView(dialogLayout).setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            if (callback != null) {
                // call the dismiss callback ir the user clicks the back button or clicks outside the dialog
                callback.onDismiss();
            }
        }
    }).setPositiveButton(cancelText, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            if (callback != null) {
                // call the dismiss callback if the user clicks the "dismiss" button
                callback.onDismiss();
            }
        }
    });
    final AlertDialog dialog = builder.show();
    ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {

        @Override
        public void onRatingChanged(RatingBar ratingBar, float v, boolean b) {
            int rating = (int) v;
            if (Countly.sharedInstance().getConsent(Countly.CountlyFeatureNames.starRating)) {
                Map<String, String> segm = new HashMap<>();
                segm.put("platform", "android");
                segm.put("app_version", DeviceInfo.getAppVersion(context));
                segm.put("rating", "" + rating);
                Countly.sharedInstance().recordEvent(STAR_RATING_EVENT_KEY, segm, 1);
            }
            dialog.dismiss();
            if (callback != null) {
                callback.onRate(rating);
            }
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) View(android.view.View) RatingBar(android.widget.RatingBar) LayoutInflater(android.view.LayoutInflater) Map(java.util.Map) HashMap(java.util.HashMap)

Example 29 with RatingBar

use of android.widget.RatingBar in project Collar by CodeZsx.

the class ViewHolder method setRating.

public ViewHolder setRating(int viewId, float rating) {
    RatingBar view = getView(viewId);
    view.setRating(rating);
    return this;
}
Also used : RatingBar(android.widget.RatingBar)

Example 30 with RatingBar

use of android.widget.RatingBar in project Taskzilla by CMPUT301W18T05.

the class NewReviewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_review);
    AppColors appColors = AppColors.getInstance();
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(appColors.getActionBarColor())));
    actionBar.setTitle(Html.fromHtml("<font color='" + appColors.getActionBarTextColor() + "'>Taskzilla</font>"));
    findViews();
    RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
    stars.getDrawable(2).setColorFilter(Color.parseColor(appColors.getActionBarTextColor()), PorterDuff.Mode.SRC_ATOP);
    setValues();
}
Also used : AppColors(com.cmput301w18t05.taskzilla.AppColors) ColorDrawable(android.graphics.drawable.ColorDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) RatingBar(android.widget.RatingBar) ActionBar(android.support.v7.app.ActionBar)

Aggregations

RatingBar (android.widget.RatingBar)88 View (android.view.View)50 TextView (android.widget.TextView)45 ImageView (android.widget.ImageView)34 LinearLayout (android.widget.LinearLayout)26 NavigationView (android.support.design.widget.NavigationView)23 ScrollView (android.widget.ScrollView)23 Intent (android.content.Intent)14 Bundle (android.os.Bundle)13 MotionEvent (android.view.MotionEvent)12 RadioButton (android.widget.RadioButton)10 SeekBar (android.widget.SeekBar)8 EditText (android.widget.EditText)7 DialogInterface (android.content.DialogInterface)6 RadioGroup (android.widget.RadioGroup)6 AlertDialog (android.app.AlertDialog)5 LayoutInflater (android.view.LayoutInflater)5 Button (android.widget.Button)5 CheckBox (android.widget.CheckBox)5 Spinner (android.widget.Spinner)5