Search in sources :

Example 1 with FollowersDataManager

use of io.plaidapp.data.api.dribbble.FollowersDataManager in project plaid by nickbutcher.

the class PlayerSheet method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_sheet);
    ButterKnife.bind(this);
    final Intent intent = getIntent();
    @PlayerSheetMode final int mode = intent.getIntExtra(EXTRA_MODE, -1);
    switch(mode) {
        case MODE_SHOT_LIKES:
            shot = intent.getParcelableExtra(EXTRA_SHOT);
            title.setText(getResources().getQuantityString(R.plurals.fans, (int) shot.likes_count, NumberFormat.getInstance().format(shot.likes_count)));
            dataManager = new ShotLikesDataManager(this, shot.id) {

                @Override
                public void onDataLoaded(List<Like> likes) {
                    adapter.addItems(likes);
                }
            };
            break;
        case MODE_FOLLOWERS:
            player = intent.getParcelableExtra(EXTRA_USER);
            title.setText(getResources().getQuantityString(R.plurals.follower_count, player.followers_count, NumberFormat.getInstance().format(player.followers_count)));
            dataManager = new FollowersDataManager(this, player.id) {

                @Override
                public void onDataLoaded(List<Follow> followers) {
                    adapter.addItems(followers);
                }
            };
            break;
        default:
            throw new IllegalArgumentException("Unknown launch mode.");
    }
    bottomSheet.registerCallback(new BottomSheet.Callbacks() {

        @Override
        public void onSheetDismissed() {
            finishAfterTransition();
        }

        @Override
        public void onSheetPositionChanged(int sheetTop, boolean interacted) {
            if (interacted && close.getVisibility() != View.VISIBLE) {
                close.setVisibility(View.VISIBLE);
                close.setAlpha(0f);
                close.animate().alpha(1f).setDuration(400L).setInterpolator(getLinearOutSlowInInterpolator(PlayerSheet.this)).start();
            }
            if (sheetTop == 0) {
                showClose();
            } else {
                showDown();
            }
        }
    });
    layoutManager = new LinearLayoutManager(this);
    playerList.setLayoutManager(layoutManager);
    playerList.setItemAnimator(new SlideInItemAnimator());
    adapter = new PlayerAdapter(this);
    dataManager.registerCallback(adapter);
    playerList.setAdapter(adapter);
    playerList.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {

        @Override
        public void onLoadMore() {
            dataManager.loadData();
        }
    });
    playerList.addOnScrollListener(titleElevation);
    // kick off initial load
    dataManager.loadData();
}
Also used : Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) FollowersDataManager(io.plaidapp.data.api.dribbble.FollowersDataManager) ShotLikesDataManager(io.plaidapp.data.api.dribbble.ShotLikesDataManager) Like(io.plaidapp.data.api.dribbble.model.Like) Follow(io.plaidapp.data.api.dribbble.model.Follow) SlideInItemAnimator(io.plaidapp.ui.recyclerview.SlideInItemAnimator) BottomSheet(io.plaidapp.ui.widget.BottomSheet) InfiniteScrollListener(io.plaidapp.ui.recyclerview.InfiniteScrollListener)

Aggregations

Intent (android.content.Intent)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 FollowersDataManager (io.plaidapp.data.api.dribbble.FollowersDataManager)1 ShotLikesDataManager (io.plaidapp.data.api.dribbble.ShotLikesDataManager)1 Follow (io.plaidapp.data.api.dribbble.model.Follow)1 Like (io.plaidapp.data.api.dribbble.model.Like)1 InfiniteScrollListener (io.plaidapp.ui.recyclerview.InfiniteScrollListener)1 SlideInItemAnimator (io.plaidapp.ui.recyclerview.SlideInItemAnimator)1 BottomSheet (io.plaidapp.ui.widget.BottomSheet)1