Search in sources :

Example 1 with RatingBar

use of android.widget.RatingBar in project RoboBinding by RoboBinding.

the class AbstractRatingBarAttributeTest method initializeViewAndListeners.

@Before
public void initializeViewAndListeners() {
    view = new RatingBar(RuntimeEnvironment.application);
    viewAddOn = new MockRatingBarAddOn(view);
}
Also used : RatingBar(android.widget.RatingBar) Before(org.junit.Before)

Example 2 with RatingBar

use of android.widget.RatingBar in project baseAdapter by hongyangAndroid.

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 3 with RatingBar

use of android.widget.RatingBar in project baseAdapter by hongyangAndroid.

the class ViewHolder method setRating.

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

Example 4 with RatingBar

use of android.widget.RatingBar in project BaseRecyclerViewAdapterHelper by CymChad.

the class BaseViewHolder method setRating.

/**
     * Sets the rating (the number of stars filled) and max of a RatingBar.
     *
     * @param viewId The view id.
     * @param rating The rating.
     * @param max    The range of the RatingBar to 0...max.
     * @return The BaseViewHolder for chaining.
     */
public BaseViewHolder setRating(int viewId, float rating, int max) {
    RatingBar view = getView(viewId);
    view.setMax(max);
    view.setRating(rating);
    return this;
}
Also used : RatingBar(android.widget.RatingBar)

Example 5 with RatingBar

use of android.widget.RatingBar in project Hummingbird-for-Android by xiprox.

the class AnimeDetailsActivity method displayLibraryElements.

/* If Anime exist in user library, show library related elements... */
public void displayLibraryElements() {
    if (libraryEntry != null) {
        if (mRemove != null)
            mRemove.setVisible(true);
        final String animeEpisodeCount = anime.getEpisodeCount() != 0 ? anime.getEpisodeCount() + "" : "?";
        mEpisodes.setText(libraryEntry.getEpisodesWatched() + "/" + animeEpisodeCount);
        mRewatching.setChecked(libraryEntry.isRewatching());
        mRewatchedTimes.setText(libraryEntry.getNumberOfRewatches() + "");
        mPrivate.setChecked(libraryEntry.isPrivate());
        Rating rating = libraryEntry.getRating();
        if (rating.isAdvanced()) {
            if (rating.getAdvancedRating() != null)
                mRatingBar.setRating(Float.parseFloat(rating.getAdvancedRating()));
            else
                mRatingBar.setRating(0);
            mRatingBar.setVisibility(View.VISIBLE);
            mSimpleRatingView.setVisibility(View.GONE);
        } else {
            if (rating.getSimpleRating() != null)
                mSimpleRatingView.setSelectedRating(Utils.getRatingFromString(rating.getSimpleRating()));
            else
                mSimpleRatingView.setSelectedRating(SimpleRatingView.Rating.NEUTRAL);
            mRatingBar.setVisibility(View.GONE);
            mSimpleRatingView.setVisibility(View.VISIBLE);
        }
        newWatchStatus = libraryEntry.getStatus();
        newEpisodesWatched = libraryEntry.getEpisodesWatched();
        newIsRewatching = libraryEntry.isRewatching();
        newRewatchedTimes = libraryEntry.getNumberOfRewatches();
        newPrivate = libraryEntry.isPrivate();
        newRating = libraryEntry.getRating().getAdvancedRating() != null ? libraryEntry.getRating().getAdvancedRating() : "0";
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(AnimeDetailsActivity.this, R.array.library_watch_status_items, R.layout.item_spinner_library_status);
        adapter.setDropDownViewResource(R.layout.item_spinner_item_library_status);
        mStatusSpinner.setAdapter(adapter);
        String watchStatus = libraryEntry.getStatus();
        if (watchStatus.equals("currently-watching"))
            mStatusSpinner.setSelection(0);
        if (watchStatus.equals("plan-to-watch"))
            mStatusSpinner.setSelection(1);
        if (watchStatus.equals("completed"))
            mStatusSpinner.setSelection(2);
        if (watchStatus.equals("on-hold"))
            mStatusSpinner.setSelection(3);
        if (watchStatus.equals("dropped"))
            mStatusSpinner.setSelection(4);
        mEpisodesHolder.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                View dialogView = getLayoutInflater().inflate(R.layout.number_picker, null);
                final NumberPicker mNumberPicker = (NumberPicker) dialogView.findViewById(R.id.number_picker);
                mNumberPicker.setMaxValue(anime.getEpisodeCount() != 0 ? anime.getEpisodeCount() : 1000);
                mNumberPicker.setValue(newEpisodesWatched);
                mNumberPicker.setWrapSelectorWheel(false);
                new MaterialDialog.Builder(AnimeDetailsActivity.this).title(R.string.content_episodes).positiveText(R.string.ok).negativeText(R.string.cancel).positiveColor(vibrantColor).negativeColorRes(R.color.text_dialog_action).customView(dialogView, true).callback(new MaterialDialog.ButtonCallback() {

                    @Override
                    public void onPositive(MaterialDialog materialDialog) {
                        newEpisodesWatched = mNumberPicker.getValue();
                        mEpisodes.setText(newEpisodesWatched + "/" + animeEpisodeCount);
                        if ((newEpisodesWatched + "").equals(animeEpisodeCount))
                            // (completed)
                            mStatusSpinner.setSelection(2);
                        updateUpdateButtonStatus(libraryEntry);
                    }
                }).show();
            }
        });
        mRewatching.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                newIsRewatching = isChecked;
                updateUpdateButtonStatus(libraryEntry);
            }
        });
        mRewatchedTimesHolder.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                View dialogView = getLayoutInflater().inflate(R.layout.number_picker, null);
                final NumberPicker mNumberPicker = (NumberPicker) dialogView.findViewById(R.id.number_picker);
                mNumberPicker.setMaxValue(200);
                mNumberPicker.setValue(newRewatchedTimes);
                mNumberPicker.setWrapSelectorWheel(false);
                new MaterialDialog.Builder(AnimeDetailsActivity.this).title(R.string.content_rewatched).positiveText(R.string.ok).negativeText(R.string.cancel).positiveColor(vibrantColor).negativeColorRes(R.color.text_dialog_action).customView(dialogView, true).callback(new MaterialDialog.ButtonCallback() {

                    @Override
                    public void onPositive(MaterialDialog materialDialog) {
                        newRewatchedTimes = mNumberPicker.getValue();
                        mRewatchedTimes.setText(newRewatchedTimes + "");
                        updateUpdateButtonStatus(libraryEntry);
                    }
                }).show();
            }
        });
        mPrivate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                newPrivate = isChecked;
                updateUpdateButtonStatus(libraryEntry);
            }
        });
        mStatusSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
                switch(position) {
                    case 0:
                        newWatchStatus = "currently-watching";
                        break;
                    case 1:
                        newWatchStatus = "plan-to-watch";
                        break;
                    case 2:
                        newWatchStatus = "completed";
                        break;
                    case 3:
                        newWatchStatus = "on-hold";
                        break;
                    case 4:
                        newWatchStatus = "dropped";
                        break;
                }
                updateUpdateButtonStatus(libraryEntry);
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {
            }
        });
        mRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {

            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                newRating = rating + "";
                updateUpdateButtonStatus(libraryEntry);
            }
        });
        mSimpleRatingView.setOnRatingChangedListener(new SimpleRatingView.OnRatingChangeListener() {

            @Override
            public void onRatingChanged(SimpleRatingView.Rating rating) {
                switch(rating) {
                    case POSITIVE:
                        newRating = "1";
                        break;
                    case NEUTRAL:
                        newRating = "3";
                        break;
                    case NEGATIVE:
                        newRating = "5";
                        break;
                }
                updateUpdateButtonStatus(libraryEntry);
            }
        });
        mActionButton.setImageResource(R.drawable.ic_upload_white_24dp);
        mActionButton.setOnClickListener(new OnLibraryUpdateClickListener());
        mLibraryProgressBar.setVisibility(View.GONE);
        mLibraryInfoHolder.setVisibility(View.VISIBLE);
    } else {
        enableFAB();
        mRemove.setVisible(false);
        mLibraryProgressBar.setVisibility(View.GONE);
        mLibraryInfoHolder.setVisibility(View.GONE);
    }
}
Also used : Rating(tr.bcxip.hummingbird.api.objects.Rating) NumberPicker(android.widget.NumberPicker) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ImageView(android.widget.ImageView) ObservableScrollView(tr.bcxip.hummingbird.widget.ObservableScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) SimpleRatingView(tr.xip.widget.simpleratingview.SimpleRatingView) TextView(android.widget.TextView) RatingBar(android.widget.RatingBar) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) SimpleRatingView(tr.xip.widget.simpleratingview.SimpleRatingView)

Aggregations

RatingBar (android.widget.RatingBar)58 View (android.view.View)35 TextView (android.widget.TextView)34 ImageView (android.widget.ImageView)27 LinearLayout (android.widget.LinearLayout)24 NavigationView (android.support.design.widget.NavigationView)23 ScrollView (android.widget.ScrollView)23 Intent (android.content.Intent)13 MotionEvent (android.view.MotionEvent)12 Bundle (android.os.Bundle)11 AlertDialog (android.app.AlertDialog)4 SuppressLint (android.annotation.SuppressLint)3 LayoutInflater (android.view.LayoutInflater)3 OnRatingBarChangeListener (android.widget.RatingBar.OnRatingBarChangeListener)3 Activity (android.app.Activity)2 DialogInterface (android.content.DialogInterface)2 CompoundButton (android.widget.CompoundButton)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Before (org.junit.Before)2