text
stringlengths
9
39.2M
dir
stringlengths
25
226
lang
stringclasses
163 values
created_date
timestamp[s]
updated_date
timestamp[s]
repo_name
stringclasses
751 values
repo_full_name
stringclasses
752 values
star
int64
1.01k
183k
len_tokens
int64
1
18.5M
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.content.Context; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.gallery.ui.GalleryActivity; import me.zhanghai.android.douya.link.UriHandler; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.Game; import me.zhanghai.android.douya.network.api.info.frodo.Photo; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.ui.RatioImageView; import me.zhanghai.android.douya.util.CollectionUtils; import me.zhanghai.android.douya.util.ImageUtils; import me.zhanghai.android.douya.util.RecyclerViewUtils; import me.zhanghai.android.douya.util.StringCompat; import me.zhanghai.android.douya.util.StringUtils; import me.zhanghai.android.douya.util.ViewUtils; public class GameDataAdapter extends BaseItemDataAdapter<Game> { private enum Items { HEADER, ITEM_COLLECTION, BADGE_LIST, INTRODUCTION, PHOTO_LIST, RATING, ITEM_COLLECTION_LIST, GAME_GUIDE_LIST, REVIEW_LIST, // TODO: Currently there's no forum for game. //FORUM_TOPIC_LIST, // TODO: Frodo API currently returns 5xx for recommendation list. //RECOMMENDATION_LIST, RELATED_DOULIST_LIST } private Data mData; public GameDataAdapter(Listener listener) { super(listener); } @Override protected Listener getListener() { return (Listener) super.getListener(); } public void setData(Data data) { mData = data; notifyDataChanged(); } public void notifyItemCollectionChanged() { int position = Items.ITEM_COLLECTION.ordinal(); if (position < getItemCount()) { notifyItemChanged(position); } } public void notifyItemCollectionListItemChanged(int position, SimpleItemCollection newItemCollection) { notifyItemCollectionListItemChanged(Items.ITEM_COLLECTION_LIST.ordinal(), position, newItemCollection); } @Override public int getTotalItemCount() { return Items.values().length; } @Override protected boolean isItemLoaded(int position) { if (mData == null) { return false; } if (mData.game == null) { return false; } switch (Items.values()[position]) { case HEADER: return true; case ITEM_COLLECTION: return true; case BADGE_LIST: return mData.rating != null; case INTRODUCTION: return true; case PHOTO_LIST: return mData.photoList != null; case RATING: return mData.rating != null; case ITEM_COLLECTION_LIST: return mData.itemCollectionList != null; case GAME_GUIDE_LIST: return mData.gameGuideList != null; case REVIEW_LIST: return mData.reviewList != null; //case FORUM_TOPIC_LIST: // return mData.forumTopicList != null; //case RECOMMENDATION_LIST: // return mData.recommendationList != null; case RELATED_DOULIST_LIST: return mData.relatedDoulistList != null; default: throw new IllegalArgumentException(); } } @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { switch (Items.values()[viewType]) { case HEADER: return createHeaderHolder(parent); case ITEM_COLLECTION: return createItemCollectionHolder(parent); case BADGE_LIST: return createBadgeListHolder(parent); case INTRODUCTION: return createIntroductionHolder(parent); case PHOTO_LIST: return createPhotoListHolder(parent); case RATING: return createRatingHolder(parent); case ITEM_COLLECTION_LIST: return createItemCollectionListHolder(parent); case GAME_GUIDE_LIST: return createGameGuideListHolder(parent); case REVIEW_LIST: return createReviewListHolder(parent); //case FORUM_TOPIC_LIST: // return createForumTopicListHolder(parent); //case RECOMMENDATION_LIST: // return createRecommendationListHolder(parent); case RELATED_DOULIST_LIST: //return createRelatedDoulistListHolder(parent); { // HACK RelatedDoulistListHolder holder = createRelatedDoulistListHolder(parent); int marginTop = holder.itemView.getContext().getResources().getDimensionPixelOffset( R.dimen.item_card_list_vertical_padding); ViewUtils.setMarginTop(holder.itemView, marginTop); return holder; } default: throw new IllegalArgumentException(); } } private HeaderHolder createHeaderHolder(ViewGroup parent) { return new HeaderHolder(ViewUtils.inflate(R.layout.item_fragment_game_header, parent)); } protected ReviewListHolder createGameGuideListHolder(ViewGroup parent) { return createReviewListHolder(parent); } @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List<Object> payloads) { super.onBindViewHolder(holder, position, payloads); switch (Items.values()[position]) { case HEADER: bindHeaderHolder(holder, mData.game); break; case ITEM_COLLECTION: bindItemCollectionHolder(holder, mData.game); break; case BADGE_LIST: bindBadgeListHolder(holder, mData.game, mData.rating); break; case INTRODUCTION: bindIntroductionHolder(holder, mData.game); break; case PHOTO_LIST: bindPhotoListHolder(holder, mData.game, mData.photoList, mData.excludeFirstPhoto); break; case RATING: bindRatingHolder(holder, mData.game, mData.rating); break; case ITEM_COLLECTION_LIST: bindItemCollectionListHolder(holder, mData.game, mData.itemCollectionList, payloads); break; case GAME_GUIDE_LIST: bindGameGuideListHolder(holder, mData.game, mData.gameGuideList); break; case REVIEW_LIST: bindReviewListHolder(holder, mData.game, mData.reviewList); break; //case FORUM_TOPIC_LIST: // bindForumTopicListHolder(holder, mData.game, mData.forumTopicList); // break; //case RECOMMENDATION_LIST: // bindRecommendationListHolder(holder, mData.game, mData.recommendationList); // break; case RELATED_DOULIST_LIST: bindRelatedDoulistListHolder(holder, mData.game, mData.relatedDoulistList); break; default: throw new IllegalArgumentException(); } } private void bindHeaderHolder(RecyclerView.ViewHolder holder, Game game) { HeaderHolder headerHolder = (HeaderHolder) holder; headerHolder.coverImage.setRatio(2, 3); // HACK: Have to use game.cover.getLargeUrl() here or it will be cropped. ImageUtils.loadImage(headerHolder.coverImage, game.cover.getLargeUrl()); headerHolder.coverImage.setOnClickListener(view -> { Context context = view.getContext(); context.startActivity(GalleryActivity.makeIntent(game.cover, context)); }); headerHolder.titleText.setText(game.title); Context context = RecyclerViewUtils.getContext(holder); String slashDelimiter = context.getString(R.string.item_information_delimiter_slash); headerHolder.platformsText.setText(StringCompat.join(slashDelimiter, game.getPlatformNames())); String spaceDelimiter = context.getString(R.string.item_information_delimiter_space); String detail = StringUtils.joinNonEmpty(spaceDelimiter, game.getYearMonth(context), StringCompat.join(slashDelimiter, game.developers)); headerHolder.detailText.setText(detail); headerHolder.genresText.setText(StringCompat.join(slashDelimiter, game.genres)); } private void bindBadgeListHolder(RecyclerView.ViewHolder holder, Game game, Rating rating) { BadgeListHolder badgeListHolder = (BadgeListHolder) holder; badgeListHolder.badgeListLayout.setTop250(null); badgeListHolder.badgeListLayout.setRating(rating, game); badgeListHolder.badgeListLayout.setGenre(R.drawable.game_badge_white_40dp, CollectionUtils.firstOrNull(game.genres), CollectableItem.Type.GAME); } @Override protected void bindIntroductionHolder(RecyclerView.ViewHolder holder, Game game) { super.bindIntroductionHolder(holder, game); IntroductionHolder introductionHolder = (IntroductionHolder) holder; introductionHolder.introductionLayout.setOnClickListener(view -> { Context context = view.getContext(); context.startActivity(ItemIntroductionActivity.makeIntent(game, context)); }); } private void bindGameGuideListHolder(RecyclerView.ViewHolder holder, Game game, List<SimpleReview> gameGuideList) { bindReviewListHolder(holder, game, gameGuideList, R.string.item_game_guide_list_title, R.string.item_game_guide_list_create, R.string.item_game_guide_list_view_more, view -> { // TODO UriHandler.open(game.url + "new_review?rtype=G", view.getContext()); }, view -> { // TODO UriHandler.open(game.url + "reviews?rtype=G", view.getContext()); }); } public interface Listener extends BaseItemDataAdapter.Listener<Game> {} public static class Data { public Game game; public Rating rating; public List<Photo> photoList; public boolean excludeFirstPhoto; public List<SimpleItemCollection> itemCollectionList; public List<SimpleReview> gameGuideList; public List<SimpleReview> reviewList; public List<SimpleItemForumTopic> forumTopicList; public List<CollectableItem> recommendationList; public List<Doulist> relatedDoulistList; public Data(Game game, Rating rating, List<Photo> photoList, boolean excludeFirstPhoto, List<SimpleItemCollection> itemCollectionList, List<SimpleReview> gameGuideList, List<SimpleReview> reviewList, List<SimpleItemForumTopic> forumTopicList, List<CollectableItem> recommendationList, List<Doulist> relatedDoulistList) { this.game = game; this.rating = rating; this.photoList = photoList; this.excludeFirstPhoto = excludeFirstPhoto; this.itemCollectionList = itemCollectionList; this.gameGuideList = gameGuideList; this.reviewList = reviewList; this.forumTopicList = forumTopicList; this.recommendationList = recommendationList; this.relatedDoulistList = relatedDoulistList; } } static class HeaderHolder extends RecyclerView.ViewHolder { @BindView(R.id.cover) public RatioImageView coverImage; @BindView(R.id.title) public TextView titleText; @BindView(R.id.platforms) public TextView platformsText; @BindView(R.id.detail) public TextView detailText; @BindView(R.id.genres) public TextView genresText; public HeaderHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/GameDataAdapter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
2,447
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.content.Context; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.gallery.ui.GalleryActivity; import me.zhanghai.android.douya.network.api.info.frodo.Book; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.ui.RatioImageView; import me.zhanghai.android.douya.ui.WebViewActivity; import me.zhanghai.android.douya.util.ImageUtils; import me.zhanghai.android.douya.util.RecyclerViewUtils; import me.zhanghai.android.douya.util.StringCompat; import me.zhanghai.android.douya.util.StringUtils; import me.zhanghai.android.douya.util.ViewUtils; public class BookDataAdapter extends BaseItemDataAdapter<Book> { private enum Items { HEADER, ITEM_COLLECTION, BADGE_LIST, INTRODUCTION, AUTHOR, TABLE_OF_CONTENTS, RATING, ITEM_COLLECTION_LIST, REVIEW_LIST, FORUM_TOPIC_LIST, RECOMMENDATION_LIST, RELATED_DOULIST_LIST } private Data mData; public BookDataAdapter(Listener listener) { super(listener); } @Override protected Listener getListener() { return (Listener) super.getListener(); } public void setData(Data data) { mData = data; notifyDataChanged(); } public void notifyItemCollectionChanged() { int position = Items.ITEM_COLLECTION.ordinal(); if (position < getItemCount()) { notifyItemChanged(position); } } public void notifyItemCollectionListItemChanged(int position, SimpleItemCollection newItemCollection) { notifyItemCollectionListItemChanged(Items.ITEM_COLLECTION_LIST.ordinal(), position, newItemCollection); } @Override public int getTotalItemCount() { return Items.values().length; } @Override protected boolean isItemLoaded(int position) { if (mData == null) { return false; } if (mData.book == null) { return false; } switch (Items.values()[position]) { case HEADER: return true; case ITEM_COLLECTION: return true; case BADGE_LIST: return mData.rating != null; case INTRODUCTION: return true; case AUTHOR: return true; case TABLE_OF_CONTENTS: return true; case RATING: return mData.rating != null; case ITEM_COLLECTION_LIST: return mData.itemCollectionList != null; case REVIEW_LIST: return mData.reviewList != null; case FORUM_TOPIC_LIST: return mData.forumTopicList != null; case RECOMMENDATION_LIST: return mData.recommendationList != null; case RELATED_DOULIST_LIST: return mData.relatedDoulistList != null; default: throw new IllegalArgumentException(); } } @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { switch (Items.values()[viewType]) { case HEADER: return createHeaderHolder(parent); case ITEM_COLLECTION: return createItemCollectionHolder(parent); case BADGE_LIST: return createBadgeListHolder(parent); case INTRODUCTION: return createIntroductionHolder(parent); case AUTHOR: return createAuthorHolder(parent); case TABLE_OF_CONTENTS: return createTableOfContentsHolder(parent); case RATING: return createRatingHolder(parent); case ITEM_COLLECTION_LIST: return createItemCollectionListHolder(parent); case REVIEW_LIST: return createReviewListHolder(parent); case FORUM_TOPIC_LIST: return createForumTopicListHolder(parent); case RECOMMENDATION_LIST: return createRecommendationListHolder(parent); case RELATED_DOULIST_LIST: return createRelatedDoulistListHolder(parent); default: throw new IllegalArgumentException(); } } private HeaderHolder createHeaderHolder(ViewGroup parent) { return new HeaderHolder(ViewUtils.inflate(R.layout.item_fragment_book_header, parent)); } @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List<Object> payloads) { super.onBindViewHolder(holder, position, payloads); switch (Items.values()[position]) { case HEADER: bindHeaderHolder(holder, mData.book); break; case ITEM_COLLECTION: bindItemCollectionHolder(holder, mData.book); break; case BADGE_LIST: bindBadgeListHolder(holder, mData.book, mData.rating); break; case INTRODUCTION: bindIntroductionHolder(holder, mData.book); break; case AUTHOR: bindAuthorHolder(holder, mData.book); break; case TABLE_OF_CONTENTS: bindTableOfContentsHolder(holder, mData.book); break; case RATING: bindRatingHolder(holder, mData.book, mData.rating); break; case ITEM_COLLECTION_LIST: bindItemCollectionListHolder(holder, mData.book, mData.itemCollectionList, payloads); break; case REVIEW_LIST: bindReviewListHolder(holder, mData.book, mData.reviewList); break; case FORUM_TOPIC_LIST: bindForumTopicListHolder(holder, mData.book, mData.forumTopicList); break; case RECOMMENDATION_LIST: bindRecommendationListHolder(holder, mData.book, mData.recommendationList); break; case RELATED_DOULIST_LIST: bindRelatedDoulistListHolder(holder, mData.book, mData.relatedDoulistList); break; default: throw new IllegalArgumentException(); } } private AuthorHolder createAuthorHolder(ViewGroup parent) { return new AuthorHolder(ViewUtils.inflate(R.layout.item_fragment_author, parent)); } private TableOfContentsHolder createTableOfContentsHolder(ViewGroup parent) { return new TableOfContentsHolder(ViewUtils.inflate(R.layout.item_fragment_table_of_contents, parent)); } private void bindHeaderHolder(RecyclerView.ViewHolder holder, Book book) { HeaderHolder headerHolder = (HeaderHolder) holder; headerHolder.coverImage.setRatio(2, 3); ImageUtils.loadImage(headerHolder.coverImage, book.cover); headerHolder.coverImage.setOnClickListener(view -> { Context context = view.getContext(); context.startActivity(GalleryActivity.makeIntent(book.cover, context)); }); headerHolder.titleText.setText(book.title); Context context = RecyclerViewUtils.getContext(holder); String slashDelimiter = context.getString(R.string.item_information_delimiter_slash); headerHolder.subtitleText.setText(StringCompat.join(slashDelimiter, book.subtitles)); headerHolder.authorsText.setText(StringCompat.join(slashDelimiter, book.authors)); String translators = StringCompat.join(slashDelimiter, book.translators); if (!TextUtils.isEmpty(translators)) { translators = context.getString(R.string.item_information_book_translators_format, translators); } headerHolder.translatorsText.setText(translators); String spaceDelimiter = context.getString(R.string.item_information_delimiter_space); String detail = StringUtils.joinNonEmpty(spaceDelimiter, book.getYearMonth(context), StringCompat.join(slashDelimiter, book.presses), StringCompat.join(slashDelimiter, book.getPageCountStrings())); headerHolder.detailText.setText(detail); } private void bindBadgeListHolder(RecyclerView.ViewHolder holder, Book book, Rating rating) { BadgeListHolder badgeListHolder = (BadgeListHolder) holder; badgeListHolder.badgeListLayout.setTop250(null); badgeListHolder.badgeListLayout.setRating(rating, book); badgeListHolder.badgeListLayout.setGenre(0, null, CollectableItem.Type.BOOK); } @Override protected void bindIntroductionHolder(RecyclerView.ViewHolder holder, Book book) { super.bindIntroductionHolder(holder, book); IntroductionHolder introductionHolder = (IntroductionHolder) holder; introductionHolder.introductionLayout.setOnClickListener(view -> { Context context = view.getContext(); context.startActivity(ItemIntroductionActivity.makeIntent(book, context)); }); } private void bindAuthorHolder(RecyclerView.ViewHolder holder, Book book) { AuthorHolder authorHolder = (AuthorHolder) holder; authorHolder.introductionText.setText(book.authorIntroduction); authorHolder.itemView.setOnClickListener(view -> { Context context = view.getContext(); context.startActivity(WebViewActivity.makeIntent(book.url, true, context)); }); } private void bindTableOfContentsHolder(RecyclerView.ViewHolder holder, Book book) { TableOfContentsHolder tableOfContentsHolder = (TableOfContentsHolder) holder; tableOfContentsHolder.tableOfContentsText.setText(book.tableOfContents); tableOfContentsHolder.itemView.setOnClickListener(view -> { Context context = view.getContext(); context.startActivity(TableOfContentsActivity.makeIntent(book, context)); }); } public interface Listener extends BaseItemDataAdapter.Listener<Book> {} public static class Data { public Book book; public Rating rating; public List<SimpleItemCollection> itemCollectionList; public List<SimpleReview> reviewList; public List<SimpleItemForumTopic> forumTopicList; public List<CollectableItem> recommendationList; public List<Doulist> relatedDoulistList; public Data(Book book, Rating rating, List<SimpleItemCollection> itemCollectionList, List<SimpleReview> reviewList, List<SimpleItemForumTopic> forumTopicList, List<CollectableItem> recommendationList, List<Doulist> relatedDoulistList) { this.book = book; this.rating = rating; this.itemCollectionList = itemCollectionList; this.reviewList = reviewList; this.forumTopicList = forumTopicList; this.recommendationList = recommendationList; this.relatedDoulistList = relatedDoulistList; } } static class HeaderHolder extends RecyclerView.ViewHolder { @BindView(R.id.cover) public RatioImageView coverImage; @BindView(R.id.title) public TextView titleText; @BindView(R.id.subtitle) public TextView subtitleText; @BindView(R.id.authors) public TextView authorsText; @BindView(R.id.translators) public TextView translatorsText; @BindView(R.id.detail) public TextView detailText; public HeaderHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } static class AuthorHolder extends RecyclerView.ViewHolder { @BindView(R.id.introduction) public TextView introductionText; public AuthorHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } static class TableOfContentsHolder extends RecyclerView.ViewHolder { @BindView(R.id.table_of_contents) public TextView tableOfContentsText; public TableOfContentsHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/BookDataAdapter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
2,421
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.content.Context; import java.util.List; import butterknife.BindDimen; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.gallery.ui.GalleryActivity; import me.zhanghai.android.douya.item.content.BaseItemFragmentResource; import me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment; import me.zhanghai.android.douya.item.content.GameFragmentResource; import me.zhanghai.android.douya.item.content.UncollectItemManager; import me.zhanghai.android.douya.link.UriHandler; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.Game; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.network.api.info.frodo.Photo; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity; import me.zhanghai.android.douya.network.api.info.frodo.SimpleGame; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.ui.BarrierAdapter; import me.zhanghai.android.douya.ui.CopyTextDialogFragment; import me.zhanghai.android.douya.util.DoubanUtils; import me.zhanghai.android.douya.util.ImageUtils; import me.zhanghai.android.douya.util.ViewUtils; public class GameFragment extends BaseItemFragment<SimpleGame, Game> implements GameFragmentResource.Listener, GameDataAdapter.Listener, ConfirmUncollectItemDialogFragment.Listener { @BindDimen(R.dimen.item_cover_vertical_margin_negative) int mContentListPaddingTopExtra; private GameAdapter mAdapter; private boolean mBackdropBound; private boolean mExcludeFirstPhoto; public static GameFragment newInstance(long gameId, SimpleGame simpleGame, Game game) { //noinspection deprecation GameFragment fragment = new GameFragment(); fragment.setArguments(gameId, simpleGame, game); return fragment; } /** * @deprecated Use {@link #newInstance(long, SimpleGame, Game)} instead. */ public GameFragment() {} @Override protected BaseItemFragmentResource<SimpleGame, Game> onAttachResource(long itemId, SimpleGame simpleItem, Game item) { return GameFragmentResource.attachTo(itemId, simpleItem, item, this); } @Override protected BarrierAdapter onCreateAdapter() { mAdapter = new GameAdapter(this); return mAdapter; } @Override protected int getContentListPaddingTopExtra() { return mContentListPaddingTopExtra; } @Override public void onChanged(int requestCode, Game newGame, Rating newRating, List<Photo> newPhotoList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newGameGuideList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList) { update(newGame, newRating, newPhotoList, newItemCollectionList, newGameGuideList, newReviewList, newForumTopicList, newRecommendationList, newRelatedDoulistList); } private void update(Game game, Rating rating, List<Photo> photoList, List<SimpleItemCollection> itemCollectionList, List<SimpleReview> gameGuideList, List<SimpleReview> reviewList, List<SimpleItemForumTopic> forumTopicList, List<CollectableItem> recommendationList, List<Doulist> relatedDoulistList) { if (game != null) { super.updateWithSimpleItem(game); } if (game == null || photoList == null) { return; } if (!mBackdropBound) { // TODO: Add game videos like movie trailer. mExcludeFirstPhoto = false; String backdropUrl = null; if (!photoList.isEmpty()) { backdropUrl = photoList.get(0).getLargeUrl(); mExcludeFirstPhoto = true; mBackdropLayout.setOnClickListener(view -> { // TODO Context context = view.getContext(); context.startActivity(GalleryActivity.makeImageListIntent(photoList, 0, context)); }); } else if (game.cover != null) { backdropUrl = game.cover.getLargeUrl(); mBackdropLayout.setOnClickListener(view -> { // TODO Context context = view.getContext(); context.startActivity(GalleryActivity.makeIntent(game.cover, context)); }); } if (backdropUrl != null) { ImageUtils.loadItemBackdropAndFadeIn(mBackdropImage, backdropUrl, null); } else { mBackdropImage.setBackgroundColor(game.getThemeColor()); ViewUtils.fadeIn(mBackdropImage); } mBackdropBound = true; } mAdapter.setData(new GameDataAdapter.Data(game, rating, photoList, mExcludeFirstPhoto, itemCollectionList, gameGuideList, reviewList, forumTopicList, recommendationList, relatedDoulistList)); if (mAdapter.getItemCount() > 0) { mContentStateLayout.setLoaded(true); } } @Override protected String makeItemUrl(long itemId) { return DoubanUtils.makeGameUrl(itemId); } @Override public void onItemCollectionChanged(int requestCode) { mAdapter.notifyItemCollectionChanged(); } @Override public void onItemCollectionListItemChanged(int requestCode, int position, SimpleItemCollection newItemCollection) { mAdapter.setItemCollectionListItem(position, newItemCollection); } @Override public void onItemCollectionListItemWriteStarted(int requestCode, int position) { mAdapter.notifyItemCollectionListItemChanged(position); } @Override public void onItemCollectionListItemWriteFinished(int requestCode, int position) { mAdapter.notifyItemCollectionListItemChanged(position); } @Override public void onUncollectItem(Game game) { ConfirmUncollectItemDialogFragment.show(this); } @Override public void uncollect() { if (!mResource.hasItem()) { return; } Game game = mResource.getItem(); UncollectItemManager.getInstance().write(game.getType(), game.id, getActivity()); } @Override public void copyText(String text) { CopyTextDialogFragment.show(text, this); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/GameFragment.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,479
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.app.Activity; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.core.util.ObjectsCompat; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.eventbus.EventBusUtils; import me.zhanghai.android.douya.eventbus.ItemCollectErrorEvent; import me.zhanghai.android.douya.eventbus.ItemCollectedEvent; import me.zhanghai.android.douya.eventbus.ItemUncollectedEvent; import me.zhanghai.android.douya.item.content.CollectItemManager; import me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment; import me.zhanghai.android.douya.item.content.UncollectItemManager; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.ui.ConfirmDiscardContentDialogFragment; import me.zhanghai.android.douya.ui.CounterTextView; import me.zhanghai.android.douya.ui.FragmentFinishable; import me.zhanghai.android.douya.util.DoubanUtils; import me.zhanghai.android.douya.util.FragmentUtils; import me.zhanghai.android.douya.util.MoreTextUtils; import me.zhanghai.android.douya.util.StringCompat; import me.zhanghai.android.douya.util.ToastUtils; import me.zhanghai.android.douya.util.ViewUtils; import me.zhanghai.android.materialratingbar.MaterialRatingBar; public class ItemCollectionFragment extends Fragment implements ConfirmUncollectItemDialogFragment.Listener, ConfirmDiscardContentDialogFragment.Listener { private static final String KEY_PREFIX = ItemCollectionFragment.class.getName() + '.'; private static final String EXTRA_ITEM = KEY_PREFIX + "item"; private static final String EXTRA_STATE = KEY_PREFIX + "state"; @BindView(R.id.toolbar) Toolbar mToolbar; @BindView(R.id.state_layout) ViewGroup mStateLayout; @BindView(R.id.state) Spinner mStateSpinner; @BindView(R.id.state_this_item) TextView mStateThisItemText; @BindView(R.id.rating_layout) ViewGroup mRatingLayout; @BindView(R.id.rating) MaterialRatingBar mRatingBar; @BindView(R.id.rating_hint) TextView mRatingHintText; @BindView(R.id.tags) EditText mTagsEdit; @BindView(R.id.comment) EditText mCommentEdit; @BindView(R.id.share_to_broadcast) CheckBox mShareToBroadcastCheckBox; @BindView(R.id.share_to_weibo) CheckBox mShareToWeiboCheckBox; @BindView(R.id.counter) CounterTextView mCounterText; private MenuItem mCollectMenuItem; private MenuItem mUncollectMenuItem; private CollectableItem mItem; private ItemCollectionState mExtraState; private ItemCollectionStateSpinnerAdapter mStateAdapter; private boolean mCollected; /** * @deprecated Use {@link #newInstance(CollectableItem, ItemCollectionState)} instead. */ public ItemCollectionFragment() {} public static ItemCollectionFragment newInstance(CollectableItem item, ItemCollectionState state) { //noinspection deprecation ItemCollectionFragment fragment = new ItemCollectionFragment(); FragmentUtils.getArgumentsBuilder(fragment) .putParcelable(EXTRA_ITEM, item) .putSerializable(EXTRA_STATE, state); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle arguments = getArguments(); mItem = arguments.getParcelable(EXTRA_ITEM); mExtraState = (ItemCollectionState) arguments.getSerializable(EXTRA_STATE); setHasOptionsMenu(true); EventBusUtils.register(this); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.item_collection_fragment, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setTitle(mItem.title); activity.setSupportActionBar(mToolbar); mStateLayout.setOnClickListener(view -> mStateSpinner.performClick()); mStateAdapter = new ItemCollectionStateSpinnerAdapter(mItem.getType(), mStateSpinner.getContext()); mStateSpinner.setAdapter(mStateAdapter); if (savedInstanceState == null) { ItemCollectionState state; if (mExtraState != null) { state = mExtraState; } else if (mItem.collection != null) { state = mItem.collection.getState(); } else { state = null; } if (state != null) { mStateSpinner.setSelection(mStateAdapter.getPositionForState(state), false); } } mStateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { onStateChanged(); } @Override public void onNothingSelected(AdapterView<?> parent) {} }); mStateThisItemText.setText(mItem.getType().getThisItem(activity)); onStateChanged(); if (savedInstanceState == null && mItem.collection != null && mItem.collection.rating != null) { mRatingBar.setRating(mItem.collection.rating.getRatingBarRating()); } mRatingBar.setOnRatingChangeListener((ratingBar, rating) -> updateRatingHint()); updateRatingHint(); if (savedInstanceState == null && mItem.collection != null) { setTags(mItem.collection.tags); } if (savedInstanceState == null && mItem.collection != null) { mCommentEdit.setText(mItem.collection.comment); } mCounterText.setEditText(mCommentEdit, ItemCollection.MAX_COMMENT_LENGTH); updateCollectStatus(); } @Override public void onDestroy() { super.onDestroy(); EventBusUtils.unregister(this); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.item_collection, menu); mCollectMenuItem = menu.findItem(R.id.action_collect); mUncollectMenuItem = menu.findItem(R.id.action_uncollect); } @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); updateOptionsMenu(); } private void updateOptionsMenu() { if (mCollectMenuItem == null && mUncollectMenuItem == null) { return; } boolean showUncollect = mItem.collection != null && (mExtraState == null || getState() == mItem.collection.getState()); mUncollectMenuItem.setVisible(showUncollect); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onFinish(); return true; case R.id.action_uncollect: onUncollect(); return true; case R.id.action_collect: onCollect(); return true; default: return super.onOptionsItemSelected(item); } } private void onStateChanged() { boolean hasRating = getState() != ItemCollectionState.TODO; ViewUtils.setVisibleOrGone(mRatingLayout, hasRating); updateOptionsMenu(); } private void updateRatingHint() { mRatingHintText.setText(DoubanUtils.getRatingHint((int) mRatingBar.getRating(), mRatingHintText.getContext())); } private void onUncollect() { ConfirmUncollectItemDialogFragment.show(this); } @Override public void uncollect() { UncollectItemManager.getInstance().write(mItem, getActivity()); } @Subscribe(threadMode = ThreadMode.POSTING) public void onItemUncollected(ItemUncollectedEvent event) { if (event.isFromMyself(this)) { return; } if (event.itemType == mItem.getType() && event.itemId == mItem.id) { finish(); } } private void onCollect() { String comment = mCommentEdit.getText().toString(); if (comment.length() > ItemCollection.MAX_COMMENT_LENGTH) { ToastUtils.show(R.string.broadcast_send_error_text_too_long, getActivity()); return; } ItemCollectionState state = getState(); int rating = getRating(); List<String> tags = getTags(); boolean shouldAllowShare = shouldAllowShare(); boolean shareToBroadcast = shouldAllowShare && mShareToBroadcastCheckBox.isChecked(); boolean shareToWeibo = shouldAllowShare && mShareToWeiboCheckBox.isChecked(); collect(state, rating, tags, comment, shareToBroadcast, shareToWeibo); } private boolean shouldAllowShare() { return mItem.collection == null || getState() != mItem.collection.getState(); } private void collect(ItemCollectionState state, int rating, List<String> tags, String comment, boolean shareToBroadcast, boolean shareToWeibo) { CollectItemManager.getInstance().write(mItem.getType(), mItem.id, state, rating, tags, comment, null, shareToBroadcast, shareToWeibo, false, getActivity()); updateCollectStatus(); } @Subscribe(threadMode = ThreadMode.POSTING) public void onBroadcastSent(ItemCollectedEvent event) { if (event.isFromMyself(this)) { return; } if (event.itemType == mItem.getType() && event.itemId == mItem.id) { mCollected = true; finish(); } } @Subscribe(threadMode = ThreadMode.POSTING) public void onItemCollectError(ItemCollectErrorEvent event) { if (event.isFromMyself(this)) { return; } if (event.itemType == mItem.getType() && event.itemId == mItem.id) { updateCollectStatus(); } } private void updateCollectStatus() { if (mCollected) { return; } CollectItemManager manager = CollectItemManager.getInstance(); boolean sending = manager.isWriting(mItem); Activity activity = getActivity(); activity.setTitle(sending ? getString(R.string.item_collection_title_saving_format, mItem.getType().getName(activity)) : mItem.title); boolean enabled = !sending; if (mCollectMenuItem != null) { mCollectMenuItem.setEnabled(enabled); } mStateLayout.setEnabled(enabled); mStateSpinner.setEnabled(enabled); mRatingBar.setIsIndicator(!enabled); mTagsEdit.setEnabled(enabled); mCommentEdit.setEnabled(enabled); mShareToBroadcastCheckBox.setEnabled(enabled); mShareToWeiboCheckBox.setEnabled(enabled); if (sending) { mStateSpinner.setSelection(mStateAdapter.getPositionForState(manager.getState(mItem)), false); // FIXME mRatingBar.setRating(manager.getRating(mItem)); setTags(manager.getTags(mItem)); mCommentEdit.setText(manager.getComment(mItem)); } } public void onFinish() { if (isChanged()) { ConfirmDiscardContentDialogFragment.show(this); } else { finish(); } } private boolean isChanged() { SimpleItemCollection collection = mItem.collection; ItemCollectionState state = getState(); if (collection != null) { boolean equalsExtraState = mExtraState != null && state == mExtraState; boolean equalsCollectionState = state == collection.getState(); if (!(equalsExtraState || equalsCollectionState)) { return true; } } if (state != ItemCollectionState.TODO) { float originalRating = collection != null && collection.rating != null ? collection.rating.getRatingBarRating() : 0; float rating = mRatingBar.getRating(); if (rating != originalRating) { return true; } } List<String> tags = getTags(); List<String> originalTags = collection != null ? collection.tags : Collections.emptyList(); if (!ObjectsCompat.equals(tags, originalTags)) { return true; } String comment = mCommentEdit.getText().toString(); String originalComment = collection != null ? MoreTextUtils.nullToEmpty(collection.comment) : ""; if (!TextUtils.equals(comment, originalComment)) { return true; } return false; } @Override public void discardContent() { finish(); } private void finish() { FragmentFinishable.finish(getActivity()); } private ItemCollectionState getState() { return mStateAdapter.getStateAtPosition(mStateSpinner.getSelectedItemPosition()); } private int getRating() { // TODO: We are assuming max is 5 here. return (int) mRatingBar.getRating(); } private List<String> getTags() { String tagsText = mTagsEdit.getText().toString(); Matcher matcher = Pattern.compile("\\S+").matcher(tagsText); List<String> tags = new ArrayList<>(); while (matcher.find()) { tags.add(matcher.group()); } return tags; } private void setTags(List<String> tags) { mTagsEdit.setText(StringCompat.join(" ", tags)); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/ItemCollectionFragment.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
2,987
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import androidx.core.util.Pair; import java.util.ArrayList; import java.util.List; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.network.api.info.frodo.Game; public class GameIntroductionFragment extends BaseItemIntroductionFragment<Game> { public static GameIntroductionFragment newInstance(Game game) { //noinspection deprecation GameIntroductionFragment fragment = new GameIntroductionFragment(); fragment.setArguments(game); return fragment; } /** * @deprecated Use {@link #newInstance(Game)} instead. */ public GameIntroductionFragment() {} @Override protected List<Pair<String, String>> makeInformationData() { List<Pair<String, String>> data = new ArrayList<>(); addTextListToData(R.string.item_introduction_game_genres, mItem.genres, data); addTextListToData(R.string.item_introduction_game_platforms, mItem.getPlatformNames(), data); addTextListToData(R.string.item_introduction_game_alternative_titles, mItem.alternativeTitles, data); addTextListToData(R.string.item_introduction_game_developers, mItem.developers, data); addTextListToData(R.string.item_introduction_game_publishers, mItem.publishers, data); addTextToData(R.string.item_introduction_game_release_date, mItem.releaseDate, data); return data; } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/GameIntroductionFragment.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
317
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.core.view.ViewCompat; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.item.content.BaseItemFragmentResource; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.ui.AppBarWrapperLayout; import me.zhanghai.android.douya.ui.BarrierAdapter; import me.zhanghai.android.douya.ui.ContentStateLayout; import me.zhanghai.android.douya.ui.OnVerticalScrollWithPagingTouchSlopListener; import me.zhanghai.android.douya.ui.RatioImageView; import me.zhanghai.android.douya.ui.TransparentDoubleClickToolbar; import me.zhanghai.android.douya.ui.WebViewActivity; import me.zhanghai.android.douya.util.DrawableUtils; import me.zhanghai.android.douya.util.FragmentUtils; import me.zhanghai.android.douya.util.LogUtils; import me.zhanghai.android.douya.util.RecyclerViewUtils; import me.zhanghai.android.douya.util.ShareUtils; import me.zhanghai.android.douya.util.StatusBarColorUtils; import me.zhanghai.android.douya.util.ToastUtils; import me.zhanghai.android.douya.util.ViewUtils; public abstract class BaseItemFragment<SimpleItemType extends CollectableItem, ItemType extends SimpleItemType> extends Fragment implements BaseItemFragmentResource.Listener<ItemType> { private static final String KEY_PREFIX = BaseItemFragment.class.getName() + '.'; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private static final String EXTRA_SIMPLE_ITEM = KEY_PREFIX + "simple_item"; private static final String EXTRA_ITEM = KEY_PREFIX + "item"; @BindView(R.id.appBarWrapper) AppBarWrapperLayout mAppBarWrapperLayout; @BindView(R.id.toolbar) TransparentDoubleClickToolbar mToolbar; @BindView(R.id.backdrop_wrapper) ViewGroup mBackdropWrapperLayout; @BindView(R.id.backdrop_layout) ViewGroup mBackdropLayout; @BindView(R.id.backdrop) RatioImageView mBackdropImage; @BindView(R.id.backdrop_scrim) View mBackdropScrim; @BindView(R.id.backdrop_play) ImageView mBackdropPlayImage; @BindView(R.id.contentState) ContentStateLayout mContentStateLayout; @BindView(R.id.content) ItemContentRecyclerView mContentList; @BindView(R.id.content_state_views) ItemContentStateViewsLayout mContentStateViewsLayout; private long mItemId; private SimpleItemType mSimpleItem; private ItemType mItem; protected BaseItemFragmentResource<SimpleItemType, ItemType> mResource; private BarrierAdapter mAdapter; public BaseItemFragment<SimpleItemType, ItemType> setArguments(long itemId, SimpleItemType simpleItem, ItemType item) { FragmentUtils.getArgumentsBuilder(this) .putLong(EXTRA_ITEM_ID, itemId) .putParcelable(EXTRA_SIMPLE_ITEM, simpleItem) .putParcelable(EXTRA_ITEM, item); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle arguments = getArguments(); mItemId = arguments.getLong(EXTRA_ITEM_ID); mSimpleItem = arguments.getParcelable(EXTRA_SIMPLE_ITEM); mItem = arguments.getParcelable(EXTRA_ITEM); setHasOptionsMenu(true); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.item_fragment, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mResource = onAttachResource(mItemId, mSimpleItem, mItem); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setSupportActionBar(mToolbar); float backdropRatio = getBackdropRatio(); boolean hasBackdrop = backdropRatio > 0; if (hasBackdrop) { StatusBarColorUtils.set(Color.TRANSPARENT, activity); ViewUtils.setLayoutFullscreen(activity); } mBackdropImage.setRatio(backdropRatio); ViewCompat.setBackground(mBackdropScrim, DrawableUtils.makeScrimDrawable(Gravity.TOP)); mContentList.setLayoutManager(new LinearLayoutManager(activity)); mAdapter = onCreateAdapter(); mContentList.setAdapter(mAdapter); mContentList.setBackdropRatio(backdropRatio); mContentList.setPaddingTopPaddingExtra(getContentListPaddingTopExtra()); if (hasBackdrop) { mContentList.setBackdropWrapper(mBackdropWrapperLayout); mContentList.addOnScrollListener(new RecyclerView.OnScrollListener() { private int mScrollY; @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { if (recyclerView.getChildCount() == 0) { return; } View firstChild = recyclerView.getChildAt(0); int firstPosition = recyclerView.getChildAdapterPosition(firstChild); boolean firstItemInLayout = firstPosition == 0; if (mScrollY == 0) { if (!firstItemInLayout) { // We are restored from previous scroll position and we don't have a // scrollY. ViewUtils.setVisibleOrInvisible(mBackdropLayout, false); return; } else { // We scrolled towards top so the first item became visible now. // Won't do anything if it is not hidden. ViewUtils.fadeIn(mBackdropLayout); mScrollY = recyclerView.getPaddingTop() - firstChild.getTop(); } } else { mScrollY += dy; } // FIXME: Animate out backdrop layout later. mBackdropLayout.setTranslationY((float) -mScrollY / 2); mBackdropScrim.setTranslationY((float) mScrollY / 2); } }); int colorPrimaryDark = ViewUtils.getColorFromAttrRes(R.attr.colorPrimaryDark, 0, activity); mContentList.addOnScrollListener( new OnVerticalScrollWithPagingTouchSlopListener(activity) { private int mStatusBarColor = Color.TRANSPARENT; @Override public void onScrolledUp() { if (mAppBarWrapperLayout.isHidden()) { mToolbar.setTransparent(!hasFirstChildReachedTop()); } mAppBarWrapperLayout.show(); } @Override public void onScrolledDown() { if (hasFirstChildReachedTop()) { mAppBarWrapperLayout.hide(); } } @Override public void onScrolled(int dy) { boolean initialize = dy == 0; boolean hasFirstChildReachedTop = hasFirstChildReachedTop(); int statusBarColor = hasFirstChildReachedTop ? colorPrimaryDark : Color.TRANSPARENT; if (mStatusBarColor != statusBarColor) { mStatusBarColor = statusBarColor; if (initialize) { StatusBarColorUtils.set(mStatusBarColor, activity); } else { StatusBarColorUtils.animateTo(mStatusBarColor, activity); } } if (mAppBarWrapperLayout.isShowing()) { if (initialize) { mToolbar.setTransparent(!hasFirstChildReachedTop); } else { mToolbar.animateToTransparent(!hasFirstChildReachedTop); } } } private boolean hasFirstChildReachedTop() { return RecyclerViewUtils.hasFirstChildReachedTop(mContentList, mToolbar.getBottom()); } }); } else { ViewUtils.setVisibleOrGone(mBackdropWrapperLayout, false); mContentList.addOnScrollListener( new OnVerticalScrollWithPagingTouchSlopListener(activity) { @Override public void onScrolledUp() { mAppBarWrapperLayout.show(); } @Override public void onScrolledDown() { if (hasFirstChildReachedTop()) { mAppBarWrapperLayout.hide(); } } private boolean hasFirstChildReachedTop() { return RecyclerViewUtils.hasFirstChildReachedTop(mContentList, 0); } }); } mToolbar.setOnDoubleClickListener(view -> { mContentList.smoothScrollToPosition(0); return true; }); mContentStateViewsLayout.setBackdropRatio(backdropRatio); mContentStateViewsLayout.setPaddingTopPaddingExtra(getContentStateViewsPaddingTopExtra()); if (mResource.hasSimpleItem()) { updateWithSimpleItem(mResource.getSimpleItem()); } mContentStateLayout.setLoading(); if (mResource.isAnyLoaded()) { mResource.notifyChanged(); } if (hasBackdrop && mAdapter.getItemCount() == 0) { mToolbar.getBackground().setAlpha(0); } } protected abstract BaseItemFragmentResource<SimpleItemType, ItemType> onAttachResource( long itemId, SimpleItemType simpleItem, ItemType item); protected float getBackdropRatio() { return 16f / 9f; } protected abstract BarrierAdapter onCreateAdapter(); protected int getContentListPaddingTopExtra() { return 0; } protected int getContentStateViewsPaddingTopExtra() { return 0; } @Override public void onDestroy() { super.onDestroy(); mResource.detach(); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.item, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: getActivity().finish(); return true; case R.id.action_share: share(); return true; case R.id.action_view_on_web: viewOnWeb(); return true; default: return super.onOptionsItemSelected(item); } } @Override public void onLoadError(int requestCode, ApiError error) { LogUtils.e(error.toString()); if (mAdapter.getItemCount() > 0) { mAdapter.setError(); } else { mContentStateLayout.setError(); } Activity activity = getActivity(); ToastUtils.show(ApiError.getErrorString(error, activity), activity); } @Override public void onItemChanged(int requestCode, ItemType newItem) {} protected void updateWithSimpleItem(SimpleItemType simpleItem) { getActivity().setTitle(simpleItem.title); } private void share() { ShareUtils.shareText(makeUrl(), getActivity()); } private void viewOnWeb() { startActivity(WebViewActivity.makeIntent(makeUrl(), true, getActivity())); } private String makeUrl() { if (mResource.hasSimpleItem()) { return mResource.getSimpleItem().getUrl(); } else { return makeItemUrl(mResource.getItemId()); } } protected abstract String makeItemUrl(long itemId); } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/BaseItemFragment.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
2,425
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.content.Context; import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.appcompat.app.AppCompatActivity; import me.zhanghai.android.douya.network.api.info.frodo.Book; import me.zhanghai.android.douya.util.FragmentUtils; public class TableOfContentsActivity extends AppCompatActivity { private static final String KEY_PREFIX = TableOfContentsActivity.class.getName() + '.'; private static final String EXTRA_BOOK = KEY_PREFIX + "book"; public static Intent makeIntent(Book item, Context context) { return new Intent(context, TableOfContentsActivity.class) .putExtra(EXTRA_BOOK, item); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Calls ensureSubDecor(). findViewById(android.R.id.content); if (savedInstanceState == null) { Intent intent = getIntent(); Book book = intent.getParcelableExtra(EXTRA_BOOK); Fragment fragment = TableOfContentsFragment.newInstance(book); FragmentUtils.add(fragment, this, android.R.id.content); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/TableOfContentsActivity.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
242
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.link.UriHandler; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.ui.RatioImageView; import me.zhanghai.android.douya.ui.SimpleAdapter; import me.zhanghai.android.douya.util.ImageUtils; import me.zhanghai.android.douya.util.ViewUtils; public class RecommendationListAdapter extends SimpleAdapter<CollectableItem, RecommendationListAdapter.ViewHolder> { public RecommendationListAdapter() { setHasStableIds(true); } @Override public long getItemId(int position) { return getItem(position).id; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new ViewHolder(ViewUtils.inflate(R.layout.item_recommendation_item, parent)); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { CollectableItem item = getItem(position); float ratio = 1; switch (item.getType()) { case BOOK: case EVENT: case GAME: case MOVIE: case TV: ratio = 2f / 3f; break; } holder.coverImage.setRatio(ratio); ImageUtils.loadImage(holder.coverImage, item.cover); holder.titleText.setText(item.title); boolean hasRating = item.rating.hasRating(); if (hasRating) { holder.ratingText.setText(item.rating.getRatingString(holder.ratingText.getContext())); } else { holder.ratingText.setText(item.getRatingUnavailableReason( holder.ratingText.getContext())); } ViewUtils.setVisibleOrGone(holder.ratingStarText, hasRating); holder.itemView.setOnClickListener(view -> { // TODO UriHandler.open(item.url, view.getContext()); }); } static class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.cover) public RatioImageView coverImage; @BindView(R.id.title) public TextView titleText; @BindView(R.id.rating) public TextView ratingText; @BindView(R.id.rating_star) public TextView ratingStarText; public ViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/RecommendationListAdapter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
536
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.content.Context; import android.os.Build; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import android.util.AttributeSet; import android.widget.FrameLayout; import butterknife.BindDimen; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; public class ItemContentStateViewsLayout extends FrameLayout { @BindDimen(R.dimen.item_content_padding_top_max) int mPaddingTopMax; private float mBackdropRatio; private int mPaddingTopPaddingExtra; public ItemContentStateViewsLayout(@NonNull Context context) { super(context); init(); } public ItemContentStateViewsLayout(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(); } public ItemContentStateViewsLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } @RequiresApi(Build.VERSION_CODES.LOLLIPOP) public ItemContentStateViewsLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); init(); } private void init() { ButterKnife.bind(this); } public float getBackdropRatio() { return mBackdropRatio; } public void setBackdropRatio(float ratio) { if (mBackdropRatio != ratio) { mBackdropRatio = ratio; requestLayout(); invalidate(); } } public void setBackdropRatio(float width, float height) { setBackdropRatio(width / height); } public int getPaddingTopPaddingExtra() { return mPaddingTopPaddingExtra; } public void setPaddingTopPaddingExtra(int paddingTopPaddingExtra) { if (mPaddingTopPaddingExtra != paddingTopPaddingExtra) { mPaddingTopPaddingExtra = paddingTopPaddingExtra; requestLayout(); invalidate(); } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int paddingTop = 0; if (mBackdropRatio > 0) { int width = MeasureSpec.getSize(widthMeasureSpec); // Should fix off-by-one-pixel visual glitch. paddingTop += (int) (width / mBackdropRatio); } paddingTop += mPaddingTopPaddingExtra; if (mPaddingTopMax > 0) { paddingTop = Math.min(paddingTop, mPaddingTopMax); } setPadding(getPaddingLeft(), paddingTop, getPaddingRight(), getPaddingBottom()); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/ItemContentStateViewsLayout.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
565
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.network.api.info.frodo.Book; import me.zhanghai.android.douya.util.FragmentUtils; import me.zhanghai.android.douya.util.TintHelper; public class TableOfContentsFragment extends Fragment { private static final String KEY_PREFIX = TableOfContentsFragment.class.getName() + '.'; private static final String EXTRA_BOOK = KEY_PREFIX + "book"; @BindView(R.id.toolbar) Toolbar mToolbar; @BindView(R.id.table_of_contents) TextView mTableOfContentsText; private Book mBook; public static TableOfContentsFragment newInstance(Book book) { //noinspection deprecation TableOfContentsFragment fragment = new TableOfContentsFragment(); FragmentUtils.getArgumentsBuilder(fragment) .putParcelable(EXTRA_BOOK, book); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle arguments = getArguments(); mBook = arguments.getParcelable(EXTRA_BOOK); setHasOptionsMenu(true); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.item_table_of_contents_fragment, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setSupportActionBar(mToolbar); TintHelper.onSetSupportActionBar(mToolbar); mTableOfContentsText.setText(mBook.tableOfContents); } @Override public boolean onOptionsItemSelected(MenuItem book) { switch (book.getItemId()) { case android.R.id.home: getActivity().finish(); return true; default: return super.onOptionsItemSelected(book); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/TableOfContentsFragment.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
511
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import androidx.recyclerview.widget.RecyclerView; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.ui.BarrierAdapter; public class GameAdapter extends BarrierAdapter { private GameDataAdapter mDataAdapter; public GameAdapter(GameDataAdapter.Listener listener) { super(new GameDataAdapter(listener)); RecyclerView.Adapter<?>[] adapters = getAdapters(); mDataAdapter = (GameDataAdapter) adapters[0]; } public void setData(GameDataAdapter.Data data) { mDataAdapter.setData(data); } public void notifyItemCollectionChanged() { mDataAdapter.notifyItemCollectionChanged(); } public void setItemCollectionListItem(int position, SimpleItemCollection newItemCollection) { mDataAdapter.notifyItemCollectionListItemChanged(position, newItemCollection); } public void notifyItemCollectionListItemChanged(int position) { mDataAdapter.notifyItemCollectionListItemChanged(position, null); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/GameAdapter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
212
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import androidx.recyclerview.widget.RecyclerView; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.ui.BarrierAdapter; public class MovieAdapter extends BarrierAdapter { private MovieDataAdapter mDataAdapter; public MovieAdapter(MovieDataAdapter.Listener listener) { super(new MovieDataAdapter(listener)); RecyclerView.Adapter<?>[] adapters = getAdapters(); mDataAdapter = (MovieDataAdapter) adapters[0]; } public void setData(MovieDataAdapter.Data data) { mDataAdapter.setData(data); } public void notifyItemCollectionChanged() { mDataAdapter.notifyItemCollectionChanged(); } public void setItemCollectionListItem(int position, SimpleItemCollection newItemCollection) { mDataAdapter.notifyItemCollectionListItemChanged(position, newItemCollection); } public void notifyItemCollectionListItemChanged(int position) { mDataAdapter.notifyItemCollectionListItemChanged(position, null); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/MovieAdapter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
214
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.ui.SimpleAdapter; import me.zhanghai.android.douya.util.ViewUtils; public class ItemAwardListAdapter extends SimpleAdapter<ItemAwardItem, ItemAwardListAdapter.ViewHolder> { public ItemAwardListAdapter() { setHasStableIds(true); } @Override public long getItemId(int position) { // Deliberately using plain hash code to identify only this instance. return getItem(position).hashCode(); } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(ViewUtils.inflate(R.layout.item_award_item, parent)); } @Override public void onBindViewHolder(ViewHolder holder, int position) { ItemAwardItem awardItem = getItem(position); holder.titleText.setText(awardItem.award.title); String category = awardItem.categories.get(0).category.title; if (awardItem.categories.size() > 1) { category = holder.categoryText.getContext().getString( R.string.item_award_category_multiple_format, category, awardItem.categories.size()); } holder.categoryText.setText(category); } static class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.title) public TextView titleText; @BindView(R.id.category) public TextView categoryText; public ViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/ItemAwardListAdapter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
374
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.content.Context; import android.content.Intent; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import me.zhanghai.android.douya.network.api.info.frodo.Game; import me.zhanghai.android.douya.network.api.info.frodo.SimpleGame; import me.zhanghai.android.douya.util.FragmentUtils; public class GameActivity extends AppCompatActivity { private static final String KEY_PREFIX = GameActivity.class.getName() + '.'; private static final String EXTRA_GAME_ID = KEY_PREFIX + "game_id"; private static final String EXTRA_SIMPLE_GAME = KEY_PREFIX + "simple_game"; private static final String EXTRA_GAME = KEY_PREFIX + "game"; public static Intent makeIntent(long gameId, Context context) { return new Intent(context, GameActivity.class) .putExtra(EXTRA_GAME_ID, gameId); } public static Intent makeIntent(SimpleGame simpleGame, Context context) { return makeIntent(simpleGame.id, context) .putExtra(EXTRA_SIMPLE_GAME, simpleGame); } public static Intent makeIntent(Game game, Context context) { return makeIntent((SimpleGame) game, context) .putExtra(EXTRA_GAME, game); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Calls ensureSubDecor(). findViewById(android.R.id.content); if (savedInstanceState == null) { Intent intent = getIntent(); long gameId = intent.getLongExtra(EXTRA_GAME_ID, -1); SimpleGame simpleGame = intent.getParcelableExtra(EXTRA_SIMPLE_GAME); Game game = intent.getParcelableExtra(EXTRA_GAME); FragmentUtils.add(GameFragment.newInstance(gameId, simpleGame, game), this, android.R.id.content); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/GameActivity.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
388
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RatingBar; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.link.UriHandler; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.ui.SimpleAdapter; import me.zhanghai.android.douya.util.ImageUtils; import me.zhanghai.android.douya.util.ViewUtils; public class ReviewListAdapter extends SimpleAdapter<SimpleReview, ReviewListAdapter.ViewHolder> { public ReviewListAdapter() { setHasStableIds(true); } @Override public long getItemId(int position) { return getItem(position).id; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(ViewUtils.inflate(R.layout.item_review_item, parent)); } @Override public void onBindViewHolder(ViewHolder holder, int position) { SimpleReview review = getItem(position); ImageUtils.loadAvatar(holder.avatarImage, review.author.avatar); holder.titleText.setText(review.title); holder.nameText.setText(review.author.name); boolean hasRating = review.rating != null; ViewUtils.setVisibleOrGone(holder.ratingBar, hasRating); if (hasRating) { holder.ratingBar.setRating(review.rating.getRatingBarRating()); } String usefulness = holder.usefulnessText.getContext().getString( R.string.item_review_usefulness_format, review.usefulCount, review.usefulCount + review.uselessCount); holder.usefulnessText.setText(usefulness); holder.abstractText.setText(review.abstract_); holder.itemView.setOnClickListener(view -> { // TODO UriHandler.open(review.url, view.getContext()); }); } static class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.avatar) public ImageView avatarImage; @BindView(R.id.title) public TextView titleText; @BindView(R.id.name) public TextView nameText; @BindView(R.id.rating) public RatingBar ratingBar; @BindView(R.id.usefulness) public TextView usefulnessText; @BindView(R.id.abstract_) public TextView abstractText; public ViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/ReviewListAdapter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
519
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.ui; import android.content.Context; import android.os.Bundle; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.List; import me.zhanghai.android.douya.eventbus.EventBusUtils; import me.zhanghai.android.douya.eventbus.MusicPlayingStateChangedEvent; import me.zhanghai.android.douya.gallery.ui.GalleryActivity; import me.zhanghai.android.douya.item.content.BaseItemFragmentResource; import me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment; import me.zhanghai.android.douya.item.content.MusicFragmentResource; import me.zhanghai.android.douya.item.content.UncollectItemManager; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.Music; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleMusic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.ui.BarrierAdapter; import me.zhanghai.android.douya.ui.CopyTextDialogFragment; import me.zhanghai.android.douya.util.DoubanUtils; import me.zhanghai.android.douya.util.ImageUtils; import me.zhanghai.android.douya.util.ViewUtils; public class MusicFragment extends BaseItemFragment<SimpleMusic, Music> implements MusicFragmentResource.Listener, MusicDataAdapter.Listener, ConfirmUncollectItemDialogFragment.Listener { private MusicAdapter mAdapter; private boolean mBackdropBound; public static MusicFragment newInstance(long musicId, SimpleMusic simpleMusic, Music music) { //noinspection deprecation MusicFragment fragment = new MusicFragment(); fragment.setArguments(musicId, simpleMusic, music); return fragment; } /** * @deprecated Use {@link #newInstance(long, SimpleMusic, Music)} instead. */ public MusicFragment() {} @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EventBusUtils.register(this); } @Override public void onDestroy() { super.onDestroy(); EventBusUtils.unregister(this); } @Override protected BaseItemFragmentResource<SimpleMusic, Music> onAttachResource(long itemId, SimpleMusic simpleItem, Music item) { return MusicFragmentResource.attachTo(itemId, simpleItem, item, this); } @Override protected float getBackdropRatio() { return ViewUtils.isInPortait(getContext()) ? 1 : 2; } @Override protected BarrierAdapter onCreateAdapter() { mAdapter = new MusicAdapter(this); return mAdapter; } @Override public void onChanged(int requestCode, Music newMusic, Rating newRating, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList) { update(newMusic, newRating, newItemCollectionList, newReviewList, newForumTopicList, newRecommendationList, newRelatedDoulistList); } private void update(Music music, Rating rating, List<SimpleItemCollection> itemCollectionList, List<SimpleReview> reviewList, List<SimpleItemForumTopic> forumTopicList, List<CollectableItem> recommendationList, List<Doulist> relatedDoulistList) { if (music != null) { super.updateWithSimpleItem(music); } if (music == null) { return; } if (!mBackdropBound) { if (ViewUtils.isInPortait(getActivity())) { ImageUtils.loadItemBackdropAndFadeIn(mBackdropImage, music.cover.getLargeUrl(), null); mBackdropLayout.setOnClickListener(view -> { // TODO Context context = view.getContext(); context.startActivity(GalleryActivity.makeIntent(music.cover, context)); }); } else { mBackdropImage.setBackgroundColor(music.getThemeColor()); ViewUtils.fadeIn(mBackdropImage); } mBackdropBound = true; } mAdapter.setData(new MusicDataAdapter.Data(music, rating, itemCollectionList, reviewList, forumTopicList, recommendationList, relatedDoulistList)); if (mAdapter.getItemCount() > 0) { mContentStateLayout.setLoaded(true); } } @Override protected String makeItemUrl(long itemId) { return DoubanUtils.makeMusicUrl(itemId); } @Override public void onItemCollectionChanged(int requestCode) { mAdapter.notifyItemCollectionChanged(); } @Override public void onItemCollectionListItemChanged(int requestCode, int position, SimpleItemCollection newItemCollection) { mAdapter.setItemCollectionListItem(position, newItemCollection); } @Override public void onItemCollectionListItemWriteStarted(int requestCode, int position) { mAdapter.notifyItemCollectionListItemChanged(position); } @Override public void onItemCollectionListItemWriteFinished(int requestCode, int position) { mAdapter.notifyItemCollectionListItemChanged(position); } @Override public void onUncollectItem(Music music) { ConfirmUncollectItemDialogFragment.show(this); } @Override public void uncollect() { if (!mResource.hasItem()) { return; } Music music = mResource.getItem(); UncollectItemManager.getInstance().write(music.getType(), music.id, getActivity()); } @Subscribe(threadMode = ThreadMode.POSTING) public void onMusicPlayingStateChanged(MusicPlayingStateChangedEvent event) { if (event.isFromMyself(this) || mAdapter == null) { return; } mAdapter.notifyTrackListChanged(); } @Override public void copyText(String text) { CopyTextDialogFragment.show(text, this); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/ui/MusicFragment.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,360
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.List; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.Game; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.network.api.info.frodo.Photo; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity; import me.zhanghai.android.douya.network.api.info.frodo.SimpleGame; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.util.FragmentUtils; public class GameFragmentResource extends BaseItemFragmentResource<SimpleGame, Game> { private static final String FRAGMENT_TAG_DEFAULT = GameFragmentResource.class.getName(); private static GameFragmentResource newInstance(long gameId, SimpleGame simpleGame, Game game) { //noinspection deprecation return new GameFragmentResource().setArguments(gameId, simpleGame, game); } public static GameFragmentResource attachTo(long gameId, SimpleGame simpleGame, Game game, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); GameFragmentResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(gameId, simpleGame, game); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static GameFragmentResource attachTo(long gameId, SimpleGame simpleGame, Game game, Fragment fragment) { return attachTo(gameId, simpleGame, game, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public GameFragmentResource() {} @Override protected GameFragmentResource setArguments(long itemId, SimpleGame simpleItem, Game item) { super.setArguments(itemId, simpleItem, item); return this; } @Override protected BaseItemResource<SimpleGame, Game> onAttachItemResource(long itemId, SimpleGame simpleItem, Game item) { return GameResource.attachTo(itemId, simpleItem, item, this); } @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.GAME; } @Override protected boolean hasPhotoList() { return true; } @Override protected boolean hasCelebrityList() { return false; } @Override protected boolean hasAwardList() { return false; } @Override protected void notifyChanged(int requestCode, Game newItem, Rating newRating, List<Photo> newPhotoList, List<SimpleCelebrity> newCelebrityList, List<ItemAwardItem> newAwardList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newGameGuideList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList) { getListener().onChanged(requestCode, newItem, newRating, newPhotoList, newItemCollectionList, newGameGuideList, newReviewList, newForumTopicList, newRecommendationList, newRelatedDoulistList); } private Listener getListener() { return (Listener) getTarget(); } public interface Listener extends BaseItemFragmentResource.Listener<Game> { void onLoadError(int requestCode, ApiError error); void onChanged(int requestCode, Game newGame, Rating newRating, List<Photo> newPhotoList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newGameGuideList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/GameFragmentResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
990
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.Collections; import java.util.List; import me.zhanghai.android.douya.content.MoreBaseListResourceFragment; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardList; import me.zhanghai.android.douya.util.FragmentUtils; public class ItemAwardListResource extends MoreBaseListResourceFragment<ItemAwardList, ItemAwardItem> { private static final String KEY_PREFIX = ItemAwardListResource.class.getName() + '.'; private static final String EXTRA_ITEM_TYPE = KEY_PREFIX + "item_type"; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private CollectableItem.Type mItemType; private long mItemId; private static final String FRAGMENT_TAG_DEFAULT = ItemAwardListResource.class.getName(); private static ItemAwardListResource newInstance(CollectableItem.Type itemType, long itemId) { //noinspection deprecation return new ItemAwardListResource().setArguments(itemType, itemId); } public static ItemAwardListResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); ItemAwardListResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(itemType, itemId); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static ItemAwardListResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment) { return attachTo(itemType, itemId, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public ItemAwardListResource() {} protected ItemAwardListResource setArguments(CollectableItem.Type itemType, long itemId) { FragmentUtils.getArgumentsBuilder(this) .putSerializable(EXTRA_ITEM_TYPE, itemType) .putLong(EXTRA_ITEM_ID, itemId); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mItemType = (CollectableItem.Type) getArguments().getSerializable(EXTRA_ITEM_TYPE); mItemId = getArguments().getLong(EXTRA_ITEM_ID); } @Override protected ApiRequest<ItemAwardList> onCreateRequest(Integer start, Integer count) { return ApiService.getInstance().getItemAwardList(mItemType, mItemId, start, count); } @Override protected void onLoadStarted() { getListener().onLoadAwardListStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean more, int count, boolean successful, List<ItemAwardItem> response, ApiError error) { if (successful) { if (more) { append(response); getListener().onLoadAwardListFinished(getRequestCode()); getListener().onAwardListAppended(getRequestCode(), Collections.unmodifiableList(response)); } else { set(response); getListener().onLoadAwardListFinished(getRequestCode()); getListener().onAwardListChanged(getRequestCode(), Collections.unmodifiableList(get())); } } else { getListener().onLoadAwardListFinished(getRequestCode()); getListener().onLoadAwardListError(getRequestCode(), error); } } private Listener getListener() { return (Listener) getTarget(); } public interface Listener { void onLoadAwardListStarted(int requestCode); void onLoadAwardListFinished(int requestCode); void onLoadAwardListError(int requestCode, ApiError error); /** * @param newAwardList Unmodifiable. */ void onAwardListChanged(int requestCode, List<ItemAwardItem> newAwardList); /** * @param appendedAwardList Unmodifiable. */ void onAwardListAppended(int requestCode, List<ItemAwardItem> appendedAwardList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/ItemAwardListResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
942
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.Collections; import java.util.List; import me.zhanghai.android.douya.content.MoreBaseListResourceFragment; import me.zhanghai.android.douya.eventbus.ItemCollectionUpdatedEvent; import me.zhanghai.android.douya.eventbus.ItemCollectionWriteFinishedEvent; import me.zhanghai.android.douya.eventbus.ItemCollectionWriteStartedEvent; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionList; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.util.FragmentUtils; public class ItemCollectionListResource extends MoreBaseListResourceFragment<ItemCollectionList, SimpleItemCollection> { private static final String KEY_PREFIX = ItemCollectionListResource.class.getName() + '.'; private static final String EXTRA_ITEM_TYPE = KEY_PREFIX + "item_type"; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private static final String EXTRA_FOLLOWINGS_FIRST = KEY_PREFIX + "followings_first"; private CollectableItem.Type mItemType; private long mItemId; private boolean mFollowingsFirst; private static final String FRAGMENT_TAG_DEFAULT = ItemCollectionListResource.class.getName(); private static ItemCollectionListResource newInstance(CollectableItem.Type itemType, long itemId, boolean followingsFirst) { //noinspection deprecation return new ItemCollectionListResource().setArguments(itemType, itemId, followingsFirst); } public static ItemCollectionListResource attachTo(CollectableItem.Type itemType, long itemId, boolean followingsFirst, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); ItemCollectionListResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(itemType, itemId, followingsFirst); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static ItemCollectionListResource attachTo(CollectableItem.Type itemType, long itemId, boolean followingsFirst, Fragment fragment) { return attachTo(itemType, itemId, followingsFirst, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public ItemCollectionListResource() {} protected ItemCollectionListResource setArguments(CollectableItem.Type itemType, long itemId, boolean followingsFirst) { FragmentUtils.getArgumentsBuilder(this) .putSerializable(EXTRA_ITEM_TYPE, itemType) .putLong(EXTRA_ITEM_ID, itemId) .putBoolean(EXTRA_FOLLOWINGS_FIRST, followingsFirst); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mItemType = (CollectableItem.Type) getArguments().getSerializable(EXTRA_ITEM_TYPE); mItemId = getArguments().getLong(EXTRA_ITEM_ID); mFollowingsFirst = getArguments().getBoolean(EXTRA_FOLLOWINGS_FIRST); } @Override protected ApiRequest<ItemCollectionList> onCreateRequest(Integer start, Integer count) { return ApiService.getInstance().getItemCollectionList(mItemType, mItemId, mFollowingsFirst, start, count); } @Override protected void onLoadStarted() { getListener().onLoadItemCollectionListStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean more, int count, boolean successful, List<SimpleItemCollection> response, ApiError error) { if (successful) { if (more) { append(response); getListener().onLoadItemCollectionListFinished(getRequestCode()); getListener().onItemCollectionListAppended(getRequestCode(), Collections.unmodifiableList(response)); } else { set(response); getListener().onLoadItemCollectionListFinished(getRequestCode()); getListener().onItemCollectionListChanged(getRequestCode(), Collections.unmodifiableList(get())); } } else { getListener().onLoadItemCollectionListFinished(getRequestCode()); getListener().onLoadItemCollectionListError(getRequestCode(), error); } } @Subscribe(threadMode = ThreadMode.POSTING) public void onItemCollectionUpdated(ItemCollectionUpdatedEvent event) { if (event.isFromMyself(this) || isEmpty()) { return; } List<SimpleItemCollection> itemCollectionList = get(); for (int i = 0, size = itemCollectionList.size(); i < size; ++i) { SimpleItemCollection itemCollection = itemCollectionList.get(i); if (itemCollection.id == event.itemCollection.id) { itemCollectionList.set(i, event.itemCollection); getListener().onItemCollectionListItemChanged(getRequestCode(), i, itemCollectionList.get(i)); } } } @Subscribe(threadMode = ThreadMode.POSTING) public void onItemCollectionWriteStarted(ItemCollectionWriteStartedEvent event) { if (event.isFromMyself(this) || isEmpty()) { return; } List<SimpleItemCollection> itemCollectionList = get(); for (int i = 0, size = itemCollectionList.size(); i < size; ++i) { SimpleItemCollection itemCollection = itemCollectionList.get(i); if (itemCollection.id == event.itemCollectionId) { getListener().onItemCollectionListItemWriteStarted(getRequestCode(), i); } } } @Subscribe(threadMode = ThreadMode.POSTING) public void onItemCollectionWriteFinished(ItemCollectionWriteFinishedEvent event) { if (event.isFromMyself(this) || isEmpty()) { return; } List<SimpleItemCollection> itemCollectionList = get(); for (int i = 0, size = itemCollectionList.size(); i < size; ++i) { SimpleItemCollection itemCollection = itemCollectionList.get(i); if (itemCollection.id == event.itemCollectionId) { getListener().onItemCollectionListItemWriteFinished(getRequestCode(), i); } } } private Listener getListener() { return (Listener) getTarget(); } public interface Listener { void onLoadItemCollectionListStarted(int requestCode); void onLoadItemCollectionListFinished(int requestCode); void onLoadItemCollectionListError(int requestCode, ApiError error); /** * @param newItemCollectionList Unmodifiable. */ void onItemCollectionListChanged(int requestCode, List<SimpleItemCollection> newItemCollectionList); /** * @param appendedItemCollectionList Unmodifiable. */ void onItemCollectionListAppended(int requestCode, List<SimpleItemCollection> appendedItemCollectionList); void onItemCollectionListItemChanged(int requestCode, int position, SimpleItemCollection newItemCollection); void onItemCollectionListItemWriteStarted(int requestCode, int position); void onItemCollectionListItemWriteFinished(int requestCode, int position); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/ItemCollectionListResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,582
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Game; import me.zhanghai.android.douya.network.api.info.frodo.SimpleGame; import me.zhanghai.android.douya.util.FragmentUtils; public class GameResource extends BaseItemResource<SimpleGame, Game> { private static final String FRAGMENT_TAG_DEFAULT = GameResource.class.getName(); private static GameResource newInstance(long gameId, SimpleGame simpleGame, Game game) { //noinspection deprecation GameResource instance = new GameResource(); instance.setArguments(gameId, simpleGame, game); return instance; } public static GameResource attachTo(long gameId, SimpleGame simpleGame, Game game, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); GameResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(gameId, simpleGame, game); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static GameResource attachTo(long gameId, SimpleGame simpleGame, Game game, Fragment fragment) { return attachTo(gameId, simpleGame, game, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public GameResource() {} @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.GAME; } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/GameResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
375
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.content.Context; import me.zhanghai.android.douya.content.ResourceWriterManager; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; public class UncollectItemManager extends ResourceWriterManager<UncollectItemWriter> { private static class InstanceHolder { public static final UncollectItemManager VALUE = new UncollectItemManager(); } public static UncollectItemManager getInstance() { return InstanceHolder.VALUE; } public void write(CollectableItem.Type itemType, long itemId, Context context) { add(new UncollectItemWriter(itemType, itemId, this), context); } public void write(CollectableItem item, Context context) { add(new UncollectItemWriter(item, this), context); } public boolean isWriting(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId) != null; } public boolean isWriting(CollectableItem item) { return isWriting(item.getType(), item.id); } private UncollectItemWriter findWriter(CollectableItem.Type itemType, long itemId) { for (UncollectItemWriter writer : getWriters()) { if (writer.getItemType() == itemType && writer.getItemId() == itemId) { return writer; } } return null; } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/UncollectItemManager.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
303
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Music; import me.zhanghai.android.douya.network.api.info.frodo.SimpleMusic; import me.zhanghai.android.douya.util.FragmentUtils; public class MusicResource extends BaseItemResource<SimpleMusic, Music> { private static final String FRAGMENT_TAG_DEFAULT = MusicResource.class.getName(); private static MusicResource newInstance(long musicId, SimpleMusic simpleMusic, Music music) { //noinspection deprecation MusicResource instance = new MusicResource(); instance.setArguments(musicId, simpleMusic, music); return instance; } public static MusicResource attachTo(long musicId, SimpleMusic simpleMusic, Music music, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); MusicResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(musicId, simpleMusic, music); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static MusicResource attachTo(long musicId, SimpleMusic simpleMusic, Music music, Fragment fragment) { return attachTo(musicId, simpleMusic, music, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public MusicResource() {} @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.MUSIC; } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/MusicResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
382
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import me.zhanghai.android.douya.content.ResourceFragment; import me.zhanghai.android.douya.eventbus.ItemCollectedEvent; import me.zhanghai.android.douya.eventbus.ItemUncollectedEvent; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.util.FragmentUtils; public abstract class BaseItemResource<SimpleItemType extends CollectableItem, ItemType extends SimpleItemType> extends ResourceFragment<ItemType, ItemType> { private final String KEY_PREFIX = getClass().getName() + '.'; private final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private final String EXTRA_SIMPLE_ITEM = KEY_PREFIX + "simple_item"; private final String EXTRA_ITEM = KEY_PREFIX + "item"; private static final int ITEM_ID_INVALID = -1; private long mItemId = ITEM_ID_INVALID; private SimpleItemType mSimpleItem; private ItemType mItem; protected BaseItemResource setArguments(long itemId, SimpleItemType simpleItem, ItemType item) { FragmentUtils.getArgumentsBuilder(this) .putLong(EXTRA_ITEM_ID, itemId) .putParcelable(EXTRA_SIMPLE_ITEM, simpleItem) .putParcelable(EXTRA_ITEM, item); return this; } public long getItemId() { ensureArguments(); return mItemId; } public SimpleItemType getSimpleItem() { // Can be called before onCreate() is called. ensureArguments(); return mSimpleItem; } public boolean hasSimpleItem() { return getSimpleItem() != null; } @Override public ItemType get() { ItemType item = super.get(); if (item == null) { // Can be called before onCreate() is called. ensureArguments(); item = mItem; } return item; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ensureArguments(); } private void ensureArguments() { if (mItemId != ITEM_ID_INVALID) { return; } Bundle arguments = getArguments(); mItem = arguments.getParcelable(EXTRA_ITEM); if (mItem != null) { mSimpleItem = mItem; mItemId = mItem.id; } else { mSimpleItem = arguments.getParcelable(EXTRA_SIMPLE_ITEM); if (mSimpleItem != null) { mItemId = mSimpleItem.id; } else { mItemId = arguments.getLong(EXTRA_ITEM_ID); } } } @Override public void onDestroy() { super.onDestroy(); if (has()) { ItemType item = get(); setArguments(item.id, item, item); } } @Override protected ApiRequest<ItemType> onCreateRequest() { return ApiService.getInstance().getItem(getItemType(), mItemId); } private CollectableItem.Type getItemType() { // Try our best for Movie/TV types. if (has()) { return get().getType(); } else if (hasSimpleItem()) { return getSimpleItem().getType(); } else { return getDefaultItemType(); } } protected abstract CollectableItem.Type getDefaultItemType(); @Override protected void onLoadStarted() { getListener().onLoadItemStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean successful, ItemType response, ApiError error) { if (successful) { set(response); getListener().onLoadItemFinished(getRequestCode()); getListener().onItemChanged(getRequestCode(), get()); } else { getListener().onLoadItemFinished(getRequestCode()); getListener().onLoadItemError(getRequestCode(), error); } } @Subscribe(threadMode = ThreadMode.POSTING) public void onItemCollected(ItemCollectedEvent event) { if (event.isFromMyself(this)) { return; } ItemType item = get(); if (event.itemType == item.getType() && event.itemId == item.id) { item.collection = event.collection; getListener().onItemChanged(getRequestCode(), item); getListener().onItemCollectionChanged(getRequestCode()); } } @Subscribe(threadMode = ThreadMode.POSTING) public void onItemUncollected(ItemUncollectedEvent event) { if (event.isFromMyself(this)) { return; } ItemType item = get(); if (event.itemType == item.getType() && event.itemId == item.id) { item.collection = null; getListener().onItemChanged(getRequestCode(), item); getListener().onItemCollectionChanged(getRequestCode()); } } private Listener<ItemType> getListener() { //noinspection unchecked return (Listener<ItemType>) getTarget(); } public interface Listener<ItemType> { void onLoadItemStarted(int requestCode); void onLoadItemFinished(int requestCode); void onLoadItemError(int requestCode, ApiError error); void onItemChanged(int requestCode, ItemType newItem); void onItemCollectionChanged(int requestCode); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/BaseItemResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,165
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Movie; import me.zhanghai.android.douya.network.api.info.frodo.SimpleMovie; import me.zhanghai.android.douya.util.FragmentUtils; public class MovieResource extends BaseItemResource<SimpleMovie, Movie> { private static final String FRAGMENT_TAG_DEFAULT = MovieResource.class.getName(); private static MovieResource newInstance(long movieId, SimpleMovie simpleMovie, Movie movie) { //noinspection deprecation MovieResource instance = new MovieResource(); instance.setArguments(movieId, simpleMovie, movie); return instance; } public static MovieResource attachTo(long movieId, SimpleMovie simpleMovie, Movie movie, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); MovieResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(movieId, simpleMovie, movie); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static MovieResource attachTo(long movieId, SimpleMovie simpleMovie, Movie movie, Fragment fragment) { return attachTo(movieId, simpleMovie, movie, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public MovieResource() {} @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.MOVIE; } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/MovieResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
379
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.ArrayList; import java.util.List; import me.zhanghai.android.douya.content.RawListResourceFragment; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CelebrityList; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity; import me.zhanghai.android.douya.util.FragmentUtils; public class CelebrityListResource extends RawListResourceFragment<CelebrityList, SimpleCelebrity> { private static final String KEY_PREFIX = CelebrityListResource.class.getName() + '.'; private static final String EXTRA_ITEM_TYPE = KEY_PREFIX + "item_type"; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private CollectableItem.Type mItemType; private long mItemId; private static final String FRAGMENT_TAG_DEFAULT = CelebrityListResource.class.getName(); private static CelebrityListResource newInstance(CollectableItem.Type itemType, long itemId) { //noinspection deprecation return new CelebrityListResource().setArguments(itemType, itemId); } public static CelebrityListResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); CelebrityListResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(itemType, itemId); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static CelebrityListResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment) { return attachTo(itemType, itemId, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public CelebrityListResource() {} protected CelebrityListResource setArguments(CollectableItem.Type itemType, long itemId) { FragmentUtils.getArgumentsBuilder(this) .putSerializable(EXTRA_ITEM_TYPE, itemType) .putLong(EXTRA_ITEM_ID, itemId); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mItemType = (CollectableItem.Type) getArguments().getSerializable(EXTRA_ITEM_TYPE); mItemId = getArguments().getLong(EXTRA_ITEM_ID); } @Override protected ApiRequest<CelebrityList> onCreateRequest() { return ApiService.getInstance().getItemCelebrityList(mItemType, mItemId); } @Override protected void onLoadStarted() { getListener().onLoadCelebrityListStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean successful, CelebrityList response, ApiError error) { onLoadFinished(successful, successful ? transformResponse(response) : null, error); } private List<SimpleCelebrity> transformResponse(CelebrityList response) { List<SimpleCelebrity> celebrityList = new ArrayList<>(); celebrityList.addAll(response.directors); for (SimpleCelebrity celebrity : celebrityList) { celebrity.isDirector = true; } celebrityList.addAll(response.actors); return celebrityList; } private void onLoadFinished(boolean successful, List<SimpleCelebrity> response, ApiError error) { if (successful) { set(response); getListener().onLoadCelebrityListFinished(getRequestCode()); getListener().onCelebrityListChanged(getRequestCode(), response); } else { getListener().onLoadCelebrityListFinished(getRequestCode()); getListener().onLoadCelebrityListError(getRequestCode(), error); } } private Listener getListener() { return (Listener) getTarget(); } public interface Listener { void onLoadCelebrityListStarted(int requestCode); void onLoadCelebrityListFinished(int requestCode); void onLoadCelebrityListError(int requestCode, ApiError error); void onCelebrityListChanged(int requestCode, List<SimpleCelebrity> newCelebrityList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/CelebrityListResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
942
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.Collections; import java.util.List; import me.zhanghai.android.douya.content.MoreBaseListResourceFragment; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemForumTopicList; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.util.FragmentUtils; public class ItemForumTopicListResource extends MoreBaseListResourceFragment<ItemForumTopicList, SimpleItemForumTopic> { private static final String KEY_PREFIX = ItemForumTopicListResource.class.getName() + '.'; private static final String EXTRA_ITEM_TYPE = KEY_PREFIX + "item_type"; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private static final String EXTRA_EPISODE = KEY_PREFIX + "episode"; private CollectableItem.Type mItemType; private long mItemId; private Integer mEpisode; private static final String FRAGMENT_TAG_DEFAULT = ItemForumTopicListResource.class.getName(); private static ItemForumTopicListResource newInstance(CollectableItem.Type itemType, long itemId, Integer episode) { //noinspection deprecation return new ItemForumTopicListResource().setArguments(itemType, itemId, episode); } public static ItemForumTopicListResource attachTo(CollectableItem.Type itemType, long itemId, Integer episode, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); ItemForumTopicListResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(itemType, itemId, episode); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static ItemForumTopicListResource attachTo(CollectableItem.Type itemType, long itemId, Integer episode, Fragment fragment) { return attachTo(itemType, itemId, episode, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public ItemForumTopicListResource() {} protected ItemForumTopicListResource setArguments(CollectableItem.Type itemType, long itemId, Integer episode) { FragmentUtils.getArgumentsBuilder(this) .putSerializable(EXTRA_ITEM_TYPE, itemType) .putLong(EXTRA_ITEM_ID, itemId) .putSerializable(EXTRA_EPISODE, episode); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mItemType = (CollectableItem.Type) getArguments().getSerializable(EXTRA_ITEM_TYPE); mItemId = getArguments().getLong(EXTRA_ITEM_ID); mEpisode = (Integer) getArguments().getSerializable(EXTRA_EPISODE); } @Override protected ApiRequest<ItemForumTopicList> onCreateRequest(Integer start, Integer count) { return ApiService.getInstance().getItemForumTopicList(mItemType, mItemId, mEpisode, start, count); } @Override protected void onLoadStarted() { getListener().onLoadForumTopicListStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean more, int count, boolean successful, List<SimpleItemForumTopic> response, ApiError error) { if (successful) { if (more) { append(response); getListener().onLoadForumTopicListFinished(getRequestCode()); getListener().onForumTopicListAppended(getRequestCode(), Collections.unmodifiableList(response)); } else { set(response); getListener().onLoadForumTopicListFinished(getRequestCode()); getListener().onForumTopicListChanged(getRequestCode(), Collections.unmodifiableList(get())); } } else { getListener().onLoadForumTopicListFinished(getRequestCode()); getListener().onLoadForumTopicListError(getRequestCode(), error); } } private Listener getListener() { return (Listener) getTarget(); } public interface Listener { void onLoadForumTopicListStarted(int requestCode); void onLoadForumTopicListFinished(int requestCode); void onLoadForumTopicListError(int requestCode, ApiError error); /** * @param newForumTopicList Unmodifiable. */ void onForumTopicListChanged(int requestCode, List<SimpleItemForumTopic> newForumTopicList); /** * @param appendedForumTopicList Unmodifiable. */ void onForumTopicListAppended(int requestCode, List<SimpleItemForumTopic> appendedForumTopicList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/ItemForumTopicListResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,055
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.content.Context; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.content.ResourceWriterManager; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.util.ToastUtils; public class VoteItemCollectionManager extends ResourceWriterManager<VoteItemCollectionWriter> { private static class InstanceHolder { public static final VoteItemCollectionManager VALUE = new VoteItemCollectionManager(); } public static VoteItemCollectionManager getInstance() { return InstanceHolder.VALUE; } /** * @deprecated Use {@link #write(CollectableItem.Type, long, SimpleItemCollection, Context)} * instead. */ public void write(CollectableItem.Type itemType, long itemId, long itemCollectionId, Context context) { add(new VoteItemCollectionWriter(itemType, itemId, itemCollectionId, this), context); } public boolean write(CollectableItem.Type itemType, long itemId, SimpleItemCollection itemCollection, Context context) { if (shouldWrite(itemCollection, context)) { //noinspection deprecation write(itemType, itemId, itemCollection.id, context); return true; } else { return false; } } private boolean shouldWrite(SimpleItemCollection itemCollection, Context context) { if (itemCollection.user.isOneself()) { ToastUtils.show(R.string.item_collection_vote_error_cannot_vote_oneself, context); return false; } else if (itemCollection.isVoted) { ToastUtils.show(R.string.item_collection_vote_error_cannot_vote_again, context); return false; } else { return true; } } public boolean isWriting(long itemCollectionId) { return findWriter(itemCollectionId) != null; } private VoteItemCollectionWriter findWriter(long itemCollectionId) { for (VoteItemCollectionWriter writer : getWriters()) { if (writer.getItemCollectionId() == itemCollectionId) { return writer; } } return null; } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/VoteItemCollectionManager.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
486
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.List; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.ReviewList; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.review.content.BaseReviewListResource; import me.zhanghai.android.douya.util.FragmentUtils; public class GameGuideListResource extends BaseReviewListResource { private static final String KEY_PREFIX = GameGuideListResource.class.getName() + '.'; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private long mItemId; private static final String FRAGMENT_TAG_DEFAULT = GameGuideListResource.class.getName(); private static GameGuideListResource newInstance(long itemId) { //noinspection deprecation return new GameGuideListResource().setArguments(itemId); } public static GameGuideListResource attachTo(long itemId, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); GameGuideListResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(itemId); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static GameGuideListResource attachTo(long itemId, Fragment fragment) { return attachTo(itemId, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public GameGuideListResource() {} protected GameGuideListResource setArguments(long itemId) { FragmentUtils.getArgumentsBuilder(this) .putLong(EXTRA_ITEM_ID, itemId); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mItemId = getArguments().getLong(EXTRA_ITEM_ID); } @Override protected ApiRequest<ReviewList> onCreateRequest(Integer start, Integer count) { return ApiService.getInstance().getGameGuideList(mItemId, start, count); } @Override protected BaseReviewListResource.Listener getListener() { return new ListenerWrapper((Listener) getTarget()); } public interface Listener { void onLoadGameGuideListStarted(int requestCode); void onLoadGameGuideListFinished(int requestCode); void onLoadGameGuideListError(int requestCode, ApiError error); /** * @param newGameGuideList Unmodifiable. */ void onGameGuideListChanged(int requestCode, List<SimpleReview> newGameGuideList); /** * @param appendedGameGuideList Unmodifiable. */ void onGameGuideListAppended(int requestCode, List<SimpleReview> appendedGameGuideList); void onGameGuideChanged(int requestCode, int position, SimpleReview newGameGuide); void onGameGuideRemoved(int requestCode, int position); } private static class ListenerWrapper implements BaseReviewListResource.Listener { private Listener mListener; public ListenerWrapper(Listener listener) { mListener = listener; } @Override public void onLoadReviewListStarted(int requestCode) { mListener.onLoadGameGuideListStarted(requestCode); } @Override public void onLoadReviewListFinished(int requestCode) { mListener.onLoadGameGuideListFinished(requestCode); } @Override public void onLoadReviewListError(int requestCode, ApiError error) { mListener.onLoadGameGuideListError(requestCode, error); } @Override public void onReviewListChanged(int requestCode, List<SimpleReview> newReviewList) { mListener.onGameGuideListChanged(requestCode, newReviewList); } @Override public void onReviewListAppended(int requestCode, List<SimpleReview> appendedReviewList) { mListener.onGameGuideListAppended(requestCode, appendedReviewList); } @Override public void onReviewChanged(int requestCode, int position, SimpleReview newReview) { mListener.onGameGuideChanged(requestCode, position, newReview); } @Override public void onReviewRemoved(int requestCode, int position) { mListener.onGameGuideRemoved(requestCode, position); } } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/GameGuideListResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
945
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import me.zhanghai.android.douya.content.ResourceFragment; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.util.FragmentUtils; public class RatingResource extends ResourceFragment<Rating, Rating> { private static final String KEY_PREFIX = RatingResource.class.getName() + '.'; private static final String EXTRA_ITEM_TYPE = KEY_PREFIX + "item_type"; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private CollectableItem.Type mItemType; private long mItemId; private static final String FRAGMENT_TAG_DEFAULT = RatingResource.class.getName(); private static RatingResource newInstance(CollectableItem.Type itemType, long itemId) { //noinspection deprecation return new RatingResource().setArguments(itemType, itemId); } public static RatingResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); RatingResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(itemType, itemId); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static RatingResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment) { return attachTo(itemType, itemId, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public RatingResource() {} protected RatingResource setArguments(CollectableItem.Type itemType, long itemId) { FragmentUtils.getArgumentsBuilder(this) .putSerializable(EXTRA_ITEM_TYPE, itemType) .putLong(EXTRA_ITEM_ID, itemId); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mItemType = (CollectableItem.Type) getArguments().getSerializable(EXTRA_ITEM_TYPE); mItemId = getArguments().getLong(EXTRA_ITEM_ID); } @Override protected ApiRequest<Rating> onCreateRequest() { return ApiService.getInstance().getItemRating(mItemType, mItemId); } @Override protected void onLoadStarted() { getListener().onLoadRatingStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean successful, Rating response, ApiError error) { if (successful) { set(response); getListener().onLoadRatingFinished(getRequestCode()); getListener().onRatingChanged(getRequestCode(), response); } else { getListener().onLoadRatingFinished(getRequestCode()); getListener().onLoadRatingError(getRequestCode(), error); } } private Listener getListener() { return (Listener) getTarget(); } public interface Listener { void onLoadRatingStarted(int requestCode); void onLoadRatingFinished(int requestCode); void onLoadRatingError(int requestCode, ApiError error); void onRatingChanged(int requestCode, Rating newRating); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/RatingResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
744
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.List; import me.zhanghai.android.douya.content.RawListResourceFragment; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.util.FragmentUtils; public class ItemRecommendationListResource extends RawListResourceFragment<List<CollectableItem>, CollectableItem> { private static final String KEY_PREFIX = ItemRecommendationListResource.class.getName() + '.'; private static final String EXTRA_ITEM_TYPE = KEY_PREFIX + "item_type"; private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private CollectableItem.Type mItemType; private long mItemId; private static final String FRAGMENT_TAG_DEFAULT = ItemRecommendationListResource.class.getName(); private static ItemRecommendationListResource newInstance(CollectableItem.Type itemType, long itemId) { //noinspection deprecation return new ItemRecommendationListResource().setArguments(itemType, itemId); } public static ItemRecommendationListResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); ItemRecommendationListResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(itemType, itemId); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static ItemRecommendationListResource attachTo(CollectableItem.Type itemType, long itemId, Fragment fragment) { return attachTo(itemType, itemId, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public ItemRecommendationListResource() {} protected ItemRecommendationListResource setArguments(CollectableItem.Type itemType, long itemId) { FragmentUtils.getArgumentsBuilder(this) .putSerializable(EXTRA_ITEM_TYPE, itemType) .putLong(EXTRA_ITEM_ID, itemId); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mItemType = (CollectableItem.Type) getArguments().getSerializable(EXTRA_ITEM_TYPE); mItemId = getArguments().getLong(EXTRA_ITEM_ID); } @Override protected ApiRequest<List<CollectableItem>> onCreateRequest() { // TODO: Utilize count. return ApiService.getInstance().getItemRecommendationList(mItemType, mItemId, null); } @Override protected void onLoadStarted() { getListener().onLoadRecommendationListStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean successful, List<CollectableItem> response, ApiError error) { if (successful) { set(response); getListener().onLoadRecommendationListFinished(getRequestCode()); getListener().onRecommendationListChanged(getRequestCode(), response); } else { getListener().onLoadRecommendationListFinished(getRequestCode()); getListener().onLoadRecommendationListError(getRequestCode(), error); } } private Listener getListener() { return (Listener) getTarget(); } public interface Listener { void onLoadRecommendationListStarted(int requestCode); void onLoadRecommendationListFinished(int requestCode); void onLoadRecommendationListError(int requestCode, ApiError error); void onRecommendationListChanged(int requestCode, List<CollectableItem> newRecommendationList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/ItemRecommendationListResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
823
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import me.zhanghai.android.douya.network.api.info.frodo.Book; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.SimpleBook; import me.zhanghai.android.douya.util.FragmentUtils; public class BookResource extends BaseItemResource<SimpleBook, Book> { private static final String FRAGMENT_TAG_DEFAULT = BookResource.class.getName(); private static BookResource newInstance(long bookId, SimpleBook simpleBook, Book book) { //noinspection deprecation BookResource instance = new BookResource(); instance.setArguments(bookId, simpleBook, book); return instance; } public static BookResource attachTo(long bookId, SimpleBook simpleBook, Book book, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); BookResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(bookId, simpleBook, book); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static BookResource attachTo(long bookId, SimpleBook simpleBook, Book book, Fragment fragment) { return attachTo(bookId, simpleBook, book, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public BookResource() {} @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.BOOK; } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/BookResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
378
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.content.Context; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.content.RequestResourceWriter; import me.zhanghai.android.douya.content.ResourceWriterManager; import me.zhanghai.android.douya.eventbus.ItemCollectionUpdatedEvent; import me.zhanghai.android.douya.eventbus.ItemCollectionWriteFinishedEvent; import me.zhanghai.android.douya.eventbus.ItemCollectionWriteStartedEvent; import me.zhanghai.android.douya.eventbus.EventBusUtils; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.util.LogUtils; import me.zhanghai.android.douya.util.ToastUtils; class VoteItemCollectionWriter extends RequestResourceWriter<VoteItemCollectionWriter, ItemCollection> { private CollectableItem.Type mItemType; private long mItemId; private long mItemCollectionId; public VoteItemCollectionWriter(CollectableItem.Type itemType, long itemId, long itemCollectionId, ResourceWriterManager<VoteItemCollectionWriter> manager) { super(manager); mItemType = itemType; mItemId = itemId; mItemCollectionId = itemCollectionId; } public CollectableItem.Type getItemType() { return mItemType; } public long getItemId() { return mItemId; } public long getItemCollectionId() { return mItemCollectionId; } @Override protected ApiRequest<ItemCollection> onCreateRequest() { return ApiService.getInstance().voteItemCollection(mItemType, mItemId, mItemCollectionId); } @Override public void onStart() { super.onStart(); EventBusUtils.postAsync(new ItemCollectionWriteStartedEvent(mItemCollectionId, this)); } @Override public void onResponse(ItemCollection response) { ToastUtils.show(R.string.item_collection_vote_successful, getContext()); EventBusUtils.postAsync(new ItemCollectionUpdatedEvent(response, this)); stopSelf(); } @Override public void onErrorResponse(ApiError error) { LogUtils.e(error.toString()); Context context = getContext(); ToastUtils.show(context.getString(R.string.item_collection_vote_failed_format, ApiError.getErrorString(error, context)), context); // Must notify to reset pending status. Off-screen items also needs to be invalidated. EventBusUtils.postAsync(new ItemCollectionWriteFinishedEvent(mItemCollectionId, this)); stopSelf(); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/VoteItemCollectionWriter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
601
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.List; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.network.api.info.frodo.Music; import me.zhanghai.android.douya.network.api.info.frodo.Photo; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleMusic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.util.FragmentUtils; public class MusicFragmentResource extends BaseItemFragmentResource<SimpleMusic, Music> { private static final String FRAGMENT_TAG_DEFAULT = MusicFragmentResource.class.getName(); private static MusicFragmentResource newInstance(long musicId, SimpleMusic simpleMusic, Music music) { //noinspection deprecation return new MusicFragmentResource().setArguments(musicId, simpleMusic, music); } public static MusicFragmentResource attachTo(long musicId, SimpleMusic simpleMusic, Music music, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); MusicFragmentResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(musicId, simpleMusic, music); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static MusicFragmentResource attachTo(long musicId, SimpleMusic simpleMusic, Music music, Fragment fragment) { return attachTo(musicId, simpleMusic, music, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public MusicFragmentResource() {} @Override protected MusicFragmentResource setArguments(long itemId, SimpleMusic simpleItem, Music item) { super.setArguments(itemId, simpleItem, item); return this; } @Override protected BaseItemResource<SimpleMusic, Music> onAttachItemResource(long itemId, SimpleMusic simpleItem, Music item) { return MusicResource.attachTo(itemId, simpleItem, item, this); } @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.MUSIC; } @Override protected boolean hasPhotoList() { return false; } @Override protected boolean hasCelebrityList() { return false; } @Override protected boolean hasAwardList() { return false; } @Override protected void notifyChanged(int requestCode, Music newItem, Rating newRating, List<Photo> newPhotoList, List<SimpleCelebrity> newCelebrityList, List<ItemAwardItem> newAwardList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newGameGuideList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList) { getListener().onChanged(requestCode, newItem, newRating, newItemCollectionList, newReviewList, newForumTopicList, newRecommendationList, newRelatedDoulistList); } private Listener getListener() { return (Listener) getTarget(); } public interface Listener extends BaseItemFragmentResource.Listener<Music> { void onLoadError(int requestCode, ApiError error); void onChanged(int requestCode, Music newMusic, Rating newRating, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/MusicFragmentResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
971
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.List; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.Movie; import me.zhanghai.android.douya.network.api.info.frodo.Photo; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity; import me.zhanghai.android.douya.network.api.info.frodo.SimpleMovie; import me.zhanghai.android.douya.util.FragmentUtils; public class MovieFragmentResource extends BaseItemFragmentResource<SimpleMovie, Movie> { private static final String FRAGMENT_TAG_DEFAULT = MovieFragmentResource.class.getName(); private static MovieFragmentResource newInstance(long movieId, SimpleMovie simpleMovie, Movie movie) { //noinspection deprecation return new MovieFragmentResource().setArguments(movieId, simpleMovie, movie); } public static MovieFragmentResource attachTo(long movieId, SimpleMovie simpleMovie, Movie movie, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); MovieFragmentResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(movieId, simpleMovie, movie); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static MovieFragmentResource attachTo(long movieId, SimpleMovie simpleMovie, Movie movie, Fragment fragment) { return attachTo(movieId, simpleMovie, movie, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public MovieFragmentResource() {} @Override protected MovieFragmentResource setArguments(long itemId, SimpleMovie simpleItem, Movie item) { super.setArguments(itemId, simpleItem, item); return this; } @Override protected BaseItemResource<SimpleMovie, Movie> onAttachItemResource(long itemId, SimpleMovie simpleItem, Movie item) { return MovieResource.attachTo(itemId, simpleItem, item, this); } @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.MOVIE; } @Override protected boolean hasPhotoList() { return true; } @Override protected boolean hasCelebrityList() { return true; } @Override protected boolean hasAwardList() { return true; } @Override protected void notifyChanged(int requestCode, Movie newItem, Rating newRating, List<Photo> newPhotoList, List<SimpleCelebrity> newCelebrityList, List<ItemAwardItem> newAwardList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newGameGuideList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList) { getListener().onChanged(requestCode, newItem, newRating, newPhotoList, newCelebrityList, newAwardList, newItemCollectionList, newReviewList, newForumTopicList, newRecommendationList, newRelatedDoulistList); } private Listener getListener() { return (Listener) getTarget(); } public interface Listener extends BaseItemFragmentResource.Listener<Movie> { void onLoadError(int requestCode, ApiError error); void onChanged(int requestCode, Movie newMovie, Rating newRating, List<Photo> newPhotoList, List<SimpleCelebrity> newCelebrityList, List<ItemAwardItem> newAwardList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/MovieFragmentResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,010
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import java.util.List; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.info.frodo.Book; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.network.api.info.frodo.Photo; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleBook; import me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.util.FragmentUtils; public class BookFragmentResource extends BaseItemFragmentResource<SimpleBook, Book> { private static final String FRAGMENT_TAG_DEFAULT = BookFragmentResource.class.getName(); private static BookFragmentResource newInstance(long bookId, SimpleBook simpleBook, Book book) { //noinspection deprecation return new BookFragmentResource().setArguments(bookId, simpleBook, book); } public static BookFragmentResource attachTo(long bookId, SimpleBook simpleBook, Book book, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); BookFragmentResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(bookId, simpleBook, book); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static BookFragmentResource attachTo(long bookId, SimpleBook simpleBook, Book book, Fragment fragment) { return attachTo(bookId, simpleBook, book, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public BookFragmentResource() {} @Override protected BookFragmentResource setArguments(long itemId, SimpleBook simpleItem, Book item) { super.setArguments(itemId, simpleItem, item); return this; } @Override protected BaseItemResource<SimpleBook, Book> onAttachItemResource(long itemId, SimpleBook simpleItem, Book item) { return BookResource.attachTo(itemId, simpleItem, item, this); } @Override protected CollectableItem.Type getDefaultItemType() { return CollectableItem.Type.BOOK; } @Override protected boolean hasPhotoList() { return false; } @Override protected boolean hasCelebrityList() { return false; } @Override protected boolean hasAwardList() { return false; } @Override protected void notifyChanged(int requestCode, Book newItem, Rating newRating, List<Photo> newPhotoList, List<SimpleCelebrity> newCelebrityList, List<ItemAwardItem> newAwardList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newGameGuideList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList) { getListener().onChanged(requestCode, newItem, newRating, newItemCollectionList, newReviewList, newForumTopicList, newRecommendationList, newRelatedDoulistList); } private Listener getListener() { return (Listener) getTarget(); } public interface Listener extends BaseItemFragmentResource.Listener<Book> { void onLoadError(int requestCode, ApiError error); void onChanged(int requestCode, Book newBook, Rating newRating, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/BookFragmentResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
966
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.content.Context; import android.os.Bundle; import java.util.List; import me.zhanghai.android.douya.app.TargetedRetainedFragment; import me.zhanghai.android.douya.doulist.content.ItemRelatedDoulistListResource; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.Doulist; import me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.Photo; import me.zhanghai.android.douya.network.api.info.frodo.Rating; import me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity; import me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic; import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview; import me.zhanghai.android.douya.photo.content.ItemPhotoListResource; import me.zhanghai.android.douya.review.content.ItemReviewListResource; import me.zhanghai.android.douya.util.FragmentUtils; public abstract class BaseItemFragmentResource<SimpleItemType extends CollectableItem, ItemType extends SimpleItemType> extends TargetedRetainedFragment implements BaseItemResource.Listener<ItemType>, RatingResource.Listener, ItemPhotoListResource.Listener, CelebrityListResource.Listener, ItemAwardListResource.Listener, ItemCollectionListResource.Listener, GameGuideListResource.Listener, ItemReviewListResource.Listener, ItemForumTopicListResource.Listener, ItemRecommendationListResource.Listener, ItemRelatedDoulistListResource.Listener { private final String KEY_PREFIX = getClass().getName() + '.'; private final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id"; private final String EXTRA_SIMPLE_ITEM = KEY_PREFIX + "simple_item"; private final String EXTRA_ITEM = KEY_PREFIX + "item"; private static final int ITEM_ID_INVALID = -1; private long mItemId = ITEM_ID_INVALID; private SimpleItemType mSimpleItem; private ItemType mItem; private BaseItemResource<SimpleItemType, ItemType> mItemResource; private RatingResource mRatingResource; private ItemPhotoListResource mPhotoListResource; private CelebrityListResource mCelebrityListResource; private ItemAwardListResource mAwardListResource; private ItemCollectionListResource mItemCollectionListResource; private GameGuideListResource mGameGuideListResource; private ItemReviewListResource mReviewListResource; private ItemForumTopicListResource mForumTopicListResource; private ItemRecommendationListResource mRecommendationListResource; private ItemRelatedDoulistListResource mRelatedDoulistListResource; private boolean mHasError; protected BaseItemFragmentResource setArguments(long itemId, SimpleItemType simpleItem, ItemType item) { FragmentUtils.getArgumentsBuilder(this) .putLong(EXTRA_ITEM_ID, itemId) .putParcelable(EXTRA_SIMPLE_ITEM, simpleItem) .putParcelable(EXTRA_ITEM, item); return this; } public long getItemId() { // Can be called before onCreate() is called. ensureArguments(); return mItemId; } public SimpleItemType getSimpleItem() { // Can be called before onCreate() is called. ensureArguments(); return mSimpleItem; } public boolean hasSimpleItem() { // Can be called before onCreate() is called. ensureArguments(); return mSimpleItem != null; } public ItemType getItem() { // Can be called before onCreate() is called. ensureArguments(); return mItem; } public boolean hasItem() { // Can be called before onCreate() is called. ensureArguments(); return mItem != null; } @Override public void onAttach(Context context) { super.onAttach(context); ensureResourcesTarget(); } private void ensureResourcesTarget() { if (mItemResource != null) { mItemResource.setTarget(this); } if (mRatingResource != null) { mRatingResource.setTarget(this); } if (mPhotoListResource != null) { mPhotoListResource.setTarget(this); } if (mCelebrityListResource != null) { mCelebrityListResource.setTarget(this); } if (mAwardListResource != null) { mAwardListResource.setTarget(this); } if (mItemCollectionListResource != null) { mItemCollectionListResource.setTarget(this); } if (mGameGuideListResource != null) { mGameGuideListResource.setTarget(this); } if (mReviewListResource != null) { mReviewListResource.setTarget(this); } if (mForumTopicListResource != null) { mForumTopicListResource.setTarget(this); } if (mRecommendationListResource != null) { mRecommendationListResource.setTarget(this); } if (mRelatedDoulistListResource != null) { mRelatedDoulistListResource.setTarget(this); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ensureArguments(); mItemResource = onAttachItemResource(mItemId, mSimpleItem, mItem); CollectableItem.Type itemType = getItemType(); mRatingResource = RatingResource.attachTo(itemType, mItemId, this); if (hasPhotoList()) { mPhotoListResource = ItemPhotoListResource.attachTo(itemType, mItemId, this); } if (hasCelebrityList()) { mCelebrityListResource = CelebrityListResource.attachTo(itemType, mItemId, this); } if (hasAwardList()) { mAwardListResource = ItemAwardListResource.attachTo(itemType, mItemId, this); } mItemCollectionListResource = ItemCollectionListResource.attachTo(itemType, mItemId, true, this); if (hasGameGuideList()) { mGameGuideListResource = GameGuideListResource.attachTo(mItemId, this); } mReviewListResource = ItemReviewListResource.attachTo(itemType, mItemId, this); if (hasForumTopicList()) { mForumTopicListResource = ItemForumTopicListResource.attachTo(itemType, mItemId, null, this); } if (hasRecommendationList()) { mRecommendationListResource = ItemRecommendationListResource.attachTo(itemType, mItemId, this); } mRelatedDoulistListResource = ItemRelatedDoulistListResource.attachTo(itemType, mItemId, this); } private void ensureArguments() { if (mItemId != ITEM_ID_INVALID) { return; } Bundle arguments = getArguments(); mItem = arguments.getParcelable(EXTRA_ITEM); if (mItem != null) { mSimpleItem = mItem; mItemId = mItem.id; } else { mSimpleItem = arguments.getParcelable(EXTRA_SIMPLE_ITEM); if (mSimpleItem != null) { mItemId = mSimpleItem.id; } else { mItemId = arguments.getLong(EXTRA_ITEM_ID); } } } protected abstract BaseItemResource<SimpleItemType, ItemType> onAttachItemResource( long itemId, SimpleItemType simpleItem, ItemType item); private CollectableItem.Type getItemType() { // Try our best for Movie/TV types. if (hasItem()) { return getItem().getType(); } else if (hasSimpleItem()) { return getSimpleItem().getType(); } else { return getDefaultItemType(); } } protected abstract CollectableItem.Type getDefaultItemType(); protected abstract boolean hasPhotoList(); protected abstract boolean hasCelebrityList(); protected abstract boolean hasAwardList(); protected boolean hasGameGuideList() { return getItemType() == CollectableItem.Type.GAME; } protected boolean hasForumTopicList() { // TODO: Currently there's no forum for game. return getItemType() != CollectableItem.Type.GAME; } protected boolean hasRecommendationList() { // TODO: Frodo API currently returns 5xx for recommendation list. return getItemType() != CollectableItem.Type.GAME; } @Override public void onDestroy() { super.onDestroy(); if (mItemResource != null) { mItemResource.detach(); } if (mRatingResource != null) { mRatingResource.detach(); } if (mPhotoListResource != null) { mPhotoListResource.detach(); } if (mCelebrityListResource != null) { mCelebrityListResource.detach(); } if (mAwardListResource != null) { mAwardListResource.detach(); } if (mItemCollectionListResource != null) { mItemCollectionListResource.detach(); } if (mGameGuideListResource != null) { mGameGuideListResource.detach(); } if (mReviewListResource != null) { mReviewListResource.detach(); } if (mForumTopicListResource != null) { mForumTopicListResource.detach(); } if (mRecommendationListResource != null) { mRecommendationListResource.detach(); } if (mRelatedDoulistListResource != null) { mRelatedDoulistListResource.detach(); } Bundle arguments = getArguments(); arguments.putLong(EXTRA_ITEM_ID, mItemId); arguments.putParcelable(EXTRA_SIMPLE_ITEM, mSimpleItem); arguments.putParcelable(EXTRA_ITEM, mItem); } @Override public void onLoadItemStarted(int requestCode) {} @Override public void onLoadItemFinished(int requestCode) {} @Override public void onLoadItemError(int requestCode, ApiError error) { notifyError(error); } @Override public void onItemChanged(int requestCode, ItemType newItem) { mItem = newItem; mSimpleItem = newItem; mItemId = newItem.id; getListener().onItemChanged(getRequestCode(), newItem); notifyChanged(); } // TODO: Item collection. //@Override //public void onItemWriteStarted(int requestCode) { // getListener().onItemWriteStarted(getRequestCode()); //} // //@Override //public void onItemWriteFinished(int requestCode) { // getListener().onItemWriteFinished(getRequestCode()); //} @Override public void onLoadRatingStarted(int requestCode) {} @Override public void onLoadRatingFinished(int requestCode) {} @Override public void onLoadRatingError(int requestCode, ApiError error) { notifyError(error); } @Override public void onRatingChanged(int requestCode, Rating newRating) { notifyChanged(); } @Override public void onLoadPhotoListStarted(int requestCode) {} @Override public void onLoadPhotoListFinished(int requestCode) {} @Override public void onLoadPhotoListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onPhotoListChanged(int requestCode, List<Photo> newPhotoList) { notifyChanged(); } @Override public void onPhotoListAppended(int requestCode, List<Photo> appendedPhotoList) { notifyChanged(); } @Override public void onPhotoRemoved(int requestCode, int position) { notifyChanged(); } @Override public void onLoadCelebrityListStarted(int requestCode) {} @Override public void onLoadCelebrityListFinished(int requestCode) {} @Override public void onLoadCelebrityListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onCelebrityListChanged(int requestCode, List<SimpleCelebrity> newCelebrityList) { notifyChanged(); } @Override public void onLoadAwardListStarted(int requestCode) {} @Override public void onLoadAwardListFinished(int requestCode) {} @Override public void onLoadAwardListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onAwardListChanged(int requestCode, List<ItemAwardItem> newAwardList) { notifyChanged(); } @Override public void onAwardListAppended(int requestCode, List<ItemAwardItem> appendedAwardList) { notifyChanged(); } @Override public void onLoadItemCollectionListStarted(int requestCode) {} @Override public void onLoadItemCollectionListFinished(int requestCode) {} @Override public void onLoadItemCollectionListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onItemCollectionListChanged(int requestCode, List<SimpleItemCollection> newItemCollectionList) { notifyChanged(); } @Override public void onItemCollectionListAppended( int requestCode, List<SimpleItemCollection> appendedItemCollectionList) { notifyChanged(); } @Override public void onItemCollectionListItemChanged(int requestCode, int position, SimpleItemCollection newItemCollection) { getListener().onItemCollectionListItemChanged(getRequestCode(), position, newItemCollection); } @Override public void onItemCollectionListItemWriteStarted(int requestCode, int position) { getListener().onItemCollectionListItemWriteStarted(getRequestCode(), position); } @Override public void onItemCollectionListItemWriteFinished(int requestCode, int position) { getListener().onItemCollectionListItemWriteFinished(getRequestCode(), position); } @Override public void onLoadGameGuideListStarted(int requestCode) {} @Override public void onLoadGameGuideListFinished(int requestCode) {} @Override public void onLoadGameGuideListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onGameGuideListChanged(int requestCode, List<SimpleReview> newGameGuideList) { notifyChanged(); } @Override public void onGameGuideListAppended(int requestCode, List<SimpleReview> appendedGameGuideList) { notifyChanged(); } @Override public void onGameGuideChanged(int requestCode, int position, SimpleReview newGameGuide) { notifyChanged(); } @Override public void onGameGuideRemoved(int requestCode, int position) { notifyChanged(); } @Override public void onLoadReviewListStarted(int requestCode) {} @Override public void onLoadReviewListFinished(int requestCode) {} @Override public void onLoadReviewListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onReviewListChanged(int requestCode, List<SimpleReview> newReviewList) { notifyChanged(); } @Override public void onReviewListAppended(int requestCode, List<SimpleReview> appendedReviewList) { notifyChanged(); } @Override public void onReviewChanged(int requestCode, int position, SimpleReview newReview) { notifyChanged(); } @Override public void onReviewRemoved(int requestCode, int position) { notifyChanged(); } @Override public void onLoadForumTopicListStarted(int requestCode) {} @Override public void onLoadForumTopicListFinished(int requestCode) {} @Override public void onLoadForumTopicListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onForumTopicListChanged(int requestCode, List<SimpleItemForumTopic> newForumTopicList) { notifyChanged(); } @Override public void onForumTopicListAppended(int requestCode, List<SimpleItemForumTopic> appendedForumTopicList) { notifyChanged(); } @Override public void onLoadRecommendationListStarted(int requestCode) {} @Override public void onLoadRecommendationListFinished(int requestCode) {} @Override public void onLoadRecommendationListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onRecommendationListChanged(int requestCode, List<CollectableItem> newRecommendationList) { notifyChanged(); } @Override public void onLoadDoulistListStarted(int requestCode) {} @Override public void onLoadDoulistListFinished(int requestCode) {} @Override public void onLoadDoulistListError(int requestCode, ApiError error) { notifyError(error); } @Override public void onDoulistListChanged(int requestCode, List<Doulist> newDoulistList) { notifyChanged(); } @Override public void onDoulistListAppended(int requestCode, List<Doulist> appendedDoulistList) { notifyChanged(); } @Override public void onDoulistChanged(int requestCode, int position, Doulist newDoulist) { notifyChanged(); } @Override public void onDoulistRemoved(int requestCode, int position) { notifyChanged(); } public boolean isAnyLoaded() { // Can be called before onCreate(). return hasItem() || (mRatingResource != null && mRatingResource.has()) || (mPhotoListResource != null && mPhotoListResource.has()) || (mCelebrityListResource != null && mCelebrityListResource.has()) || (mAwardListResource != null && mAwardListResource.has()) || (mItemCollectionListResource != null && mItemCollectionListResource.has()) || (mGameGuideListResource != null && mGameGuideListResource.has()) || (mReviewListResource != null && mReviewListResource.has()) || (mForumTopicListResource != null && mForumTopicListResource.has()) || (mRecommendationListResource != null && mRecommendationListResource.has()) || (mRelatedDoulistListResource != null && mRelatedDoulistListResource.has()); } public void notifyChanged() { // HACK: Add SimpleRating to Rating. ItemType item = getItem(); Rating rating = mRatingResource != null ? mRatingResource.get() : null; if (rating != null && item != null) { rating.rating = item.rating; //noinspection deprecation rating.ratingUnavailableReason = item.ratingUnavailableReason; } notifyChanged(getRequestCode(), item, rating, mPhotoListResource != null ? mPhotoListResource.get() : null, mCelebrityListResource != null ? mCelebrityListResource.get() : null, mAwardListResource != null ? mAwardListResource.get() : null, mItemCollectionListResource != null ? mItemCollectionListResource.get() : null, mGameGuideListResource != null ? mGameGuideListResource.get() : null, mReviewListResource != null ? mReviewListResource.get() : null, mForumTopicListResource != null ? mForumTopicListResource.get() : null, mRecommendationListResource != null ? mRecommendationListResource.get() : null, mRelatedDoulistListResource != null ? mRelatedDoulistListResource.get() : null); } protected abstract void notifyChanged(int requestCode, ItemType newItem, Rating newRating, List<Photo> newPhotoList, List<SimpleCelebrity> newCelebrityList, List<ItemAwardItem> newAwardList, List<SimpleItemCollection> newItemCollectionList, List<SimpleReview> newGameGuideList, List<SimpleReview> newReviewList, List<SimpleItemForumTopic> newForumTopicList, List<CollectableItem> newRecommendationList, List<Doulist> newRelatedDoulistList); private void notifyError(ApiError error) { if (!mHasError) { mHasError = true; getListener().onLoadError(getRequestCode(), error); } } @Override public void onItemCollectionChanged(int requestCode) { getListener().onItemCollectionChanged(getRequestCode()); } private Listener<ItemType> getListener() { //noinspection unchecked return (Listener<ItemType>) getTarget(); } public interface Listener<ItemType> { void onLoadError(int requestCode, ApiError error); void onItemChanged(int requestCode, ItemType newItem); void onItemCollectionChanged(int requestCode); void onItemCollectionListItemChanged(int requestCode, int position, SimpleItemCollection newItemCollection); void onItemCollectionListItemWriteStarted(int requestCode, int position); void onItemCollectionListItemWriteFinished(int requestCode, int position); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/BaseItemFragmentResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
4,473
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.content.Context; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.content.RequestResourceWriter; import me.zhanghai.android.douya.content.ResourceWriterManager; import me.zhanghai.android.douya.eventbus.EventBusUtils; import me.zhanghai.android.douya.eventbus.ItemUncollectedEvent; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollection; import me.zhanghai.android.douya.util.LogUtils; import me.zhanghai.android.douya.util.ToastUtils; class UncollectItemWriter extends RequestResourceWriter<UncollectItemWriter, ItemCollection> { private CollectableItem.Type mItemType; private long mItemId; UncollectItemWriter(CollectableItem.Type itemType, long itemId, ResourceWriterManager<UncollectItemWriter> manager) { super(manager); mItemType = itemType; mItemId = itemId; } UncollectItemWriter(CollectableItem item, ResourceWriterManager<UncollectItemWriter> manager) { this(item.getType(), item.id, manager); } public CollectableItem.Type getItemType() { return mItemType; } public long getItemId() { return mItemId; } @Override protected ApiRequest<ItemCollection> onCreateRequest() { return ApiService.getInstance().uncollectItem(mItemType, mItemId); } @Override public void onResponse(ItemCollection response) { Context context = getContext(); ToastUtils.show(context.getString(R.string.item_uncollect_successful_format, mItemType.getName(context)), context); EventBusUtils.postAsync(new ItemUncollectedEvent(mItemType, mItemId, this)); stopSelf(); } @Override public void onErrorResponse(ApiError error) { LogUtils.e(error.toString()); Context context = getContext(); ToastUtils.show(context.getString(R.string.item_uncollect_failed_format, mItemType.getName(context), ApiError.getErrorString(error, context)), context); stopSelf(); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/UncollectItemWriter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
509
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.content.Context; import java.util.List; import me.zhanghai.android.douya.content.ResourceWriterManager; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState; public class CollectItemManager extends ResourceWriterManager<CollectItemWriter> { private static class InstanceHolder { public static final CollectItemManager VALUE = new CollectItemManager(); } public static CollectItemManager getInstance() { return InstanceHolder.VALUE; } public void write(CollectableItem.Type itemType, long itemId, ItemCollectionState state, int rating, List<String> tags, String comment, List<Long> gamePlatformIds, boolean shareToBroadcast, boolean shareToWeibo, boolean shareToWeChatMoments, Context context) { add(new CollectItemWriter(itemType, itemId, state, rating, tags, comment, gamePlatformIds, shareToBroadcast, shareToWeibo, shareToWeChatMoments, this), context); } public void write(CollectableItem item, ItemCollectionState state, int rating, List<String> tags, String comment, List<Long> gamePlatformIds, boolean shareToBroadcast, boolean shareToWeibo, boolean shareToWeChatMoments, Context context) { add(new CollectItemWriter(item, state, rating, tags, comment, gamePlatformIds, shareToBroadcast, shareToWeibo, shareToWeChatMoments, this), context); } public boolean isWriting(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId) != null; } public boolean isWriting(CollectableItem item) { return isWriting(item.getType(), item.id); } private CollectItemWriter findWriter(CollectableItem.Type itemType, long itemId) { for (CollectItemWriter writer : getWriters()) { if (writer.getItemType() == itemType && writer.getItemId() == itemId) { return writer; } } return null; } public ItemCollectionState getState(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getState(); } public ItemCollectionState getState(CollectableItem item) { return getState(item.getType(), item.id); } public int getRating(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getRating(); } public int getRating(CollectableItem item) { return getRating(item.getType(), item.id); } public List<String> getTags(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getTags(); } public List<String> getTags(CollectableItem item) { return getTags(item.getType(), item.id); } public String getComment(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getComment(); } public String getComment(CollectableItem item) { return getComment(item.getType(), item.id); } public List<Long> getGamePlatformIds(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getGamePlatformIds(); } public List<Long> getGamePlatformIds(CollectableItem item) { return getGamePlatformIds(item.getType(), item.id); } public boolean getShareToBroadcast(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getShareToBroadcast(); } public boolean getShareToBroadcast(CollectableItem item) { return getShareToBroadcast(item.getType(), item.id); } public boolean getShareToWeibo(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getShareToWeibo(); } public boolean getShareToWeibo(CollectableItem item) { return getShareToWeibo(item.getType(), item.id); } public boolean getShareToWeChatMoments(CollectableItem.Type itemType, long itemId) { return findWriter(itemType, itemId).getShareToWeChatMoments(); } public boolean getShareToWeChatMoments(CollectableItem item) { return getShareToWeChatMoments(item.getType(), item.id); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/CollectItemManager.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
954
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.app.Dialog; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatDialogFragment; import me.zhanghai.android.douya.R; public class ConfirmUncollectItemDialogFragment extends AppCompatDialogFragment { /** * @deprecated Use {@link #newInstance()} instead. */ public ConfirmUncollectItemDialogFragment() {} public static ConfirmUncollectItemDialogFragment newInstance() { //noinspection deprecation return new ConfirmUncollectItemDialogFragment(); } @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity(), getTheme()) .setMessage(R.string.item_uncollect_confirm) .setPositiveButton(R.string.ok, (dialog, which) -> getListener().uncollect()) .setNegativeButton(R.string.cancel, null) .create(); } private Listener getListener() { return (Listener) getParentFragment(); } public static void show(Fragment fragment) { ConfirmUncollectItemDialogFragment.newInstance() .show(fragment.getChildFragmentManager(), null); } public interface Listener { void uncollect(); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/ConfirmUncollectItemDialogFragment.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
270
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.item.content; import android.content.Context; import java.util.List; import me.zhanghai.android.douya.R; import me.zhanghai.android.douya.content.RequestResourceWriter; import me.zhanghai.android.douya.content.ResourceWriterManager; import me.zhanghai.android.douya.eventbus.EventBusUtils; import me.zhanghai.android.douya.eventbus.ItemCollectErrorEvent; import me.zhanghai.android.douya.eventbus.ItemCollectedEvent; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.CollectableItem; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollection; import me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState; import me.zhanghai.android.douya.util.LogUtils; import me.zhanghai.android.douya.util.ToastUtils; class CollectItemWriter extends RequestResourceWriter<CollectItemWriter, ItemCollection> { private CollectableItem.Type mItemType; private long mItemId; private ItemCollectionState mState; private int mRating; private List<String> mTags; private String mComment; private List<Long> mGamePlatformIds; private boolean mShareToBroadcast; private boolean mShareToWeibo; private boolean mShareToWeChatMoments; CollectItemWriter(CollectableItem.Type itemType, long itemId, ItemCollectionState state, int rating, List<String> tags, String comment, List<Long> gamePlatformIds, boolean shareToBroadcast, boolean shareToWeibo, boolean shareToWeChatMoments, ResourceWriterManager<CollectItemWriter> manager) { super(manager); mItemType = itemType; mItemId = itemId; mState = state; mRating = rating; mTags = tags; mComment = comment; mGamePlatformIds = gamePlatformIds; mShareToBroadcast = shareToBroadcast; mShareToWeibo = shareToWeibo; mShareToWeChatMoments = shareToWeChatMoments; } CollectItemWriter(CollectableItem item, ItemCollectionState state, int rating, List<String> tags, String comment, List<Long> gamePlatformIds, boolean shareToBroadcast, boolean shareToWeibo, boolean shareToWeChatMoments, ResourceWriterManager<CollectItemWriter> manager) { this(item.getType(), item.id, state, rating, tags, comment, gamePlatformIds, shareToBroadcast, shareToWeibo, shareToWeChatMoments, manager); } public CollectableItem.Type getItemType() { return mItemType; } public long getItemId() { return mItemId; } public ItemCollectionState getState() { return mState; } public int getRating() { return mRating; } public List<String> getTags() { return mTags; } public String getComment() { return mComment; } public List<Long> getGamePlatformIds() { return mGamePlatformIds; } public boolean getShareToBroadcast() { return mShareToBroadcast; } public boolean getShareToWeibo() { return mShareToWeibo; } public boolean getShareToWeChatMoments() { return mShareToWeChatMoments; } @Override protected ApiRequest<ItemCollection> onCreateRequest() { return ApiService.getInstance().collectItem(mItemType, mItemId, mState, mRating, mTags, mComment, mGamePlatformIds, mShareToBroadcast, mShareToWeibo, mShareToWeChatMoments); } @Override public void onResponse(ItemCollection response) { Context context = getContext(); ToastUtils.show(context.getString(R.string.item_collect_successful_format, mItemType.getName(context)), context); EventBusUtils.postAsync(new ItemCollectedEvent(mItemType, mItemId, response, this)); stopSelf(); } @Override public void onErrorResponse(ApiError error) { LogUtils.e(error.toString()); Context context = getContext(); ToastUtils.show(context.getString(R.string.item_collect_failed_format, mItemType.getName(context), ApiError.getErrorString(error, context)), context); EventBusUtils.postAsync(new ItemCollectErrorEvent(mItemType, mItemId, this)); stopSelf(); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/item/content/CollectItemWriter.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
993
```java /* * All Rights Reserved. */ package me.zhanghai.android.douya.diary.content; import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.Collections; import java.util.List; import me.zhanghai.android.douya.content.MoreBaseListResourceFragment; import me.zhanghai.android.douya.eventbus.DiaryDeletedEvent; import me.zhanghai.android.douya.eventbus.DiaryUpdatedEvent; import me.zhanghai.android.douya.eventbus.EventBusUtils; import me.zhanghai.android.douya.network.api.ApiError; import me.zhanghai.android.douya.network.api.ApiRequest; import me.zhanghai.android.douya.network.api.ApiService; import me.zhanghai.android.douya.network.api.info.frodo.Diary; import me.zhanghai.android.douya.network.api.info.frodo.DiaryList; import me.zhanghai.android.douya.util.FragmentUtils; public class UserDiaryListResource extends MoreBaseListResourceFragment<DiaryList, Diary> { private static final String KEY_PREFIX = UserDiaryListResource.class.getName() + '.'; private static final String EXTRA_USER_ID_OR_UID = KEY_PREFIX + "user_id_or_uid"; private String mUserIdOrUid; private static final String FRAGMENT_TAG_DEFAULT = UserDiaryListResource.class.getName(); private static UserDiaryListResource newInstance(String userIdOrUid) { //noinspection deprecation return new UserDiaryListResource().setArguments(userIdOrUid); } public static UserDiaryListResource attachTo(String userIdOrUid, Fragment fragment, String tag, int requestCode) { FragmentActivity activity = fragment.getActivity(); UserDiaryListResource instance = FragmentUtils.findByTag(activity, tag); if (instance == null) { instance = newInstance(userIdOrUid); FragmentUtils.add(instance, activity, tag); } instance.setTarget(fragment, requestCode); return instance; } public static UserDiaryListResource attachTo(String userIdOrUid, Fragment fragment) { return attachTo(userIdOrUid, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID); } /** * @deprecated Use {@code attachTo()} instead. */ public UserDiaryListResource() {} protected UserDiaryListResource setArguments(String userIdOrUid) { FragmentUtils.getArgumentsBuilder(this) .putString(EXTRA_USER_ID_OR_UID, userIdOrUid); return this; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mUserIdOrUid = getArguments().getString(EXTRA_USER_ID_OR_UID); } @Override protected ApiRequest<DiaryList> onCreateRequest(Integer start, Integer count) { return ApiService.getInstance().getDiaryList(mUserIdOrUid, start, count); } @Override protected void onLoadStarted() { getListener().onLoadDiaryListStarted(getRequestCode()); } @Override protected void onLoadFinished(boolean more, int count, boolean successful, List<Diary> response, ApiError error) { if (successful) { if (more) { append(response); getListener().onLoadDiaryListFinished(getRequestCode()); getListener().onDiaryListAppended(getRequestCode(), Collections.unmodifiableList(response)); } else { set(response); getListener().onLoadDiaryListFinished(getRequestCode()); getListener().onDiaryListChanged(getRequestCode(), Collections.unmodifiableList(get())); } for (Diary diary : response) { EventBusUtils.postAsync(new DiaryUpdatedEvent(diary, this)); } } else { getListener().onLoadDiaryListFinished(getRequestCode()); getListener().onLoadDiaryListError(getRequestCode(), error); } } @Subscribe(threadMode = ThreadMode.POSTING) public void onDiaryUpdated(DiaryUpdatedEvent event) { if (event.isFromMyself(this) || isEmpty()) { return; } List<Diary> diaryList = get(); for (int i = 0, size = diaryList.size(); i < size; ++i) { Diary diary = diaryList.get(i); if (diary.id == event.diary.id) { diaryList.set(i, event.diary); getListener().onDiaryChanged(getRequestCode(), i, diaryList.get(i)); } } } @Subscribe(threadMode = ThreadMode.POSTING) public void onDiaryDeleted(DiaryDeletedEvent event) { if (event.isFromMyself(this) || isEmpty()) { return; } List<Diary> diaryList = get(); for (int i = 0, size = diaryList.size(); i < size; ) { Diary diary = diaryList.get(i); if (diary.id == event.diaryId) { diaryList.remove(i); getListener().onDiaryRemoved(getRequestCode(), i); --size; } else { ++i; } } } private Listener getListener() { return (Listener) getTarget(); } public interface Listener { void onLoadDiaryListStarted(int requestCode); void onLoadDiaryListFinished(int requestCode); void onLoadDiaryListError(int requestCode, ApiError error); /** * @param newDiaryList Unmodifiable. */ void onDiaryListChanged(int requestCode, List<Diary> newDiaryList); /** * @param appendedDiaryList Unmodifiable. */ void onDiaryListAppended(int requestCode, List<Diary> appendedDiaryList); void onDiaryChanged(int requestCode, int position, Diary newDiary); void onDiaryRemoved(int requestCode, int position); } } ```
/content/code_sandbox/app/src/main/java/me/zhanghai/android/douya/diary/content/UserDiaryListResource.java
java
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,272
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <dimen name="card_list_horizontal_padding">8dp</dimen> <dimen name="card_horizontal_margin">6dp</dimen> <dimen name="card_header_horizontal_margin">8dp</dimen> <dimen name="card_corner_radius">2dp</dimen> <dimen name="profile_large_avatar_size">112dp</dimen> <dimen name="profile_large_avatar_bottom_from_toolbar_bottom">8dp</dimen> <dimen name="item_content_padding_top_max">180dp</dimen> <dimen name="item_backdrop_play_layout_height">@dimen/item_content_padding_top_max</dimen> <dimen name="item_content_horizontal_margin">@dimen/screen_edge_horizontal_margin</dimen> <dimen name="item_card_list_horizontal_padding">8dp</dimen> <dimen name="item_card_list_vertical_padding">8dp</dimen> <dimen name="item_card_horizontal_margin">6dp</dimen> <dimen name="item_card_vertical_margin">5dp</dimen> </resources> ```
/content/code_sandbox/app/src/main/res/values-w600dp/dimens.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
267
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <item name="match_parent" type="dimen" format="integer">-1</item> <item name="wrap_content" type="dimen" format="integer">-2</item> <item name="weight_1_when_phone" type="dimen" format="float">1</item> <item name="weight_1_when_tablet" type="dimen" format="float">0</item> <!-- ~ L: @android:layout/notification_template_material_big_media ~ @android:dimen/notification_large_icon_width 64dp ~ @android:layout/notification_template_material_big_media_narrow 128dp ~ N: @android:dimen/media_notification_expanded_image_max_size 94dp --> <dimen name="media_display_icon_max_size">128dp</dimen> <!-- @see MediaSession#mMaxBitmapSize --> <dimen name="media_art_max_size">320dp</dimen> <!-- @deprecated: Not reliable, for example on MIUI. --> <dimen name="status_bar_height">25dp</dimen> <dimen name="screen_edge_horizontal_margin">16dp</dimen> <dimen name="screen_edge_horizontal_margin_with_4dp_padding">12dp</dimen> <dimen name="screen_edge_horizontal_margin_with_8dp_padding">8dp</dimen> <dimen name="screen_edge_horizontal_margin_with_12dp_padding">4dp</dimen> <dimen name="screen_edge_horizontal_margin_with_16dp_padding">0dp</dimen> <dimen name="screen_edge_horizontal_margin_negative">-16dp</dimen> <dimen name="screen_edge_horizontal_margin_negative_half">-8dp</dimen> <dimen name="content_horizontal_margin">72dp</dimen> <dimen name="content_horizontal_margin_from_screen_edge">56dp</dimen> <dimen name="content_horizontal_margin_from_screen_edge_with_24dp_padding">32dp</dimen> <dimen name="content_horizontal_margin_from_screen_edge_with_40dp_padding">16dp</dimen> <dimen name="content_horizontal_margin_from_screen_edge_with_44dp_padding">12dp</dimen> <dimen name="screen_edge_vertical_margin">@dimen/screen_edge_horizontal_margin</dimen> <dimen name="content_horizontal_space">16dp</dimen> <dimen name="content_horizontal_space_with_4dp_padding">12dp</dimen> <dimen name="content_horizontal_space_with_8dp_padding">8dp</dimen> <dimen name="content_vertical_space">16dp</dimen> <dimen name="content_vertical_space_with_4dp_padding">12dp</dimen> <dimen name="content_vertical_space_with_6dp_padding">10dp</dimen> <dimen name="content_vertical_space_half">8dp</dimen> <dimen name="toolbar_navigation_button_left_margin">-2dp</dimen> <dimen name="toolbar_title_left_margin">18dp</dimen> <dimen name="toolbar_button_left_margin">@dimen/toolbar_button_right_margin</dimen> <dimen name="toolbar_button_right_margin">2dp</dimen> <dimen name="toolbar_overflow_button_right_margin">-6dp</dimen> <dimen name="toolbar_edit_left_margin">12dp</dimen> <dimen name="toolbar_edit_right_margin">18dp</dimen> <dimen name="toolbar_height">56dp</dimen> <dimen name="toolbar_and_toolbar_height">112dp</dimen> <dimen name="tab_height">48dp</dimen> <dimen name="toolbar_and_tab_height">104dp</dimen> <dimen name="appbar_elevation">4dp</dimen> <dimen name="drawer_max_width">@dimen/design_navigation_max_width</dimen> <dimen name="navigation_header_height">172dp</dimen> <dimen name="navigation_header_avatar_size">64dp</dimen> <dimen name="list_padding_vertical">8dp</dimen> <dimen name="single_line_list_item_height">48dp</dimen> <dimen name="single_line_list_item_with_avatar_height">56dp</dimen> <dimen name="two_line_list_item_height">72dp</dimen> <dimen name="three_line_list_item_height">88dp</dimen> <!-- Using hard-coded 1dp as height for shared-element transition on Android 5.0 --> <dimen name="horizontal_divider_height">1dp</dimen> <dimen name="vertical_space_width">2dp</dimen> <!-- 3x toolbar height per Material Design Spec. --> <dimen name="scrim_height">168dp</dimen> <dimen name="card_list_horizontal_padding">0dp</dimen> <dimen name="card_activity_width">@dimen/match_parent</dimen> <dimen name="card_activity_horizontal_margin">0dp</dimen> <dimen name="card_view_width">@dimen/match_parent</dimen> <dimen name="card_elevation">2dp</dimen> <!-- See RoundRectDrawableWithShadow.calculate{Horizontal,Vertical}Padding(). --> <dimen name="card_shadow_horizontal_margin">-2dp</dimen> <dimen name="card_shadow_vertical_margin">-3dp</dimen> <dimen name="card_vertical_space">16dp</dimen> <dimen name="card_vertical_space_half">8dp</dimen> <dimen name="card_horizontal_margin">@dimen/card_shadow_horizontal_margin</dimen> <dimen name="card_vertical_margin">5dp</dimen> <dimen name="card_header_horizontal_margin">@dimen/screen_edge_horizontal_margin</dimen> <dimen name="card_header_bottom_margin">-4dp</dimen> <dimen name="card_corner_radius">0dp</dimen> <dimen name="card_content_horizontal_margin">16dp</dimen> <dimen name="card_content_horizontal_margin_with_4dp_padding">12dp</dimen> <dimen name="card_content_horizontal_margin_with_8dp_padding">8dp</dimen> <dimen name="card_content_horizontal_margin_with_12dp_padding">4dp</dimen> <dimen name="card_content_horizontal_space">16dp</dimen> <dimen name="card_content_horizontal_space_with_4dp_padding">12dp</dimen> <dimen name="card_content_horizontal_space_with_12dp_padding">4dp</dimen> <dimen name="card_content_horizontal_space_with_16dp_padding">0dp</dimen> <dimen name="card_content_vertical_margin_large">24dp</dimen> <dimen name="card_content_vertical_margin">16dp</dimen> <dimen name="card_content_vertical_margin_with_4dp_padding">12dp</dimen> <dimen name="card_content_vertical_margin_with_12dp_padding">4dp</dimen> <dimen name="card_content_vertical_margin_small">8dp</dimen> <dimen name="card_content_vertical_space">16dp</dimen> <dimen name="card_content_vertical_space_with_4dp_padding">12dp</dimen> <dimen name="card_content_vertical_space_half">8dp</dimen> <dimen name="card_action_margin">8dp</dimen> <dimen name="card_action_margin_with_4dp_padding">4dp</dimen> <dimen name="card_action_margin_with_8dp_padding">0dp</dimen> <dimen name="icon_size">24dp</dimen> <dimen name="touch_target_size">48dp</dimen> <dimen name="toolbar_button_size">48dp</dimen> <dimen name="avatar_size">40dp</dimen> <dimen name="avatar_padding">4dp</dimen> <dimen name="avatar_padding_negative">-4dp</dimen> <dimen name="avatar_small_padding">12dp</dimen> <dimen name="icon_button_padding">12dp</dimen> <dimen name="button_bar_horizontal_divider_width">0dp</dimen> <dimen name="fab_margin">16dp</dimen> <dimen name="dialog_padding_horizontal_with_4dp_padding">20dp</dimen> <dimen name="dialog_content_padding_top">14dp</dimen> <dimen name="dialog_content_padding_bottom">24dp</dimen> <dimen name="dialog_content_padding_bottom_with_8dp_padding">16dp</dimen> <dimen name="profile_large_avatar_size">128dp</dimen> <dimen name="profile_large_avatar_bottom_from_toolbar_bottom">8dp</dimen> <dimen name="profile_small_avatar_size">32dp</dimen> <dimen name="item_content_padding_top_max">0dp</dimen> <dimen name="item_backdrop_play_layout_height">@dimen/match_parent</dimen> <dimen name="item_content_horizontal_margin">0dp</dimen> <dimen name="item_card_list_horizontal_padding">4dp</dimen> <dimen name="item_card_list_vertical_padding">4dp</dimen> <dimen name="item_card_horizontal_margin">2dp</dimen> <dimen name="item_card_vertical_margin">1dp</dimen> <dimen name="item_cover_width_long">104dp</dimen> <dimen name="item_cover_width_square">150dp</dimen> <dimen name="item_cover_horizontal_margin">@dimen/screen_edge_horizontal_margin</dimen> <dimen name="item_cover_vertical_margin">@dimen/screen_edge_horizontal_margin</dimen> <dimen name="item_cover_vertical_margin_negative">@dimen/screen_edge_horizontal_margin_negative</dimen> <dimen name="item_badge_list_space">20dp</dimen> <dimen name="item_badge_size">60dp</dimen> <dimen name="item_badge_padding">10dp</dimen> <dimen name="item_celebrity_avatar_height">120dp</dimen> <dimen name="item_photo_list_height">240dp</dimen> <dimen name="item_rating_distribution_bar_min_width">1dp</dimen> <dimen name="item_rating_distribution_bar_max_width">160dp</dimen> <dimen name="item_recommendation_cover_height">144dp</dimen> <dimen name="image_min_width">240dp</dimen> <dimen name="image_max_height">640dp</dimen> </resources> ```
/content/code_sandbox/app/src/main/res/values/dimens.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
2,452
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <integer name="item_comment_max_length">140</integer> <integer name="ime_action_done">6</integer> </resources> ```
/content/code_sandbox/app/src/main/res/values/integers.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
58
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <string name="pref_default_value_empty_string" /> <string name="pref_key_active_account_name">key_active_account_name</string> <string name="pref_key_recent_one_account_name">key_recent_one_account_name</string> <string name="pref_key_recent_two_account_name">key_recent_two_account_name</string> <string name="pref_key_show_long_url_for_link_entity">key_show_long_url_for_link_entity</string> <bool name="pref_default_value_show_long_url_for_link_entity">true</bool> <string name="pref_key_night_mode">key_night_mode</string> <string-array name="pref_entry_values_night_mode"> <!--<item>0</item>--> <item>1</item> <item>2</item> <item>3</item> </string-array> <!--<string name="pref_default_value_night_mode">0</string>--> <string name="pref_default_value_night_mode">1</string> <string name="pref_key_auto_refresh_home">key_auto_refresh_home</string> <bool name="pref_default_value_auto_refresh_home">true</bool> <string name="pref_key_long_click_to_quick_rebroadcast">key_long_click_to_quick_rebroadcast</string> <bool name="pref_default_value_long_click_to_quick_rebroadcast">true</bool> <string name="pref_key_long_click_to_show_send_comment_activity">key_long_click_to_show_send_comment_activity</string> <bool name="pref_default_value_long_click_to_show_send_comment_activity">true</bool> <string name="pref_key_show_album_art_on_lock_screen">key_show_album_art_on_lock_screen</string> <bool name="pref_default_value_show_album_art_on_lock_screen">true</bool> <string name="pref_key_progressive_third_party_app">key_enable_progressive_third_party_app</string> <bool name="pref_default_value_progressive_third_party_app">true</bool> <string name="pref_key_open_url_with">key_open_url_with</string> <string-array name="pref_entry_values_open_url_with"> <item>0</item> <item>1</item> <item>2</item> </string-array> <string name="pref_default_value_open_url_with">0</string> <string name="pref_key_open_with_native_in_webview">key_open_with_native_in_webview</string> <bool name="pref_default_value_open_with_native_in_webview">true</bool> <string name="pref_key_request_desktop_site_in_webview">key_request_desktop_site_in_webview</string> <bool name="pref_default_value_request_desktop_site_in_webview">true</bool> <string name="pref_key_create_new_task_for_webview">key_create_new_task_for_webview</string> <bool name="pref_default_value_create_new_task_for_webview">false</bool> <string name="pref_key_item_collection_share_to_broadcast">key_item_collection_share_to_broadcast</string> <bool name="pref_default_value_item_collection_share_to_broadcast">true</bool> <string name="pref_key_item_collection_share_to_weibo">key_item_collection_share_to_weibo</string> <bool name="pref_default_value_item_collection_share_to_weibo">false</bool> </resources> ```
/content/code_sandbox/app/src/main/res/values/prefs.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
742
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <attr name="darkTheme" format="reference" /> <attr name="colorPrimaryDarkWithoutSystemWindowScrim" format="color" /> <attr name="colorPrimaryLight" format="color" /> <attr name="textColorPrimaryDark" format="color" /> <attr name="iconButtonTint" format="color" /> <declare-styleable name="CardIconButton"> <attr name="android:src" /> <attr name="android:text" /> </declare-styleable> <declare-styleable name="ContentStateLayout"> <attr name="animationEnabled" format="boolean" /> <attr name="loadingView" format="reference" /> <attr name="contentView" format="reference" /> <attr name="emptyView" format="reference" /> <attr name="errorView" format="reference" /> </declare-styleable> <declare-styleable name="FriendlySwipeRefreshLayout"> <attr name="progressOffset" format="dimension" /> <attr name="progressDistanceOffset" format="dimension" /> </declare-styleable> <declare-styleable name="ImageLayout"> <attr name="fillOrientation" format="enum"> <enum name="horizontal" value="0" /> <enum name="vertical" value="1" /> </attr> </declare-styleable> <declare-styleable name="InsetBackgroundFrameLayout"> <attr name="insetBackground" format="color" /> </declare-styleable> <declare-styleable name="RatioHeightRecyclerView"> <attr name="ratio" format="string" /> </declare-styleable> </resources> ```
/content/code_sandbox/app/src/main/res/values/attrs.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
384
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <!-- Additions. --> <style name="TextAppearance.AppCompat.Body1.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Body2.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Button.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Caption.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Display1.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Display2.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Display3.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Display4.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="TextAppearance.AppCompat.Headline.Inverse"> <item name="android:textColor">?android:attr/textColorPrimaryInverse</item> <item name="android:textColorHint">?android:attr/textColorHintInverse</item> <item name="android:textColorHighlight">?android:attr/textColorHighlightInverse</item> <item name="android:textColorLink">?android:attr/textColorLinkInverse</item> </style> <style name="Base.TextAppearance.Douya.Widget.ActionBar.Menu" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu"> <item name="android:textSize">@dimen/abc_text_size_menu_material</item> </style> <style name="TextAppearance.Douya.Widget.ActionBar.Menu" parent="@style/Base.TextAppearance.Douya.Widget.ActionBar.Menu" /> <!-- Declare our own styles so that we won't be switched to platform styles. --> <style name="Base.TextAppearance.Douya.Widget.ActionBar.Title" parent="Base.TextAppearance.AppCompat.Widget.ActionBar.Title"> <item name="android:textSize">@dimen/abc_text_size_title_material_toolbar</item> </style> <style name="Base.TextAppearance.Douya.Widget.ActionBar.Title.Inverse" parent="Base.TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"> <item name="android:textSize">@dimen/abc_text_size_title_material_toolbar</item> </style> <style name="TextAppearance.Douya.Widget.ActionBar.Title" parent="Base.TextAppearance.Douya.Widget.ActionBar.Title" /> <style name="TextAppearance.Douya.Widget.ActionBar.Title.Inverse" parent="Base.TextAppearance.Douya.Widget.ActionBar.Title.Inverse" /> <style name="Base.TextAppearance.Widget.Douya.Toolbar.Title" parent="TextAppearance.Douya.Widget.ActionBar.Title" /> <style name="TextAppearance.Widget.Douya.Toolbar.Title" parent="Base.TextAppearance.Widget.Douya.Toolbar.Title" /> <style name="Base.Widget.Douya.Toolbar" parent="Base.Widget.AppCompat.Toolbar"> <item name="titleTextAppearance">@style/TextAppearance.Widget.Douya.Toolbar.Title</item> </style> <style name="Widget.Douya.Toolbar" parent="Base.Widget.Douya.Toolbar" /> <style name="Widget.Douya.Toolbar.Button.Navigation" parent="@style/Widget.AppCompat.Toolbar.Button.Navigation"> <item name="android:paddingStart">0dp</item> </style> <style name="TextAppearance.Widget.Douya.Toolbar.Title.WebView" parent="TextAppearance.Widget.Douya.Toolbar.Title"> <item name="android:textSize">16dp</item> </style> <style name="TextAppearance.Widget.Douya.Toolbar.Subtitle.WebView" parent="TextAppearance.Widget.AppCompat.Toolbar.Subtitle"> <item name="android:textSize">12dp</item> </style> </resources> ```
/content/code_sandbox/app/src/main/res/values/styles.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,460
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <style name="ThemeOverlay.Douya.ActionBar" parent="ThemeOverlay.AppCompat.ActionBar" /> <style name="ThemeOverlay.Douya.Dark" parent="ThemeOverlay.AppCompat.Dark"> <item name="colorAccent">@color/douya_accent</item> </style> <style name="ThemeOverlay.Douya.Dark.ActionBar" parent="ThemeOverlay.AppCompat.Dark.ActionBar"> <item name="colorAccent">@android:color/white</item> </style> <style name="ThemeOverlay.Douya.Light" parent="ThemeOverlay.AppCompat.Light"> <item name="colorAccent">@color/douya_accent</item> </style> <style name="Theme.AppCompat.Light.DialogWhenLarge.LightStatusBar" parent="Theme.AppCompat.Light.DialogWhenLarge" /> <style name="Theme.AppCompat.Light.DarkActionBar.DialogWhenLarge" parent="Theme.AppCompat.Light.DarkActionBar" /> <style name="DarkTheme" parent="ThemeOverlay.AppCompat.Dark" /> <style name="DarkTheme.Light" parent="ThemeOverlay.AppCompat.Dark"> <item name="colorAccent">@color/douya_accent</item> </style> <style name="Base.Theme.Douya" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Fixes. --> <item name="actionBarTheme">@style/ThemeOverlay.Douya.Dark.ActionBar</item> <item name="actionBarPopupTheme">@style/ThemeOverlay.Douya.Light</item> <item name="android:listDivider">@drawable/list_divider_light</item> <item name="colorPrimary">@color/douya_primary</item> <item name="colorPrimaryDark">@color/douya_primary_dark</item> <item name="colorAccent">@color/douya_accent</item> <item name="darkTheme">@style/DarkTheme.Light</item> <item name="colorPrimaryDarkWithoutSystemWindowScrim">@color/douya_primary_dark_without_system_window_scrim</item> </style> <style name="Base.Theme.Douya.Dark" parent="Theme.AppCompat"> <!-- Fixes. --> <item name="actionBarTheme">@style/ThemeOverlay.Douya.Dark.ActionBar</item> <item name="android:listDivider">@drawable/list_divider_dark</item> <item name="colorAccent">@color/douya_accent</item> <item name="darkTheme">@style/DarkTheme</item> <item name="colorPrimaryDarkWithoutSystemWindowScrim">@android:color/black</item> </style> <style name="Theme.Douya" parent="Base.Theme.Douya"> <item name="actionModeBackground">@color/background_material_dark</item> <item name="windowActionBar">false</item> <item name="windowActionModeOverlay">true</item> <item name="windowNoTitle">true</item> <!-- Fixes. --> <item name="actionMenuTextAppearance">@style/TextAppearance.Douya.Widget.ActionBar.Menu</item> <item name="dividerHorizontal">?android:dividerHorizontal</item> <item name="dividerVertical">?android:dividerVertical</item> <item name="android:textColorLink">?colorAccent</item> <item name="toolbarStyle">@style/Widget.Douya.Toolbar</item> <item name="toolbarNavigationButtonStyle">@style/Widget.Douya.Toolbar.Button.Navigation</item> </style> <style name="Theme.Douya.Dark" parent="Base.Theme.Douya.Dark"> <item name="actionModeBackground">@color/background_material_dark</item> <item name="windowActionBar">false</item> <item name="windowActionModeOverlay">true</item> <item name="windowNoTitle">true</item> <!-- Fixes. --> <item name="actionMenuTextAppearance">@style/TextAppearance.Douya.Widget.ActionBar.Menu</item> <item name="dividerHorizontal">?android:dividerHorizontal</item> <item name="dividerVertical">?android:dividerVertical</item> <item name="android:textColorLink">?colorAccent</item> <item name="toolbarStyle">@style/Widget.Douya.Toolbar</item> <item name="toolbarNavigationButtonStyle">@style/Widget.Douya.Toolbar.Button.Navigation</item> </style> <style name="Theme.Douya.TransparentStatusBar"> <item name="android:statusBarColor">@android:color/transparent</item> </style> <style name="Theme.Douya.Translucent" parent="Theme.Douya.TransparentStatusBar"> <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:windowAnimationStyle">@null</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowDisablePreview">true</item> <item name="android:windowIsTranslucent">true</item> </style> <style name="Theme.Douya.TransparentBackground" parent="Theme.Douya.TransparentStatusBar"> <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowIsTranslucent">true</item> </style> <style name="Theme.Douya.DarkBackground" parent="Theme.Douya.TransparentBackground"> <item name="android:windowBackground">@color/dark_70_percent</item> </style> <style name="Theme.Douya.PrimaryColorBackground"> <item name="android:windowBackground">?colorPrimary</item> </style> <style name="Theme.Douya.ScrimStatusBar"> <item name="android:statusBarColor">@color/system_window_scrim</item> </style> <style name="Base.Theme.Douya.DialogWhenLarge" parent="Theme.AppCompat.Light.DarkActionBar.DialogWhenLarge"> <!-- Fixes. --> <item name="actionBarTheme">@style/ThemeOverlay.Douya.Dark.ActionBar</item> <item name="actionBarPopupTheme">@style/ThemeOverlay.Douya.Light</item> <item name="android:dividerHorizontal">@drawable/list_divider_light</item> <item name="android:dividerVertical">@drawable/list_divider_light</item> <item name="colorPrimary">@color/douya_primary</item> <item name="colorPrimaryDark">@color/douya_primary_dark</item> <item name="colorAccent">@color/douya_accent</item> <item name="darkTheme">@style/DarkTheme.Light</item> <item name="colorPrimaryDarkWithoutSystemWindowScrim">@color/douya_primary_dark_without_system_window_scrim</item> </style> <style name="Base.Theme.Douya.Light.DialogWhenLarge" parent="Theme.AppCompat.Light.DialogWhenLarge.LightStatusBar"> <!-- Fixes. --> <item name="actionBarTheme">@style/ThemeOverlay.Douya.ActionBar</item> <item name="android:dividerHorizontal">@drawable/list_divider_light</item> <item name="android:dividerVertical">@drawable/list_divider_light</item> <item name="colorAccent">@color/douya_accent</item> <item name="darkTheme">@style/DarkTheme</item> <item name="colorPrimaryDarkWithoutSystemWindowScrim">?colorPrimary</item> </style> <style name="Base.Theme.Douya.Dark.DialogWhenLarge" parent="Theme.AppCompat.DialogWhenLarge"> <!-- Fixes. --> <item name="actionBarTheme">@style/ThemeOverlay.Douya.Dark.ActionBar</item> <item name="android:dividerHorizontal">@drawable/list_divider_dark</item> <item name="android:dividerVertical">@drawable/list_divider_dark</item> <item name="colorAccent">@color/douya_accent</item> <item name="darkTheme">@style/DarkTheme</item> <item name="colorPrimaryDarkWithoutSystemWindowScrim">@android:color/black</item> </style> <style name="Theme.Douya.DialogWhenLarge" parent="Base.Theme.Douya.DialogWhenLarge"> <item name="actionModeBackground">@color/background_material_dark</item> <item name="windowActionBar">false</item> <item name="windowActionModeOverlay">true</item> <item name="windowNoTitle">true</item> <!-- Fixes. --> <item name="actionMenuTextAppearance">@style/TextAppearance.Douya.Widget.ActionBar.Menu</item> <item name="dividerHorizontal">?android:dividerHorizontal</item> <item name="dividerVertical">?android:dividerVertical</item> <item name="android:textColorLink">?colorAccent</item> <item name="toolbarStyle">@style/Widget.Douya.Toolbar</item> <item name="toolbarNavigationButtonStyle">@style/Widget.Douya.Toolbar.Button.Navigation</item> </style> <style name="Theme.Douya.Light.DialogWhenLarge" parent="Base.Theme.Douya.Light.DialogWhenLarge"> <item name="actionModeBackground">@color/background_material_dark</item> <item name="windowActionBar">false</item> <item name="windowActionModeOverlay">true</item> <item name="windowNoTitle">true</item> <!-- Fixes. --> <item name="actionMenuTextAppearance">@style/TextAppearance.Douya.Widget.ActionBar.Menu</item> <item name="dividerHorizontal">?android:dividerHorizontal</item> <item name="dividerVertical">?android:dividerVertical</item> <item name="android:textColorLink">?colorAccent</item> <item name="toolbarStyle">@style/Widget.Douya.Toolbar</item> <item name="toolbarNavigationButtonStyle">@style/Widget.Douya.Toolbar.Button.Navigation</item> </style> <style name="Base.Theme.Douya.MainActivity" parent="Theme.Douya.ScrimStatusBar"> <item name="android:windowBackground">@color/grey_200</item> </style> <style name="Theme.Douya.MainActivity" parent="Base.Theme.Douya.MainActivity" /> <style name="Theme.Douya.MainActivity.ColdStart"> <item name="android:statusBarColor">@android:color/transparent</item> <item name="android:windowBackground">@drawable/window_background_statusbar_toolbar_tab</item> </style> <style name="Base.Theme.Douya.BroadcastActivity" parent="Theme.Douya.DarkBackground"> <item name="android:colorBackground">@color/grey_100</item> </style> <style name="Theme.Douya.BroadcastActivity" parent="Base.Theme.Douya.BroadcastActivity"> <item name="android:statusBarColor">?colorPrimaryDark</item> </style> <style name="ThemeOverlay.Douya.Gallery.Dialog" parent="ThemeOverlay.AppCompat.Dialog"> <item name="colorAccent">@color/douya_accent</item> </style> <style name="ThemeOverlay.Douya.Gallery.Dialog.Alert" parent="ThemeOverlay.AppCompat.Dialog.Alert"> <item name="colorAccent">@color/douya_accent</item> </style> <style name="Base.Theme.Douya.Gallery" parent="Theme.Douya.Dark"> <item name="colorAccent">@android:color/white</item> <item name="android:windowBackground">@android:color/black</item> <item name="dialogTheme">@style/ThemeOverlay.Douya.Gallery.Dialog</item> <item name="alertDialogTheme">@style/ThemeOverlay.Douya.Gallery.Dialog.Alert</item> </style> <style name="Theme.Douya.Gallery" parent="Base.Theme.Douya.Gallery"> <item name="android:navigationBarColor">@color/dark_70_percent</item> <item name="android:statusBarColor">@color/dark_70_percent</item> </style> <style name="DarkTheme.Light.Book" parent="DarkTheme.Light"> <item name="colorAccent">@color/book_accent</item> </style> <style name="Base.Theme.Douya.Book" parent="Theme.Douya"> <item name="colorPrimary">@color/book_primary</item> <item name="colorPrimaryDark">@color/book_primary_dark</item> <item name="colorPrimaryLight">@color/book_primary_light</item> <item name="colorAccent">@color/book_accent</item> <item name="textColorPrimaryDark">@color/book_primary_dark</item> <item name="iconButtonTint">@color/icon_button_tint_book</item> <item name="android:windowBackground">@color/grey_200</item> <item name="darkTheme">@style/DarkTheme.Light.Book</item> </style> <style name="Base.Theme.Douya.Book.Dark" parent="Theme.Douya"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/book_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_book</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.Book" parent="Base.Theme.Douya.Book" /> <style name="Base.Theme.Douya.Book.DialogWhenLarge" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimary">@color/book_primary</item> <item name="colorPrimaryDark">@color/book_primary_dark</item> <item name="colorPrimaryLight">@color/book_primary_light</item> <item name="colorAccent">@color/book_accent</item> <item name="textColorPrimaryDark">@color/book_primary_dark</item> <item name="iconButtonTint">@color/icon_button_tint_book</item> <item name="darkTheme">@style/DarkTheme.Light.Book</item> </style> <style name="Base.Theme.Douya.Book.DialogWhenLarge.Dark" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/book_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_book</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.Book.DialogWhenLarge" parent="Base.Theme.Douya.Book.DialogWhenLarge" /> <style name="DarkTheme.Light.Movie" parent="DarkTheme.Light"> <item name="colorAccent">@color/movie_accent</item> </style> <style name="Base.Theme.Douya.Movie" parent="Theme.Douya"> <item name="colorPrimary">@color/movie_primary</item> <item name="colorPrimaryDark">@color/movie_primary_dark</item> <item name="colorPrimaryLight">@color/movie_primary_light</item> <item name="colorAccent">@color/movie_accent</item> <item name="textColorPrimaryDark">@color/movie_primary_dark</item> <item name="iconButtonTint">@color/icon_button_tint_movie</item> <item name="android:windowBackground">@color/grey_200</item> <item name="darkTheme">@style/DarkTheme.Light.Movie</item> </style> <style name="Base.Theme.Douya.Movie.Dark" parent="Theme.Douya"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/movie_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_movie</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.Movie" parent="Base.Theme.Douya.Movie" /> <style name="Base.Theme.Douya.Movie.DialogWhenLarge" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimary">@color/movie_primary</item> <item name="colorPrimaryDark">@color/movie_primary_dark</item> <item name="colorPrimaryLight">@color/movie_primary_light</item> <item name="colorAccent">@color/movie_accent</item> <item name="textColorPrimaryDark">@color/movie_primary_dark</item> <item name="iconButtonTint">@color/icon_button_tint_movie</item> <item name="darkTheme">@style/DarkTheme.Light.Movie</item> </style> <style name="Base.Theme.Douya.Movie.DialogWhenLarge.Dark" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/movie_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_movie</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.Movie.DialogWhenLarge" parent="Base.Theme.Douya.Movie.DialogWhenLarge" /> <style name="DarkTheme.Light.Music" parent="DarkTheme.Light"> <item name="colorAccent">@color/music_accent</item> </style> <style name="Base.Theme.Douya.Music" parent="Theme.Douya"> <item name="colorPrimary">@color/music_primary</item> <item name="colorPrimaryDark">@color/music_primary_dark</item> <item name="colorPrimaryLight">@color/music_primary_light</item> <item name="colorAccent">@color/music_accent</item> <item name="textColorPrimaryDark">@color/music_primary_dark</item> <item name="android:windowBackground">@color/grey_200</item> <item name="iconButtonTint">@color/icon_button_tint_music</item> <item name="darkTheme">@style/DarkTheme.Light.Music</item> </style> <style name="Base.Theme.Douya.Music.Dark" parent="Theme.Douya"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/music_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_music</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.Music" parent="Base.Theme.Douya.Music" /> <style name="Base.Theme.Douya.Music.DialogWhenLarge" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimary">@color/music_primary</item> <item name="colorPrimaryDark">@color/music_primary_dark</item> <item name="colorPrimaryLight">@color/music_primary_light</item> <item name="colorAccent">@color/music_accent</item> <item name="textColorPrimaryDark">@color/music_primary_dark</item> <item name="iconButtonTint">@color/icon_button_tint_music</item> <item name="darkTheme">@style/DarkTheme.Light.Music</item> </style> <style name="Base.Theme.Douya.Music.DialogWhenLarge.Dark" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/music_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_music</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.Music.DialogWhenLarge" parent="Base.Theme.Douya.Music.DialogWhenLarge" /> <style name="DarkTheme.Light.GameApp" parent="DarkTheme.Light"> <item name="colorAccent">@color/game_app_accent</item> </style> <style name="Base.Theme.Douya.GameApp" parent="Theme.Douya"> <item name="colorPrimary">@color/game_app_primary</item> <item name="colorPrimaryDark">@color/game_app_primary_dark</item> <item name="colorPrimaryLight">@color/game_app_primary_light</item> <item name="colorAccent">@color/game_app_accent</item> <item name="textColorPrimaryDark">@color/game_app_primary_dark</item> <item name="android:windowBackground">@color/grey_200</item> <item name="iconButtonTint">@color/icon_button_tint_game_app</item> <item name="darkTheme">@style/DarkTheme.Light.GameApp</item> </style> <style name="Base.Theme.Douya.GameApp.Dark" parent="Theme.Douya"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/game_app_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_game_app</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.GameApp" parent="Base.Theme.Douya.GameApp" /> <style name="Base.Theme.Douya.GameApp.DialogWhenLarge" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimary">@color/game_app_primary</item> <item name="colorPrimaryDark">@color/game_app_primary_dark</item> <item name="colorPrimaryLight">@color/game_app_primary_light</item> <item name="colorAccent">@color/game_app_accent</item> <item name="textColorPrimaryDark">@color/game_app_primary_dark</item> <item name="iconButtonTint">@color/icon_button_tint_game_app</item> <item name="darkTheme">@style/DarkTheme.Light.GameApp</item> </style> <style name="Base.Theme.Douya.GameApp.DialogWhenLarge.Dark" parent="Theme.Douya.DialogWhenLarge"> <item name="colorPrimaryLight">@color/grey_850</item> <item name="colorAccent">@color/game_app_accent</item> <item name="textColorPrimaryDark">?android:textColorPrimary</item> <item name="iconButtonTint">@color/icon_button_tint_game_app</item> <item name="darkTheme">@style/DarkTheme</item> </style> <style name="Theme.Douya.GameApp.DialogWhenLarge" parent="Base.Theme.Douya.GameApp.DialogWhenLarge" /> <style name="Base.ThemeOverlay.Douya.Calendar" parent=""> <item name="android:textColorSecondary">@color/calendar_secondary_text_light</item> <item name="android:textColorHighlight">@color/calendar_highlight_text</item> <item name="colorControlActivated">@color/calendar_control_activated</item> </style> <style name="Base.ThemeOverlay.Douya.Calendar.Dark" parent=""> <item name="android:textColorSecondary">@color/calendar_secondary_text_dark</item> <item name="android:textColorHighlight">@color/calendar_highlight_text</item> <item name="colorControlActivated">@color/calendar_control_activated</item> </style> <style name="ThemeOverlay.Douya.Calendar" parent="Base.ThemeOverlay.Douya.Calendar" /> </resources> ```
/content/code_sandbox/app/src/main/res/values/themes.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
5,294
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <item name="glide_view_target_tag" type="id" /> <item name="progress_bar_compat_object_animator_tag" type="id" /> </resources> ```
/content/code_sandbox/app/src/main/res/values/ids.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
65
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <color name="blue_50">#e3f2fD</color> <color name="blue_300">#64B5F6</color> <color name="blue_500">#2196f3</color> <color name="blue_700">#1976d2</color> <color name="brown_50">#efebe9</color> <color name="brown_300">#a1887f</color> <color name="brown_500">#795548</color> <color name="brown_700">#5d4037</color> <color name="green_50">#e8f5e9</color> <color name="green_100">#c8e6c9</color> <color name="green_300">#81c784</color> <color name="green_500">#4caf50</color> <color name="green_700">#388e3c</color> <color name="green_800">#2e7d32</color> <color name="grey_50">#fafafa</color> <color name="grey_100">#f5f5f5</color> <color name="grey_200">#eeeeee</color> <color name="grey_300">#e0e0e0</color> <color name="grey_600">#757575</color> <color name="grey_700">#616161</color> <color name="grey_800">#424242</color> <color name="grey_850">#303030</color> <color name="teal_50">#e0f2f1</color> <color name="teal_300">#4db6ac</color> <color name="teal_500">#009688</color> <color name="teal_700">#00796b</color> <color name="dark_30_percent">#4d000000</color> <color name="dark_50_percent">#80000000</color> <color name="dark_70_percent">#b3000000</color> <color name="system_window_scrim">#44000000</color> <color name="window_background_light">@color/grey_50</color> <color name="window_background_dark">#303030</color> <color name="card_background_light">@android:color/white</color> <color name="card_background_dark">@color/grey_800</color> <color name="douya_primary">@color/green_500</color> <color name="douya_primary_dark">@color/green_700</color> <color name="douya_primary_dark_without_system_window_scrim">#4dc252</color> <color name="douya_accent">@color/green_500</color> <color name="book_primary">@color/brown_500</color> <color name="book_primary_dark">@color/brown_700</color> <color name="book_primary_light">@color/brown_50</color> <color name="book_accent">@color/brown_500</color> <color name="movie_primary">@color/blue_500</color> <color name="movie_primary_dark">@color/blue_700</color> <color name="movie_primary_light">@color/blue_50</color> <color name="movie_accent">@color/blue_500</color> <color name="music_primary">@color/teal_500</color> <color name="music_primary_dark">@color/teal_700</color> <color name="music_primary_light">@color/teal_50</color> <color name="music_accent">@color/teal_500</color> <color name="game_app_primary">@color/green_500</color> <color name="game_app_primary_dark">@color/green_700</color> <color name="game_app_primary_light">@color/green_50</color> <color name="game_app_accent">@color/green_500</color> <color name="calendar_secondary_text_light">#b3000000</color> <color name="calendar_secondary_text_dark">#b3ffffff</color> <color name="calendar_highlight_text">#00897b</color> <color name="calendar_control_activated">#ffab00</color> </resources> ```
/content/code_sandbox/app/src/main/res/values/colors.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
986
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <style name="Theme.AppCompat.Light.DialogWhenLarge.LightStatusBar" parent="Theme.AppCompat.Light.DialogWhenLarge"> <item name="colorPrimaryDark">@color/grey_300</item> <item name="android:windowLightStatusBar">true</item> </style> </resources> ```
/content/code_sandbox/app/src/main/res/values-v23/themes.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
92
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <dimen name="status_bar_height">24dp</dimen> </resources> ```
/content/code_sandbox/app/src/main/res/values-v23/dimens.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
47
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <adaptive-icon xmlns:android="path_to_url"> <background android:drawable="@color/douya_primary" /> <foreground android:drawable="@drawable/launcher_icon_foreground" /> </adaptive-icon> ```
/content/code_sandbox/app/src/main/res/mipmap-anydpi-v26/launcher_icon_round.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
69
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <PreferenceScreen xmlns:android="path_to_url"> <PreferenceCategory android:title="@string/settings_appearance_title"> <SwitchPreferenceCompat android:key="@string/pref_key_show_long_url_for_link_entity" android:title="@string/settings_show_long_url_for_link_entity_title" android:defaultValue="@bool/pref_default_value_show_long_url_for_link_entity" android:summary="@string/settings_show_long_url_for_link_entity_summary" /> <com.takisoft.preferencex.SimpleMenuPreference android:key="@string/pref_key_night_mode" android:title="@string/settings_night_mode_title" android:defaultValue="@string/pref_default_value_night_mode" android:entries="@array/settings_night_mode_entries" android:entryValues="@array/pref_entry_values_night_mode" android:summary="@string/settings_night_mode_summary" /> </PreferenceCategory> <PreferenceCategory android:title="@string/settings_behavior_title"> <SwitchPreferenceCompat android:key="@string/pref_key_auto_refresh_home" android:title="@string/settings_auto_refresh_home_title" android:defaultValue="@bool/pref_default_value_auto_refresh_home" /> <SwitchPreferenceCompat android:key="@string/pref_key_long_click_to_quick_rebroadcast" android:title="@string/settings_long_click_to_quick_rebroadcast_title" android:defaultValue="@bool/pref_default_value_long_click_to_quick_rebroadcast" /> <SwitchPreferenceCompat android:key="@string/pref_key_long_click_to_show_send_comment_activity" android:title="@string/settings_long_click_to_show_send_comment_activity_title" android:defaultValue="@bool/pref_default_value_long_click_to_show_send_comment_activity" /> <SwitchPreferenceCompat android:key="@string/pref_key_show_album_art_on_lock_screen" android:title="@string/settings_show_album_art_on_lock_screen_title" android:defaultValue="@bool/pref_default_value_show_album_art_on_lock_screen" /> <SwitchPreferenceCompat android:key="@string/pref_key_progressive_third_party_app" android:title="@string/settings_progressive_third_party_app_title" android:defaultValue="@bool/pref_default_value_progressive_third_party_app" android:summary="@string/settings_progressive_third_party_app_summary" /> <com.takisoft.preferencex.SimpleMenuPreference android:key="@string/pref_key_open_url_with" android:title="@string/settings_open_url_with_title" android:defaultValue="@string/pref_default_value_open_url_with" android:entries="@array/settings_open_url_with_entries" android:entryValues="@array/pref_entry_values_open_url_with" android:summary="@string/settings_open_url_with_summary" /> <SwitchPreferenceCompat android:key="@string/pref_key_open_with_native_in_webview" android:title="@string/settings_open_with_native_in_webview_title" android:defaultValue="@bool/pref_default_value_open_with_native_in_webview" android:summary="@string/settings_open_with_native_in_webview_summary" /> <SwitchPreferenceCompat android:key="@string/pref_key_request_desktop_site_in_webview" android:title="@string/settings_request_desktop_site_in_webview_title" android:defaultValue="@bool/pref_default_value_request_desktop_site_in_webview" android:summary="@string/settings_request_desktop_site_in_webview_summary" /> <me.zhanghai.android.douya.settings.ui.CreateNewTaskForWebViewSwitchPreference android:key="@string/pref_key_create_new_task_for_webview" android:title="@string/settings_create_new_task_for_webview_title" android:defaultValue="@bool/pref_default_value_create_new_task_for_webview" android:summary="@string/settings_create_new_task_for_webview_summary" /> </PreferenceCategory> <PreferenceCategory android:title="@string/settings_about_title"> <Preference android:title="@string/settings_privacy_policy_title"> <intent android:action="android.intent.action.VIEW" android:data="path_to_url" /> </Preference> <Preference android:title="@string/settings_about_douya_title"> <intent android:targetPackage="me.zhanghai.android.douya" android:targetClass="me.zhanghai.android.douya.settings.ui.AboutActivity" /> </Preference> </PreferenceCategory> </PreferenceScreen> ```
/content/code_sandbox/app/src/main/res/xml/settings.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
933
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <!-- ~ TODO: ~ android:smallIcon="@drawable/launcher_icon_small" ~ android:accountPreferences="@xml/account_preferences" --> <account-authenticator xmlns:android="path_to_url" android:accountType="@string/application_id" android:icon="@mipmap/launcher_icon" android:smallIcon="@mipmap/launcher_icon" android:label="@string/app_name" /> ```
/content/code_sandbox/app/src/main/res/xml/authenticator.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
113
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <paths> <!-- See com.bumptech.glide.load.engine.cache.DiskCache.Factory.DEFAULT_DISK_CACHE_DIR . --> <cache-path name="glide_cache" path="image_manager_disk_cache/" /> <!-- See android.os.Environment.DIRECTORY_PICTURES . --> <!-- Should be kept in sync with FileUtils --> <external-path name="pictures" path="Pictures/Douya/" /> </paths> ```
/content/code_sandbox/app/src/main/res/xml/file_provider_paths.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
108
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <appwidget-provider xmlns:android="path_to_url" android:minWidth="320dp" android:minHeight="320dp" android:minResizeWidth="250dp" android:minResizeHeight="250dp" android:resizeMode="horizontal|vertical" android:initialLayout="@layout/calendar_appwidget" android:previewImage="@drawable/calendar_rating_progress" android:updatePeriodMillis="0" android:widgetCategory="home_screen|keyguard" /> ```
/content/code_sandbox/app/src/main/res/xml/calendar_appwidget.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
126
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <vector xmlns:android="path_to_url" android:width="40dp" android:height="40dp" android:viewportWidth="20" android:viewportHeight="20"> <path android:fillColor="#FFF5F5F5" android:pathData="M10,0C4.48,0 0,4.48 0,10s4.48,10 10,10 10,-4.48 10,-10S15.52,0 10,0zm0,3c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zm0,14.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z" /> </vector> ```
/content/code_sandbox/app/src/main/res/drawable-night/avatar_icon_40dp.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
286
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <ripple xmlns:android="path_to_url" android:color="?colorControlHighlight"> <item android:id="@android:id/mask"> <shape android:shape="oval"> <solid android:color="@android:color/white" /> </shape> </item> <item> <selector> <item android:state_enabled="false" android:state_activated="true"> <shape android:shape="oval"> <solid android:color="@color/green_700" /> </shape> </item> <item android:state_enabled="false"> <shape android:shape="oval"> <solid android:color="@color/green_800" /> </shape> </item> <item android:state_activated="true"> <shape android:shape="oval"> <solid android:color="?colorControlActivated" /> </shape> </item> <item> <shape android:shape="oval"> <solid android:color="@color/grey_700" /> </shape> </item> </selector> </item> </ripple> ```
/content/code_sandbox/app/src/main/res/drawable-night/card_icon_button_background.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
272
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <selector xmlns:android="path_to_url"> <item android:color="@android:color/white" /> </selector> ```
/content/code_sandbox/app/src/main/res/drawable-night/card_icon_button_tint.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
52
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <vector xmlns:android="path_to_url" android:width="40dp" android:height="40dp" android:viewportWidth="20" android:viewportHeight="20"> <path android:fillColor="#FFF5F5F5" android:pathData="M9.99,0C4.47,0 0,4.48 0,10s4.47,10 9.99,10C15.52,20 20,15.52 20,10S15.52,0 9.99,0zm4.24,16L10,13.45 5.77,16l1.12,-4.81 -3.73,-3.23 4.92,-0.42L10,3l1.92,4.53 4.92,0.42 -3.73,3.23L14.23,16z"/> </vector> ```
/content/code_sandbox/app/src/main/res/drawable-night/recommendation_avatar_icon_40dp.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
233
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <selector xmlns:android="path_to_url"> <item android:state_enabled="false" android:color="@color/green_300" /> <item android:state_activated="true" android:color="?colorControlActivated" /> <item android:color="?colorControlNormal" /> </selector> ```
/content/code_sandbox/app/src/main/res/color-night/icon_button_tint_game_app.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
91
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <selector xmlns:android="path_to_url"> <item android:state_enabled="false" android:color="@color/blue_300" /> <item android:state_activated="true" android:color="?colorControlActivated" /> <item android:color="?colorControlNormal" /> </selector> ```
/content/code_sandbox/app/src/main/res/color-night/icon_button_tint_movie.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
90
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <selector xmlns:android="path_to_url"> <item android:state_enabled="false" android:color="@color/teal_300" /> <item android:state_activated="true" android:color="?colorControlActivated" /> <item android:color="?colorControlNormal" /> </selector> ```
/content/code_sandbox/app/src/main/res/color-night/icon_button_tint_music.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
92
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <selector xmlns:android="path_to_url"> <item android:state_enabled="false" android:color="@color/brown_300" /> <item android:state_activated="true" android:color="?colorControlActivated" /> <item android:color="?colorControlNormal" /> </selector> ```
/content/code_sandbox/app/src/main/res/color-night/icon_button_tint_book.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
91
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <dimen name="toolbar_overflow_button_right_margin">-4dp</dimen> </resources> ```
/content/code_sandbox/app/src/main/res/values-v22/dimens.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
50
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <dimen name="toolbar_height">48dp</dimen> <dimen name="toolbar_and_tab_height">96dp</dimen> <dimen name="scrim_height">144dp</dimen> </resources> ```
/content/code_sandbox/app/src/main/res/values-w600dp-land/dimens.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
79
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <style name="Theme.AppCompat.Light.DarkActionBar.DialogWhenLarge" parent="Base.Theme.AppCompat.Light.Dialog.FixedSize"> <item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item> <item name="actionBarWidgetTheme">@null</item> <item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item> <!-- Panel attributes --> <item name="listChoiceBackgroundIndicator">@drawable/abc_list_selector_holo_dark</item> <item name="colorPrimaryDark">@color/primary_dark_material_dark</item> <item name="colorPrimary">@color/primary_material_dark</item> </style> </resources> ```
/content/code_sandbox/app/src/main/res/values-large/themes.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
175
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <vector xmlns:android="path_to_url" xmlns:aapt="path_to_url" android:width="108dp" android:height="108dp" android:viewportWidth="108" android:viewportHeight="108"> <path android:pathData="M 36.771484 36.0625 L 36.771484 40.955078 L 39.537109 43.720703 L 39.466797 43.720703 L 39.466797 58.890625 L 43.744141 63.167969 L 43.748047 63.175781 C 44.395744 64.462707 45.013897 65.819538 45.4375 67.1875 L 35 67.1875 L 35 71.9375 L 105.71094 142.64648 L 143.71094 142.64648 L 143.71094 137.89648 L 136.30273 130.48828 C 136.32933 130.42608 136.35611 130.36497 136.38281 130.30273 L 135.70703 129.62695 L 138.89062 129.59961 L 138.89062 114.43164 L 136.125 111.66602 L 142.08008 111.66602 L 142.08008 106.77344 L 71.369141 36.0625 L 36.771484 36.0625 z"> <aapt:attr name="android:fillColor"> <gradient android:type="linear" android:startX="0" android:startY="0" android:endX="108" android:endY="108"> <item android:offset="0" android:color="#33000000" /> <item android:offset="1" android:color="#00000000" /> </gradient> </aapt:attr> </path> <path android:fillColor="@android:color/white" android:pathData="m 35,67.186577 h 10.437013 c -0.766561,-2.475494 -2.163872,-4.940778 -3.237085,-6.952585 l 3.044476,-1.306746 -5.777985,-0.03704 V 43.720149 h 28.712683 v 15.16971 l -4.643652,0.03739 2.136962,0.665356 c -1.10121,2.571527 -2.159465,5.120086 -3.443711,7.593974 H 73 v 4.75 H 35 Z M 60.035674,58.891792 H 47.177726 c 1.57491,2.526595 2.662393,4.725146 3.657203,7.514329 l -1.648277,0.749286 7.254428,-0.0042 c 1.430385,-2.808638 2.647969,-5.527393 3.594594,-8.259392 z M 63.28731,48.470145 H 44.429103 v 5.67165 H 63.28731 Z M 36.772388,36.06342 h 34.597011 v 4.891796 H 36.772388 Z" /> </vector> ```
/content/code_sandbox/app/src/main/res/drawable-anydpi-v26/launcher_icon_foreground.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
809
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url"> <group android:id="@+id/navigation_group_primary" android:checkableBehavior="single"> <item android:id="@+id/navigation_home" android:icon="@drawable/home_icon_white_24dp" android:title="@string/navigation_home" /> <item android:id="@+id/navigation_book" android:icon="@drawable/book_icon_white_24dp" android:title="@string/navigation_book" /> <item android:id="@+id/navigation_movie" android:icon="@drawable/movie_icon_white_24dp" android:title="@string/navigation_movie" /> <item android:id="@+id/navigation_music" android:icon="@drawable/music_icon_white_24dp" android:title="@string/navigation_music" /> </group> <!-- Set an id on this group to show a divider. --> <!--<group android:id="@+id/navigation_group_secondary" > <item android:id="@+id/navigation_calendar" android:icon="@drawable/event_note_icon_white_24dp" android:title="@string/navigation_calendar" /> </group>--> <!-- Set an id on this group to show a divider. --> <group android:id="@+id/navigation_group_tertiary" > <item android:id="@+id/navigation_settings" android:icon="@drawable/settings_icon_white_24dp" android:title="@string/navigation_settings" /> <item android:id="@+id/navigation_feedback" android:icon="@drawable/feedback_icon_white_24dp" android:title="@string/navigation_feedback" /> </group> </menu> ```
/content/code_sandbox/app/src/main/res/menu/navigation.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
377
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".broadcast.ui.SendBroadcastActivity"> <item android:id="@+id/action_send" android:icon="@drawable/send_icon_white_24dp" android:orderInCategory="100" android:title="@string/broadcast_send" app:showAsAction="always" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/broadcast_send_broadcast.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
123
```xml <resources> <string name="ok"></string> <string name="cancel"></string> <string name="close"></string> <string name="copy_to_clipboard"></string> <string name="discard"></string> <string name="keep_editing"></string> <string name="no"></string> <string name="reload"></string> <string name="save"></string> <string name="share"></string> <string name="space">" "</string> <string name="yes"></string> <string name="activity_not_found"></string> <string name="copied_to_clipboard_format">\n%1$s</string> <string name="confirm_close_discarding_content"></string> <string name="counter_format">%1$d/%2$d</string> <string name="load_empty"></string> <string name="load_error"></string> <string name="more"></string> <string name="not_yet_implemented"></string> <string name="open_settings"></string> <string name="report_abuse"></string> <string name="view_more"></string> <string name="view_more_with_count_format">%1$d</string> <string name="view_on_web"></string> <string name="just_now"></string> <string name="minute_format">%1$d</string> <string name="hour_format">%1$d</string> <string name="today_hour_minute_pattern"> HH:mm</string> <string name="yesterday_hour_minute_pattern"> HH:mm</string> <string name="month_day_hour_minute_pattern">Md HH:mm</string> <string name="date_hour_minute_pattern">yMd HH:mm</string> <string name="today"></string> <string name="yesterday"></string> <string name="month_day_pattern">Md</string> <string name="date_pattern">yMd</string> <string name="year_month_pattern">yM</string> <string name="year_month_format">%1$d%2$d</string> <string name="year_pattern">y</string> <string name="year_format">%1$d</string> <string name="duration_hour_minute_second_format">%1$d:%2$02d:%3$02d</string> <string name="duration_minute_second_format">%1$02d:%2$02d</string> <string name="media_action_play"></string> <string name="media_action_pause"></string> <string name="media_action_skip_to_previous"></string> <string name="media_action_skip_to_next"></string> <string name="notices_title">@string/settings_open_source_licenses_title</string> <string name="notices_close">@string/close</string> <string name="app_name"></string> <string name="api_error_parse"></string> <string name="api_error_auth_failure"></string> <string name="api_error_timeout"></string> <string name="api_error_no_connection"></string> <string name="api_error_network"></string> <string name="api_error_invalid_error_response"></string> <string name="api_error_invalid_request_997"></string> <string name="api_error_unknown_v2_error"> V2 </string> <string name="api_error_need_permission"></string> <string name="api_error_uri_not_found"></string> <string name="api_error_missing_args"></string> <string name="api_error_image_too_large"></string> <string name="api_error_has_ban_word"></string> <string name="api_error_input_too_short"></string> <string name="api_error_target_not_found"></string> <string name="api_error_need_captcha"></string> <string name="api_error_image_unknown"></string> <string name="api_error_image_wrong_format"></string> <string name="api_error_image_wrong_ck"></string> <string name="api_error_image_ck_expired"></string> <string name="api_error_title_missing"></string> <string name="api_error_desc_missing"></string> <string name="api_error_unknown"></string> <string name="api_error_token_invalid_request_scheme"></string> <string name="api_error_token_invalid_request_method"></string> <string name="api_error_token_access_token_is_missing"> access_token</string> <string name="api_error_token_invalid_access_token">access_token </string> <string name="api_error_token_invalid_apikey">API Key </string> <string name="api_error_token_apikey_is_blocked">API Key </string> <string name="api_error_token_access_token_has_expired">access_token </string> <string name="api_error_token_invalid_request_uri"></string> <string name="api_error_token_invalid_credencial1"></string> <string name="api_error_token_invalid_credencial2">API Key </string> <string name="api_error_token_not_trial_user"></string> <string name="api_error_token_rate_limit_exceeded1"></string> <string name="api_error_token_rate_limit_exceeded2">IP </string> <string name="api_error_token_required_parameter_is_missing"></string> <string name="api_error_token_unsupported_grant_type"> grant_type</string> <string name="api_error_token_unsupported_response_type"> response_type</string> <string name="api_error_token_client_secret_mismatch">client_secret </string> <string name="api_error_token_redirect_uri_mismatch">redirect_uri </string> <string name="api_error_token_invalid_authorization_code">authorization_code </string> <string name="api_error_token_invalid_refresh_token">refresh_token </string> <string name="api_error_token_username_password_mismatch"></string> <string name="api_error_token_invalid_user"></string> <string name="api_error_token_user_has_blocked"></string> <string name="api_error_token_access_token_has_expired_since_password_changed">access_token </string> <string name="api_error_token_access_token_has_not_expired">access_token </string> <string name="api_error_token_invalid_request_scope"> scope </string> <string name="api_error_token_invalid_request_source"></string> <string name="api_error_token_thirdparty_login_auth_failed"></string> <string name="api_error_token_user_locked"></string> <string name="api_error_followship_already_followed"></string> <string name="api_error_followship_not_followed_yet"></string> <string name="api_error_broadcast_not_found"></string> <string name="api_error_rebroadcast_broadcast_deleted"></string> <string name="notification_channel_send_broadcast_name"></string> <string name="notification_channel_send_broadcast_description"></string> <string name="notification_channel_play_music_name"></string> <string name="notification_channel_play_music_description"></string> <string name="auth_title_new"></string> <string name="auth_title_add"></string> <string name="auth_title_update"></string> <string name="auth_title_confirm"></string> <string name="auth_username"></string> <string name="auth_password"></string> <string name="auth_sign_in"></string> <string name="auth_sign_up"></string> <string name="auth_error_empty_username"></string> <string name="auth_error_empty_password"></string> <string name="auth_error_invalid_response"></string> <string name="auth_error_unknown"></string> <string name="auth_select_account"></string> <string name="gallery_title"></string> <string name="gallery_title_multiple_format">%1$d/%2$d</string> <string name="gallery_network_error"></string> <string name="gallery_load_error"></string> <string name="gallery_save_permission_request_message"></string> <string name="gallery_save_permission_permanently_denied_message"></string> <string name="gallery_save_permission_denied"></string> <string name="gallery_save_successful"></string> <string name="gallery_save_failed"></string> <string name="webview_title"></string> <string name="webview_go_forward"></string> <string name="webview_open_with_native"></string> <string name="webview_copy_url"></string> <string name="webview_error_url_empty"></string> <string name="webview_request_desktop_site"></string> <string name="webview_open_in_browser"></string> <string name="webview_download_permission_request_message"></string> <string name="webview_download_permission_permanently_denied_message"></string> <string name="webview_download_permission_denied"></string> <string name="webview_downloading"></string> <string name="navigation_home"></string> <string name="navigation_book"></string> <string name="navigation_movie"></string> <string name="navigation_music"></string> <string name="navigation_calendar"></string> <string name="navigation_settings"></string> <string name="navigation_feedback"></string> <string name="navigation_add_account"></string> <string name="navigation_remove_current_account"></string> <string name="navigation_remove_current_account_confirm"></string> <string name="navigation_manage_accounts"></string> <string name="main_notification"></string> <string name="main_doumail"></string> <string name="main_search"></string> <string name="home_broadcast"></string> <string name="home_discover"></string> <string name="home_topic"></string> <string name="home_online"></string> <string name="broadcast_list_title_default"></string> <string name="broadcast_list_title_user_format">%s </string> <string name="broadcast_list_title_topic_format">#%s#</string> <string name="broadcast_send_title"></string> <string name="broadcast_send_intent_filter_title"></string> <string name="broadcast_send_title_sending"></string> <string name="broadcast_send"></string> <string name="broadcast_send_error_empty"></string> <string name="broadcast_send_error_text_too_long"></string> <string name="broadcast_sending"></string> <string name="broadcast_sending_notification_title"></string> <string name="broadcast_sending_notification_text_uploading_images_format">%1$d/%2$d</string> <string name="broadcast_sending_notification_text_sending"></string> <string name="broadcast_send_successful"></string> <string name="broadcast_send_failed_format">%1$s</string> <string name="broadcast_send_failed_notification_title_format">%1$s</string> <string name="broadcast_send_failed_notification_text"></string> <string name="broadcast_send_add_image"></string> <string name="broadcast_send_capture_image_permission_request_message"></string> <string name=your_sha256_hashge"></string> <string name="broadcast_send_capture_image_permission_denied"></string> <string name="broadcast_send_add_image_too_many"> 9 </string> <string name="broadcast_send_remove_all_images"></string> <string name="broadcast_send_remove_all_images_confirm"></string> <string name="broadcast_send_add_link"></string> <string name="broadcast_send_edit_link"></string> <string name="broadcast_send_remove_link"></string> <string name="broadcast_send_remove_link_confirm"></string> <string name="broadcast_send_link_default_title"></string> <string name="broadcast_send_edit_link_title"></string> <string name="broadcast_send_edit_link_url_caption"></string> <string name="broadcast_send_edit_link_url_hint">path_to_url <string name="broadcast_send_edit_link_url_error"></string> <string name="broadcast_send_edit_link_title_caption"></string> <string name="broadcast_send_edit_link_title_hint"></string> <string name="broadcast_send_add_mention">\@</string> <string name="broadcast_send_add_topic"></string> <string name="broadcast_title"></string> <string name="broadcast_rebroadcasted_by_format"> %1$s </string> <string name="broadcast_rebroadcasted_broadcast_text_rebroadcaster_format">%1$s</string> <string name="broadcast_rebroadcasted_broadcast_text_rebroadcast_deleted"></string> <string name="broadcast_rebroadcasted_broadcast_text_more_rebroadcast"></string> <string name="broadcast_rebroadcasted_broadcast_deleted"></string> <string name="broadcast_image_list_count_format">%1$d </string> <string name="broadcast_like"></string> <string name="broadcast_comment"></string> <string name="broadcast_rebroadcast"></string> <string name="broadcast_like_error_cannot_like_oneself"></string> <string name="broadcast_like_successful"></string> <string name="broadcast_like_failed_format">%1$s</string> <string name="broadcast_unlike_successful"></string> <string name="broadcast_unlike_failed_format">%1$s</string> <string name="broadcast_rebroadcast_successful"></string> <string name="broadcast_rebroadcast_failed_format">%1$s</string> <string name="broadcast_unrebroadcast_confirm"></string> <string name="broadcast_unrebroadcast_successful"></string> <string name="broadcast_unrebroadcast_failed_format">%1$s</string> <string name="broadcast_rebroadcast_title"></string> <string name="broadcast_rebroadcast_title_rebroadcasting"></string> <string name="broadcast_rebroadcast_text_hint"></string> <string name="broadcast_view_activity"></string> <string name="broadcast_comment_action_title"></string> <string name="broadcast_comment_action_reply_to"></string> <string name="broadcast_comment_action_copy_text"></string> <string name="broadcast_comment_action_delete"></string> <string name="broadcast_comment_delete_confirm"></string> <string name="broadcast_comment_delete_successful"></string> <string name="broadcast_comment_delete_failed_format">%1$s</string> <string name="broadcast_send_comment_title"></string> <string name="broadcast_send_comment_title_sending"></string> <string name="broadcast_send_comment_hint"></string> <string name="broadcast_send_comment_hint_disabled">@string/broadcast_send_comment_disabled</string> <string name="broadcast_send_comment_disabled"></string> <string name="broadcast_send_comment"></string> <string name="broadcast_send_comment_error_empty"></string> <string name="broadcast_send_comment_successful"></string> <string name="broadcast_send_comment_failed_format">%1$s</string> <string name="broadcast_copy_text"></string> <string name="broadcast_copy_text_not_loaded"></string> <string name="broadcast_delete"></string> <string name="broadcast_delete_confirm"></string> <string name="broadcast_delete_successful"></string> <string name="broadcast_delete_failed_format">%1$s</string> <string name="broadcast_likers_title_format">%1$d </string> <string name="broadcast_likers_title_empty"></string> <string name="broadcast_rebroadcasts_title_format">%1$d </string> <string name="broadcast_rebroadcasts_title_empty"></string> <string name="broadcast_rebroadcasts_simple_rebroadcast_text"></string> <string name="user_follow_error_cannot_follow_oneself"></string> <string name="user_following"></string> <string name="user_follow_successful"></string> <string name="user_follow_failed_format">%1$s</string> <string name="user_unfollow_confirm"></string> <string name="user_unfollowing"></string> <string name="user_unfollow_successful"></string> <string name="user_unfollow_failed_format">%1$s</string> <string name="profile_join_time_format">%1$s </string> <string name="profile_join_time_location_format">%1$s %2$s</string> <string name="profile_edit"></string> <string name="profile_follow"></string> <string name="profile_following"></string> <string name="profile_following_mutual"></string> <string name="profile_send_doumail"></string> <string name="profile_blacklist"></string> <string name="profile_introduction_title"></string> <string name="profile_introduction_empty"></string> <string name="profile_broadcasts_title"></string> <string name="profile_broadcasts_empty"></string> <string name="profile_followship_title"></string> <string name="profile_following_empty"></string> <string name="profile_follower_count_format"> %1$d </string> <string name="profile_follower_list_title"></string> <string name="profile_following_list_title"></string> <string name="profile_diaries_title"></string> <string name="profile_diaries_empty"></string> <string name="profile_items_empty_format">%1$s%2$s</string> <string name="profile_items_non_primary_format">%1$s%2$d</string> <string name="profile_reviews_title"></string> <string name="profile_reviews_empty"></string> <string name="item_app_name"></string> <string name="item_app_action"></string> <string name="item_app_this_item"></string> <string name="item_book_name"></string> <string name="item_book_action"></string> <string name="item_book_this_item"></string> <string name="item_game_name"></string> <string name="item_game_action"></string> <string name="item_game_this_item"></string> <string name="item_event_name"></string> <string name="item_event_action"></string> <string name="item_event_this_item"></string> <string name="item_movie_name"></string> <string name="item_movie_action"></string> <string name="item_movie_this_item"></string> <string name="item_music_name"></string> <string name="item_music_action"></string> <string name="item_music_this_item"></string> <string name="item_tv_name"></string> <string name="item_tv_action"></string> <string name="item_tv_this_item"></string> <string name="item_todo_format">%1$s</string> <string name="item_doing_format">%1$s</string> <string name="item_done_format">%1$s</string> <string name="item_book_title"></string> <string name="item_movie_title"></string> <string name="item_music_title"></string> <string name="item_game_title"></string> <string name="item_information_delimiter_space">" "</string> <string name="item_information_delimiter_slash">" / "</string> <string name="item_information_book_translators_format">%1$s</string> <string name="item_collection_edit"></string> <string name="item_collection_uncollect"></string> <string name="item_top_250"> 250</string> <string name="item_top_250_badge">TOP</string> <string name="item_top_250_rank_format">%1$d</string> <string name="item_similar_items"></string> <string name="item_rating_unavailable">\?</string> <string name="item_rating_unavailable_reason_fallback"></string> <string name="item_rating_format">%1$.1f</string> <string name="item_rating_format_ten">%1$.0f</string> <string name="item_rating_count_format">%1$,d</string> <string name="item_introduction_empty"></string> <string name="item_introduction_title"></string> <string name="item_author_title"></string> <string name="item_table_of_contents_title"></string> <string name="item_photo_list_view_more"></string> <string name="item_celebrity_director"></string> <string name="item_award_category_multiple_format">%1$s %2$d</string> <string name="item_track_list_title"></string> <string name="item_track_list_play_all"></string> <string name="item_collection_list_title"></string> <string name="item_collection_list_create"></string> <string name="item_collection_vote_count_format">%1$d</string> <string name="item_collection_list_view_more"></string> <string name="item_collection_vote_error_cannot_vote_oneself"></string> <string name="item_collection_vote_error_cannot_vote_again"></string> <string name="item_collection_vote_successful"></string> <string name="item_collection_vote_failed_format">%1$s</string> <string name="item_game_guide_list_title"></string> <string name="item_game_guide_list_create"></string> <string name="item_game_guide_list_view_more"></string> <string name="item_review_list_title"></string> <string name="item_review_list_create"></string> <string name="item_review_list_view_more"></string> <string name="item_review_usefulness_format">%1$d/%2$d </string> <string name="item_forum_topic_list_title"></string> <string name="item_forum_topic_list_create"></string> <string name="item_forum_topic_like_count_format">%1$d</string> <string name="item_forum_topic_comment_count_format">%1$d</string> <string name="item_forum_topic_update"></string> <string name="item_forum_topic_list_view_more"></string> <string name="item_recommendation_list_title"></string> <string name="item_related_doulist_list_title"></string> <string name="item_related_doulist_follower_count_format">%1$d </string> <string name="item_collection_title"></string> <string name="item_collection_title_saving_format">%1$s</string> <string name="item_uncollect_confirm"></string> <string name="item_uncollect_successful_format">%1$s</string> <string name="item_uncollect_failed_format">%1$s%2$s</string> <string name="item_collection_collect"></string> <string name="item_collect_successful_format">%1$s</string> <string name="item_collect_failed_format">%1$s%2$s</string> <string name="item_state_i"></string> <string name="item_rating"></string> <string-array name="item_rating_hints"> <item></item> <item></item> <item></item> <item></item> <item></item> </string-array> <string name="item_rating_hint_unknown"></string> <string name="item_tags"></string> <string name="item_tags_hint"></string> <string name="item_comment_hint"></string> <string name="item_share_to"></string> <string name="item_share_to_broadcast"></string> <string name="item_share_to_weibo"></string> <string name="item_introduction_celebrity_delimiter"></string> <string name="item_introduction_movie_cast_and_credits"></string> <string name="item_introduction_movie_directors"></string> <string name="item_introduction_movie_actors"></string> <string name="item_introduction_movie_original_title"></string> <string name="item_introduction_movie_genres"></string> <string name="item_introduction_movie_countries"></string> <string name="item_introduction_movie_languages"></string> <string name="item_introduction_movie_release_dates"></string> <string name="item_introduction_movie_episode_count"></string> <string name="item_introduction_movie_durations"></string> <string name="item_introduction_movie_alternative_titles"></string> <string name="item_introduction_music_artists"></string> <string name="item_introduction_music_genres"></string> <string name="item_introduction_music_types"></string> <string name="item_introduction_music_media"></string> <string name="item_introduction_music_release_dates"></string> <string name="item_introduction_music_publishers"></string> <string name="item_introduction_music_disc_counts"></string> <string name="item_introduction_book_authors"></string> <string name="item_introduction_book_presses"></string> <string name="item_introduction_book_subtitles"></string> <string name="item_introduction_book_translators"></string> <string name="item_introduction_book_release_dates"></string> <string name="item_introduction_book_page_counts"></string> <string name="item_introduction_book_prices"></string> <string name="item_introduction_game_genres"></string> <string name="item_introduction_game_platforms"></string> <string name="item_introduction_game_alternative_titles"></string> <string name="item_introduction_game_developers"></string> <string name="item_introduction_game_publishers"></string> <string name="item_introduction_game_release_date"></string> <string name="calendar_title"></string> <string name="calendar_chinese_calendar"></string> <string name="calendar_date_pattern">Md</string> <string-array name="calendar_day_of_week_names"> <item></item> <item></item> <item></item> <item></item> <item></item> <item></item> <item></item> </string-array> <string name="calendar_day_of_month_format">%1$d</string> <string name="calendar_title_format"> %1$s </string> <string name="calendar_rating_format">%1$.1f</string> <string name="calendar_event_format"> %1$s </string> <string name="settings_title"></string> <string name="settings_appearance_title"></string> <string name="settings_show_long_url_for_link_entity_title"></string> <string name="settings_show_long_url_for_link_entity_summary"> douc.cc </string> <string name="settings_night_mode_title"></string> <string name="settings_night_mode_summary">%1$s</string> <string-array name="settings_night_mode_entries"> <!--<item></item>--> <item></item> <item></item> <item></item> </string-array> <string name="settings_behavior_title"></string> <string name="settings_auto_refresh_home_title"></string> <string name="settings_long_click_to_quick_rebroadcast_title"></string> <string name="settings_long_click_to_show_send_comment_activity_title"></string> <string name="settings_show_album_art_on_lock_screen_title"></string> <string name="settings_progressive_third_party_app_title"></string> <string name="settings_progressive_third_party_app_summary"></string> <string name="settings_open_url_with_title"></string> <string name="settings_open_url_with_summary">%1$s</string> <string-array name="settings_open_url_with_entries"> <item></item> <item></item> <item>Custom Tabs</item> </string-array> <string name="settings_open_with_native_in_webview_title"></string> <string name="settings_open_with_native_in_webview_summary"></string> <string name="settings_request_desktop_site_in_webview_title"></string> <string name="settings_request_desktop_site_in_webview_summary"></string> <string name="settings_create_new_task_for_webview_title"></string> <string name="settings_create_new_task_for_webview_summary"></string> <string name="settings_create_new_task_for_webview_summary_below_lollipop"> Android 5.0 </string> <string name="settings_about_title"></string> <string name="settings_open_source_licenses_title"></string> <string name="settings_open_source_licenses_html_style_light" translatable="false"> body { font-family: sans-serif; overflow-wrap: break-word; } pre { background: #eeeeee; padding: 1em; white-space: pre-wrap; } a, a:link, a:visited, a:hover, a:focus, a:active { color: #4caf50; } </string> <string name="settings_open_source_licenses_html_style_dark" translatable="false"> body { background: #424242; color: white; font-family: sans-serif; overflow-wrap: break-word; } pre { background: #303030; padding: 1em; white-space: pre-wrap; } a, a:link, a:visited, a:hover, a:focus, a:active { color: #4caf50; } </string> <string name="settings_privacy_policy_title"></string> <string name="settings_about_douya_title"></string> <string name="about_title"></string> <string name="about_name">@string/app_name</string> <string name="about_words">Douban, Yet Another</string> <string name="about_version_format"> %1$s</string> <string name="about_credit"></string> <string name="about_douban">\@douban-douya</string> <string name="about_confirm_enable_scalpel_title"></string> <string name="about_confirm_enable_scalpel_message">\n1. \n2. \n3. \n\n\n\n\n</string> </resources> ```
/content/code_sandbox/app/src/main/res/values/strings.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
6,402
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".broadcast.ui.BroadcastActivity"> <item android:id="@+id/action_copy_text" android:orderInCategory="100" android:title="@string/broadcast_copy_text" app:showAsAction="never" /> <item android:id="@+id/action_delete" android:orderInCategory="100" android:title="@string/broadcast_delete" app:showAsAction="never" /> <item android:id="@+id/action_share" android:orderInCategory="100" android:title="@string/share" app:showAsAction="never" /> <item android:id="@+id/action_view_on_web" android:orderInCategory="100" android:title="@string/view_on_web" app:showAsAction="never" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/broadcast.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
234
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".broadcast.ui.RebroadcastBroadcastActivity"> <item android:id="@+id/action_rebroadcast" android:icon="@drawable/send_icon_white_24dp" android:orderInCategory="100" android:title="@string/broadcast_rebroadcast" app:showAsAction="always" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/broadcast_rebroadcast_broadcast.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
126
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".item.ui.MovieActivity"> <item android:id="@+id/action_share" android:orderInCategory="100" android:title="@string/share" app:showAsAction="never" /> <item android:id="@+id/action_view_on_web" android:orderInCategory="100" android:title="@string/view_on_web" app:showAsAction="never" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/item.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
150
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url"> <item android:id="@+id/action_go_forward" android:title="@string/webview_go_forward" app:showAsAction="never" /> <item android:id="@+id/action_reload" android:title="@string/reload" app:showAsAction="never" /> <item android:id="@+id/action_copy_url" android:title="@string/webview_copy_url" app:showAsAction="never" /> <item android:id="@+id/action_share" android:title="@string/share" app:showAsAction="never" /> <item android:id="@+id/action_open_with_native" android:checkable="true" android:title="@string/webview_open_with_native" app:showAsAction="never" /> <item android:id="@+id/action_request_desktop_site" android:checkable="true" android:title="@string/webview_request_desktop_site" app:showAsAction="never" /> <item android:id="@+id/action_open_in_browser" android:title="@string/webview_open_in_browser" app:showAsAction="never" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/webview.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
304
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".broadcast.ui.BroadcastListActivity"> <item android:id="@+id/action_share" android:orderInCategory="100" android:title="@string/share" app:showAsAction="never" /> <item android:id="@+id/action_view_on_web" android:orderInCategory="100" android:title="@string/view_on_web" app:showAsAction="never" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/broadcast_list.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
151
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".item.ui.ItemCollectionActivity"> <item android:id="@+id/action_uncollect" android:icon="@drawable/delete_icon_white_24dp" android:orderInCategory="100" android:title="@string/item_collection_uncollect" app:showAsAction="always" /> <item android:id="@+id/action_collect" android:icon="@drawable/ok_icon_white_24dp" android:orderInCategory="100" android:title="@string/item_collection_collect" app:showAsAction="always" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/item_collection.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
180
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".profile.ui.ProfileActivity"> <item android:id="@+id/action_send_doumail" android:icon="@drawable/mail_icon_white_24dp" android:orderInCategory="100" android:title="@string/profile_send_doumail" app:showAsAction="ifRoom" /> <item android:id="@+id/action_blacklist" android:orderInCategory="100" android:title="@string/profile_blacklist" app:showAsAction="never" /> <item android:id="@+id/action_report_abuse" android:orderInCategory="100" android:title="@string/report_abuse" app:showAsAction="never" /> <item android:id="@+id/action_share" android:orderInCategory="100" android:title="@string/share" app:showAsAction="never" /> <item android:id="@+id/action_view_on_web" android:orderInCategory="100" android:title="@string/view_on_web" app:showAsAction="never" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/profile.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
295
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:tools="path_to_url" tools:context=".item.ui.MovieActivity"> <item android:id="@+id/action_edit" android:title="@string/item_collection_edit" /> <item android:id="@+id/action_uncollect" android:title="@string/item_collection_uncollect" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/item_collection_actions.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
107
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".broadcast.ui.BroadcastActivity"> <item android:id="@+id/action_save" android:orderInCategory="100" android:title="@string/save" app:showAsAction="never" /> <item android:id="@+id/action_share" android:orderInCategory="100" android:title="@string/share" app:showAsAction="never" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/gallery.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
146
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".MainActivity"> <item android:id="@+id/action_notification" android:orderInCategory="100" android:title="@string/main_notification" app:actionLayout="@layout/action_item_badge" app:showAsAction="always" /> <item android:id="@+id/action_doumail" android:orderInCategory="100" android:title="@string/main_doumail" app:actionLayout="@layout/action_item_badge" app:showAsAction="always" /> <item android:id="@+id/action_search" android:icon="@drawable/search_icon_white_24dp" android:title="@string/main_search" android:orderInCategory="100" app:showAsAction="always" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/main.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
226
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <menu xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" tools:context=".broadcast.ui.SendCommentActivity"> <item android:id="@+id/action_send_comment" android:icon="@drawable/send_icon_white_24dp" android:orderInCategory="100" android:title="@string/broadcast_send_comment" app:showAsAction="always" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/broadcast_send_comment.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
125
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <resources> <item name="weight_1_when_phone" type="dimen" format="float">0</item> <item name="weight_1_when_tablet" type="dimen" format="float">1</item> <dimen name="screen_edge_horizontal_margin">24dp</dimen> <dimen name="screen_edge_horizontal_margin_with_4dp_padding">20dp</dimen> <dimen name="screen_edge_horizontal_margin_with_8dp_padding">16dp</dimen> <dimen name="screen_edge_horizontal_margin_with_12dp_padding">12dp</dimen> <dimen name="screen_edge_horizontal_margin_with_16dp_padding">8dp</dimen> <dimen name="screen_edge_horizontal_margin_negative">-24dp</dimen> <dimen name="screen_edge_horizontal_margin_negative_half">-12dp</dimen> <dimen name="content_horizontal_margin">80dp</dimen> <dimen name="toolbar_navigation_button_left_margin">6dp</dimen> <dimen name="toolbar_button_right_margin">10dp</dimen> <dimen name="toolbar_overflow_button_right_margin">-4dp</dimen> <dimen name="toolbar_edit_left_margin">20dp</dimen> <dimen name="toolbar_height">64dp</dimen> <dimen name="toolbar_and_toolbar_height">128dp</dimen> <dimen name="toolbar_and_tab_height">112dp</dimen> <dimen name="navigation_header_height">192dp</dimen> <dimen name="scrim_height">192dp</dimen> <dimen name="card_list_horizontal_padding">12dp</dimen> <dimen name="card_activity_horizontal_margin">@dimen/content_horizontal_margin</dimen> <dimen name="card_view_width">600dp</dimen> <dimen name="card_vertical_space">24dp</dimen> <dimen name="card_vertical_space_half">12dp</dimen> <dimen name="card_horizontal_margin">10dp</dimen> <dimen name="card_vertical_margin">9dp</dimen> <dimen name="card_header_horizontal_margin">12dp</dimen> <dimen name="card_header_bottom_margin">-8dp</dimen> <dimen name="card_corner_radius">2dp</dimen> <dimen name="toolbar_button_size">56dp</dimen> <dimen name="button_bar_horizontal_divider_width">8dp</dimen> <dimen name="fab_margin">24dp</dimen> <dimen name="profile_large_avatar_size">192dp</dimen> <dimen name="profile_large_avatar_bottom_from_toolbar_bottom">32dp</dimen> <dimen name="profile_small_avatar_size">40dp</dimen> <dimen name="item_content_padding_top_max">0dp</dimen> <dimen name="item_backdrop_play_layout_height">@dimen/match_parent</dimen> <dimen name="item_content_horizontal_margin">0dp</dimen> <dimen name="item_card_list_horizontal_padding">8dp</dimen> <dimen name="item_card_list_vertical_padding">8dp</dimen> <dimen name="item_card_horizontal_margin">6dp</dimen> <dimen name="item_card_vertical_margin">5dp</dimen> <dimen name="item_cover_width_long">160dp</dimen> <dimen name="item_badge_list_space">24dp</dimen> <dimen name="item_badge_size">72dp</dimen> <dimen name="item_badge_padding">12dp</dimen> </resources> ```
/content/code_sandbox/app/src/main/res/values-sw600dp/dimens.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
861
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <me.zhanghai.android.douya.ui.ForegroundRelativeLayout xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/avatar_padding_negative" android:paddingLeft="@dimen/screen_edge_horizontal_margin_with_4dp_padding" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:paddingTop="@dimen/content_vertical_space" android:paddingBottom="@dimen/content_vertical_space" android:clipToPadding="false" android:foreground="?selectableItemBackground"> <me.zhanghai.android.douya.ui.SimpleCircleImageView android:id="@+id/avatar" android:layout_width="@dimen/touch_target_size" android:layout_height="@dimen/touch_target_size" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:padding="@dimen/avatar_padding" android:src="@drawable/avatar_icon_40dp" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/avatar" android:layout_toLeftOf="@id/button_bar" android:layout_alignParentTop="true" android:layout_marginLeft="@dimen/content_horizontal_margin_from_screen_edge_with_44dp_padding" android:layout_marginTop="@dimen/avatar_padding" android:ellipsize="end" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <LinearLayout android:id="@+id/rating_and_date" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignLeft="@id/name" android:layout_toLeftOf="@id/button_bar" android:layout_below="@id/name" android:gravity="center_vertical" android:orientation="horizontal"> <me.zhanghai.android.materialratingbar.MaterialRatingBar android:id="@+id/rating" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="-1dp" android:layout_marginRight="7dp" android:layout_marginTop="-2dp" android:layout_marginBottom="-2dp" android:minHeight="14dp" android:maxHeight="14dp" app:mrb_progressTint="?android:textColorSecondary" style="@style/Widget.MaterialRatingBar.RatingBar.Indicator.Small" /> <TextView android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Caption" /> </LinearLayout> <LinearLayout android:id="@+id/button_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="-8dp" android:orientation="horizontal"> <LinearLayout android:id="@+id/vote_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="7dp" android:background="?selectableItemBackgroundBorderless" android:duplicateParentState="true" android:src="@drawable/like_icon_white_18dp" app:tint="?iconButtonTint" tools:ignore="MissingPrefix" /> <me.zhanghai.android.douya.ui.AutoGoneTextView android:id="@+id/vote_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="-2dp" android:layout_marginTop="1dp" android:duplicateParentState="true" android:includeFontPadding="false" android:textAppearance="@style/TextAppearance.AppCompat.Caption" android:textColor="?iconButtonTint" /> </LinearLayout> <ImageButton android:id="@+id/menu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="7dp" android:background="?selectableItemBackgroundBorderless" android:src="@drawable/more_vertical_icon_white_18dp" app:tint="?colorControlNormal" tools:ignore="MissingPrefix" /> </LinearLayout> <TextView android:id="@+id/comment" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignLeft="@id/name" android:layout_below="@id/rating_and_date" android:layout_marginTop="12dp" android:lineSpacingMultiplier="1.2" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> </me.zhanghai.android.douya.ui.ForegroundRelativeLayout> ```
/content/code_sandbox/app/src/main/res/layout/item_collection_item.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,151
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" xmlns:app="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:paddingTop="@dimen/content_vertical_space" android:paddingBottom="@dimen/content_vertical_space" android:background="?selectableItemBackground" android:orientation="vertical"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Title" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="6dp" android:paddingBottom="6dp" android:clipToPadding="false" android:gravity="center_vertical" android:orientation="horizontal"> <me.zhanghai.android.douya.ui.SimpleCircleImageView android:id="@+id/avatar" android:layout_width="16dp" android:layout_height="16dp" android:layout_marginBottom="-0.5dp" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:ellipsize="end" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Caption" /> <me.zhanghai.android.materialratingbar.MaterialRatingBar android:id="@+id/rating" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="7dp" android:layout_marginRight="-1dp" android:layout_marginTop="-2dp" android:layout_marginBottom="-2dp" android:minHeight="14dp" android:maxHeight="14dp" app:mrb_progressTint="?android:textColorSecondary" style="@style/Widget.MaterialRatingBar.RatingBar.Indicator.Small" /> <TextView android:id="@+id/usefulness" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:ellipsize="end" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Caption" /> </LinearLayout> <TextView android:id="@+id/abstract_" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:lineSpacingMultiplier="1.2" android:maxLines="4" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="?android:textColorSecondary" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/item_review_item.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
659
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <me.zhanghai.android.douya.item.ui.BadgeListLayout xmlns:android="path_to_url" android:id="@+id/badge_list_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/item_content_horizontal_margin" android:layout_marginRight="@dimen/item_content_horizontal_margin" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:paddingTop="@dimen/content_horizontal_space" android:paddingBottom="@dimen/content_horizontal_space" android:background="?colorBackgroundFloating" /> ```
/content/code_sandbox/app/src/main/res/layout/item_fragment_badge_list.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
167
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <FrameLayout xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".item.ui.ItemCollectionActivity"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="@dimen/toolbar_and_toolbar_height" android:layout_marginBottom="@dimen/toolbar_height" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:animateLayoutChanges="true" android:divider="?dividerHorizontal" android:orientation="vertical" android:showDividers="middle"> <FrameLayout android:id="@+id/rating_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="@dimen/single_line_list_item_with_avatar_height" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:clipChildren="false" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="@string/item_rating" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" android:textColor="?android:textColorSecondary" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/content_horizontal_margin_from_screen_edge" android:clipChildren="false" android:clipToPadding="false" android:gravity="center_vertical"> <me.zhanghai.android.materialratingbar.MaterialRatingBar android:id="@+id/rating" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="-3dp" android:layout_marginRight="-3dp" android:stepSize="1" style="@style/Widget.MaterialRatingBar.RatingBar" /> <TextView android:id="@+id/rating_hint" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/content_horizontal_space" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> </LinearLayout> </FrameLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/screen_edge_horizontal_margin" android:layout_marginRight="@dimen/screen_edge_horizontal_margin" android:layout_marginTop="17dp" android:layout_marginBottom="17dp" android:text="@string/item_tags" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" android:textColor="?android:textColorSecondary" /> <EditText android:id="@+id/tags" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="@dimen/content_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:paddingTop="17dp" android:paddingBottom="17dp" android:background="@null" android:hint="@string/item_tags_hint" android:maxLines="2" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> </FrameLayout> <EditText android:id="@+id/comment" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:paddingTop="@dimen/content_vertical_space" android:paddingBottom="@dimen/content_vertical_space" android:background="@null" android:gravity="top" android:hint="@string/item_comment_hint"> <requestFocus /> </EditText> </LinearLayout> </ScrollView> <!-- TODO: Add a compatible shadow. --> <LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/toolbar_height" android:layout_gravity="bottom" android:background="?colorBackgroundFloating" android:elevation="@dimen/appbar_elevation" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/screen_edge_horizontal_margin" android:text="@string/item_share_to" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <me.zhanghai.android.douya.ui.PreferenceCheckBox android:id="@+id/share_to_broadcast" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/content_horizontal_space_with_8dp_padding" android:key="@string/pref_key_item_collection_share_to_broadcast" android:defaultValue="@bool/pref_default_value_item_collection_share_to_broadcast" android:text="@string/item_share_to_broadcast" /> <me.zhanghai.android.douya.ui.PreferenceCheckBox android:id="@+id/share_to_weibo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/content_horizontal_space_with_8dp_padding" android:key="@string/pref_key_item_collection_share_to_weibo" android:defaultValue="@bool/pref_default_value_item_collection_share_to_weibo" android:text="@string/item_share_to_weibo" /> <Space android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" /> <me.zhanghai.android.douya.ui.CounterTextView android:id="@+id/counter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="@dimen/screen_edge_horizontal_margin" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> </LinearLayout> <me.zhanghai.android.douya.ui.AppBarWrapperLayout android:id="@+id/appBarWrapper" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?colorPrimary" android:elevation="@dimen/appbar_elevation" android:orientation="vertical" android:theme="?actionBarTheme"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" android:paddingLeft="@dimen/toolbar_navigation_button_left_margin" android:paddingRight="@dimen/toolbar_button_right_margin" app:navigationIcon="@drawable/close_icon_white_24dp" app:popupTheme="?actionBarPopupTheme" app:titleMarginStart="@dimen/toolbar_title_left_margin" /> <LinearLayout android:id="@+id/state_layout" android:layout_width="match_parent" android:layout_height="@dimen/toolbar_height" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/item_state_i" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> <Spinner android:id="@+id/state" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@null" app:popupTheme="?actionBarPopupTheme" tools:ignore="MissingPrefix" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="-15dp" android:layout_marginRight="9dp" android:src="@drawable/spinner_caret_icon_white_24dp" app:tint="?colorControlNormal" tools:ignore="MissingPrefix" /> <TextView android:id="@+id/state_this_item" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> </LinearLayout> </LinearLayout> </me.zhanghai.android.douya.ui.AppBarWrapperLayout> </FrameLayout> ```
/content/code_sandbox/app/src/main/res/layout/item_collection_fragment.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
1,979
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" xmlns:app="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?dividerHorizontal" android:orientation="vertical" android:showDividers="middle"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin" android:paddingRight="@dimen/card_content_horizontal_margin" android:background="?selectableItemBackground" android:ellipsize="end" android:gravity="center_vertical" android:maxLines="1" android:text="@string/profile_reviews_title" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" android:textColor="?android:textColorSecondary" /> <LinearLayout android:id="@+id/review_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?dividerHorizontal" android:dividerPadding="@dimen/card_content_horizontal_margin" android:orientation="vertical" android:showDividers="middle" /> <TextView android:id="@+id/empty" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin" android:paddingRight="@dimen/card_content_horizontal_margin" android:gravity="center_vertical" android:text="@string/profile_reviews_empty" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <TextView android:id="@+id/view_more" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin_with_4dp_padding" android:paddingRight="@dimen/card_content_horizontal_margin" android:background="?selectableItemBackground" android:clickable="true" android:drawableLeft="@drawable/forward_icon_white_24dp" android:drawablePadding="@dimen/card_content_horizontal_space_with_4dp_padding" android:ellipsize="end" android:focusable="true" android:gravity="center_vertical" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="?android:textColorSecondary" app:drawableTint="?android:textColorSecondary" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/profile_reviews_layout.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
570
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" xmlns:app="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?dividerHorizontal" android:orientation="vertical" android:showDividers="middle"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin" android:paddingRight="@dimen/card_content_horizontal_margin" android:background="?selectableItemBackground" android:ellipsize="end" android:gravity="center_vertical" android:maxLines="1" android:text="@string/profile_followship_title" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" android:textColor="?android:textColorSecondary" /> <LinearLayout android:id="@+id/following_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="@dimen/list_padding_vertical" android:paddingBottom="@dimen/list_padding_vertical" android:orientation="vertical" /> <TextView android:id="@+id/empty" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin" android:paddingRight="@dimen/card_content_horizontal_margin" android:gravity="center_vertical" android:text="@string/profile_following_empty" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <TextView android:id="@+id/view_more" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin_with_4dp_padding" android:paddingRight="@dimen/card_content_horizontal_margin" android:background="?selectableItemBackground" android:clickable="true" android:drawableLeft="@drawable/forward_icon_white_24dp" android:drawablePadding="@dimen/card_content_horizontal_space_with_4dp_padding" android:ellipsize="end" android:focusable="true" android:gravity="center_vertical" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="?android:textColorSecondary" app:drawableTint="?android:textColorSecondary" /> <TextView android:id="@+id/follower" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin" android:paddingRight="@dimen/card_content_horizontal_margin" android:background="?selectableItemBackground" android:clickable="true" android:ellipsize="end" android:focusable="true" android:gravity="center_vertical" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/profile_followship_layout.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
693
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/item_content_horizontal_margin" android:layout_marginRight="@dimen/item_content_horizontal_margin" android:paddingBottom="@dimen/content_vertical_space_half" android:background="?colorBackgroundFloating" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:paddingTop="@dimen/content_vertical_space" android:paddingBottom="@dimen/content_vertical_space" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/item_track_list_title" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> <Space android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" /> <me.zhanghai.android.douya.ui.ColoredBorderButton android:id="@+id/play_all" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="0dp" android:minHeight="0dp" android:layout_marginLeft="-4dp" android:layout_marginRight="-4dp" android:layout_marginTop="-6dp" android:layout_marginBottom="-6dp" android:padding="6dp" android:text="@string/item_track_list_play_all" android:textSize="@dimen/abc_text_size_caption_material" style="@style/Widget.AppCompat.Button.Borderless.Colored" /> </LinearLayout> <me.zhanghai.android.douya.ui.AdapterLinearLayout android:id="@+id/track_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/item_fragment_track_list.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
481
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/item_content_horizontal_margin" android:layout_marginRight="@dimen/item_content_horizontal_margin" android:background="?colorBackgroundFloating" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:paddingTop="@dimen/content_vertical_space" android:paddingBottom="@dimen/content_vertical_space" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/item_review_list_title" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> <Space android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" /> <me.zhanghai.android.douya.ui.ColoredBorderButton android:id="@+id/create" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="0dp" android:minHeight="0dp" android:layout_marginLeft="-4dp" android:layout_marginRight="-4dp" android:layout_marginTop="-6dp" android:layout_marginBottom="-6dp" android:padding="6dp" android:text="@string/item_review_list_create" android:textSize="@dimen/abc_text_size_caption_material" style="@style/Widget.AppCompat.Button.Borderless.Colored" /> </LinearLayout> <me.zhanghai.android.douya.ui.AdapterLinearLayout android:id="@+id/review_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" /> <Button android:id="@+id/view_more" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?selectableItemBackground" android:paddingTop="@dimen/content_vertical_space" android:paddingBottom="@dimen/content_vertical_space" android:includeFontPadding="false" android:text="@string/item_review_list_view_more" android:textAppearance="@style/TextAppearance.AppCompat.Widget.Button.Borderless.Colored" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/item_fragment_review_list.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
578
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <merge xmlns:android="path_to_url" xmlns:app="path_to_url"> <me.zhanghai.android.douya.ui.DoubleClickToolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" android:paddingRight="@dimen/toolbar_overflow_button_right_margin" app:popupTheme="?actionBarPopupTheme" app:titleMarginStart="@dimen/toolbar_title_left_margin"> <TextView android:id="@+id/toolbar_username" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/content_horizontal_margin" android:ellipsize="end" android:singleLine="true" android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" /> </me.zhanghai.android.douya.ui.DoubleClickToolbar> <Space android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" android:layout_marginTop="@dimen/profile_large_avatar_bottom_from_toolbar_bottom" /> <LinearLayout android:id="@+id/profile_header_animate_changes_layout_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="-4dp" android:layout_marginBottom="-4dp" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:animateLayoutChanges="true" android:clipToPadding="false" android:gravity="center" android:orientation="vertical"> <me.zhanghai.android.douya.ui.AutoGoneTextView android:id="@+id/username" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="36dp" android:ellipsize="end" android:gravity="center_vertical" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Headline" android:textSize="26sp" /> <me.zhanghai.android.douya.ui.AutoGoneTextView android:id="@+id/signature" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="24dp" android:ellipsize="end" android:gravity="center_vertical" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <me.zhanghai.android.douya.ui.JoinTimeLocationAutoGoneTextView android:id="@+id/join_time_location" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="24dp" android:ellipsize="end" android:gravity="center_vertical" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> </LinearLayout> <Space android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" /> <FrameLayout android:id="@+id/profile_header_animate_changes_layout_2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="-16dp" android:layout_marginBottom="-16dp" android:paddingLeft="@dimen/screen_edge_horizontal_margin" android:paddingRight="@dimen/screen_edge_horizontal_margin" android:animateLayoutChanges="true" android:clipToPadding="false"> <me.zhanghai.android.douya.ui.AnimateCompoundDrawableButton android:id="@+id/follow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|top" android:paddingLeft="10dp" android:drawablePadding="6dp" android:visibility="gone" style="?borderlessButtonStyle" /> </FrameLayout> <Space android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" android:layout_marginBottom="4dp" /> </merge> ```
/content/code_sandbox/app/src/main/res/layout/profile_header_appbar_content_include.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
944
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <me.zhanghai.android.douya.ui.ContentStateLayout xmlns:android="path_to_url" xmlns:app="path_to_url" android:id="@+id/content_state" android:layout_width="match_parent" android:layout_height="@dimen/two_line_list_item_height" app:animationEnabled="false"> <Space android:id="@+id/empty" android:layout_width="0dp" android:layout_height="0dp" /> </me.zhanghai.android.douya.ui.ContentStateLayout> ```
/content/code_sandbox/app/src/main/res/layout/content_state_item.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
144
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <me.zhanghai.android.materialprogressbar.MaterialProgressBar xmlns:android="path_to_url" android:id="@+id/loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:indeterminate="true" style="@style/Widget.MaterialProgressBar.ProgressBar" /> ```
/content/code_sandbox/app/src/main/res/layout/content_state_layout_default_loading_view.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
99
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <TextView xmlns:android="path_to_url" android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="?attr/dropdownListPreferredItemHeight" android:ellipsize="marquee" android:paddingLeft="16dp" android:paddingRight="16dp" android:singleLine="true" style="?attr/spinnerDropDownItemStyle" /> ```
/content/code_sandbox/app/src/main/res/layout/simple_spinner_dropdown_item.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
115
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <TextView xmlns:android="path_to_url" android:id="@+id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/load_empty" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" /> ```
/content/code_sandbox/app/src/main/res/layout/content_state_layout_default_empty_view.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
95
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Caption" android:textColor="?android:textColorPrimary" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="@style/TextAppearance.AppCompat.Caption" android:textIsSelectable="true" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/item_introduction_pair_item.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
171
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" xmlns:app="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?dividerHorizontal" android:orientation="vertical" android:showDividers="middle"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin" android:paddingRight="@dimen/card_content_horizontal_margin" android:background="?selectableItemBackground" android:ellipsize="end" android:gravity="center_vertical" android:maxLines="1" android:text="@string/profile_diaries_title" android:textAppearance="@style/TextAppearance.AppCompat.Subhead" android:textColor="?android:textColorSecondary" /> <LinearLayout android:id="@+id/diary_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?dividerHorizontal" android:dividerPadding="@dimen/card_content_horizontal_margin" android:orientation="vertical" android:showDividers="middle" /> <TextView android:id="@+id/empty" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin" android:paddingRight="@dimen/card_content_horizontal_margin" android:gravity="center_vertical" android:text="@string/profile_diaries_empty" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <TextView android:id="@+id/view_more" android:layout_width="match_parent" android:layout_height="@dimen/single_line_list_item_height" android:paddingLeft="@dimen/card_content_horizontal_margin_with_4dp_padding" android:paddingRight="@dimen/card_content_horizontal_margin" android:background="?selectableItemBackground" android:clickable="true" android:drawableLeft="@drawable/forward_icon_white_24dp" android:drawablePadding="@dimen/card_content_horizontal_space_with_4dp_padding" android:ellipsize="end" android:focusable="true" android:gravity="center_vertical" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="?android:textColorSecondary" app:drawableTint="?android:textColorSecondary" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/profile_diaries_layout.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
573
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ All Rights Reserved. --> <LinearLayout xmlns:android="path_to_url" xmlns:app="path_to_url" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <me.zhanghai.android.douya.ui.AutoGoneTextView android:id="@+id/rebroadcasted_by" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/card_header_horizontal_margin" android:layout_marginRight="@dimen/card_header_horizontal_margin" android:layout_marginTop="@dimen/card_vertical_space_half" android:layout_marginBottom="@dimen/card_header_bottom_margin" android:ellipsize="end" android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="?android:textColorTertiary" /> <me.zhanghai.android.douya.ui.FriendlyCardView android:id="@+id/card" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/card_horizontal_margin" android:layout_marginRight="@dimen/card_horizontal_margin" android:layout_marginTop="@dimen/card_vertical_margin" android:layout_marginBottom="@dimen/card_vertical_margin" android:clickable="true" android:focusable="true" android:foreground="?selectableItemBackground" app:cardCornerRadius="@dimen/card_corner_radius" app:cardMaxElevation="@dimen/card_elevation"> <me.zhanghai.android.douya.broadcast.ui.BroadcastLayout android:id="@+id/broadcast" android:layout_width="match_parent" android:layout_height="wrap_content" /> </me.zhanghai.android.douya.ui.FriendlyCardView> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/broadcast_item.xml
xml
2016-02-01T13:44:19
2024-08-15T05:23:34
Douya
zhanghai/Douya
4,549
422