Search in sources :

Example 6 with ParallaxRecyclerAdapter

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);
}
Also used : ExampleData(de.madcyph3r.example.data.ExampleData) StartSectionActivity(de.madcyph3r.example.example.menu.StartSectionActivity) AllMenuTypesActivity(de.madcyph3r.example.example.menu.AllMenuTypesActivity) SectionFragmentTitleActivity(de.madcyph3r.example.example.menu.SectionFragmentTitleActivity) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) AddRemoveMenuItemsActivity(de.madcyph3r.example.example.menu.AddRemoveMenuItemsActivity) ParallaxRecyclerAdapter(com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter) OnlyIconsActivity(de.madcyph3r.example.example.theme.OnlyIconsActivity) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView)

Example 7 with ParallaxRecyclerAdapter

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);
}
Also used : ExampleData(de.madcyph3r.example.data.ExampleData) MultiPaneSupportActivity(de.madcyph3r.example.example.drawerTypes.MultiPaneSupportActivity) MultiPaneSupportBelowToolbarActivity(de.madcyph3r.example.example.drawerTypes.MultiPaneSupportBelowToolbarActivity) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) OwnDrawerWidthActivity(de.madcyph3r.example.example.theme.OwnDrawerWidthActivity) HeadItemThreeActivity(de.madcyph3r.example.example.headerTypes.HeadItemThreeActivity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ParallaxRecyclerAdapter(com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter) NoHeaderActivity(de.madcyph3r.example.example.headerTypes.NoHeaderActivity) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) NoHeaderBelowToolbarActivity(de.madcyph3r.example.example.headerTypes.NoHeaderBelowToolbarActivity)

Example 8 with ParallaxRecyclerAdapter

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);
}
Also used : ExampleData(de.madcyph3r.example.data.ExampleData) ArrayList(java.util.ArrayList) HeadItemTwoNoFragmentLoadOnChangeActivity(de.madcyph3r.example.example.headItemTypes.HeadItemTwoNoFragmentLoadOnChangeActivity) AddRemoveMenuItemsActivity(de.madcyph3r.example.example.menu.AddRemoveMenuItemsActivity) ParallaxRecyclerAdapter(com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter) HeadItemTwoOnlyOneHasMenuActivity(de.madcyph3r.example.example.headItemTypes.HeadItemTwoOnlyOneHasMenuActivity) MasterChildNavActivity(de.madcyph3r.example.example.functionally.MasterChildNavActivity) ImageView(android.widget.ImageView) NoClosePrevDrawerActivity_Activity(de.madcyph3r.example.example.functionally.NoClosePrevDrawerActivity_Activity) ClosePrevDrawerActivity_Activity(de.madcyph3r.example.example.functionally.ClosePrevDrawerActivity_Activity) SetCustomFragmentActivity(de.madcyph3r.example.example.functionally.SetCustomFragmentActivity) AddRemoveHeadItemRuntimeActivity(de.madcyph3r.example.example.functionally.AddRemoveHeadItemRuntimeActivity) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) NoClosePrevDrawerActivity_Activity(de.madcyph3r.example.example.functionally.NoClosePrevDrawerActivity_Activity) ActionBarButtonsActivity(de.madcyph3r.example.example.functionally.ActionBarButtonsActivity) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

Intent (android.content.Intent)8 RecyclerView (android.support.v7.widget.RecyclerView)8 View (android.view.View)8 ViewGroup (android.view.ViewGroup)8 ImageView (android.widget.ImageView)8 TextView (android.widget.TextView)8 ParallaxRecyclerAdapter (com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter)8 ExampleData (de.madcyph3r.example.data.ExampleData)8 ArrayList (java.util.ArrayList)8 HeadItemThreeActivity (de.madcyph3r.example.example.headerTypes.HeadItemThreeActivity)3 AddRemoveMenuItemsActivity (de.madcyph3r.example.example.menu.AddRemoveMenuItemsActivity)3 HeadItemTwoNoFragmentLoadOnChangeActivity (de.madcyph3r.example.example.headItemTypes.HeadItemTwoNoFragmentLoadOnChangeActivity)2 HeadItemTwoOnlyOneHasMenuActivity (de.madcyph3r.example.example.headItemTypes.HeadItemTwoOnlyOneHasMenuActivity)2 HeadItemFiveActivity (de.madcyph3r.example.example.headerTypes.HeadItemFiveActivity)2 HeadItemOneActivity (de.madcyph3r.example.example.headerTypes.HeadItemOneActivity)2 NoHeaderActivity (de.madcyph3r.example.example.headerTypes.NoHeaderActivity)2 NoHeaderBelowToolbarActivity (de.madcyph3r.example.example.headerTypes.NoHeaderBelowToolbarActivity)2 OnlyIconsActivity (de.madcyph3r.example.example.theme.OnlyIconsActivity)2 OwnDrawerWidthActivity (de.madcyph3r.example.example.theme.OwnDrawerWidthActivity)2 BackPatternCustomActivity (de.madcyph3r.example.example.backPattern.BackPatternCustomActivity)1