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