use of me.henrytao.recyclerview.holder.HeaderHolder in project smooth-app-bar-layout by henrytao-me.
the class SmoothScrollSnapActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_smooth_scroll_snap);
ButterKnife.bind(this);
setSupportActionBar(vToolbar);
vToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(new DynamicAdapter<>(Utils.getSampleData())) {
@Override
public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return null;
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
}
};
vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
vRecyclerView.setAdapter(adapter);
}
use of me.henrytao.recyclerview.holder.HeaderHolder in project smooth-app-bar-layout by henrytao-me.
the class SmoothSwipeRefreshLayoutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_smooth_swipe_refresh_layout);
ButterKnife.bind(this);
setSupportActionBar(vToolbar);
vToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mAdapter = new DynamicAdapter<>(Utils.getSampleData());
RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {
@Override
public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return null;
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
}
};
vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
vRecyclerView.setAdapter(adapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
}
});
itemTouchHelper.attachToRecyclerView(vRecyclerView);
// set progress view offset
int actionBarSize = ResourceUtils.getActionBarSize(this);
int progressViewStart = getResources().getDimensionPixelSize(R.dimen.app_bar_height) - actionBarSize;
int progressViewEnd = progressViewStart + (int) (actionBarSize * 1.5f);
vSwipeRefreshLayout.setProgressViewOffset(true, progressViewStart, progressViewEnd);
mHandler = new Handler();
mCallback = new Runnable() {
@Override
public void run() {
if (!isFinishing()) {
vSwipeRefreshLayout.setRefreshing(false);
}
}
};
vSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mHandler.postDelayed(mCallback, 2000);
}
});
}
use of me.henrytao.recyclerview.holder.HeaderHolder in project smooth-app-bar-layout by henrytao-me.
the class PagerWithHeaderFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
vNestedScrollView.setVisibility(mIsRecyclerView ? View.GONE : View.VISIBLE);
vRecyclerView.setVisibility(mIsRecyclerView ? View.VISIBLE : View.GONE);
if (mIsRecyclerView) {
mAdapter = new DynamicAdapter<>(getSampleData());
RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {
@Override
public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return null;
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new HeaderHolder(layoutInflater, viewGroup, mHeaderLayout);
}
};
vRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
vRecyclerView.setAdapter(adapter);
} else {
vItemPagerHeaderSpacing.setVisibility(mHeaderLayout == R.layout.item_pager_header_spacing ? View.VISIBLE : View.GONE);
vItemHeaderViewPagerParallaxSpacing.setVisibility(mHeaderLayout == R.layout.item_header_view_pager_parallax_spacing ? View.VISIBLE : View.GONE);
vTextView.setText(mIsShort ? R.string.text_short : R.string.text_long);
}
}
use of me.henrytao.recyclerview.holder.HeaderHolder in project smooth-app-bar-layout by henrytao-me.
the class SmoothAvatarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_smooth_avatar);
ButterKnife.bind(this);
setSupportActionBar(vToolbar);
vToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(new DynamicAdapter<>(Utils.getSampleData())) {
@Override
public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return null;
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
}
};
vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
vRecyclerView.setAdapter(adapter);
}
use of me.henrytao.recyclerview.holder.HeaderHolder in project smooth-app-bar-layout by henrytao-me.
the class SmoothPreScrollActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_smooth_scroll_exit_until_collapsed);
ButterKnife.bind(this);
setSupportActionBar(vToolbar);
vToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mAdapter = new DynamicAdapter<>(me.henrytao.smoothappbarlayoutdemo.util.Utils.getSampleData());
RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {
@Override
public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return null;
}
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
}
};
vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
vRecyclerView.setAdapter(adapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
}
});
itemTouchHelper.attachToRecyclerView(vRecyclerView);
Utils.intPreScroll(vSmoothAppBarLayout, vRecyclerView, 300);
}
Aggregations