use of com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter in project AdvancedMaterialDrawer by madcyph3r.
the class MenuFragment method createAdapter.
private void createAdapter(RecyclerView recyclerView) {
final List<ExampleData> content = new ArrayList<>();
content.add(new ExampleData("All Menu Types", AllMenuTypesActivity.class));
content.add(new ExampleData("Add And Remove Menu Items At Runtime", AddRemoveMenuItemsActivity.class));
content.add(new ExampleData("Section With Custom Fragment Title", SectionFragmentTitleActivity.class));
content.add(new ExampleData("Set Start Section", StartSectionActivity.class));
content.add(new ExampleData("Only Icons Menu", OnlyIconsActivity.class));
final ParallaxRecyclerAdapter<ExampleData> adapter = new ParallaxRecyclerAdapter<>(content);
View header = getActivity().getLayoutInflater().inflate(R.layout.recycleview_header, recyclerView, false);
ImageView headerImage = (ImageView) header.findViewById(R.id.imageViewHeader);
headerImage.setImageResource(R.drawable.l_7);
adapter.setParallaxHeader(header, recyclerView);
adapter.setData(content);
adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i).getTitle());
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
final ViewHolder holder = new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.recycleview_row, viewGroup, false));
return holder;
}
@Override
public int getItemCount() {
return content.size();
}
});
adapter.setOnParallaxScroll(new ParallaxRecyclerAdapter.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View view) {
((MainActivity) getActivity()).setActionBarAlpha(percentage);
}
});
adapter.setOnClickEvent(new ParallaxRecyclerAdapter.OnClickEvent() {
@Override
public void onClick(View view, int i) {
if (i >= 0) {
Intent intent = new Intent(getActivity(), adapter.getData().get(i).getClazz());
startActivity(intent);
}
}
});
recyclerView.setAdapter(adapter);
}
use of com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter in project AdvancedMaterialDrawer by madcyph3r.
the class DrawerTypesFragment method createAdapter.
private void createAdapter(RecyclerView recyclerView) {
final List<ExampleData> content = new ArrayList<>();
content.add(new ExampleData("No Header (Default Drawer)", NoHeaderActivity.class));
content.add(new ExampleData("Three HeadItem Header (Default Drawer)", HeadItemThreeActivity.class));
content.add(new ExampleData("No Header Below Toolbar (Below Drawer)", NoHeaderBelowToolbarActivity.class));
content.add(new ExampleData("Own Drawer Width", OwnDrawerWidthActivity.class));
content.add(new ExampleData("MultiPane (Tablet) Support (Tablet Drawer)", MultiPaneSupportActivity.class));
content.add(new ExampleData("MultiPane (Tablet) And Below ToolBar Support (Tablet, Below Drawer)", MultiPaneSupportBelowToolbarActivity.class));
final ParallaxRecyclerAdapter<ExampleData> adapter = new ParallaxRecyclerAdapter<>(content);
View header = getActivity().getLayoutInflater().inflate(R.layout.recycleview_header, recyclerView, false);
ImageView headerImage = (ImageView) header.findViewById(R.id.imageViewHeader);
headerImage.setImageResource(R.drawable.l_2);
adapter.setParallaxHeader(header, recyclerView);
adapter.setData(content);
adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i).getTitle());
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
final ViewHolder holder = new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.recycleview_row, viewGroup, false));
return holder;
}
@Override
public int getItemCount() {
return content.size();
}
});
adapter.setOnParallaxScroll(new ParallaxRecyclerAdapter.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View view) {
((MainActivity) getActivity()).setActionBarAlpha(percentage);
}
});
adapter.setOnClickEvent(new ParallaxRecyclerAdapter.OnClickEvent() {
@Override
public void onClick(View view, int i) {
if (i >= 0) {
Intent intent = new Intent(getActivity(), adapter.getData().get(i).getClazz());
startActivity(intent);
}
}
});
recyclerView.setAdapter(adapter);
}
use of com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter in project AdvancedMaterialDrawer by madcyph3r.
the class FunctionallyFragment method createAdapter.
private void createAdapter(RecyclerView recyclerView) {
final List<ExampleData> content = new ArrayList<>();
content.add(new ExampleData("Change/Hide Actionbar Button", ActionBarButtonsActivity.class));
content.add(new ExampleData("Add Remove HeadItems At Runtime", AddRemoveHeadItemRuntimeActivity.class));
content.add(new ExampleData("Add And Remove Menu Items At Runtime", AddRemoveMenuItemsActivity.class));
content.add(new ExampleData("No Close Previous Drawer Activity", NoClosePrevDrawerActivity_Activity.class));
content.add(new ExampleData("Close Previous Drawer Activity", ClosePrevDrawerActivity_Activity.class));
content.add(new ExampleData("Set Custom Fragment (Not From Section)", SetCustomFragmentActivity.class));
content.add(new ExampleData("Head Item Style (Two Items) Only First Item Has a Menu", HeadItemTwoOnlyOneHasMenuActivity.class));
content.add(new ExampleData("Head Item Style (Two Items) Fragment Doesn't Change On HeadItem Change", HeadItemTwoNoFragmentLoadOnChangeActivity.class));
content.add(new ExampleData("Master Child Navigation", MasterChildNavActivity.class));
final ParallaxRecyclerAdapter<ExampleData> adapter = new ParallaxRecyclerAdapter<>(content);
View header = getActivity().getLayoutInflater().inflate(R.layout.recycleview_header, recyclerView, false);
ImageView headerImage = (ImageView) header.findViewById(R.id.imageViewHeader);
headerImage.setImageResource(R.drawable.l_3);
adapter.setParallaxHeader(header, recyclerView);
adapter.setData(content);
adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i).getTitle());
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
final ViewHolder holder = new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.recycleview_row, viewGroup, false));
return holder;
}
@Override
public int getItemCount() {
return content.size();
}
});
adapter.setOnParallaxScroll(new ParallaxRecyclerAdapter.OnParallaxScroll() {
@Override
public void onParallaxScroll(float percentage, float offset, View view) {
((MainActivity) getActivity()).setActionBarAlpha(percentage);
}
});
adapter.setOnClickEvent(new ParallaxRecyclerAdapter.OnClickEvent() {
@Override
public void onClick(View view, int i) {
if (i >= 0) {
Intent intent = new Intent(getActivity(), adapter.getData().get(i).getClazz());
startActivity(intent);
}
}
});
recyclerView.setAdapter(adapter);
}
Aggregations