use of me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState in project Douya by DreaminginCodeZH.
the class ProfileItemsLayout method bind.
protected void bind(UserItems primaryItems, UserItems secondaryItems, UserItems tertiaryItems) {
final Context context = getContext();
ItemCollectionState state = primaryItems.getState();
CollectableItem.Type type = primaryItems.getType();
String stateString = state.getString(type, context);
mTitleText.setText(stateString);
OnClickListener viewMoreListener = new OnClickListener() {
@Override
public void onClick(View view) {
onViewPrimaryItems();
}
};
mTitleText.setOnClickListener(viewMoreListener);
mViewMoreText.setOnClickListener(viewMoreListener);
mItemAdapter.replace(primaryItems.items);
ViewUtils.setVisibleOrGone(mItemList, !primaryItems.items.isEmpty());
mEmptyView.setText(context.getString(R.string.profile_items_empty_format, stateString, type.getName(context)));
ViewUtils.setVisibleOrGone(mEmptyView, primaryItems.items.isEmpty());
if (primaryItems.total > primaryItems.items.size()) {
mViewMoreText.setText(context.getString(R.string.view_more_with_count_format, primaryItems.total));
} else {
mViewMoreText.setVisibility(GONE);
}
if (secondaryItems != null && secondaryItems.total > 0) {
mSecondaryText.setText(context.getString(R.string.profile_items_non_primary_format, secondaryItems.getState().getString(secondaryItems.getType(), context), secondaryItems.total));
mSecondaryText.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
onViewSecondaryItems();
}
});
} else {
mSecondaryText.setVisibility(GONE);
}
if (tertiaryItems != null && tertiaryItems.total > 0) {
mTertiaryText.setText(context.getString(R.string.profile_items_non_primary_format, tertiaryItems.getState().getString(tertiaryItems.getType(), context), tertiaryItems.total));
mTertiaryText.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
onViewTertiaryItems();
}
});
} else {
mTertiaryText.setVisibility(GONE);
}
}
use of me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState 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