use of android.support.v7.widget.RecyclerView.Adapter in project UltimateAndroid by cymcsg.
the class MaterialTabTextActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.material_tab_text_activity_main);
Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
this.setSupportActionBar(toolbar);
tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost);
pager = (ViewPager) this.findViewById(R.id.pager);
// init view pager
adapter = new ViewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// when user do a swipe the selected tab change
tabHost.setSelectedNavigationItem(position);
}
});
// insert all tabs from pagerAdapter data
for (int i = 0; i < adapter.getCount(); i++) {
tabHost.addTab(tabHost.newTab().setText(adapter.getPageTitle(i)).setTabListener(this));
}
}
use of android.support.v7.widget.RecyclerView.Adapter in project UltimateAndroid by cymcsg.
the class SnackbarRecyclerViewSampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.snack_bar_activity_recyclerview_sample);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
List<String> data = new ArrayList<String>();
for (int i = 0; i < 25; i++) {
data.add(String.format("Item %d", (i + 1)));
}
SimpleDataAdapter adapter = new SimpleDataAdapter(android.R.layout.simple_list_item_1, data, this);
mRecyclerView.setAdapter(adapter);
}
use of android.support.v7.widget.RecyclerView.Adapter in project kickmaterial by byoutline.
the class ProjectsListFragment method setUpAdapters.
private void setUpAdapters() {
/** NEW ADAPTER **/
layoutManager = new GridLayoutManager(getActivity(), 2);
final boolean showHeader = sharedPreferences.getBoolean(PREFS_SHOW_HEADER, true);
// TODO: decide when to hide it.
sharedPreferences.edit().putBoolean(PREFS_SHOW_HEADER, false).apply();
final ProjectsAdapter.ItemViewTypeProvider itemViewTypeProvider = new ProjectsAdapter.ItemViewTypeProvider(showHeader);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (itemViewTypeProvider.getViewType(position) == ProjectsAdapter.NORMAL_ITEM) {
return 1;
}
return 2;
}
});
projectListRv.setEndlessScrollListener(this);
projectListRv.setLayoutManager(layoutManager);
adapter = new ProjectsAdapter(getActivity(), this, showHeader, itemViewTypeProvider);
projectListRv.setAdapter(adapter);
}
use of android.support.v7.widget.RecyclerView.Adapter in project kickmaterial by byoutline.
the class SearchListFragment method setUpAdapters.
private void setUpAdapters() {
projectListRv.setEndlessScrollListener(this);
layoutManager = new LinearLayoutManager(getActivity());
projectListRv.setLayoutManager(layoutManager);
projectListRv.addItemDecoration(new SearchListSeparator(getActivity().getApplicationContext()));
adapter = new SearchAdapter(getActivity(), this);
projectListRv.setAdapter(adapter);
}
use of android.support.v7.widget.RecyclerView.Adapter 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