use of android.support.v7.widget.RecyclerView.LayoutManager in project nucleus by konmik.
the class MainFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
check1.setText(MainPresenter.NAME_1);
check2.setText(MainPresenter.NAME_2);
pager = new RxPager(10, page -> {
adapter.showProgress();
getPresenter().requestNext(page);
});
adapter = new SimpleListAdapter<>(R.layout.recycler_view_progress, new ClassViewHolderType<>(ServerAPI.Item.class, R.layout.item, v -> new SimpleViewHolder<>(v, this::onItemClick)));
recyclerView.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.addOnScrollListener(new OnScrollPaging(layoutManager, adapter, pager::next));
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project android-oss by kickstarter.
the class ThanksActivity method onCreate.
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.thanks_layout);
ButterKnife.bind(this);
((KSApplication) getApplication()).component().inject(this);
shareDialog = new ShareDialog(this);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recommendedProjectsRecyclerView.setLayoutManager(layoutManager);
adapter = new ThanksAdapter(viewModel);
recommendedProjectsRecyclerView.setAdapter(adapter);
Observable.timer(500L, TimeUnit.MILLISECONDS, Schedulers.newThread()).compose(ignoreValues()).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> animateBackground());
RxView.clicks(shareButton).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> viewModel.inputs.shareClick());
RxView.clicks(shareOnFacebookButton).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> viewModel.inputs.shareOnFacebookClick());
RxView.clicks(shareOnTwitterButton).compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> viewModel.inputs.shareOnTwitterClick());
viewModel.outputs.projectName().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::showBackedProject);
viewModel.outputs.showConfirmGamesNewsletterDialog().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> showConfirmGamesNewsletterDialog());
viewModel.outputs.showGamesNewsletterDialog().compose(bindToLifecycle()).take(1).delay(700L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> showGamesNewsletterDialog());
viewModel.outputs.showRatingDialog().compose(bindToLifecycle()).take(1).delay(700L, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> showRatingDialog());
viewModel.outputs.showRecommendations().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::showRecommendations);
viewModel.outputs.startDiscovery().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startDiscovery);
viewModel.outputs.startProject().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startProject);
viewModel.outputs.startShare().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startShare);
viewModel.outputs.startShareOnFacebook().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startShareOnFacebook);
viewModel.outputs.startShareOnTwitter().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(this::startShareOnTwitter);
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project android-oss by kickstarter.
the class ViewPledgeActivity method onCreate.
@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_pledge_layout);
ButterKnife.bind(this);
final RewardsItemAdapter rewardsItemAdapter = new RewardsItemAdapter();
rewardsItemRecyclerView.setAdapter(rewardsItemAdapter);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
rewardsItemRecyclerView.setLayoutManager(layoutManager);
final Environment environment = environment();
ksString = environment.ksString();
RxView.clicks(projectContextView).compose(bindToLifecycle()).observeOn(mainThread()).subscribe(__ -> viewModel.inputs.projectClicked());
viewModel.outputs.backerNameTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(backerNameTextView::setText);
viewModel.outputs.backerNumberTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(this::setBackerNumberTextViewText);
viewModel.outputs.backingAmountAndDateTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(ad -> setBackingAmountAndDateTextViewText(ad.first, ad.second));
viewModel.outputs.backingStatus().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(this::setBackingStatusTextViewText);
viewModel.outputs.creatorNameTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(this::setCreatorNameTextViewText);
viewModel.outputs.goBack().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(__ -> back());
viewModel.outputs.loadBackerAvatar().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(this::loadBackerAvatar);
viewModel.outputs.loadProjectPhoto().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(url -> Picasso.with(this).load(url).into(projectContextPhotoImageView));
viewModel.outputs.projectNameTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(projectContextProjectNameTextView::setText);
viewModel.outputs.rewardsItems().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(rewardsItemAdapter::rewardsItems);
viewModel.outputs.rewardsItemsAreHidden().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(ViewUtils.setGone(rewardsItemSection));
viewModel.outputs.rewardMinimumAndDescriptionTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(md -> setRewardMinimumAndDescriptionTextViewText(md.first, md.second));
viewModel.outputs.shippingAmountTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(shippingAmountTextView::setText);
viewModel.outputs.shippingLocationTextViewText().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(shippingLocationTextView::setText);
viewModel.outputs.shippingSectionIsHidden().compose(bindToLifecycle()).observeOn(mainThread()).subscribe(ViewUtils.setGone(shippingSection));
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project baseAdapter by hongyangAndroid.
the class WrapperUtils method onAttachedToRecyclerView.
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) {
innerAdapter.onAttachedToRecyclerView(recyclerView);
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
}
});
gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
}
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project plaid by nickbutcher.
the class PlayerActivity method bindPlayer.
void bindPlayer() {
if (player == null)
return;
final Resources res = getResources();
final NumberFormat nf = NumberFormat.getInstance();
Glide.with(this).load(player.getHighQualityAvatarUrl()).placeholder(R.drawable.avatar_placeholder).transform(circleTransform).into(avatar);
playerName.setText(player.name.toLowerCase());
if (!TextUtils.isEmpty(player.bio)) {
DribbbleUtils.parseAndSetText(bio, player.bio);
} else {
bio.setVisibility(View.GONE);
}
shotCount.setText(res.getQuantityString(R.plurals.shots, player.shots_count, nf.format(player.shots_count)));
if (player.shots_count == 0) {
shotCount.setCompoundDrawablesRelativeWithIntrinsicBounds(null, getDrawable(R.drawable.avd_no_shots), null, null);
}
setFollowerCount(player.followers_count);
likesCount.setText(res.getQuantityString(R.plurals.likes, player.likes_count, nf.format(player.likes_count)));
// load the users shots
dataManager = new PlayerShotsDataManager(this, player) {
@Override
public void onDataLoaded(List<Shot> data) {
if (data != null && data.size() > 0) {
if (adapter.getDataItemCount() == 0) {
loading.setVisibility(View.GONE);
ViewUtils.setPaddingTop(shots, likesCount.getBottom());
}
adapter.addAndResort(data);
}
}
};
adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this));
shots.setAdapter(adapter);
shots.setItemAnimator(new SlideInItemAnimator());
shots.setVisibility(View.VISIBLE);
layoutManager = new GridLayoutManager(this, columns);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return adapter.getItemColumnSpan(position);
}
});
shots.setLayoutManager(layoutManager);
shots.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
@Override
public void onLoadMore() {
dataManager.loadData();
}
});
shots.setHasFixedSize(true);
// forward on any clicks above the first item in the grid (i.e. in the paddingTop)
// to 'pass through' to the view behind
shots.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int firstVisible = layoutManager.findFirstVisibleItemPosition();
if (firstVisible > 0)
return false;
// if no data loaded then pass through
if (adapter.getDataItemCount() == 0) {
return container.dispatchTouchEvent(event);
}
final RecyclerView.ViewHolder vh = shots.findViewHolderForAdapterPosition(0);
if (vh == null)
return false;
final int firstTop = vh.itemView.getTop();
if (event.getY() < firstTop) {
return container.dispatchTouchEvent(event);
}
return false;
}
});
// check if following
if (dataManager.getDribbblePrefs().isLoggedIn()) {
if (player.id == dataManager.getDribbblePrefs().getUserId()) {
TransitionManager.beginDelayedTransition(container);
follow.setVisibility(View.GONE);
ViewUtils.setPaddingTop(shots, container.getHeight() - follow.getHeight() - ((ViewGroup.MarginLayoutParams) follow.getLayoutParams()).bottomMargin);
} else {
final Call<Void> followingCall = dataManager.getDribbbleApi().following(player.id);
followingCall.enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
following = response.isSuccessful();
if (!following)
return;
TransitionManager.beginDelayedTransition(container);
follow.setText(R.string.following);
follow.setActivated(true);
}
@Override
public void onFailure(Call<Void> call, Throwable t) {
}
});
}
}
if (player.shots_count > 0) {
// kick off initial load
dataManager.loadData();
} else {
loading.setVisibility(View.GONE);
}
}
Aggregations