use of io.plaidapp.data.api.dribbble.ShotLikesDataManager 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();
}
Aggregations