Search in sources :

Example 1 with MaterialRatingBar

use of me.zhanghai.android.materialratingbar.MaterialRatingBar in project Douya by DreaminginCodeZH.

the class ItemCollectionFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    //activity.setTitle(getTitle());
    activity.setSupportActionBar(mToolbar);
    // As in https://developer.android.com/guide/topics/ui/controls/radiobutton.html .
    View.OnClickListener collectionStateButtonOnClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (!((RadioButton) view).isChecked()) {
                return;
            }
            ItemCollectionState oldCollectionState = mCollectionState;
            switch(view.getId()) {
                case R.id.todo:
                    mCollectionState = ItemCollectionState.TODO;
                    break;
                case R.id.doing:
                    mCollectionState = ItemCollectionState.DOING;
                    break;
                case R.id.done:
                    mCollectionState = ItemCollectionState.DONE;
                    break;
            }
            if (mCollectionState != oldCollectionState) {
                onCollectionStateChanged();
            }
        }
    };
    mTodoButton.setOnClickListener(collectionStateButtonOnClickListener);
    mDoingButton.setOnClickListener(collectionStateButtonOnClickListener);
    mDoneButton.setOnClickListener(collectionStateButtonOnClickListener);
    mRatingBar.setOnRatingChangeListener(new MaterialRatingBar.OnRatingChangeListener() {

        @Override
        public void onRatingChanged(MaterialRatingBar ratingBar, float rating) {
            mRatingHintText.setText(DoubanUtils.getRatingHint((int) rating, mRatingHintText.getContext()));
        }
    });
}
Also used : MaterialRatingBar(me.zhanghai.android.materialratingbar.MaterialRatingBar) AppCompatActivity(android.support.v7.app.AppCompatActivity) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) ItemCollectionState(me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 ItemCollectionState (me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState)1 MaterialRatingBar (me.zhanghai.android.materialratingbar.MaterialRatingBar)1