Search in sources :

Example 1 with Game

use of me.zhanghai.android.douya.network.api.info.frodo.Game in project Douya by DreaminginCodeZH.

the class ItemIntroductionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Calls ensureSubDecor().
    findViewById(android.R.id.content);
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        CollectableItem item = intent.getParcelableExtra(EXTRA_ITEM);
        Fragment fragment;
        switch(item.getType()) {
            case APP:
                // TODO
                throw new UnsupportedOperationException();
            case BOOK:
                fragment = BookIntroductionFragment.newInstance((Book) item);
                break;
            case EVENT:
                // TODO
                throw new UnsupportedOperationException();
            case GAME:
                fragment = GameIntroductionFragment.newInstance((Game) item);
                break;
            case MOVIE:
            case TV:
                fragment = MovieIntroductionFragment.newInstance((Movie) item);
                break;
            case MUSIC:
                fragment = MusicIntroductionFragment.newInstance((Music) item);
                break;
            default:
                throw new IllegalArgumentException();
        }
        FragmentUtils.add(fragment, this, android.R.id.content);
    }
}
Also used : Movie(me.zhanghai.android.douya.network.api.info.frodo.Movie) CollectableItem(me.zhanghai.android.douya.network.api.info.frodo.CollectableItem) Game(me.zhanghai.android.douya.network.api.info.frodo.Game) Book(me.zhanghai.android.douya.network.api.info.frodo.Book) Music(me.zhanghai.android.douya.network.api.info.frodo.Music) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment)

Example 2 with Game

use of me.zhanghai.android.douya.network.api.info.frodo.Game in project Douya by DreaminginCodeZH.

the class GameActivity method onCreate.

@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);
    }
}
Also used : SimpleGame(me.zhanghai.android.douya.network.api.info.frodo.SimpleGame) Game(me.zhanghai.android.douya.network.api.info.frodo.Game) SimpleGame(me.zhanghai.android.douya.network.api.info.frodo.SimpleGame) Intent(android.content.Intent)

Example 3 with Game

use of me.zhanghai.android.douya.network.api.info.frodo.Game in project Douya by DreaminginCodeZH.

the class GameFragment method update.

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);
    }
}
Also used : Context(android.content.Context) SimpleReview(me.zhanghai.android.douya.network.api.info.frodo.SimpleReview) Context(android.content.Context) UncollectItemManager(me.zhanghai.android.douya.item.content.UncollectItemManager) UriHandler(me.zhanghai.android.douya.link.UriHandler) GalleryActivity(me.zhanghai.android.douya.gallery.ui.GalleryActivity) BaseItemFragmentResource(me.zhanghai.android.douya.item.content.BaseItemFragmentResource) CollectableItem(me.zhanghai.android.douya.network.api.info.frodo.CollectableItem) CopyTextDialogFragment(me.zhanghai.android.douya.ui.CopyTextDialogFragment) BindDimen(butterknife.BindDimen) Doulist(me.zhanghai.android.douya.network.api.info.frodo.Doulist) Rating(me.zhanghai.android.douya.network.api.info.frodo.Rating) Game(me.zhanghai.android.douya.network.api.info.frodo.Game) ImageUtils(me.zhanghai.android.douya.util.ImageUtils) ViewUtils(me.zhanghai.android.douya.util.ViewUtils) ConfirmUncollectItemDialogFragment(me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment) ItemAwardItem(me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem) SimpleCelebrity(me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity) BarrierAdapter(me.zhanghai.android.douya.ui.BarrierAdapter) R(me.zhanghai.android.douya.R) GameFragmentResource(me.zhanghai.android.douya.item.content.GameFragmentResource) DoubanUtils(me.zhanghai.android.douya.util.DoubanUtils) List(java.util.List) SimpleItemForumTopic(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic) SimpleItemCollection(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection) Photo(me.zhanghai.android.douya.network.api.info.frodo.Photo) SimpleGame(me.zhanghai.android.douya.network.api.info.frodo.SimpleGame)

Example 4 with Game

use of me.zhanghai.android.douya.network.api.info.frodo.Game in project Douya by DreaminginCodeZH.

the class GameFragment method uncollect.

@Override
public void uncollect() {
    if (!mResource.hasItem()) {
        return;
    }
    Game game = mResource.getItem();
    UncollectItemManager.getInstance().write(game.getType(), game.id, getActivity());
}
Also used : Game(me.zhanghai.android.douya.network.api.info.frodo.Game) SimpleGame(me.zhanghai.android.douya.network.api.info.frodo.SimpleGame)

Aggregations

Game (me.zhanghai.android.douya.network.api.info.frodo.Game)4 SimpleGame (me.zhanghai.android.douya.network.api.info.frodo.SimpleGame)3 Intent (android.content.Intent)2 CollectableItem (me.zhanghai.android.douya.network.api.info.frodo.CollectableItem)2 Context (android.content.Context)1 Fragment (androidx.fragment.app.Fragment)1 BindDimen (butterknife.BindDimen)1 List (java.util.List)1 R (me.zhanghai.android.douya.R)1 GalleryActivity (me.zhanghai.android.douya.gallery.ui.GalleryActivity)1 BaseItemFragmentResource (me.zhanghai.android.douya.item.content.BaseItemFragmentResource)1 ConfirmUncollectItemDialogFragment (me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment)1 GameFragmentResource (me.zhanghai.android.douya.item.content.GameFragmentResource)1 UncollectItemManager (me.zhanghai.android.douya.item.content.UncollectItemManager)1 UriHandler (me.zhanghai.android.douya.link.UriHandler)1 Book (me.zhanghai.android.douya.network.api.info.frodo.Book)1 Doulist (me.zhanghai.android.douya.network.api.info.frodo.Doulist)1 ItemAwardItem (me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem)1 Movie (me.zhanghai.android.douya.network.api.info.frodo.Movie)1 Music (me.zhanghai.android.douya.network.api.info.frodo.Music)1