Skip to content

Commit

Permalink
[Feature] Add hasDoingState() for item Type.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Apr 13, 2018
1 parent f1fc27c commit 6aa8d5a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ protected void bindItemCollectionHolder(RecyclerView.ViewHolder holder, T item)
context.startActivity(ItemCollectionActivity.makeIntent(item, ItemCollectionState.TODO,
context));
});
boolean doingVisible = itemCollection == null || state == ItemCollectionState.TODO;
boolean doingVisible = item.getType().hasDoingState() && (itemCollection == null
|| state == ItemCollectionState.TODO);
ViewUtils.setVisibleOrGone(itemCollectionHolder.doingButton, doingVisible);
itemCollectionHolder.doingButton.setOnClickListener(view -> {
Context context = view.getContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,32 @@ public abstract class CollectableItem extends BaseItem {

public enum Type {

APP("app", R.string.item_app_name, R.string.item_app_action, R.string.item_app_this_item),
BOOK("book", R.string.item_book_name, R.string.item_book_action, R.string.item_book_this_item),
EVENT("event", R.string.item_event_name, R.string.item_event_action, R.string.item_event_this_item),
GAME("game", R.string.item_game_name, R.string.item_game_action, R.string.item_game_this_item),
MOVIE("movie", R.string.item_movie_name, R.string.item_movie_action, R.string.item_movie_this_item),
MUSIC("music", R.string.item_music_name, R.string.item_music_action, R.string.item_music_this_item),
TV("tv", R.string.item_tv_name, R.string.item_tv_action, R.string.item_tv_this_item);
APP("app", R.string.item_app_name, R.string.item_app_action, R.string.item_app_this_item,
false),
BOOK("book", R.string.item_book_name, R.string.item_book_action,
R.string.item_book_this_item, true),
EVENT("event", R.string.item_event_name, R.string.item_event_action,
R.string.item_event_this_item, false),
GAME("game", R.string.item_game_name, R.string.item_game_action,
R.string.item_game_this_item, true),
MOVIE("movie", R.string.item_movie_name, R.string.item_movie_action,
R.string.item_movie_this_item, false),
MUSIC("music", R.string.item_music_name, R.string.item_music_action,
R.string.item_music_this_item, true),
TV("tv", R.string.item_tv_name, R.string.item_tv_action, R.string.item_tv_this_item, true);

private String mApiString;
private int mNameRes;
private int mActionRes;
private int mThisItemRes;
private boolean mHasDoingState;

Type(String apiString, int nameRes, int actionRes, int thisItemRes) {
Type(String apiString, int nameRes, int actionRes, int thisItemRes, boolean hasDoingState) {
mApiString = apiString;
mNameRes = nameRes;
mActionRes = actionRes;
mThisItemRes = thisItemRes;
mHasDoingState = hasDoingState;
}

public static Type ofApiString(String apiString, Type defaultValue) {
Expand Down Expand Up @@ -84,6 +92,10 @@ public int getThisItemRes() {
public String getThisItem(Context context) {
return context.getString(mThisItemRes);
}

public boolean hasDoingState() {
return mHasDoingState;
}
}

@SerializedName("body_bg_color")
Expand Down

0 comments on commit 6aa8d5a

Please sign in to comment.